Anders and Briegel in Python
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

36 lignes
1.1KB

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