我不知道如何检测到它从屏幕上脱离,有人可以帮助吗?我正在使用webGl和three.js。
您可以使用frustum测试,有点像这样:
// 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's off-screen!
}
这是从WebGlrenderer来源复制的。