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.

49 lignes
1.5KB

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