xzw 1 year ago
parent
commit
d4592ebafd

+ 29 - 243
public/static/lib/potree/potree.js

@@ -71406,10 +71406,10 @@ void main()
 			this.textBorderThick = options.textBorderThick || 0;
 			this.fontface = 'Arial';
 			this.fontsize = options.fontsize ||  16; 
-	        this.textBorderColor = options.textBorderColor || { r: 0, g: 0, b: 0, a: 0.0 };
-			this.backgroundColor = options.backgroundColor || { r: 255, g: 255, b: 255, a: 1.0 };
-			this.textColor = options.textColor || {r: 0, g: 0, b: 0, a: 1.0};
-	        this.borderColor = options.borderColor || { r: 0, g: 0, b: 0, a: 0.0 };
+	        this.textBorderColor = options.textBorderColor ? Common$1.CloneObject(options.textBorderColor):{ r: 0, g: 0, b: 0, a: 0.0 };
+			this.backgroundColor = options.backgroundColor ? Common$1.CloneObject(options.backgroundColor):{ r: 255, g: 255, b: 255, a: 1.0 };
+			this.textColor = options.textColor ? Common$1.CloneObject(options.textColor):{r: 0, g: 0, b: 0, a: 1.0};
+	        this.borderColor = options.borderColor  ? Common$1.CloneObject(options.borderColor):{ r: 0, g: 0, b: 0, a: 0.0 };
 			this.borderRadius = options.borderRadius || 6;
 	        this.margin = options.margin;
 	        if(options.text != void 0)this.setText(options.text);
@@ -71429,19 +71429,19 @@ void main()
 		}
 
 		setTextColor(color){
-			this.textColor = color;
+			this.textColor = Common$1.CloneObject(color);
 
 			this.updateTexture();
 		}
 
 		setBorderColor(color){
-			this.borderColor = color;
+			this.borderColor =  Common$1.CloneObject(color);
 
 			this.updateTexture();
 		}
 
 		setBackgroundColor(color){
-			this.backgroundColor = color;
+			this.backgroundColor =  Common$1.CloneObject(color);
 
 			this.updateTexture();
 		}
