xzw 3 tahun lalu
induk
melakukan
4329491ecd
3 mengubah file dengan 118 tambahan dan 105 penghapusan
  1. 113 101
      public/lib/potree/potree.js
  2. 1 1
      public/lib/potree/potree.js.map
  3. 4 3
      src/sdk/cover/index.js

+ 113 - 101
public/lib/potree/potree.js

@@ -778,13 +778,14 @@
         
         
         useDepthTex: true,//使用深度贴图,但不代表一定有(得到的intersect更快速准确和稳定)   SS-t-7DUfWAUZ3V  
-        
+        matUseDepth:false, 
         //panoEdit:
         datasetsPanos:{},
         
         //mergeModel:
         boundAddObjs:false,
         intersectOnObjs:false,
+        
     };
 
      
@@ -56724,7 +56725,9 @@ void main() {
     		};  
             
             let defines = {};
-            if(o.useDepth && Features.EXT_DEPTH.isSupported())defines.useDepth = '';
+            
+            let useDepth = o.useDepth && Features.EXT_DEPTH.isSupported() && Potree.settings.matUseDepth;
+            if(useDepth )defines.useDepth = '';
             if(o.map)defines.use_map = ''; 
             super({ 
                 uniforms,
@@ -56740,7 +56743,7 @@ void main() {
                 this.opacity = o.opacity;
             }
            
-            if(o.useDepth && Features.EXT_DEPTH.isSupported()) this.useDepth_ = true;
+            if(useDepth) this.useDepth_ = true;
             
             
             let setSize = (e)=>{//如果出现横条状的异常,往往是viewportOffset出错 
@@ -59512,15 +59515,15 @@ void main() {
                 //默认
                 lineWidth : 5,  
                 color:0xffffff,
-                transparent : true, depthWrite:false,  depthTest:false,
+                transparent : true, depthWrite:true,  depthTest:true,
                 dashSize : 0.1, gapSize:0.1, 
             }, o, {
                 //修正覆盖:
                 dashed: o.dashWithDepth ? supportExtDepth && !!o.dashed : !!o.dashed ,
                 dashWithDepth:!!o.dashWithDepth,//只在被遮住的部分显示虚线
-                useDepth: !!o.useDepth,  
+                useDepth: Potree.settings.matUseDepth  && !!o.useDepth,  
                 supportExtDepth,
-                
+                 
             });
             
             
@@ -61224,7 +61227,7 @@ void main() {
                         gapSize: 0.04,    
                         transparent: true,
                         opacity: config$1.measure.default.opacity,
-                        depthTestWhenPick:true,
+                        depthTestWhenPick:true, 
                     }),
                     edgeSelect:  LineDraw.createFatLineMat({
                         color: config$1.measure.highlight.color,//'#f0ff00',
@@ -61233,6 +61236,7 @@ void main() {
                         lineWidth: config$1.measure.lineWidth  ,
                         transparent: true,
                         opacity: config$1.measure.highlight.opacity
+                        
                     }),
                     guide:   LineDraw.createFatLineMat({
                         color:config$1.measure.guide.color, 
@@ -63766,11 +63770,9 @@ void main() {
              modelEditing.updateMatrixWorld()   
             let boundCenter = modelEditing.boundingBox.getCenter(new THREE.Vector3).applyMatrix4(modelEditing.matrixWorld);
              */
-            MergeEditor.moveBoundCenter(new Vector2$1(x,y, model.boundCenter.z));  //使模型中心的xy在鼠标所在位置
-            
-            
-            model.dispatchEvent("position_changed");
-            
+            MergeEditor.moveBoundCenterTo(modelEditing,new Vector3(x,y, modelEditing.boundCenter.z));  //使模型中心的xy在鼠标所在位置
+             
+            modelEditing.dispatchEvent("position_changed"); 
              
         };
         let cancelMove = ()=>{ 
@@ -63804,18 +63806,20 @@ void main() {
                 {//transform
                     let updateBound = ()=>{ 
                         model.updateMatrixWorld();
-                        viewer.updateModelBound();
-                        model.dispatchEvent('transformChanged'); 
+                        viewer.updateModelBound(); 
                     };  
                     let maintainBtmZAndCenter = ()=>{
                         MergeEditor.maintainBoundXY(model);
                         MergeEditor.setModelBtmHeight(model); 
                         updateBound();
+                        model.dispatchEvent('transformChanged'); 
                     };
                     model.addEventListener('position_changed', ()=>{
-                        MergeEditor.getBoundCenter(model);//更新boundcenter
                         updateBound();
-                    }); 
+                        MergeEditor.getBoundCenter(model);//更新boundcenter
+                        MergeEditor.computeBtmHeight(model);
+                        model.dispatchEvent('transformChanged'); 
+                    });
                     model.addEventListener("orientation_changed", maintainBtmZAndCenter );
                     model.addEventListener("scale_changed", maintainBtmZAndCenter );
                     
@@ -85577,13 +85581,13 @@ void main() {
     		this.hoverViewport = viewport;
             if(!viewport)return//刚变化viewport时会找不到
              
-    		
+    		let isFlying = this.viewer.viewports.some(e=>e.view.isFlying());
             let intersectPoint;
             
             
             if(e.onlyGetIntersect || !this.drag || this.drag.object || viewport.alignment ){ //没有拖拽物体,但按下鼠标了的话,不intersect
             
-                let dontIntersectPointcloud =  this.drag && viewport.alignment && Potree.settings.editType == 'pano' || viewer.images360.flying; // flying 时可能卡顿
+                let dontIntersectPointcloud =  this.drag && viewport.alignment && Potree.settings.editType == 'pano' || isFlying;/* viewer.images360.flying */ // flying 时可能卡顿
                 //console.log('dontIntersectPointcloud',dontIntersectPointcloud)
                 intersectPoint = this.getIntersect(viewport,  e.onlyGetIntersect, e.pickWindowSize, dontIntersectPointcloud, e.whichPointcloud); //数据集多的时候卡顿
                 //console.log('intersectPoint', intersectPoint)
@@ -85649,10 +85653,13 @@ void main() {
             } 
             
             
+            
             if(!isTouch || e.touches.length == 1){ 
             
-                if(!this.drag || this.drag.notPressMouse ){
-                    let hoveredElements = this.getHoveredElements(); 
+                if((!this.drag || this.drag.notPressMouse || Potree.settings.intersectOnObjs && this.drag.object) && !isFlying){
+                    
+                    /* let blacklist = this.drag && this.drag */
+                    let hoveredElements = this.getHoveredElements( ); 
                     if(hoveredElements.length > 0){
                         let names = hoveredElements.map(h => h.object.name).join(", ");
                         if (this.logMessages) console.log(`${this.constructor.name}: onMouseMove; hovered: '${names}'`);
@@ -115088,7 +115095,9 @@ ENDSEC
             
             viewer.addEventListener('global_single_click',(e)=>{
                 if(viewer.inputHandler.selection[0] ||//正在平移和旋转,不允许更换
-                    viewer.scene.cameraAnimations.length  //正在播放
+                    viewer.scene.cameraAnimations.length ||  //正在播放
+                    e.drag && e.drag.notPressMouse   //在加测量线
+                    //e.clickElement && e.clickElement != e.intersect.object
                 ){
                     return
                 }
@@ -115106,6 +115115,10 @@ ENDSEC
                 }
             });  
             
+            
+            viewer.ssaaRenderPass.enabled = false;
+            viewer.outlinePass.enabled = true;
+            
         },
         
         
@@ -115143,7 +115156,7 @@ ENDSEC
             viewer.objs.remove(model);
         },
         
-        selectModel(model, state=true, ifFocus, by2d){
+        selectModel(model, state=true, fitBound, by2d){
             if(!model) {
                 model = this.selected;
                 state = false;
@@ -115152,10 +115165,13 @@ ENDSEC
             if(state){
                 if(this.selected){
                     if(this.selected == model) return
-                    else this.selectModel(this.selected, false, ifFocus, by2d);
+                    else this.selectModel(this.selected, false, fitBound, by2d);
                 }
                 this.selected = model;
-                ifFocus && MergeEditor.focusOn(model);     //通过在场景里点击模型的话,不focus
+                 
+                MergeEditor.focusOn(model, 500, !!fitBound);     //通过在场景里点击模型的话,不focus
+                 
+               
                 viewer.outlinePass.selectedObjects = [model];
                 
                 if(model.isPointcloud){
@@ -115200,15 +115216,21 @@ ENDSEC
             })  //setView can cancel bump
              
         }, */
-        focusOn(objects, duration = 400){  
+        focusOn(objects, duration = 400, fitBound=true){  
             if(!(objects instanceof Array)){
                 objects = [objects];
             }
             let boundingBox = new Box3;
             objects.forEach(object=>{
                 boundingBox.union(object.boundingBox.clone().applyMatrix4(object.matrixWorld));
-            }); 
-            viewer.focusOnObject({boundingBox}, 'boundingBox', duration  );  
+            });
+             
+            if(fitBound){
+                viewer.focusOnObject({boundingBox}, 'boundingBox', duration); 
+            }else {
+                viewer.focusOnObject({position: boundingBox.getCenter(new Vector3)},  'point', duration, {dontChangePos: true});
+            }
+               
              
         },
         
@@ -115227,6 +115249,13 @@ ENDSEC
             model.position.z += (hopeZ - center.z);
         },
         
+        computeBtmHeight(model){ //位移之后重新计算btmHeight
+            model.updateMatrixWorld();
+            let boundingBox2 = model.boundingBox.clone().applyMatrix4(model.matrixWorld);
+            let size = boundingBox2.getSize(new Vector3);
+            let center = boundingBox2.getCenter(new Vector3);
+            model.btmHeight = center.z - size.z / 2; 
+        },
         
         maintainBoundXY(model){ //在旋转和缩放后,立即执行这个函数,使boundCenter保持原位
              
@@ -115621,7 +115650,7 @@ ENDSEC
             this.forbitTex = texLoader$9.load(Potree.resourcePath+'/textures/pic-forbid.png'); 
             
             //this.layers.set(0/* RenderLayers.RETICULE */);
-            this.renderOrder = 0;
+            this.renderOrder = 100;
             this.layers.set(Potree.config.renderLayers.marker);
             
             
@@ -115826,7 +115855,7 @@ ENDSEC
                  
                 
                 
-                this.position.copy(location);/* .add(normal.clone().multiplyScalar(.01)); */
+                this.position.copy(location);/* .add(normal.clone().multiplyScalar(.01));  */
                 this.updateMatrix();  //lookAt之前要保证得到matrix
                 this.lookAt(this.position.clone().add(this.direction));
                 
@@ -118759,16 +118788,15 @@ ENDSEC
             if(data) { 
                 animation.name = data.name;
                 animation.duration = data.duration;
-                //animation.t = data.t;
-                //animation.curveType = data.curveType;
-                //animation.visible = data.visible; 
+                animation.useDurSlice = data.useDurSlice;
+                 
                 for(const cpdata of data.points){ 
                     /* const position = Potree.Utils.datasetPosTransform({ fromDataset: true, position: cpdata.position, datasetId: Potree.settings.originDatasetId })
                     const target = Potree.Utils.datasetPosTransform({ fromDataset: true, position: cpdata.target, datasetId: Potree.settings.originDatasetId })
                      */
                     const position = new Vector3().copy(cpdata.position);
                     const target = new Vector3().copy(cpdata.target);  
-                    const duration = cpdata.duration;
+                    const duration = cpdata.time;
                     const cp = animation.createControlPoint(null, {position, target, duration}); 
                 }
             }
@@ -121656,7 +121684,7 @@ ENDSEC
         addPass: function (pass){ 
             this.childPass = pass;
         },
-    	render: function (scene, camera,  renderer, writeBuffer, readBuffer, maskActive, renderFun ) {
+    	render: function (scene, camera, viewports, renderer, writeBuffer, readBuffer, maskActive, renderFun ) {
             if(this.useCopy ){
                 scene = this.copyPass.scene; camera = this.copyPass.camera;
             }
@@ -122004,28 +122032,24 @@ ENDSEC
 
     	},
 
-    	render: function ( scene, camera, renderFun  ) {
+    	render: function ( scene, camera, viewports, renderFun  ) {
 
     		var maskActive = false;
-
-    		var pass, i, il = this.passes.length;
+            let passes = this.passes.filter(e=>e.enabled);
+    		var pass, i, il = passes.length;
 
             if(this.readTarget){ //add 使用当前renderTarget中的像素 
-                this.copyPass.render(scene,camera, this.renderer, this.readBuffer, this.renderer.getRenderTarget()  );
-            } 
-            
+                this.copyPass.render(scene, this.renderer, this.readBuffer, this.renderer.getRenderTarget()  );
+            }  
             
-
     		for ( i = 0; i < il; i ++ ) {
 
-    			pass = this.passes[ i ];
-
-    			if ( pass.enabled === false ) continue;
-
+    			pass = passes[ i ];
+     
 
                 //if(i == il-1)pass.renderToScreen = true//
                     
-    			pass.render( scene, camera, this.renderer, this.writeBuffer, this.readBuffer, maskActive, renderFun );
+    			pass.render( scene, camera, viewports, this.renderer, this.writeBuffer, this.readBuffer, maskActive, renderFun );
         
     			if ( pass.needsSwap ) {
 
@@ -122730,7 +122754,7 @@ ENDSEC
 
     	},
 
-    	render: function (scenes, camera, renderer, writeBuffer, readBuffer,  maskActive, renderFun ) {
+    	render: function (scenes, camera, viewports,  renderer, writeBuffer, readBuffer,  maskActive, renderFun ) {
             if(!(scenes instanceof Array))scenes = [scenes];
     		if ( this.selectedObjects.length > 0 ) {
                 
@@ -122743,9 +122767,10 @@ ENDSEC
                         scenes.forEach(scene=>renderer.render( scene, camera)); 
                     }
                 };
+                viewports.forEach(e=>  e.beforeRender = ()=>{ 
+                    this.replaceDepthToViewZ( e.camera   );
+                });
                 
-                //add
-                this.replaceDepthToViewZ( camera   );
     	   
     			this.oldClearColor.copy( renderer.getClearColor(new Color) );
     			this.oldClearAlpha = renderer.getClearAlpha();
@@ -122773,12 +122798,19 @@ ENDSEC
                 //renderer.setRenderTarget(this.renderTargetDepthBuffer)
                 //renderer.clear()
     			//renderer.render( scene, camera/* , this.renderTargetDepthBuffer, true  */);
-     
+                
     			// Make selected objects visible
     			this.changeVisibilityOfSelectedObjects( true );
 
-    			// Update Texture Matrix for Depth compare
-    			this.updateTextureMatrix(camera);
+        
+                viewports.forEach(e=>  e.beforeRender = ()=>{ 
+                    // Update Texture Matrix for Depth compare
+                    this.updateTextureMatrix(e.camera);
+                    this.prepareMaskMaterial.uniforms[ "cameraNearFar" ].value = new Vector2$1( e.camera.near, e.camera.far );
+                });
+
+
+    			
 
     			// Make non selected objects invisible, and draw only the selected objects, by comparing the depth buffer of non selected objects
     			this.changeVisibilityOfNonSelectedObjects( false , scenes);
@@ -122789,7 +122821,6 @@ ENDSEC
                 });
                 
                 
-    			this.prepareMaskMaterial.uniforms[ "cameraNearFar" ].value = new Vector2$1( camera.near, camera.far );
     			this.prepareMaskMaterial.uniforms[ "depthTexture" ].value = this.renderTargetDepthBuffer.texture;
     			this.prepareMaskMaterial.uniforms[ "textureMatrix" ].value = this.textureMatrix;
     			 
@@ -122797,7 +122828,9 @@ ENDSEC
                 //renderer.clear()
                 //renderer.render( scene, camera/* , this.renderTargetMaskBuffer, true */ );
                 render2(this.renderTargetMaskBuffer);
-                  
+                
+                viewports.forEach((e)=>{e.beforeRender = null;});  
+                
     			this.changeVisibilityOfNonSelectedObjects( true , scenes);
                 
                 
@@ -122807,21 +122840,7 @@ ENDSEC
                 });
     			
 
-    			// 2. Downsample to Half resolution
-    			/*this.quad.material = this.materialCopy;
-    			this.copyUniforms[ "tDiffuse" ].value = this.renderTargetMaskBuffer.texture;
-    			renderer.render( this.scene, this.camera, this.renderTargetMaskDownSampleBuffer, true );
-
-    			this.tempPulseColor1.copy( this.visibleEdgeColor );
-    			this.tempPulseColor2.copy( this.hiddenEdgeColor );
-
-    			 if ( this.pulsePeriod > 0 ) {
-
-    				var scalar = ( 1 + 0.25 ) / 2 + Math.cos( performance.now() * 0.01 / this.pulsePeriod ) * ( 1.0 - 0.25 ) / 2;
-    				this.tempPulseColor1.multiplyScalar( scalar );
-    				this.tempPulseColor2.multiplyScalar( scalar );
-
-    			} */
+    			 
 
     			// 3. Apply Edge Detection Pass
     			this.quad.material = this.edgeDetectionMaterial;
@@ -122839,36 +122858,24 @@ ENDSEC
                 if ( this.renderToScreen ) {
                     this.quad.material.transparent = true;
                     buffer = null; 
-                    renderer.setClearColor( this.oldClearColor, this.oldClearAlpha ); 
+                    renderer.setClearColor( this.oldClearColor, this.oldClearAlpha );  
                     render2();
+                    
+                    //绘制到全屏
+                    let renderSize = renderer.getSize(new Vector2$1()); //是client大小
+                    renderer.setViewport(0, 0, renderSize.x, renderSize.y); //规定视口,影响图形变换(画布的使用范围) 
+                    renderer.setScissorTest( false );
+                      
                 }else {
                     renderer.setClearColor( 0x000000, 0 );
                     renderer.clear();
                 } 
+                
+                
                 renderer.setRenderTarget(buffer/* this.renderTargetEdgeBuffer1 */);
                 
                 renderer.render( this.scene,  this.camera/* , this.renderTargetEdgeBuffer1, true  */);
-                
-                /* 
-    			// 4. Apply Blur on Half res
-    			this.quad.material = this.separableBlurMaterial1;
-    			this.separableBlurMaterial1.uniforms[ "colorTexture" ].value = this.renderTargetEdgeBuffer1.texture;
-    			this.separableBlurMaterial1.uniforms[ "direction" ].value = OutlinePass.BlurDirectionX;
-    			this.separableBlurMaterial1.uniforms[ "kernelRadius" ].value = this.edgeThickness;
-    			renderer.render( this.scene, this.camera, this.renderTargetBlurBuffer1, true );
-    			this.separableBlurMaterial1.uniforms[ "colorTexture" ].value = this.renderTargetBlurBuffer1.texture;
-    			this.separableBlurMaterial1.uniforms[ "direction" ].value = OutlinePass.BlurDirectionY;
-    			renderer.render( this.scene, this.camera, this.renderTargetEdgeBuffer1, true ); 
-
-    			// Apply Blur on quarter res
-    			this.quad.material = this.separableBlurMaterial2;
-    			this.separableBlurMaterial2.uniforms[ "colorTexture" ].value = this.renderTargetEdgeBuffer1.texture;
-    			this.separableBlurMaterial2.uniforms[ "direction" ].value = OutlinePass.BlurDirectionX;
-    			renderer.render( this.scene, this.camera, this.renderTargetBlurBuffer2, true );
-    			this.separableBlurMaterial2.uniforms[ "colorTexture" ].value = this.renderTargetBlurBuffer2.texture;
-    			this.separableBlurMaterial2.uniforms[ "direction" ].value = OutlinePass.BlurDirectionY;
-    			renderer.render( this.scene, this.camera, this.renderTargetEdgeBuffer2, true );
-                */  
+               
 
                 //这次删掉
     			/* // Blend it additively over the input texture
@@ -123544,11 +123551,12 @@ ENDSEC
                 
                 
                 //add:  for 截图时抗锯齿
-                 
+                  
                 {
                     this.composer = new EffectComposer( this.renderer );
                     this.ssaaRenderPass = new SSAARenderPass(0x000000, 0);
-                    //this.composer.addPass( this.ssaaRenderPass );   
+                    this.composer.addPass( this.ssaaRenderPass ); 
+                    
                     //this.ssaaRenderPass.useCopy = true
                     //this.ssaaRenderPass.renderToScreen = true; 
                     //this.ssaaRenderPass.needsSwap = false
@@ -123593,6 +123601,7 @@ ENDSEC
                     
                     let outlinePass = this.outlinePass = new OutlinePass( );
                     outlinePass.renderToScreen = true;  //这样更流畅,不用ssaa了,缺点是outline有锯齿
+                    outlinePass.enabled = false;
                     this.composer.addPass( outlinePass );
                     outlinePass.edgeStrength = 10;
                     outlinePass.edgeGlow = 0; 
@@ -126346,7 +126355,7 @@ ENDSEC
     	render(params){//add params
     		if(Potree.measureTimings) performance.mark("render-start");
             if(this.outlinePass.selectedObjects.length){  
-                this.composer.render(this.inputHandler.interactiveScenes.concat(this.scene.scene).concat(viewer.scene.scenePointCloud), this.mainViewport.camera, this.renderDefault.bind(this));  
+                this.composer.render(this.inputHandler.interactiveScenes.concat(this.scene.scene).concat(viewer.scene.scenePointCloud), null, this.viewports, this.renderDefault.bind(this));  
             }else {  
                 this.renderDefault(params);
             }  
@@ -126484,7 +126493,7 @@ ENDSEC
             
             
             
-           
+            let mapViewport; 
             let mainViewport = this.mainViewport;
             let viewports = [mainViewport];
             let oldStates = { 
@@ -126492,7 +126501,7 @@ ENDSEC
                 pano: Potree.settings.displayMode == 'showPanos' ? viewer.images360.currentPano : null,
             };
             if(useMap){
-                let mapViewport = this.mapViewer.viewports[0];
+                mapViewport = this.mapViewer.viewports[0];
                 viewports.push(mapViewport);
                 oldStates.viewports.push(mapViewport.clone());  
                 oldStates.attachedToViewer = this.mapViewer.attachedToViewer;
@@ -126831,11 +126840,14 @@ ENDSEC
                 }
                 
                 if(Potree.settings.displayMode == 'showPointCloud'){ 
-                    dis = bestDistance;
-                    let dir = o.direction ? o.direction.clone().negate() : this.mainViewport.view.direction.negate();//new THREE.Vector3().subVectors(camera.position, target).normalize() 
-                      
-                    position.copy(target).add(dir.multiplyScalar(dis));
-                
+                    if(o.dontChangePos){
+                        position.copy(cameraPos);
+                    }else {
+                        dis = bestDistance;
+                        let dir = o.direction ? o.direction.clone().negate() : this.mainViewport.view.direction.negate();//new THREE.Vector3().subVectors(camera.position, target).normalize() 
+                          
+                        position.copy(target).add(dir.multiplyScalar(dis));
+                    }
                     /* if(o.checkIntersect){//识别被点云遮住的话 
                         let ifShelter 
                         

File diff ditekan karena terlalu besar
+ 1 - 1
public/lib/potree/potree.js.map


+ 4 - 3
src/sdk/cover/index.js

@@ -258,7 +258,7 @@ export const enter = (dom) => {
         enterSceneGuide(pathArr){//导览  (不需要修改参数)
             let editor = viewer.modules.CamAniEditor
             console.log('pathArr',pathArr)
-        
+           
             /* type SceneGuidec = {
               position: {x,y,z}
               target: {x,y,z}
@@ -268,11 +268,12 @@ export const enter = (dom) => {
             */
             let data = {
                 duration: pathArr.reduce(function(total, currentValue ){return total+currentValue.time}, 0), //总时长
-                points: pathArr
+                points: pathArr,
+                useDurSlice:true
             }
             let animation = editor.createAnimation(data)
             //注:最多只存在一条导览
-            animation.useDurSlice = true 
+             
              
             
             let bus = mitt()