what I'm trying to achieve: at first, you're only able to select objects within the group "interactable". when you click on an "interactable" object, you can now select any object within group "master". (you're picking up an interactable then selecting an object to place it on.)
"master" contains the group "interactable". right now I'm only able to switch from selecting within "interactable" to selecting within "master" without "interactable".
here's my code:
function render() {
raycaster.setFromCamera(mouse, camera);
if (obj_selected) {intersects = raycaster.intersectObjects(master.children)}
else {intersects = raycaster.intersectObjects(interactable.children)}
if (intersects.length > 0) {
if (INTERSECTED) INTERSECTED.material.emissive.setHex(INTERSECTED.currentHex);
INTERSECTED = intersects[0].object;
INTERSECTED.currentHex = INTERSECTED.material.emissive.getHex();
INTERSECTED.material.emissive.setHex( 0xf4425f );
} else {
if (INTERSECTED) INTERSECTED.material.emissive.setHex(INTERSECTED.currentHex);
INTERSECTED = null;
}
renderer.render(scene, camera);
}
I hope my explanation wasn't too confusing. thanks in advance.