Просмотр исходного кода

THREE.Frustum.prototype.intersectsObject update

xzw недель назад: 3
Родитель
Сommit
7432693289
3 измененных файлов с 60 добавлено и 49 удалено
  1. 1 1
      libs/three.js/build/three.module.js
  2. 5 3
      src/custom/mergeStartTest.js
  3. 54 45
      src/custom/three.shim.js

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

@@ -24452,7 +24452,7 @@ function WebGLRenderer( parameters ) {
 				}
 
 				if ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) {
-
+ 
 					if ( sortObjects ) {
 
 						_vector3.setFromMatrixPosition( object.matrixWorld )

+ 5 - 3
src/custom/mergeStartTest.js

@@ -356,9 +356,11 @@ var start = function(dom, mapDom, number, fileServer, webSite){ //t-Zvd3w0m
     ], tileIndex = Potree.browser.urlHasValue('tileIndex',true) || 0
     
      let glbUrls = [ 
-     //   {url:`${Potree.resourcePath}/models/glb/animation/man.glb`, angle:0},//transform后,SkinnedMesh莫名移近会消失,可能模型没做好
-     //   {url:`${Potree.resourcePath}/models/glb/animation/kid.glb`, angle:Math.PI/2},
      
+        {url:`${Potree.resourcePath}/models/glb/animation/man.glb`, angle:0}, 
+         {url:`${Potree.resourcePath}/models/glb/animation/Xgrids_robot_1_v2.glb`, angle:0},
+     
+     //   {url:`${Potree.resourcePath}/models/glb/animation/kid.glb`, angle:Math.PI/2}, 
      //   {url:`${Potree.resourcePath}/models/glb/animation/Soldier.glb`, angle:Math.PI/2},
          
         {url:`${Potree.resourcePath}/models/glb/animation/man--walk.glb`, angle:Math.PI/2},  
@@ -563,7 +565,7 @@ var start = function(dom, mapDom, number, fileServer, webSite){ //t-Zvd3w0m
                 
                 viewer.loadModel({ 
                     fileType:'glb', 
-                     unlit:true,
+                    unlit:true,
                     url ,
                     transform : { 
                         rotation : [angle,  0,   0],

+ 54 - 45
src/custom/three.shim.js

@@ -470,52 +470,32 @@ THREE.Curve.prototype.getPointAt = function(u, optionalTarget) {
 
 }
 
-const _inverseMatrix$3 = /*@__PURE__*/
-new THREE.Matrix4();
-const _ray$3 = /*@__PURE__*/
-new THREE.Ray();
-const _sphere$6 = /*@__PURE__*/
-new THREE.Sphere();
-const _sphereHitAt = /*@__PURE__*/
-new THREE.Vector3();
+const _inverseMatrix$3 = new THREE.Matrix4();
+const _ray$3 = new THREE.Ray();
+const _sphere$6 = new THREE.Sphere();
+const _sphereHitAt = new THREE.Vector3();
 
-const _vA$1 = /*@__PURE__*/
-new THREE.Vector3();
-const _vB$1 = /*@__PURE__*/
-new THREE.Vector3();
-const _vC$1 = /*@__PURE__*/
-new THREE.Vector3();
+const _vA$1 = new THREE.Vector3();
+const _vB$1 = new THREE.Vector3();
+const _vC$1 = new THREE.Vector3();
 
-const _tempA = /*@__PURE__*/
-new THREE.Vector3();
-const _morphA = /*@__PURE__*/
-new THREE.Vector3();
+const _tempA = new THREE.Vector3();
+const _morphA = new THREE.Vector3();
 
-const _intersectionPoint = /*@__PURE__*/
-new THREE.Vector3();
-const _intersectionPointWorld = /*@__PURE__*/
-new THREE.Vector3();
+const _intersectionPoint = new THREE.Vector3();
+const _intersectionPointWorld = new THREE.Vector3();
 
-const _basePosition = /*@__PURE__*/
-new THREE.Vector3();
+const _basePosition = new THREE.Vector3();
 
-const _skinIndex = /*@__PURE__*/
-new THREE.Vector4();
-const _skinWeight = /*@__PURE__*/
-new THREE.Vector4();
+const _skinIndex = new THREE.Vector4();
+const _skinWeight = new THREE.Vector4();
 
-const _vector3 = /*@__PURE__*/
-new THREE.Vector3();
-const _matrix4 = /*@__PURE__*/
-new THREE.Matrix4();
-const _vertex = /*@__PURE__*/
-new THREE.Vector3();
-const _sphere$5 = /*@__PURE__*/
-new THREE.Sphere();
-const _inverseMatrix$2 = /*@__PURE__*/
-new THREE.Matrix4();
-const _ray$2 = /*@__PURE__*/
-new THREE.Ray();
+const _vector3 = new THREE.Vector3();
+const _matrix4 = new THREE.Matrix4();
+const _vertex =  new THREE.Vector3();
+const _sphere$5 =  new THREE.Sphere();
+const _inverseMatrix$2 = new THREE.Matrix4();
+const _ray$2 = new THREE.Ray();
 
 THREE.SkinnedMesh.prototype.computeBoundingSphere = function() {
 
@@ -844,11 +824,11 @@ THREE.SkinnedMesh.prototype._computeIntersections = function(raycaster, intersec
 
 }
 
-const _v40 = /*@__PURE__*/
+const _v40 = 
 new THREE.Vector4();
-const _v41 = /*@__PURE__*/
+const _v41 = 
 new THREE.Vector4();
-const _v42 = /*@__PURE__*/
+const _v42 = 
 new THREE.Vector4();
 function checkGeometryIntersection(object, material, raycaster, ray, uv, uv1, normal, a, b, c) {
 
@@ -938,9 +918,9 @@ function checkIntersection$1(object, material, raycaster, ray, pA, pB, pC, point
 
 }
 
-const _v1$6 = /*@__PURE__*/
+const _v1$6 = 
 new THREE.Vector3();
-const _v2$3 = /*@__PURE__*/
+const _v2$3 = 
 new THREE.Vector3();
 THREE.Sphere.prototype.expandByPoint = function(point) {
 
@@ -1018,6 +998,31 @@ THREE.InterleavedBufferAttribute.prototype.applyNormalMatrix = function(m) {
 
 }
 
+
+
+THREE.Frustum.prototype.intersectsObject = function( object ) {
+
+    if ( object.boundingSphere !== undefined ) {//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 );
+
+}
+
+
 THREE.Color.prototype.getHSV = function() {
     //or hsb   色相、饱和度、明度(不同于hsl的亮度,只有色相是和hsl一样)代码源于deepseek 
     let r = this.r, g = this.g, b = this.b
@@ -1081,3 +1086,7 @@ THREE.Color.prototype.set = function(){
     if(arguments.length >= 3)return this.setRGB.apply(this, arguments)
     return oldSet.apply(this, arguments)
 }
+
+
+
+