Anders and Briegel in Python
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

49 líneas
1.4KB

  1. var materials = {};
  2. materials.textures = {
  3. sprite: new THREE.Texture()
  4. };
  5. materials.load = function() {
  6. materials.textures.sprite = new THREE.Texture(document.getElementById("ball"));
  7. materials.textures.sprite.needsUpdate = true;
  8. };
  9. materials.curveProperties = {
  10. splineDensity: 10,
  11. curvature: 100
  12. };
  13. materials.materials = {
  14. edge: new THREE.LineBasicMaterial({
  15. color: "gray",
  16. transparent: false,
  17. linewidth: 1
  18. }),
  19. point: new THREE.PointsMaterial({
  20. size: 0.1,
  21. map: materials.textures.sprite,
  22. alphaTest: 0.5,
  23. transparent: true,
  24. vertexColors: THREE.VertexColors
  25. }),
  26. qubit: qubit = new THREE.PointsMaterial({
  27. size: 0.8,
  28. map: materials.textures.sprite,
  29. alphaTest: 0.5,
  30. transparent: true,
  31. vertexColors: THREE.VertexColors
  32. })
  33. };
  34. materials.makeCurve = function(a, b) {
  35. var length = new THREE.Vector3().subVectors(a, b).length();
  36. var bend = new THREE.Vector3(length / curveProperties.curvature, length / curveProperties.curvature, 0);
  37. var mid = new THREE.Vector3().add(a).add(b).multiplyScalar(0.5).add(bend);
  38. var spline = new THREE.CatmullRomCurve3([a, mid, b]);
  39. var geometry = new THREE.Geometry();
  40. var splinePoints = spline.getPoints(curveProperties.splineDensity);
  41. Array.prototype.push.apply(geometry.vertices, splinePoints);
  42. return new THREE.Line(geometry, materials.materials.edge);
  43. };