@@ -136917,7 +136917,7 @@ ENDSEC
 	                    }); 
 	                }else {
 	                    viewer.scene.measurements.forEach((e)=>{
-	                        e.edgeLabels.forEach(label=>{
+	                        e.edgeLabels.forEach(label=>{ 
 	                            label.backgroundColor.a = label._oldA  ;//透明的抗锯齿渲染会变黑,所以去除透明
 	                            label.updateTexture();  
 	                        });
@@ -138334,246 +138334,32 @@ ENDSEC
 	    }
 	    
 	    
-	     
-	        
-	    addFire(){   
-	  
-	        if(Potree.settings.number == 't-CwfhfqJ'){
-	            let position = Potree.Utils.datasetPosTransform({
-	                pointcloud:viewer.scene.pointclouds[0], 
-	                position: new Vector3(4.4318,-0.580291847759, -0.78),
-	                fromDataset:true 
-	            }); 
-	            
-	            viewer.modules.ParticleEditor.addParticle( {
-	                 type:'fire',
-	                 positions:[position],
-	                 radius:0.42, 
-	                 height:10,
-	            });
-	             
-	            viewer.modules.ParticleEditor.addParticle( {
-	                 type:'smoke',
-	                 positions: [ new Vector3().addVectors(position,new Vector3(0,0,0.3))],
-	                 positionStyle : 'sphere' , 
-	                 positionRadius : 0.3,                        
-	                 sizeTween: [[0, 0.3, 0.9, 1], [0.05, 0.1,  1,   0.8]],
-	                 opacityBase : 0.2,
-	                 opacityTween :[ [0, 0.3,  0.7, 0.95, 1], [0, 0.2, 1 , 0.1, 0] ], 
-	                 velocityBase     : new Vector3( 0,  0,  1),
-	                 velocitySpread   : new Vector3( 0.2, 0.2, -0.3), 
-	                 accelerationBase : 0.2,
-	                 accelerationSpread : 0.7,	
-	                 radius:0,
-	                 //particlesPerSecond : 30,
-	                 particleDeathAge   : 3.0,                         
-	            });
-	            
-	            viewer.modules.ParticleEditor.addParticle( {
-	                 type:'explode',
-	                 name:'fire splash',
-	                 position: new Vector3().addVectors(position,new Vector3(0,0,0.3)), 
-	                 size: 0.1,
-	                sizeRange: 0.3,
-	                sizeTween:[[0, 0.05, 0.3, 0.45], [0, 0.02, 0.1, 0.05] ],
-	                opacityTween:  [[0, 0.05, 0.3, 0.45], [1, 1, 0.5, 0]] , 
-	                speed : 1,            //sphere
-	                speedRange : 4,
-	                radius: 0.1,
-	                acceleration : 0.3,         
-	                accelerationRange : 1,
-	                particleSpaceTime:0,
-	                strength:4,
-	            });
-	        }
-	    }
-
-
-	        
-	    
-	    
-	    addVideo(){
-	        if(Potree.settings.number != 'SS-t-P6zBR73Gke')return
-	        var geo = new PlaneGeometry(1, 1, 1, 1);
-	        
-	        var videoInfo = this.videoInfo = [ 
-	            {
-	                id: '40-2', 
-	                url: 'https://laser-oss.4dkankan.com/testdata/SS-t-P6zBR73Gke/temp/poi/2022/05/10/0aabafee-36b8-455d-9c11-0780bf694786.mp4',
-	                rotation:[-1.494468618954883,   -1.4987317433158989,  -3.061254983446741],
-	                position:[ 19.801820617361624,  2.884673619844108,   -0.03362305858221648],
-	                scale:[3.5741423153151763,  2.8738725275578703, 1], 
-	            },
-
-	            
-	            { 
-	                id: 40,
-	                /* rotation:[-1.534692822378723, 0.01083403560862361,  3.141535283661569],
-	                position:[17.2934294239949861, 2.413510747928117, -0.008057029580231356], */
-	                url: 'https://laser-oss.4dkankan.com/testdata/SS-t-P6zBR73Gke/temp/poi/2022/05/09/7896d6ef-a2d6-4fd7-949c-768782a5b484.mp4',
-	             
-	                rotation:[-1.5487684197910518,   0.021848470169552752, -3.1387534893955236],
-	                position:[17.277316608096, 2.0840432922115846,  -0.0931149415437065],
-	                scale:[2.0821757723834047, 0.6129478480765236, 1], 
-	                visibles: [40]
-	            },
-	             
-	        ];
-	        let add = (info)=>{
-	            var video = $(`<video  controls="controls" loop autoplay x5-playsinline="" webkit-playsinline="true" playsinline="true" controlslist="nodownload"></video>`)[0];
-	            video.setAttribute("crossOrigin", 'Anonymous'); 
-	            video.src = info.url || Potree.resourcePath+`/video/${Potree.settings.number}/${info.id}.mp4`;
-	            
-	            var map = new VideoTexture(video); 
-	            var plane = this.videoPlane = new Mesh(geo, new MeshBasicMaterial({
-	                color:"#ffffff", 
-	                transparent: !0,
-	                depthTest:false,
-	                opacity:0 ,
-	                //side:2,            
-	                map
-	            }));
-	            plane.position.fromArray(info.position);  
-	            plane.rotation.fromArray(info.rotation); 
-	            info.scale && plane.scale.fromArray(info.scale); 
-	            this.scene.scene.add(plane);
-	            info.plane = plane;
-	            plane.boundingBox = new Box3(new Vector3(0,-0.5,0),new Vector3(1,-0.4,0.2));
-	            video.addEventListener('loadeddata', function(e) {
-	                 video.play(); 
-	                 if(!info.visibles/* ||!viewer.images360.currentPano || info.visibles.includes(viewer.images360.currentPano.id) */){
-	                     plane.material.opacity = 1;
-	                 } 
-	                    
-	                 info.scale || plane.scale.set(video.videoWidth/1000,video.videoHeight/1000,1);  // 1080 * 1920
-	                 console.log('video loadeddata', info.id);
-	            }); 
-	            
-	            
-	            
-	            if(info.visibles){
-	                this.images360.addEventListener('flyToPano' ,(e)=>{//飞之前 
-	                    if(info.visibles.includes(e.toPano.pano.id)){ //出现 
-	                        setTimeout(()=>{
-	                            plane.visible = true; 
-	                            video.currentTime = 0;        
-	                            video.play();
-	                            if(video.paused){
-	                                var startPlay = ()=>{
-	                                    plane.visible && video.play(); 
-	                                    this.removeEventListener('global_mousedown', startPlay);
-	                                };
-	                                this.addEventListener('global_mousedown', startPlay);
-	                            }
-	                            Potree.settings.zoom.enabled = false;
-	                            
-	                            transitions.start(lerp.property(plane.material, "opacity", 1 ) , e.toPano.duration*0.4 , ()=>{
-	                      
-	                            }, 0,   easing['easeInOutQuad']);  
-	                        },  e.toPano.duration*0.6);  //时间上不能和消失的重叠 延迟 
-	                        
-	                    }else {
-	                        //消失
-	                        transitions.start(lerp.property(plane.material, "opacity", 0,  ) , e.toPano.duration*0.4, ()=>{
-	                            if(!info){
-	                                plane.visible = false;
-	                                video.pause();
-	                                Potree.settings.zoom.enabled = true; 
-	                            }
-	                        }, 0,   easing['easeInOutQuad']);
-	                    } 
-	                    
-	                });
-	            }
-	                
-	            
-	            
-	            var startPlay = ()=>{
-	                video.play(); 
-	                //video.pause()
-	                //video.currentTime = 0.1;
-	                this.removeEventListener('global_mousedown', startPlay);
-	            };
-	            
-	            this.addEventListener('global_mousedown', startPlay);
-	            Potree.settings.isTest && plane.addEventListener('select',(e)=>{console.log(e);});
-	        };
-	        
-
-	        videoInfo.forEach(info=>{
-	            add(info); 
-	        }); 
-	 
-	     
-	     
-	     
-	        
-	        
-	        /* this.images360.addEventListener('flyToPano' ,(e)=>{//飞之前
-	            if(Potree.settings.displayMode != 'showPanos') return
-	            let info = videoInfo[e.toPano.pano.id]
-	            if(info ){ //出现 
-	                setTimeout(()=>{
-	                    plane.visible = true;  
-	                    plane.position.fromArray(info.position)  
-	                    plane.rotation.fromArray(info.rotation)
-	                            
-	                    video.src = Potree.resourcePath+`/video/${Potree.settings.number}/${e.toPano.pano.id}.mp4`
-	                    video.play();
-	                    video.currentTime = 0
-	                    Potree.settings.zoom.enabled = false
-	                    
-	                    transitions.start(lerp.property(plane.material, "opacity", 1 ) , e.toPano.duration*0.4 , ()=>{
-	              
-	                    }, 0,   easing['easeInOutQuad'])  
-	                },  e.toPano.duration*0.6)  //时间上不能和消失的重叠 延迟
-	                
-	                
+	    setDisplay(state, cause='setDisplay'){//如果创建了iframe,主页的需要隐藏的话需要释放一些内存出来。iframe关闭前也释放下比较保险
+	        state = !!state;
+	        this.objs.children.forEach(e=>{
+	            if(e.fileType == '3dTiles'){
+	                let tileset = e.runtime.getTileset();
+	                Potree.Utils.updateVisible(e,  cause, state);
+	                if(!state) tileset._cache.trim(); //使下一次update时dispose所有不可见的tiles
+	                e.runtime.update(16, this.renderer, this.mainViewport.camera, true);
+	                if(state) this.dispatchEvent('content_changed');
 	            }
-	            
-	            //消失
-	            transitions.start(lerp.property(plane.material, "opacity", 0,  ) , e.toPano.duration*0.4, ()=>{
-	                if(!info){
-	                    plane.visible = false
-	                    video.pause()
-	                    Potree.settings.zoom.enabled = true 
-	                }
-	            }, 0,   easing['easeInOutQuad'])
-	            
-	            
-	        })
+	        });
 	        
 	        
+	        if(state){
+	            Potree.pointBudget = 6*1000*1000; //先随便写一个, 随后mergeEditor.updateMemoryUsage
+	        }else {
+	            Potree.pointBudget = 0;
+	            Potree.updatePointClouds(this.scene.pointclouds,  this.mainViewport.camera,  this.mainViewport.resolution );
+	        }
+	        this.dispatchEvent({type:'setDisplay',state});
 	        
-	        this.images360.addEventListener('endChangeMode',(e)=>{  //暂时不处理初始加载时就在有视频的点位上的情况
-	            if(e.mode == 'showPanos'){ 
-	                let info = videoInfo[this.images360.currentPano.id]
-	                if(info ){ //出现  
-	                    plane.visible = true;  
-	                    plane.position.fromArray(info.position)  
-	                    plane.rotation.fromArray(info.rotation)
-	                    plane.material.opacity = 0   
-	                    
-	                    video.src = Potree.resourcePath+`/video/${Potree.settings.number}/${this.images360.currentPano.id}.mp4`
-	                    video.play();
-	                    video.currentTime = 0
-	                    Potree.settings.zoom.enabled = false
-	                    
-	                    transitions.start(lerp.property(plane.material, "opacity", 1, (e)=>{console.log('fadeIn',e)}) , 300 , ()=>{
-	              
-	                    }, 0,   easing['easeInOutQuad'])   
-	                    
-	                }  
-	            }else{
-	                plane.visible = false; 
-	                Potree.settings.zoom.enabled = true
-	            }
-	            
-	        })
-	         
-	        */
+	        this.paused = !state;  
 	    }
-	    
+	        
+	     
+	      
 	    addSprite(e){//api
 	        let sprite; 
 	        

File diff suppressed because it is too large
+ 1 - 1
public/static/lib/potree/potree.js.map


+ 3 - 1
src/sdk/laser/core/enter.js

@@ -1039,7 +1039,9 @@ var enter = ({
             viewer.navCubeViewer.dispatchEvent('leaveTopView')
         },
 
-        
+        destroy(){//重新创建viewer,删了旧的
+            viewer.setDisplay(false)
+        }
 
     };
     Potree.sdk = sdk;