提交 de6d62bf 编写于 作者: I ide user ide_gero3

improve frustum culling

上级 eeef494f
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -44,8 +44,7 @@ THREE.Frustum.prototype.contains = function ( object ) {
var distance,
planes = this.planes,
matrix = object.matrixWorld,
scale = THREE.Frustum.__v1.set( matrix.getColumnX().length(), matrix.getColumnY().length(), matrix.getColumnZ().length() ),
radius = - object.geometry.boundingSphere.radius * Math.max( scale.x, Math.max( scale.y, scale.z ) );
radius = - object.geometry.boundingSphere.radius * matrix.getMaxScaleOnAxis();
for ( var i = 0; i < 6; i ++ ) {
......
......@@ -805,6 +805,16 @@ THREE.Matrix4.prototype = {
return this;
},
getMaxScaleOnAxis : function () {
var scaleXSq = this.n11 * this.n11 + this.n21 * this.n21 + this.n31 * this.n31;
var scaleYSq = this.n12 * this.n12 + this.n22 * this.n22 + this.n32 * this.n32;
var scaleZSq = this.n13 * this.n13 + this.n23 * this.n23 + this.n33 * this.n33;
return Math.sqrt(Math.max( scaleXSq , Math.max( scaleYSq , scaleZSq )));
},
//
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册