# Webgl基于Three.js的开发——利用Frustum来判断相交或者包含

function initFrustum()
{
//定义锥形物体最远的四个点
var topLeftPoint = new THREE.Vector3(-2000,2000,-1000);
var topRightPoint= new THREE.Vector3(2000,2000,-1000);
var bottomLeftPoint = new THREE.Vector3(-2000, -2000, -1000);
var bottomRightPoint = new THREE.Vector3(2000, -2000, -1000);
//定义锥形物体最近的四个点
var nearTopLeftPoint = new THREE.Vector3(-2000, 2000, 1000);
var nearTopRightPoint = new THREE.Vector3(2000, 2000, 1000);
var nearBottomLeftPoint = new THREE.Vector3(-2000, -2000, 1000);
var nearBottomRightPoint = new THREE.Vector3(2000, -2000, 1000);
topPlane = new THREE.Plane();
bottomPlane = new THREE.Plane();
rightPlane = new THREE.Plane();
leftPlane = new THREE.Plane();
nearPlane = new THREE.Plane();
farPlane = new THREE.Plane();
topPlane.setFromCoplanarPoints(nearTopLeftPoint, topLeftPoint, topRightPoint);
leftPlane.setFromCoplanarPoints(nearTopLeftPoint, topLeftPoint, bottomLeftPoint);
bottomPlane.setFromCoplanarPoints(nearBottomLeftPoint, bottomLeftPoint, bottomRightPoint);
rightPlane.setFromCoplanarPoints(nearBottomRightPoint, bottomRightPoint, topRightPoint);
farPlane.setFromCoplanarPoints(topLeftPoint, topRightPoint, bottomLeftPoint);
nearPlane.setFromCoplanarPoints(nearTopLeftPoint,nearTopRightPoint,nearBottomLeftPoint);
frustum = new THREE.Frustum(topPlane,leftPlane,bottomPlane,rightPlane,farPlane,nearPlane);
}

frustum.intersectsObject(intersects[0].object)

• 广告
• 抄袭
• 版权
• 政治
• 色情
• 无意义
• 其他

120