xzw 7 ماه پیش
والد
کامیت
5098234287

+ 2 - 0
src/custom/mergeStartTest.js

@@ -388,6 +388,8 @@ var start = function(dom, mapDom, number, fileServer, webSite){ //t-Zvd3w0m
     
     
     let objUrls = [ 
+    
+        'https://4dkk.4dage.com/scene_view_data/KK-t-JyP3NbEwHAi/data/mesh/mesh',
         Potree.resourcePath+'/models/obj/sphere', 
         Potree.resourcePath+'/models/obj/28M/GW1H',
         //Potree.resourcePath+'/models/obj/496M/Model', 

+ 32 - 3
src/custom/modules/mergeModel/MergeEditor.js

@@ -202,7 +202,35 @@ let MergeEditor = {
                 return
             }
             
-            if(e.intersect){
+            
+            
+            
+            let object = e.intersect?.object || e.intersect?.pointcloud
+            let objects = this.getAllObjects()
+            if(!objects.includes(object) || Potree.settings.displayMode == 'showPanos' && object.panos.length) object = null //不是可选的
+            if(object){
+                let posInModel = Potree.Utils.datasetPosTransform({ toDataset: true, position: e.intersect.location.clone(),  object })
+                if(this.selected != object){ 
+                    this.selectModel(object, posInModel) 
+                }else{
+                    //if(!viewer.inputHandler.selection[0]){//正在平移和旋转,不允许取消
+                      if(this.selected == object && this.transformControls.object == object && this.transformControls.mode == 'translate'){
+                          this.selectModel(object, posInModel)  //update click pos
+                      }else{
+                          this.selectModel(null)
+                      }
+                    //}
+                }       
+            }else{
+                //if(!viewer.inputHandler.selection[0]){
+                    this.selectModel(null)
+                //}                
+            }
+            
+            
+            
+            
+            /* if(e.intersect){
                 let object = e.intersect.object || e.intersect.pointcloud
                 let objects = this.getAllObjects()
                 let posInModel = Potree.Utils.datasetPosTransform({ toDataset: true, position: e.intersect.location.clone(),  object })
@@ -221,7 +249,7 @@ let MergeEditor = {
                 //if(!viewer.inputHandler.selection[0]){
                     this.selectModel(null)
                 //}                
-            }
+            } */
         })  
         
         viewer.inputHandler.addEventListener('keydown', (e)=>{
@@ -838,6 +866,7 @@ let MergeEditor = {
                     mats.forEach(mat=>{
                         if(mat.originOpacity == void 0 ){
                             mat.originOpacity = mesh.material.opacity
+                            mat.oriTransparent = mesh.material.oriTransparent
                         }
                         mat.opacity = mat.originOpacity * opacity
                         
@@ -852,7 +881,7 @@ let MergeEditor = {
                             mesh.renderOrder = Potree.config.renderOrders.model+1 //如果是一个mesh多个material咋整? obj的。 暂时默认全部opacity一样吧
                             //mesh.material.depthWrite = false
                         }else{
-                            mat.transparent = false
+                            mat.transparent = (model.is4dkkModel || model.fileType == '3dTiles') ? false : mat.oriTransparent //有的贴图含透明度
                             mesh.renderOrder = Potree.config.renderOrders.model
                             //mesh.material.depthWrite = true
                         }

+ 1 - 1
src/custom/modules/panos/Images360.js

@@ -785,7 +785,7 @@ export class Images360 extends THREE.EventDispatcher{
     judgeModelMat(object/* , isCurModel */){
         if(!(Potree.settings.mergeType2 && Potree.settings.modelSkybox))return
         object.traverse(mesh=>{
-            if(mesh.isMonitor)return {stopContinue:true}
+            if(mesh.external)return {stopContinue:true}
             if(mesh.material){
                 if(!mesh.materialOutside){
                     mesh.materialOutside = mesh.material

+ 64 - 45
src/custom/objects/Monitor.js

@@ -38,6 +38,7 @@ export default class Monitor extends THREE.Object3D{
     constructor(data, model){
         super()
         this.isMonitor = true 
+        this.external = external//全景时不换材质
         warnHls()
         
         data.video = testUrl
@@ -101,6 +102,7 @@ export default class Monitor extends THREE.Object3D{
             opacity: 0.1,
             side: THREE.DoubleSide,
             depthTest: false,
+            visible: !!data.showScope
         })  
          
         
@@ -109,8 +111,8 @@ export default class Monitor extends THREE.Object3D{
             map: new THREE.VideoTexture(this.video),
             side: THREE.DoubleSide,
             depthTest: false,
-            transparent: true,
-            // opacity: 0.5,
+            transparent: true, 
+            
         })
         // 摄像头
         if (!cameraModel) {
@@ -133,7 +135,7 @@ export default class Monitor extends THREE.Object3D{
         this.updateAspect()
         
         if(data.showTitle){ 
-            let group = new THREE.Shim.FollowRootObject(this) //透明有问题,只有放到overlayScene里渲染了
+            let group = new THREE.Shim.FollowRootObject(this) //透明有问题,只有放到overlayScene里渲染了 (大小好像还是跟随模型了
             
             this.titleLabel = new TextSprite({
                 text: data.name,
@@ -151,6 +153,15 @@ export default class Monitor extends THREE.Object3D{
             group.add(this.titleLabel)
             viewer.scene.overlayScene.add(group)
             group.name = 'monitorLabel'
+            
+            
+            
+            this.addEventListener('isVisible',()=>{
+                Potree.Utils.updateVisible(group,'follow',this.realVisible()) 
+            })
+            this.parent.addEventListener('isVisible',()=>{
+                Potree.Utils.updateVisible(group,'follow',this.realVisible()) 
+            })
         }
         
         
@@ -265,9 +276,10 @@ export default class Monitor extends THREE.Object3D{
             position: camera.position.clone(),
             quaternion: camera.quaternion.clone()
         }
-        this.showVideo(true)
+        this.data.showScope && this.showVideo(true)
         this.video.pause()//先显示出画面
         setTimeout(()=>{
+            this.data.showScope || this.showVideo(true)
             viewer.mainViewport.cameraLayers = ['monitor'] //hide others 
             viewer.scene.monitors.forEach(e=>Potree.Utils.updateVisible(e,'watch', e == this  ))
         },800)
@@ -298,6 +310,7 @@ export default class Monitor extends THREE.Object3D{
         viewer.mainViewport.view.cancelFlying()
         viewer.mainViewport.cameraLayers = null
         viewer.scene.monitors.forEach(e=>Potree.Utils.updateVisible(e,'watch', true  ))
+        this.data.showScope || this.showVideo(false)
         this.video.pause()
         viewer.mainViewport.view.setView({
             position: this.oldState.position,
@@ -309,7 +322,7 @@ export default class Monitor extends THREE.Object3D{
             },
             callback:()=>{
                 viewer.renderArea.style['pointer-events'] = ''; 
-                this.showVideo(false)
+                this.data.showScope && this.showVideo(false)
                 viewer.mainViewport.view.setRotMode('standard')  
             },
             duration:1000
@@ -446,47 +459,51 @@ export default class Monitor extends THREE.Object3D{
  
  
     updateMesh() { 
-        console.log('updateMesh')
+         
         let nearHeight, nearWidth, farHeight, farWidth
         nearHeight = Math.tan(THREE.MathUtils.degToRad(this.fov / 2)) * this.cylinderNear
         nearWidth = nearHeight * this.aspect        //根据canvas比例调整视频面的比例,保持和canvas一致。
         farHeight = Math.tan(THREE.MathUtils.degToRad(this.fov / 2)) * this.cylinderFar
         farWidth = farHeight * this.aspect
-       
-        // 投射体(底面以外)
-        let vertices = [],
-            bottomVertices = []
-        vertices.push(-nearWidth, nearHeight, -this.cylinderNear)
-        vertices.push(nearWidth, nearHeight, -this.cylinderNear)
-        vertices.push(nearWidth, -nearHeight, -this.cylinderNear)
-        vertices.push(-nearWidth, -nearHeight, -this.cylinderNear)
-        bottomVertices.push(-farWidth, farHeight, -this.cylinderFar)
-        bottomVertices.push(farWidth, farHeight, -this.cylinderFar)
-        bottomVertices.push(farWidth, -farHeight, -this.cylinderFar)
-        bottomVertices.push(-farWidth, -farHeight, -this.cylinderFar)
-        vertices = vertices.concat(bottomVertices)
         let firstBuild = !this.cylinder
-        if (firstBuild) {
-            let uvs = []
-            uvs.push(0, 1, 1, 1, 1, 0, 0, 0)
-            uvs.push(0, 1, 1, 1, 1, 0, 0, 0)
-
-            let indexs = []
-            indexs.push(0, 1, 3, 2, 3, 1)
-            indexs.push(0, 1, 4, 5, 4, 1)
-            indexs.push(1, 2, 5, 6, 5, 2)
-            indexs.push(2, 3, 6, 7, 6, 3)
-            indexs.push(3, 0, 7, 4, 7, 0)
-            // indexs.push(4, 7, 5, 6, 5, 7)
-            let cylinderGeo = new THREE.BufferGeometry()
-            cylinderGeo.setAttribute('uv', new THREE.BufferAttribute(new Float32Array(uvs), 2))
-            cylinderGeo.setIndex(new THREE.BufferAttribute(new Uint16Array(indexs), 1))
-            this.cylinder = new THREE.Mesh(cylinderGeo, this.normalMat)
-            //if (this.control.player.$app.config.mobile) this.cylinder.rotateZ(-Math.PI / 2)       //用户自己旋转屏幕吧
+        if(this.data.showScope){
+            // 投射体(底面以外)
+            let vertices = [],
+                bottomVertices = []
+            vertices.push(-nearWidth, nearHeight, -this.cylinderNear)
+            vertices.push(nearWidth, nearHeight, -this.cylinderNear)
+            vertices.push(nearWidth, -nearHeight, -this.cylinderNear)
+            vertices.push(-nearWidth, -nearHeight, -this.cylinderNear)
+            bottomVertices.push(-farWidth, farHeight, -this.cylinderFar)
+            bottomVertices.push(farWidth, farHeight, -this.cylinderFar)
+            bottomVertices.push(farWidth, -farHeight, -this.cylinderFar)
+            bottomVertices.push(-farWidth, -farHeight, -this.cylinderFar)
+            vertices = vertices.concat(bottomVertices)
+          
+            if (firstBuild) {
+                let uvs = []
+                uvs.push(0, 1, 1, 1, 1, 0, 0, 0)
+                uvs.push(0, 1, 1, 1, 1, 0, 0, 0)
+
+                let indexs = []
+                indexs.push(0, 1, 3, 2, 3, 1)
+                indexs.push(0, 1, 4, 5, 4, 1)
+                indexs.push(1, 2, 5, 6, 5, 2)
+                indexs.push(2, 3, 6, 7, 6, 3)
+                indexs.push(3, 0, 7, 4, 7, 0)
+                // indexs.push(4, 7, 5, 6, 5, 7)
+                let cylinderGeo = new THREE.BufferGeometry()
+                cylinderGeo.setAttribute('uv', new THREE.BufferAttribute(new Float32Array(uvs), 2))
+                cylinderGeo.setIndex(new THREE.BufferAttribute(new Uint16Array(indexs), 1))
+                this.cylinder = new THREE.Mesh(cylinderGeo, this.normalMat) 
+                //if (this.control.player.$app.config.mobile) this.cylinder.rotateZ(-Math.PI / 2)       //用户自己旋转屏幕吧
+                this.obj3d.add(this.cylinder)
+            }
+            this.cylinder.geometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(vertices), 3))
+        }else if(!this.cylinder){
+            this.cylinder = new THREE.Group() 
             this.obj3d.add(this.cylinder)
         }
-        this.cylinder.geometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(vertices), 3))
-
         // 投射体底面 (视频)
         const bottomGeo = new THREE.PlaneGeometry(farWidth * 2, farHeight * 2)
         if (firstBuild) {
@@ -498,13 +515,15 @@ export default class Monitor extends THREE.Object3D{
         }
         this.cylinder.bottom.position.set(0, 0, this.cylinderNear - this.cylinderFar)
 
-        // 投射体线框
-        if (firstBuild) {
-            this.cylinder.line = new THREE.LineSegments(new THREE.EdgesGeometry(this.cylinder.geometry), new THREE.LineBasicMaterial({ color: 0xffffff, opacity: 0.6, transparent: true }))
-            this.cylinder.add(this.cylinder.line)
-        } else {
-            this.cylinder.line.geometry.dispose()
-            this.cylinder.line.geometry = new THREE.EdgesGeometry(this.cylinder.geometry)
+        if(this.data.showScope){
+            // 投射体线框
+            if (firstBuild) {
+                this.cylinder.line = new THREE.LineSegments(new THREE.EdgesGeometry(this.cylinder.geometry), new THREE.LineBasicMaterial({ color: 0xffffff, opacity: 0.6, transparent: true }))
+                this.cylinder.add(this.cylinder.line)
+            } else {
+                this.cylinder.line.geometry.dispose()
+                this.cylinder.line.geometry = new THREE.EdgesGeometry(this.cylinder.geometry)
+            }
         }
     }
 

+ 1 - 1
src/custom/objects/Overlay.js

@@ -17,7 +17,7 @@ export default class Overlay extends THREE.Object3D {
     constructor(data){
         super()
         this.data = data
-        
+        this.external = external//全景时不换材质
         
         var plane = new THREE.Mesh(
             planeGeometry,

+ 60 - 47
src/custom/start.js

@@ -897,56 +897,68 @@ export function mergeEditStart(dom, mapDom){
                 
                 if(!model.isPointcloud){ //有经纬度    3dtiles
                     prop.baseRotation && model.rotation.copy(prop.baseRotation) //有的需要翻转90度 
-                    let lonlat = prop.raw?.wgs84 || prop.raw?.rtkLocation  //前者为素材库的osgb的
-                    if(lonlat){ 
-                        var locationLonLat = lonlat.split(',').map(e=>parseFloat(e))
-                        var location = new THREE.Vector3().fromArray(viewer.transform.lonlatToLocal.forward(locationLonLat)) 
+                    
+                    if(prop.raw?.convertType){//带坐标的osgb,原本给cesium用的,把在球面的转为平面的坐标
+                         
+                        let center = new THREE.Vector3().fromArray(model.runtime.getTileset().tileset.root.transform.slice(12,15))
+                         
+                        let pos = math.fromCes(center)  
+                        model.position.copy(pos) 
+                        //viewer.modules.MergeEditor.moveBoundCenterTo( model, new THREE.Vector3().fromArray(pos) )  
+                        //因为bound中心在原点所以上面两句都可以 
                         
                         model.hasLonLat = true 
-                       
-                        if( model.fileType == '3dTiles' && prop.is4dkkModel ){ //深时深光mesh
-                            model.position.fromArray(model.runtime.getTileset().tileset.root.boundingVolume.box.slice(0,3))//必须要平移一段才能重合 
-                            model.position.copy(Potree.math.convertVector.ZupToYup(model.position))
-                             
-                            //绕原点旋转  类似Alignment.setMatrix 和点云一样处理 
-                            if(prop.raw.orientation){
-                                model.updateMatrixWorld()//此时和点云没有旋转平移时一样。
-                                let rotMatrix = new THREE.Matrix4().makeRotationAxis(new THREE.Vector3(0,0,1),  parseFloat(prop.raw.orientation)   )  
-                                let pos2Matrix = new THREE.Matrix4().setPosition(location);//最后是平移
-                                var matrix = new THREE.Matrix4().multiplyMatrices(pos2Matrix, rotMatrix);
-                                model.matrix.premultiply(matrix) 
-                                model.matrix.decompose(model.position,model.quaternion,model.scale)
+                    }else{ 
+                        let lonlat = /* prop.raw?.wgs84 ||  */prop.raw?.rtkLocation  //前者为素材库的osgb的
+                        if(lonlat){ 
+                            var locationLonLat = lonlat.split(',').map(e=>parseFloat(e))
+                            var location = new THREE.Vector3().fromArray(viewer.transform.lonlatToLocal.forward(locationLonLat)) 
+                            
+                            model.hasLonLat = true 
+                           
+                            if( model.fileType == '3dTiles' && prop.is4dkkModel ){ //深时深光mesh
+                                model.position.fromArray(model.runtime.getTileset().tileset.root.boundingVolume.box.slice(0,3))//必须要平移一段才能重合 
+                                model.position.copy(Potree.math.convertVector.ZupToYup(model.position))
+                                 
+                                //绕原点旋转  类似Alignment.setMatrix 和点云一样处理 
+                                if(prop.raw.orientation){
+                                    model.updateMatrixWorld()//此时和点云没有旋转平移时一样。
+                                    let rotMatrix = new THREE.Matrix4().makeRotationAxis(new THREE.Vector3(0,0,1),  parseFloat(prop.raw.orientation)   )  
+                                    let pos2Matrix = new THREE.Matrix4().setPosition(location);//最后是平移
+                                    var matrix = new THREE.Matrix4().multiplyMatrices(pos2Matrix, rotMatrix);
+                                    model.matrix.premultiply(matrix) 
+                                    model.matrix.decompose(model.position,model.quaternion,model.scale)
+                                }else{
+                                    model.position.add(location)
+                                }
                             }else{
-                                model.position.add(location)
-                            }
-                        }else{
-                             
-                            MergeEditor.moveBoundCenterTo(model, location )   
-                            if(prop.raw?.orientation){
-                                model.rotation.y = parseFloat(prop.raw.orientation)  
-                            }  
-                            if(prop.is4dkkModel){
-                                console.warn('遇到is4dkkModel的且有经纬度的mesh,但不是3dtiles!看看位置准不准', model)
-                                //4dkk应该是可以对的上的。但如果是3dtiles非4dkk的,目前没办法对准,cesium是可以
-                                
-                                //看见的场景说是市场不会带rtk的。所以我们这边标品也没存rtk的坐标信息。和产品聊了,不处理。意思就是,只有激光场景开启了rtk的rtkLocation才有值
-                                /* if(model.panos?.length){//只能通过漫游点经纬度来校准 
-                                    //但这时候panos还没加载。。。。
-                                    let sceneCode = ...从url中解析
-                                    Potree.loadDatasets((data)=>{ //获取datasetId
-                                        let originDataset = data.find(e=>e.sceneCode == sceneCode);//只加载初始数据集  
-                                        Potree.loadPanos(originDataset.datasetId,()=>{
-                                            shouldPos = 获取坐标  data[0].location经纬度
-                                            model.position.add(new THREE.Vector3().subVectors(shouldPos, model.panos[0].position))
-                                        }) 
-                                  }, sceneCode, (e)=>{
-                                            console.log(e)
-                                  } , prop.prefix) 
-                                } */
-                            }
-                        }   
+                                 
+                                MergeEditor.moveBoundCenterTo(model, location )   
+                                if(prop.raw?.orientation){
+                                    model.rotation.y = parseFloat(prop.raw.orientation)  
+                                }  
+                                if(prop.is4dkkModel){
+                                    console.warn('遇到is4dkkModel的且有经纬度的mesh,但不是3dtiles!看看位置准不准', model)
+                                    //4dkk应该是可以对的上的。但如果是3dtiles非4dkk的,目前没办法对准,cesium是可以
+                                    
+                                    //看见的场景说是市场不会带rtk的。所以我们这边标品也没存rtk的坐标信息。和产品聊了,不处理。意思就是,只有激光场景开启了rtk的rtkLocation才有值
+                                    /* if(model.panos?.length){//只能通过漫游点经纬度来校准 
+                                        //但这时候panos还没加载。。。。
+                                        let sceneCode = ...从url中解析
+                                        Potree.loadDatasets((data)=>{ //获取datasetId
+                                            let originDataset = data.find(e=>e.sceneCode == sceneCode);//只加载初始数据集  
+                                            Potree.loadPanos(originDataset.datasetId,()=>{
+                                                shouldPos = 获取坐标  data[0].location经纬度
+                                                model.position.add(new THREE.Vector3().subVectors(shouldPos, model.panos[0].position))
+                                            }) 
+                                      }, sceneCode, (e)=>{
+                                                console.log(e)
+                                      } , prop.prefix) 
+                                    } */
+                                }
+                            }   
+                        }
                     }
-                    
                 }
                 
                 if(model.fileType == 'shp'){
@@ -1098,7 +1110,8 @@ export function mergeEditStart(dom, mapDom){
                 loadDone(object)
             }
                
-            let info = {  
+            let info = {
+                prop,
                 fileType: prop.type, 
                 id: prop.id,
                 unlit: prop.unlit,

+ 7 - 4
src/custom/viewer/ViewerNew.js

@@ -3641,10 +3641,9 @@ export class Viewer extends ViewerBase{
               
         }
         
-        if(this.map3d){
+        if(this.map3d && viewport == this.mainViewport){
             Potree.Utils.setCameraLayers(viewport.camera,  ['map'] )  
-            viewer.renderer.render(this.scene.scene, viewport.camera);  
-            
+            viewer.renderer.render(this.scene.scene, viewport.camera);   
         }
         
         //全景图的部分和点云有点相关就不移动到这了。但是如果是showPanos模式,就不要渲染背景了。
@@ -5823,7 +5822,9 @@ export class Viewer extends ViewerBase{
                     }
                    
                    
-                    
+                    if(fileInfo_.prop?.is4dkkModel){
+                        child.material.color.set(1,1,1); //看到有obj不是白色
+                    }
                     
                 } 
             } );
@@ -5831,6 +5832,8 @@ export class Viewer extends ViewerBase{
         this.objs.add(object) 
         
         
+        
+        
         if(fileInfo_.transform){
             let setTransfrom = (name)=>{
                 let value = fileInfo_.transform[name]

+ 45 - 37
src/custom/viewer/map/Map.js

@@ -142,6 +142,7 @@ export class MapLayer extends THREE.EventDispatcher{ // 包括了 MapLayerBase S
     removeMap(t){
         var e = this.maps.indexOf(t);
         if(e >= 0){
+            t.cacheAutoClear('all')
             t.removeFromSceneGroup(this.sceneGroup) 
             this.maps.splice(e, 1) 
         }
@@ -235,7 +236,7 @@ export class MapLayer extends THREE.EventDispatcher{ // 包括了 MapLayerBase S
  
 
 export class TiledMapBase extends THREE.EventDispatcher{
-    constructor( name, mapLayer, tileColor, projection){
+    constructor( name, mapLayer, tileColor, projection, maxTotalCount=100){
         super();
         this.name = name 
         this.mapLayer = mapLayer,
@@ -262,23 +263,22 @@ export class TiledMapBase extends THREE.EventDispatcher{
         
         //add:
         this.cache = [] //缓存。要删除的tile不立刻dispose,以便迅速再显示。每次都从第一个删除。
-        this.maxTotalCount = 1000
+        this.maxTotalCount = maxTotalCount 
     }
     
-    cacheAutoClear(){//清除超出数量的缓存 add
+    cacheAutoClear(type){//清除超出数量的缓存 add
         let len = this.cache.length,  cacheCopy = this.cache.slice()
-        let overCount = this.objectGroup.children.length + len - this.maxTotalCount
+        let overCount = this.objectGroup.children.length + len - (type == 'all' ? 0 : this.maxTotalCount)
         if(overCount > 0){
             let i = 0, delCount = Math.min(len, overCount) 
-            let dels = this.cache.splice(0,delCount)
-            dels.forEach(tile=>{ 
-                tile._mesh.material.dispose()
-                tile._mesh.geometry.dispose()
-                tile._mesh.material.map?.dispose()
-                tile._mesh = null
-                tile.textureLoaded = false
-            }) 
-             
+            let dels = this.cache.splice(0,delCount) 
+            dels.forEach(mesh=>{ 
+                mesh.material.dispose()
+                mesh.geometry.dispose()
+                mesh.material.map?.dispose()
+                mesh.tile._mesh = null
+            })
+            //console.log('dispose mesh', dels.map(e=>e.name))
         }     
     }
     
@@ -591,7 +591,10 @@ function addLoadTile(tile){
                     tile.map.mapLayer.needUpdate = true //表示还要继续update(以removeChildren)
                     
                     if(tile.map instanceof TiledMapOpenStreetMap){
-                        tile.map.maxLoading = browser.isMobile() ? 5 : 10;    
+                        tile.map.maxLoading = 10;
+                        browser.isMobile() && (tile.map.maxLoading /= 2),
+                        tile.map.mapLayer.is3d && (tile.map.maxLoading /= 3)//怕转动卡
+                        
                     } 
                     tile.map.mapLayer.dispatchEvent('tileLoaded')
                 }
@@ -735,10 +738,15 @@ export class MapTile{
     
      */ 
     createTileObject(entity, tileSize, centerXatMap, centerYatMap){
-     
-        let tileIndex = this.map.cache.findIndex(e=>e == this)
        
-        if(tileIndex == -1){  
+        let mesh 
+        let meshIndex = this.map.cache.findIndex(e=>e.name == this.name)
+        
+        if(meshIndex != -1){
+            mesh = this.map.cache.splice(meshIndex,1)[0]
+            this.textureLoaded = !0
+            
+        }else{ 
             mesh = this.createMesh(entity.transformMapToLocal,tileSize, centerXatMap, centerYatMap),
             mesh.name = this.name 
             if(showTileName){
@@ -753,18 +761,16 @@ export class MapTile{
                 Potree.Utils.setObjectLayers(mesh, 'map' )
                 mesh.renderOrder = -(1e6 - z - 100 * (entity.zIndex || 0));
                 
-                this.texURL = p
-                newBuilt = true
+                this.texURL = p  
+               
+            } 
                 
-            }   
-            //this.map.cacheAutoClear() //增加一个就可能要减少一个  
-        }else{ 
-            
-            mesh = this.map.cache.splice(tileIndex,1)[0]//从缓存取出 
-        }
-           
-        this.mesh = mesh 
-        tileIndex > -1 && addLoadTile(this)
+            //console.log('创建mesh',this.name)
+        }            
+        this.mesh = mesh
+        mesh.tile = this 
+        meshIndex == -1 && addLoadTile(this) 
+        
     }
     
   /* getVertices(transform, tileSize, centerXatMap, centerYatMap){
@@ -865,8 +871,9 @@ export class MapTile{
         if (this.mesh){
             
             if(this.mesh.material.map){//add 已经有图或在加载图
-                this.mesh_ = this.mesh 
-                this.map.cache.push(this) //加入缓存
+                this._mesh = this.mesh 
+                this.map.cache.push(this.mesh) //加入缓存  
+                //console.log('加入缓存', this.name)
             }else{
                 cancelLoad(this)
             }
@@ -878,13 +885,12 @@ export class MapTile{
             }else{
                 cancelLoad(this)
             }   
-            
             this.mesh.material.dispose() //o.disposeMeshMaterial(this.mesh),
             this.mesh.geometry.dispose()  */
             this.mesh = void 0
         }
         this.meshAdded = !1 
-        
+        this.textureLoaded = !1
         //this.texURL && this.texURL.includes('testdata') && console.log('removeObject3D', this.id, 'hasMesh',hasMesh, this.texURL.split('map_tiles/')[1] )
     }
     
@@ -916,9 +922,10 @@ proj4.defs("EPSG:3857", "+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +
 export class TiledMapOpenStreetMap extends TiledMapBase{
     constructor(mapLayer, tileColor){
          
-        //Potree.settings.mapCompany = 'google' 
-        
-        super('map', mapLayer, tileColor/* ,  projection */ ) //EPSG projection
+        let projection = Potree.settings.mapCompany == 'google' ? "EPSG:900913" : "EPSG:3857"
+        let maxTotalCount = mapLayer.is3d ? 1400 : 300
+        browser.isMobile() && (maxTotalCount /= 2)
+        super('map', mapLayer, tileColor ,  projection, maxTotalCount ) //EPSG projection
         //this.baseUrl = "https://wprd03.is.autonavi.com/appmaptile?style=7&x=${x}&y=${y}&z=${z}",
         //this.baseUrl = "https://webrd01.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=7&x=${x}&y=${y}&z=${z}" //最高只到18 level
         this.switchStyle()
@@ -926,13 +933,13 @@ export class TiledMapOpenStreetMap extends TiledMapBase{
         this.mapSizeM = Math.floor(6378137 * Math.PI * 2)//40075016, 不要超出地图projection范围  //  40075017   //总占据多少米(地球赤道周长)    和三维空间的不一样 - -, 空间上的是直径,地图上的是半个圆周
         this.bias = 0.5 
         this.minDepth = 1 //add  因0的无图或不全
-        if(Potree.settings.mapCompany == 'google'){
+        /* if(Potree.settings.mapCompany == 'google'){
             this.attribution = "© PopSmart,  © 谷歌地图"
             this.projection = "EPSG:900913"      //"EPSG:4326"//4550
         }else{
             this.attribution = "© PopSmart,  © 高德地图"
             this.projection = "EPSG:3857"
-        }
+        } */
             
     }
     
@@ -1009,6 +1016,7 @@ export class TiledMapOpenStreetMap extends TiledMapBase{
         this.style = style
         this.setEnable(false)
         this.setEnable(true)
+        this.cacheAutoClear('all')
         viewer.dispatchEvent('content_changed')
     }
     

+ 2 - 2
src/viewer/EDLRendererNew.js

@@ -260,8 +260,8 @@ export class EDLRenderer{//Eye-Dome Lighting 眼罩照明
                         viewer.images360.fastTranMaskPass.render()
                     } 
                     //if( viewer.objs.children.length == 0 || !params.useModelOnRT  ) return //没有模型需要绘制遮挡
-                    if(viewer.objs.children.filter(e=>!e.is4dkkModel && e.visible).length == 0)return //需要绘制遮挡的小物体(layers为model)的个数为0    
-                }
+                    //if(viewer.objs.children.filter(e=>!e.is4dkkModel && e.visible).length == 0)return //需要绘制遮挡的小物体(layers为model)的个数为0    
+                }   //直接绘制吧,is4dkkModel的还有monitor要绘制
                  
                  
             }