Is there a more efficient method to retrieve the original object used to set a Box3 (using Box.setFromObject) once the Box3 detects a collision?
Currently, I am storing the Box3 in an array and then adding the object that was initially used to create the Box3 into a separate array:
var cube = new THREE.Mesh( geometry, material );
cube.name = "box0";
scene.add( cube );
var bbox = new THREE.Box3();
bbox.setFromObject( cube );
bboxList.push(bbox);
bboxObjectNameList.push(cube.name);
I then iterate through both arrays each frame:
for(i=0;i<bboxList.length;i++)
{
if(bboxList[i].containsPoint(camera.position)) {
hitName = bboxObjectNameList[i];
hitObj = scene.getObjectByName(hitName);
}
}
If anyone has suggestions on a better approach to identify the object associated with the Box3, please share.
Using Three.js r84