|
1234567891011121314151617181920212223242526272829303132333435363738 |
- var materials = {};
-
- // Is called on boot
- materials.prepare = function() {
- var ballSprite = new THREE.Texture(document.getElementById("ball"));
- ballSprite.needsUpdate = true;
- materials.edge = new THREE.LineBasicMaterial({
- color: "black",
- transparent: false,
- linewidth: 1
- });
- materials.edge.depthTest = false;
- materials.qubit = new THREE.PointsMaterial({
- size: 0.4,
- map: ballSprite,
- alphaTest: 0.5,
- transparent: true,
- vertexColors: THREE.VertexColors
- });
- materials.curveProperties = {
- splineDensity: 10,
- curvature: 20
- };
- };
-
- materials.makeCurve = function(a, b) {
- materials.curveProperties.splineDensity = curvy.checked ? 10 : 1;
- console.log("New curve, " + materials.curveProperties.splineDensity);
- var length = new THREE.Vector3().subVectors(a, b).length();
- var bend = new THREE.Vector3(length / materials.curveProperties.curvature, length / materials.curveProperties.curvature, 0);
- var mid = new THREE.Vector3().add(a).add(b).multiplyScalar(0.5).add(bend);
- var spline = new THREE.CatmullRomCurve3([a, mid, b]);
- var geometry = new THREE.Geometry();
- var splinePoints = spline.getPoints(materials.curveProperties.splineDensity);
- Array.prototype.push.apply(geometry.vertices, splinePoints);
- return new THREE.Line(geometry, materials.edge);
- };
-
|