Anders and Briegel in Python
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

36 行
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. };