Kaynağa Gözat

fix: Potree.settings.libsUrl = './lib/'

xzw 3 yıl önce
ebeveyn
işleme
f17e1dff2a

+ 98 - 19
public/lib/potree/potree.js

@@ -56901,13 +56901,26 @@ void main() {
         
         realVisible(){
             let parent = this;
+            
+            let v;
             while(parent){
                 if(parent.visible === false){
-                    return false 
+                    v = false;
+                    break; 
                 }
                 parent = parent.parent;
             }
-            return true
+            v = true;
+            if(!this.latestRealVisi && v){//变为可见后先update 
+                this.latestRealVisi = true;
+                setTimeout(()=>{
+                    this.update();
+                },1);//延迟 防止无限调用
+                return false
+            }
+            
+            this.latestRealVisi = v;
+            return v;
         }
         
         update(e){
@@ -60285,7 +60298,7 @@ void main() {
                     || this.isAtWrongPlace && this.isNew
                     || !e.isAtDomElement && this.isNew//如果是刚添加时在其他dom点击, 不要响应
                     ||  e.hoverViewport != viewer.mainViewport && this.unableDragAtMap //垂直的测量线不允许在地图上放点
-                    || !getDifferentPoint(this.points, this.points.length) //不允许和之前的点相同 
+                    || this.isNew && !getDifferentPoint(this.points, this.points.length )   //不允许和之前的点相同, 但这句在点云稀疏时会导致难结束 
                 ) 
             ){
                 return this.continueDrag(null,e)    
@@ -81127,21 +81140,22 @@ void main() {
         pan (x, y) { //发现pan其实就是translate
     		this.translate(x, 0, y);
     	}
-    	translate (x, y, z) {
+    	translate (x, y, z, forceHorizon ) {
+            //相机方向
     		let dir = new Vector3(0, 1, 0);
-    		dir.applyAxisAngle(new Vector3(1, 0, 0), this.pitch);
-    		dir.applyAxisAngle(new Vector3(0, 0, 1), this.yaw);
+    		dir.applyAxisAngle(new Vector3(1, 0, 0), forceHorizon ? 0 : this.pitch); //上下角度
+    		dir.applyAxisAngle(new Vector3(0, 0, 1), this.yaw);//水平角度
 
     		let side = new Vector3(1, 0, 0);
-    		side.applyAxisAngle(new Vector3(0, 0, 1), this.yaw);
+    		side.applyAxisAngle(new Vector3(0, 0, 1), this.yaw);  //垂直于相机当前水平朝向的 左右方向
 
-    		let up = side.clone().cross(dir);
+    		let up = side.clone().cross(dir); //垂直于相机当前水平朝向的 向上方向
 
-    		let t = side.multiplyScalar(x)
-    			.add(dir.multiplyScalar(y))
-    			.add(up.multiplyScalar(z));
+    		let t = side.multiplyScalar(x)   //x影响 左右分量
+    			.add(dir.multiplyScalar(y))  //y影响 前后分量
+    			.add(up.multiplyScalar(z));  //z影响 上下分量
                  
-            if(this.fixZWhenPan) t.setZ(0); //在水平面上平移
+            
             
     		this.position = this.position.add(t);
             this.restrictPos();
@@ -103419,6 +103433,17 @@ ENDSEC
             this.dollyStart = new Vector2$1;
             this.dollyEnd = new Vector2$1;
             
+            
+            this.keys = {
+                FORWARD: ['W'.charCodeAt(0), 38],
+                BACKWARD: ['S'.charCodeAt(0), 40],
+                LEFT: ['A'.charCodeAt(0), 37],
+                RIGHT: ['D'.charCodeAt(0), 39],
+                UP: ['Q'.charCodeAt(0)],
+                DOWN: ['E'.charCodeAt(0)], 
+            };
+            
+            
     		let drag = (e) => {
                 if(!this.enabled)return
      
@@ -103610,7 +103635,12 @@ ENDSEC
             }) */
             
             
-            
+            this.viewer.addEventListener('focusOnObject',(o)=>{
+                if(o.position && o.CamTarget){
+                    let distance = o.position.distanceTo(o.CamTarget);
+                    if(distance < minRadius) minRadius = distance * 0.5; //融合页面当focus一个很小的物体时,需要将minRadius也调小
+                }
+            });
             
     	}
 
@@ -103731,6 +103761,46 @@ ENDSEC
             if(!this.enabled)return
     		let view = this.scene.view;
 
+
+
+
+            { // accelerate while input is given
+    			let ih = this.viewer.inputHandler;
+
+    			let moveForward = this.keys.FORWARD.some(e => ih.pressedKeys[e]);
+    			let moveBackward = this.keys.BACKWARD.some(e => ih.pressedKeys[e]);
+    			let moveLeft = this.keys.LEFT.some(e => ih.pressedKeys[e]);
+    			let moveRight = this.keys.RIGHT.some(e => ih.pressedKeys[e]);
+    			let moveUp = this.keys.UP.some(e => ih.pressedKeys[e]);
+    			let moveDown = this.keys.DOWN.some(e => ih.pressedKeys[e]);
+                
+                 
+                  
+                let px = 0 , py = 0, pz = 0;
+                if(moveForward){
+                    py = 1;
+                }else if(moveBackward){
+                    py = -1;
+                }
+                
+                if(moveLeft){
+                    px = -1;
+                }else if(moveRight){
+                    px = 1;
+                }
+                if(moveUp){
+                    pz = 1;
+                }else if(moveDown){
+                    pz = -1;
+                }
+                
+                (px!=0 || py!=0 || pz!=0) && view.translate(px, py, pz, true); 
+                 
+            }
+                    
+     
+
+
     		{ // apply rotation
     			let progression = Math.min(1, this.fadeFactor * delta);
 
@@ -115941,7 +116011,11 @@ ENDSEC
     			if ( axis.indexOf( 'Z' ) === - 1 ) offset.z = 0;
 
     			if ( space === 'local' && axis !== 'XYZ' ) {
-
+                    //xzw 加,否则会反向---------------
+                    object.scale.x < 0 && (offset.x *= -1);
+                    object.scale.y < 0 && (offset.y *= -1);
+                    object.scale.z < 0 && (offset.z *= -1);
+                    //---------------------------------
     				offset.applyQuaternion( quaternionStart ).divide( parentScale );
 
     			} else {
@@ -116156,7 +116230,7 @@ ENDSEC
 
     			// Apply rotate
     			if ( space === 'local' && axis !== 'E' && axis !== 'XYZE' ) {
-
+                    object.scale[axis.toLowerCase()] < 0 && (rotationAngle *= -1); //xzw 加,否则会反向 
     				object.quaternion.copy( quaternionStart );
     				object.quaternion.multiply( _tempQuaternion.setFromAxisAngle( rotationAxis, rotationAngle ) ).normalize();
 
@@ -117440,7 +117514,7 @@ ENDSEC
         
         init(){
              
-            {
+            { 
                 let ground = this.ground = new InfiniteGridHelper(1, 10000, new Color('#fff'), 10000, 0.2, 0.3);
                 viewer.scene.scene.add(ground); 
                 //再加两条线否则在正侧边看不到
@@ -126315,7 +126389,7 @@ ENDSEC
                     mtlLoader : new MTLLoader( manager ),
                     glbLoader : new GLTFLoader(undefined, this.renderer, Potree.settings.libsUrl )
                  
-                };
+                }; 
                 //add test
                 /* const environment = new RoomEnvironment();
                 const pmremGenerator = new THREE.PMREMGenerator( this.renderer ); 
@@ -129211,12 +129285,17 @@ ENDSEC
                 }
                 let boundSize = bound.getSize(new Vector3);
                 
-                 
+                
                 {
+                    
                     boundSize.x *= scale; //稍微放大一些,不然会靠到屏幕边缘
                     boundSize.y *= scale;  
+                    let min = 0.0001;
+                    boundSize.x = Math.max(min, boundSize.x);
+                    boundSize.y = Math.max(min, boundSize.y);
                 }
                 
+                
                 let aspect = boundSize.x / boundSize.y;
                 if(camera.aspect > aspect){//视野更宽则用bound的纵向来决定
                     dis = boundSize.y/2/ Math.tan(MathUtils.degToRad(camera.fov / 2)) + boundSize.z/2; 
@@ -129501,7 +129580,7 @@ ENDSEC
                 }
             });
              
-            
+            this.dispatchEvent({type:'focusOnObject', CamTarget:target, position}); //给controls发送信息
             
             return {promise:deferred.promise()}
         }

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
public/lib/potree/potree.js.map


+ 1 - 1
src/sdk/cover/index.js

@@ -7,7 +7,7 @@ export const enter = (dom, isLocal) => {
     
     Potree.settings.isOfficial = true //标记为正式、非测试版本 
     //Potree.fileServer = axios 
-    Potree.settings.libsUrl = '../lib/'
+    Potree.settings.libsUrl = './lib/'
     
     const tagLimitDis = 8;