Anders and Briegel in Python
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

58 рядки
1.6KB

  1. var textures = {};
  2. var materials = {};
  3. // Curve settings
  4. var curveProperties = {
  5. splineDensity: 10,
  6. curvature: 100
  7. };
  8. // Load the site texture from the data URI
  9. function loadMaterials(argument) {
  10. textures.sprite = new THREE.Texture(document.getElementById("ball"));
  11. textures.sprite.needsUpdate = true;
  12. var lineStyle = {
  13. color: "gray",
  14. transparent: false,
  15. linewidth: 1
  16. };
  17. materials.edge = new THREE.LineBasicMaterial(lineStyle);
  18. var pointStyle = {
  19. size: 0.1,
  20. map: textures.sprite,
  21. alphaTest: 0.5,
  22. transparent: true,
  23. vertexColors:THREE.VertexColors
  24. };
  25. materials.point = new THREE.PointsMaterial(pointStyle);
  26. var qubitStyle = {
  27. size: 0.8,
  28. map: textures.sprite,
  29. alphaTest: 0.5,
  30. transparent: true,
  31. vertexColors:THREE.VertexColors
  32. };
  33. materials.qubit = new THREE.PointsMaterial(qubitStyle);
  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. }