Преглед изворни кода

skinMesh 经常被frustum cull的bug

xzw пре 2 месеци
родитељ
комит
dcb18c671e
2 измењених фајлова са 29 додато и 1 уклоњено
  1. 3 1
      libs/three.js/build/three.module.js
  2. 26 0
      src/custom/three.shim.js

+ 3 - 1
libs/three.js/build/three.module.js

@@ -26242,7 +26242,9 @@ function SkinnedMesh( geometry, material ) {
 	this.bindMode = 'attached';
 	this.bindMatrix = new Matrix4();
 	this.bindMatrixInverse = new Matrix4();
-
+    //xzw add:
+    this.boundingBox = null;
+    this.boundingSphere = null;
 }
 
 SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {

+ 26 - 0
src/custom/three.shim.js

@@ -986,6 +986,32 @@ THREE.Triangle.getInterpolation = function( point, p1, p2, p3, v1, v2, v3, targe
 
 
 
+THREE.Frustum.prototype.intersectsObject = function( object ) {
+    /* if(object.name == '网格001' && object.geometry.attributes.position.count == 5778){
+        debugger
+    } */
+    if ( object.boundingSphere !== undefined ) {//null   skinMesh 173ver  和frustumCull有关
+
+        if ( object.boundingSphere === null ) object.computeBoundingSphere();
+
+        _sphere$5.copy( object.boundingSphere ).applyMatrix4( object.matrixWorld );
+
+    } else {
+
+        const geometry = object.geometry;
+
+        if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
+
+        _sphere$5.copy( geometry.boundingSphere ).applyMatrix4( object.matrixWorld );
+
+    }
+
+    return this.intersectsSphere( _sphere$5 );
+
+}
+
+
+