Browse Source

fix: overlay

xzw 3 months ago
parent
commit
18a8c86e05
3 changed files with 59 additions and 39 deletions
  1. 48 33
      public/lib/potree/potree.js
  2. 1 1
      public/lib/potree/potree.js.map
  3. 10 5
      src/sdk/cover/index.js

+ 48 - 33
public/lib/potree/potree.js

@@ -24986,6 +24986,7 @@
 	        loadDone(object);
 	      };
 	      var info = {
+	        prop,
 	        fileType: prop.type,
 	        id: prop.id,
 	        unlit: prop.unlit,
@@ -26074,6 +26075,7 @@
 	}
 	class TiledMapBase extends EventDispatcher {
 	  constructor(name, mapLayer, tileColor, projection) {
+	    var maxTotalCount = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 100;
 	    super();
 	    this.name = name;
 	    this.mapLayer = mapLayer, this.tileColor = tileColor, this.bias = 0;
@@ -26094,7 +26096,7 @@
 
 	    //add:
 	    this.cache = []; //缓存。要删除的tile不立刻dispose,以便迅速再显示。每次都从第一个删除。
-	    this.maxTotalCount = 1000;
+	    this.maxTotalCount = maxTotalCount;
 	  }
 	  cacheAutoClear() {
 	    //清除超出数量的缓存 add
@@ -26105,14 +26107,14 @@
 	      var i = 0,
 	        delCount = Math.min(len, overCount);
 	      var dels = this.cache.splice(0, delCount);
-	      dels.forEach(tile => {
-	        var _tile$_mesh$material$;
-	        tile._mesh.material.dispose();
-	        tile._mesh.geometry.dispose();
-	        (_tile$_mesh$material$ = tile._mesh.material.map) === null || _tile$_mesh$material$ === void 0 || _tile$_mesh$material$.dispose();
-	        tile._mesh = null;
-	        tile.textureLoaded = false;
+	      dels.forEach(mesh => {
+	        var _mesh$material$map;
+	        mesh.material.dispose();
+	        mesh.geometry.dispose();
+	        (_mesh$material$map = mesh.material.map) === null || _mesh$material$map === void 0 || _mesh$material$map.dispose();
+	        mesh.tile._mesh = null;
 	      });
+	      //console.log('dispose mesh', dels.map(e=>e.name))
 	    }
 	  }
 	  get zoomLevel() {
@@ -26358,7 +26360,8 @@
 	          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');
 	        }
@@ -26485,8 +26488,12 @@
 	  
 	   */
 	  createTileObject(entity, tileSize, centerXatMap, centerYatMap) {
-	    var tileIndex = this.map.cache.findIndex(e => e == this);
-	    if (tileIndex == -1) {
+	    var mesh;
+	    var 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) {
 	        this.textureLoaded = !0; //add 
@@ -26501,14 +26508,13 @@
 	        Potree.Utils.setObjectLayers(mesh, 'map');
 	        mesh.renderOrder = -(1e6 - z - 100 * (entity.zIndex || 0));
 	        this.texURL = p;
-	        newBuilt = true;
 	      }
-	      //this.map.cacheAutoClear() //增加一个就可能要减少一个  
-	    } else {
-	      mesh = this.map.cache.splice(tileIndex, 1)[0]; //从缓存取出 
+
+	      //console.log('创建mesh',this.name)
 	    }
 	    this.mesh = mesh;
-	    tileIndex > -1 && addLoadTile(this);
+	    mesh.tile = this;
+	    meshIndex == -1 && addLoadTile(this);
 	  }
 
 	  /* getVertices(transform, tileSize, centerXatMap, centerYatMap){
@@ -26602,8 +26608,9 @@
 	    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);
 	      }
@@ -26615,13 +26622,12 @@
 	      }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] )
 	  }
 	  removeChildren() {
@@ -26646,9 +26652,10 @@
 
 	class TiledMapOpenStreetMap extends TiledMapBase {
 	  constructor(mapLayer, tileColor) {
-	    //Potree.settings.mapCompany = 'google' 
-
-	    super('map', mapLayer, tileColor /* ,  projection */); //EPSG projection
+	    var projection = Potree.settings.mapCompany == 'google' ? "EPSG:900913" : "EPSG:3857";
+	    var 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();
@@ -26656,13 +26663,13 @@
 	    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') {
