Three.js: Raycaster and invisible meshes

Created on 6 Nov 2015  路  7Comments  路  Source: mrdoob/three.js

I noticed that since v72, the raycaster ignore clicks on objects that are set to visible = false;
I also noticed that some people asked to let the choice to the developer to manage the raycaster to allow clicks on invisible objects as well as visible.

Is there a plan on the roadmap to implement this ?

Thanks

Duplicate

Most helpful comment

You can do this. Just set the material visibility to false instead of the object visibility.

All 7 comments

You can do this. Just set the material visibility to false instead of the object visibility.

I can't do this because all my objects share a common material, and I need to show only certain meshes at a given time. If I implement your solution, when I will show the material, it will show all the meshes

Maybe the right solution for this will be to implement layers in Raycaster.

You should still be able to use THREE.Mesh.prototype.raycast directly on the mesh with visible = false:

// instead of
// var intersects = raycaster.intersectObject( mesh );
var intersects = [];
mesh.raycast( raycaster, intersects );
if( intersects.length > 0 ) { ...

Yep. That too!

Could layers be practically emulated using children of scene? Such as scene.add(layer1), scene.add(layer2) and then raycaster.intersectObjects(layer1.children, true), for example?

Closing this issue. #14700 tracks how Raycaster should handle invisible objects and whether or not it should utilize Layer.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fernandojsg picture fernandojsg  路  85Comments

DefinitelyMaybe picture DefinitelyMaybe  路  88Comments

sunag picture sunag  路  161Comments

jonobr1 picture jonobr1  路  95Comments

kumavis picture kumavis  路  153Comments