Answers for "threejs check if camera is pointing towards object"

0

threejs check if camera is pointing towards object

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

// Your 3d point to check
var pos = new THREE.Vector3(x, y, z);
if (frustum.containsPoint(pos)) {
    // Do something with the position...
}
Posted by: Guest on April-01-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language