Three.js - Using Projector And Ray To Selected A Vertex
My overall aim is to be able to load an .obj file which is a human body. Allow the user to select two vertices and highlight them with flags. Then find the index of the two vertice
Solution 1:
To fix this I created a mesh from the object returned by the obj loader using this code
var loader = new THREE.OBJLoader();
loader.load( "img/originalMeanModel.obj", function (object) {
object.children[0].geometry.computeFaceNormals();
var geometry = object.children[0].geometry;
console.log(geometry);
THREE.GeometryUtils.center(geometry);
var material = new THREE.MeshLambertMaterial({color: 0xffffff, shading: THREE.FlatShading, vertexColors: THREE.VertexColors });
mesh = new THREE.Mesh(geometry, material);
model = mesh;
// model = object;
scene.add( model );
} );
Then when performing the intersectObject I did it on the model not the scene
var intersects = ray.intersectObject(model);
Post a Comment for "Three.js - Using Projector And Ray To Selected A Vertex"