fatman13
fatman13

Reputation: 162

How to find intersect with Object3d in Three js?

I have a json model exported from Revit using RvtVa3c. I added the model to the scene using ObjectLoader.

var loader = new THREE.ObjectLoader(manager);
loader.load( 'mesa.js', function ( object ) {
  scene.add(object);
}

Then I tried both...

// From Va3cViewer.js
var raycaster = new THREE.Raycaster( camera.position, vector.sub( camera.position ).normalize() );
var intersects = raycaster.intersectObjects( targetList );

and...

// From three js example code 
// have onMouseMove event and raycaster initialized elsewhere in the code
raycaster.setFromCamera( mouse, camera );
var intersects = raycaster.intersectObjects( scene.children );

Both didn't find any intersect. I have read one post about calling computeFaceNormals() on geometry before trying to find intersect, but no children have geometry when I debugged the code. Is there no way to find intersect with object3d? Please help. Many thanks in advance.

Source here.

Upvotes: 0

Views: 2136

Answers (1)

fatman13
fatman13

Reputation: 162

Just Found this post.

Adding the second argument of "true" seemed to do the trick.

var intersects = raycaster.intersectObjects( targetList, true );

Upvotes: 1

Related Questions