|
- var materials = {};
- materials.textures = {
- sprite: new THREE.Texture()
- };
-
- materials.load = function() {
- materials.textures.sprite = new THREE.Texture(document.getElementById("ball"));
- materials.textures.sprite.needsUpdate = true;
- };
-
- materials.curveProperties = {
- splineDensity: 10,
- curvature: 100
- };
-
- materials.materials = {
- edge: new THREE.LineBasicMaterial({
- color: "gray",
- transparent: false,
- linewidth: 1
- }),
- point: new THREE.PointsMaterial({
- size: 0.1,
- map: materials.textures.sprite,
- alphaTest: 0.5,
- transparent: true,
- vertexColors: THREE.VertexColors
- }),
- qubit: qubit = new THREE.PointsMaterial({
- size: 0.8,
- map: materials.textures.sprite,
- alphaTest: 0.5,
- transparent: true,
- vertexColors: THREE.VertexColors
- })
- };
-
- materials.makeCurve = function(a, b) {
- var length = new THREE.Vector3().subVectors(a, b).length();
- var bend = new THREE.Vector3(length / curveProperties.curvature, length / 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(curveProperties.splineDensity);
- Array.prototype.push.apply(geometry.vertices, splinePoints);
- return new THREE.Line(geometry, materials.materials.edge);
- };
|