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.

curve.js 920B

123456789101112131415161718192021222324
  1. // Curve settings
  2. var curveProperties = {
  3. splineDensity: 30,
  4. curvature: 10
  5. };
  6. // Add a curved edge between two points
  7. function makeEdge(e) {
  8. // Make the geometry of the curve
  9. var a = new THREE.Vector3(e.start[0], e.start[1], e.start[2]);
  10. var b = new THREE.Vector3(e.end[0], e.end[1], e.end[2]);
  11. var length = new THREE.Vector3().subVectors(a, b).length();
  12. var bend = new THREE.Vector3(length / curveProperties.curvature, length / curveProperties.curvature, 0);
  13. var mid = new THREE.Vector3().add(a).add(b).multiplyScalar(0.5).add(bend);
  14. var spline = new THREE.CatmullRomCurve3([a, mid, b]);
  15. var geometry = new THREE.Geometry();
  16. var splinePoints = spline.getPoints(curveProperties.splineDensity);
  17. Array.prototype.push.apply(geometry.vertices, splinePoints);
  18. // Make the actual Object3d thing
  19. var line = new THREE.Line(geometry, materials.edge);
  20. return line;
  21. }