javascript - Three.js Raycaster not detecting scene mesh -


i using three.js r67 in chrome version 35.0.1916.153 m

i attempting intersect custom meshes have created in scene. raycaster not appear registering meshes although exist within scene.children .

mesh creation code:

if (modelvertices != null && modelvertices.length >= 3) {             triangles = three.shape.utils.triangulateshape ( modelvertices, holes );              for( var = 0; < triangles.length; i++ ){                 modelgeometry.faces.push( new three.face3( triangles[i][0], triangles[i][2], triangles[i][2] ));                  }              modelgeometry.computefacenormals();             var modelmesh = new three.mesh(modelgeometry, material);             modelmesh.material.side = three.doubleside;             polyhedralzgroup.add(modelmesh)     } 

raycasting code:

                var projector = new three.projector();                 projector.unprojectvector( vector, camera );                  var raycaster = new three.raycaster( camera.position, vector.sub( camera.position ).normalize() );                 //console.log("work");                 // see if ray camera world hits 1 of our meshes                  var intersects = raycaster.intersectobjects( scene.children, true );                 helper.position.set( 0, 0, 0 );                 //console.log(intersects.length);                 if ( intersects.length > 0 ) {                       if (intersects[ 0 ].face != null) {                     helper.lookat( intersects[ 0 ].face.normal );                     helper.position.copy( intersects[ 0 ].point );  } 

as in code, using computefacenormals(); isn't issue (see here). oddly scene seems intersecting other geometries constructed using simple triangles (i.e. not using three.shape.utils.triangulateshape ; pushing triangle vertices , faces manually) fine means can't issue not taking account canvas offset intersecting. have examined both geometries , there doesn't seem fundamental differences between two.

example of object not being intersected

does have ideas issue may be?

the issue fact way vertices had been constructed: using strings. although three.js allows construct vertices (and therefore geometry , mesh) , in turn display geometry using strings, not allow use vertices raycasting. more succinctly issue reduced to:

changing this:

avertex = new three.vector3( part[0], part[1] , part[2] ); 

to this:

avertex = new three.vector3( parsefloat(part[0]), parsefloat(part[1]) , parsefloat(part[2]) ); 

i'm not sure if bug or feature, seems no errors thrown when using vertices in string format, although can't raycast on objects string vertex geometries (possibly because normals can't computed?).


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -