在我的场景中,有很多对象组(Object3Ds),我已经设置了一个系统,用于点击/悬停在它们上面做某些事情。当它使用raycaster查找鼠标下的对象时,它会返回单个对象,而不是组(我需要)。
我用来获取光标下对象的代码如下:
raycaster.setFromCamera(mouse, camera);
clickobjstore = raycaster.intersectObjects(objects, true);
// The following doesn't work because intersects[0] is not the group, it's the object within the group!
for (j = 0; j < intersects[0].object.children.length; j++) {
intersects[0].object.children[j].material.color.setHex(0x1A75FF);
}
答案 0 :(得分:2)
Object3D class为您存储对parent
- 对象的引用:
var objectGroup = intersects[0].parent;
for (j = 0; j < objectGroup.children.length; j++) {
objectGroup.children[j].material.color.setHex(0x1A75FF);
}