xzw 4 anos atrás
pai
commit
564db7dc6e
1 arquivos alterados com 52 adições e 14 exclusões
  1. 52 14
      public/static/js/main_2020_show.js

+ 52 - 14
public/static/js/main_2020_show.js

@@ -15946,19 +15946,41 @@ window.Modernizr = function(n, e, t) {
         hot.prototype.setVisiblePanos = function(visibleData){ 
             this.visiblePanos = []; 
             
-            this.model.panos.list.forEach((pano)=>{
-                this.visiblePanos.push(pano.id) 
-            })
-            
-            /* this.model.panos.list.forEach((pano)=>{// 模型遮挡的, 直接不可见
-                if(visibleData && !visibleData.includes(pano.id))return; //在热点可视中设置过,不可见
-                var isShelter = convertTool.ifIntersectChunks(pano.position, this.position, {model: this.model.colliders});
-                if(!isShelter){
-                    this.visiblePanos.push(pano.id)
-                }
-            }) */
+             
+            let c = this.model.panos.list.length * this.model.colliders.length
+            if(c < 20000){
+                this.model.panos.list.forEach((pano)=>{// 模型遮挡的, 直接不可见
+                    if(visibleData && !visibleData.includes(pano.id))return; //在热点可视中设置过,不可见
+                    var isShelter = convertTool.ifIntersectChunks(pano.position, this.position, {model: this.model.colliders});
+                    if(!isShelter){
+                        this.visiblePanos.push(pano.id)
+                    }
+                }) 
+            }else{
+                let c1 = Math.ceil(25000 / this.model.colliders.length)
+                let start = 0
+                let interval = setInterval(()=>{
+                    let end = start + c1; 
+                    end = Math.min(end, this.model.panos.list.length)
+                    let i = start
+                    start = end
+                    for(;i<end; i++){ 
+                        var pano = this.model.panos.list[i]
+                        if(visibleData && !visibleData.includes(pano.id))return; //在热点可视中设置过,不可见
+                        var isShelter = convertTool.ifIntersectChunks(pano.position, this.position, {model: this.model.colliders});
+                        if(!isShelter){
+                            this.visiblePanos.push(pano.id)
+                        }
+                    } 
+                    if(end>=this.model.panos.list.length){
+                        //console.log(window.hotsi ?(++window.hotsi): (window.hotsi = 1))
+                        clearInterval(interval)
+                    }
+                },20 )
+                
+                
+            }
         }
-        
 		 //绘制热点
 		hot.prototype.build = function(){
             var t = r.UniformsUtils.clone(f.hot.uniforms); 
@@ -18387,8 +18409,24 @@ window.Modernizr = function(n, e, t) {
                     this.tags[t].build();
                 
                 //add-----
-                for(let i in this.hots){
-                    this.hots[i].setVisiblePanos(this.hots[i].visibleData);
+                { 
+                    let c = this.panos.list.length * this.colliders.length
+                    if(c < 20000){
+                        for(let i in this.hots){
+                            this.hots[i].setVisiblePanos(this.hots[i].visibleData);
+                        }
+                    }else{//防止加载时间过长,分批计算
+                        console.log('hot分批setVisiblePanos')
+                        let hotsId = Object.keys(this.hots)
+                        let i = 0
+                        let hotVisiInterval = setInterval(()=>{
+                            this.hots[hotsId[i]].setVisiblePanos(this.hots[hotsId[i]].visibleData);
+                            i++;
+                            if(i>=hotsId.length){
+                                clearInterval(hotVisiInterval)
+                            }
+                        }, Math.round(c/1000)) 
+                    }    
                 }
                 //---------