2012-10-29 120 views

回答

2

您可以使用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 sources複製。

+0

我得到類型錯誤:THREE.Frustum不是構造函數,當我嘗試運行這段代碼 – smuggledPancakes

+0

我必須有一個過時的three.js所的文件,現在它工作的感謝! – smuggledPancakes