-	      this.attribution = "© PopSmart,  © 谷歌地图";
-	      this.projection = "EPSG:900913"; //"EPSG:4326"//4550
-	    } else {
-	      this.attribution = "© PopSmart,  © 高德地图";
-	      this.projection = "EPSG:3857";
-	    }
+	    /* if(Potree.settings.mapCompany == 'google'){
+	        this.attribution = "© PopSmart,  © 谷歌地图"
+	        this.projection = "EPSG:900913"      //"EPSG:4326"//4550
+	    }else{
+	        this.attribution = "© PopSmart,  © 高德地图"
+	        this.projection = "EPSG:3857"
+	    } */
 	  }
 	  getTileUrl(x, y, z) {
 	    return this.baseUrl.replace(/\${x}/, x.toString(10)).replace(/\${y}/, y.toString(10)).replace(/\${z}/, z.toString(10));
@@ -34468,7 +34475,7 @@
 	  judgeModelMat(object /* , isCurModel */) {
 	    if (!(Potree.settings.mergeType2 && Potree.settings.modelSkybox)) return;
 	    object.traverse(mesh => {
-	      if (mesh.isMonitor) return {
+	      if (mesh.external) return {
 	        stopContinue: true
 	      };
 	      if (mesh.material) {
@@ -61994,6 +62001,7 @@
 	  constructor(data, model) {
 	    super();
 	    this.isMonitor = true;
+	    this.external = external; //全景时不换材质
 	    warnHls();
 	    data.video = testUrl;
 	    this.data = data;
@@ -69241,6 +69249,8 @@
 	  constructor(data) {
 	    super();
 	    this.data = data;
+	    this.external = external; //全景时不换材质
+
 	    var plane = new Mesh(planeGeometry$2, new BasicMaterial({
 	      color: '#00c8af',
 	      opacity: 0.2,
@@ -76127,6 +76137,7 @@
 	          mats.forEach(mat => {
 	            if (mat.originOpacity == void 0) {
 	              mat.originOpacity = mesh.material.opacity;
+	              mat.oriTransparent = mesh.material.oriTransparent;
 	            }
 	            mat.opacity = mat.originOpacity * opacity;
 	            if (mat.opacity < 1) {
@@ -76140,7 +76151,7 @@
 	              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
 	            }
@@ -90162,7 +90173,7 @@
 	        viewer.renderer.render(viewer.scene.scene, viewer.scene.cameraBG);
 	      }
 	    }
-	    if (this.map3d) {
+	    if (this.map3d && viewport == this.mainViewport) {
 	      Potree.Utils.setCameraLayers(viewport.camera, ['map']);
 	      viewer.renderer.render(this.scene.scene, viewport.camera);
 	    }
@@ -92183,6 +92194,7 @@
 	      object.traverse(child => {
 	        var is = child.isMesh || child instanceof Points || child.isLine;
 	        if (is) {
+	          var _fileInfo_$prop;
 	          child.renderOrder = Potree.config.renderOrders.model;
 	          var boundingBox_;
 	          if (child instanceof SkinnedMesh) {
@@ -92229,6 +92241,9 @@
 	          } else {
 	            child.material = changeMat(child.material);
 	          }
+	          if ((_fileInfo_$prop = fileInfo_.prop) !== null && _fileInfo_$prop !== void 0 && _fileInfo_$prop.is4dkkModel) {
+	            child.material.color.set(1, 1, 1); //看到有obj不是白色
+	          }
 	        }
 	      });
 	    }

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


+ 10 - 5
src/sdk/cover/index.js

@@ -2653,13 +2653,18 @@ function load4dkkMedias(model){//加载四维看看的一些媒体物品
                     //Potree.addModel(prop, prop.done, prop.progressFun, prop.onError)
                     prop.type = 'media'
                     prop.model = model
-                    prop.position = Potree.Utils.tran4dkkVecInModel(new THREE.Vector3().fromArray(prop.pos), model) ,
-                    prop.rotation = new THREE.Euler().setFromQuaternion(new THREE.Quaternion().fromArray(prop.qua)),
+                    prop.position = Potree.Utils.tran4dkkVecInModel(new THREE.Vector3().fromArray(prop.pos), model)  
+                    
+                    let qua = new THREE.Quaternion().fromArray(prop.qua).normalize()
+                    if(model.props.baseRotation?.x == 0){ //该模型已经矫正,无需旋转90度,但是场景的数据需要,导致monitor和模型不匹配,需要再旋转
+                        qua.copy(Potree.math.convertQuaternion.YupToZup(qua))
+                    }
+                    prop.rotation = new THREE.Euler().setFromQuaternion(qua)
                     //prop.url =  location.origin + '/oss/scene_view_data/'+ model.props.raw.num + '/user/'+prop.url,
-                    prop.url = location.origin + sceneJsonPath.replace('data/scene.json','user/'+prop.url),  //offline different
-                     
+                    prop.url = sceneJsonPath.replace('data/scene.json','user/'+prop.url)  //offline different
                     
-                    prop.id = prop.sid 
+                    if(!prop.url.substr(0,5).includes('http')) prop.url = location.origin + prop.url
+                 
                      //Potree.settings.urls.getPrefix(8,model)
                      //isNew:true, //是否新创建而非加载  
                     Potree.addModel(prop,(overlay)=>{