Anders and Briegel in Python
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 line
1.6KB

  1. var textures = {};
  2. var materials = {};
  3. // Load the site texture from the data URI
  4. function loadMaterials(argument) {
  5. textures.sprite = new THREE.Texture(document.getElementById("ball"));
  6. textures.sprite.needsUpdate = true;
  7. var lineStyle = {
  8. color: "gray",
  9. transparent: false,
  10. linewidth: 1
  11. };
  12. materials.edge = new THREE.LineBasicMaterial(lineStyle);
  13. var pointStyle = {
  14. size: 0.1,
  15. map: textures.sprite,
  16. alphaTest: 0.5,
  17. transparent: true,
  18. vertexColors:THREE.VertexColors
  19. };
  20. materials.point = new THREE.PointsMaterial(pointStyle);
  21. var qubitStyle = {
  22. size: 0.8,
  23. map: textures.sprite,
  24. alphaTest: 0.5,
  25. transparent: true,
  26. vertexColors:THREE.VertexColors
  27. };
  28. materials.qubit = new THREE.PointsMaterial(qubitStyle);
  29. }
  30. // Curve settings
  31. var curveProperties = {
  32. splineDensity: 10,
  33. curvature: 100
  34. };
  35. // Add a curved edge between two points
  36. function makeCurve(a, b) {
  37. // Make the geometry of the curve
  38. var length = new THREE.Vector3().subVectors(a, b).length();
  39. var bend = new THREE.Vector3(length / curveProperties.curvature, length / curveProperties.curvature, 0);
  40. var mid = new THREE.Vector3().add(a).add(b).multiplyScalar(0.5).add(bend);
  41. var spline = new THREE.CatmullRomCurve3([a, mid, b]);
  42. var geometry = new THREE.Geometry();
  43. var splinePoints = spline.getPoints(curveProperties.splineDensity);
  44. Array.prototype.push.apply(geometry.vertices, splinePoints);
  45. // Make the actual Object3d thing
  46. var line = new THREE.Line(geometry, materials.edge);
  47. return line;
  48. }