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

frustum culling improved

上级 c09d8349
...@@ -44,8 +44,7 @@ THREE.Frustum.prototype.contains = function ( object ) { ...@@ -44,8 +44,7 @@ THREE.Frustum.prototype.contains = function ( object ) {
var distance, var distance,
planes = this.planes, planes = this.planes,
matrix = object.matrixWorld, matrix = object.matrixWorld,
scale = THREE.Frustum.__v1.set( matrix.getColumnX().length(), matrix.getColumnY().length(), matrix.getColumnZ().length() ), radius = - object.geometry.boundingSphere.radius * matrix.getMaxScaleOnAxis();
radius = - object.geometry.boundingSphere.radius * Math.max( scale.x, Math.max( scale.y, scale.z ) );
for ( var i = 0; i < 6; i ++ ) { for ( var i = 0; i < 6; i ++ ) {
......
...@@ -805,6 +805,16 @@ THREE.Matrix4.prototype = { ...@@ -805,6 +805,16 @@ THREE.Matrix4.prototype = {
return this; 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.
先完成此消息的编辑!
想要评论请 注册