문제

I have a threejs scene with intersection checking on objects. I'm adding every scene object to the array which is then checked by the raycaster.

var intersects = raycaster.intersectObjects( scene.children );

I then check the color of an object and change it on contact with the mouse pointer.

INTERSECTED.material.emissive.setHex( 0xff0000 );

If I add a helper object, like CameraHelper or GridHelper, to the scene I get constant errors because .getHex .setHex is not possible with the helper objects.

Is it possible to exclude the helper objects from this check and how would I do this?

It has to be something like scene.children - scene.helpers but I cannot come up with a way to do this. Thanks for the help.

도움이 되었습니까?

해결책

Create an array of objects that you want Raycaster to process.

var objects = [];

objects.push( mesh1 );
objects.push( mesh2 );

---

var intersects = raycaster.intersectObjects( objects, recursiveFlag );

three.js r.73

다른 팁

From my understanding, there are 2 solutions:

A reason you might not want to use Group for this is because you might be using Group to keep multiple objects together but you would only want to raycast test for some objects in the Group.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top