MozillaReality/mred

add efficient bounding box state to each object

blairmacintyre opened this issue · 0 comments

Would like to write a script that does "isInView", essentially doing something like this

camera.updateMatrix();
camera.updateMatrixWorld();
var frustum = new THREE.Frustum();
frustum.setFromMatrix(new THREE.Matrix4().multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse));  

var box = event.target.bbox
return frustum.intersectsBox(box)) 

Could use sphere, too (but BoxHelper makes boxes easy). Problem is efficiently calculating either when there is nesting and transformations.