- createDebugMesh(scene) {\r
- /**\r
- * helper function to generate a single line\r
- * between two Vertices with a given color\r
- * @param {Vector3} from \r
- * @param {Vector3} to \r
- * @param {number} color \r
- */\r
- function addLine(from, to, color) {\r
- let geometry = new THREE.Geometry();\r
- geometry.vertices.push(from);\r
- geometry.vertices.push(to);\r
- let material = new THREE.LineBasicMaterial( { color: color, linewidth: 10 } );\r
- let line = new THREE.Line(geometry, material);\r
- line.renderOrder = 1;\r
- scene.add(line);\r
- }\r
- /**\r
- * helper function to generate a small sphere\r
- * at a given Vertex Position with color\r
- * @param {Vector3} point \r
- * @param {number} color \r
- */\r
- function addPoint(point, color) {\r
- const geometry = new THREE.SphereGeometry( 0.05, 32, 32 );\r
- const material = new THREE.MeshBasicMaterial( { color: color } );\r
- const sphere = new THREE.Mesh( geometry, material );\r
- sphere.position.set(point.x, point.y, point.z);\r
- scene.add( sphere );\r
- }\r
-\r
- let lineColor = 0x000000;\r
- let pointColor = 0xff00000;\r
-\r
- /**\r
- * generate one line for each of the 6 springs\r
- * and one point for each of the 4 vertices\r
- * for all of the faces\r
- */\r
- for (let i in this.faces) {\r
- let face = this.faces[i];\r
- addLine(this.geometry.vertices[face.a], this.geometry.vertices[face.b], lineColor);\r
- addLine(this.geometry.vertices[face.a], this.geometry.vertices[face.c], lineColor);\r
- addLine(this.geometry.vertices[face.a], this.geometry.vertices[face.d], lineColor);\r
- addLine(this.geometry.vertices[face.b], this.geometry.vertices[face.c], lineColor);\r
- addLine(this.geometry.vertices[face.b], this.geometry.vertices[face.d], lineColor);\r
- addLine(this.geometry.vertices[face.c], this.geometry.vertices[face.d], lineColor);\r
-\r
- addPoint(this.geometry.vertices[face.a], pointColor);\r
- addPoint(this.geometry.vertices[face.b], pointColor);\r
- addPoint(this.geometry.vertices[face.c], pointColor);\r
- addPoint(this.geometry.vertices[face.d], pointColor);\r
- }\r