How can I get my grid to leave the screen?

I can’t figure out how to determine how this is happening on the screen, can anyone help? I use WebGL and Three.js.

0
source share
1 answer

You can use Frustum testing a bit like this:

// Create a new Frustum object (for efficiency, do this only once) var frustum = new THREE.Frustum(); // Helper matrix (for efficiency, do this only once) var projScreenMatrix = new THREE.Matrix4(); // Set the matrix from camera matrices (which are updated on each renderer.render() call) projScreenMatrix.multiply( camera.projectionMatrix, camera.matrixWorldInverse ); // Update the frustum frustum.setFromMatrix( projScreenMatrix ); // Test for visibility if ( !frustum.contains( object ) ) { // It off-screen! } 

This is copied from WebGLRenderer Sources .

+2
source

Source: https://habr.com/ru/post/1442856/


All Articles