|
@@ -1,6 +1,6 @@
|
|
|
import * as THREE from "../../../../libs/three.js/build/three.module.js";
|
|
|
-
|
|
|
-
|
|
|
+import math from '../../utils/math.js'
|
|
|
+import browser from '../../utils/browser.js'
|
|
|
|
|
|
let texLoader = new THREE.TextureLoader()
|
|
|
texLoader.crossOrigin = "anonymous"
|
|
@@ -30,16 +30,19 @@ let tempVector = new THREE.Vector3, //sharedata
|
|
|
|
|
|
|
|
|
|
|
|
-const HALF_WORLD_SIZE = 21e6
|
|
|
+const HALF_WORLD_SIZE = 21e6 //略大于半个周长(mapSizeM/2)
|
|
|
const MAX_VERTICAL_DIST = 2
|
|
|
const MAX_VERTICAL_DIST_TO_BEST = 1
|
|
|
|
|
|
-
|
|
|
+function defineLocalProj(locationLonLat){
|
|
|
+ proj4.defs("LOCAL_MAP", "+proj=tmerc +ellps=WGS84 +lon_0=" + locationLonLat[0].toPrecision(15) + " +lat_0=" + locationLonLat[1].toPrecision(15));
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
//高德坐标拾取工具 : https://lbs.amap.com/tools/picker
|
|
|
-
|
|
|
+
|
|
|
|
|
|
export class MapLayer extends THREE.EventDispatcher{ // 包括了 MapLayerBase SceneLayer
|
|
|
constructor(viewer_, viewport){
|
|
@@ -52,7 +55,7 @@ export class MapLayer extends THREE.EventDispatcher{ // 包括了 MapLayerBase S
|
|
|
this.maps = []
|
|
|
this.frustum = new THREE.Frustum
|
|
|
this.frustumMatrix = new THREE.Matrix4
|
|
|
- this.tileColor = /* i && i.tileColor ? i.tileColor : */new THREE.Color(16777215)
|
|
|
+ this.tileColor = new THREE.Color(16777215)
|
|
|
this.viewport = viewport
|
|
|
this.changeViewer(viewer_)
|
|
|
//添加地图
|
|
@@ -61,18 +64,13 @@ export class MapLayer extends THREE.EventDispatcher{ // 包括了 MapLayerBase S
|
|
|
|
|
|
|
|
|
//map.setEnable(false)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /* this.on('needUpdate',()=>{
|
|
|
- this.mapLayer.update()
|
|
|
- })
|
|
|
- */
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- addMapEntity(data, datasetId){
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ addMapEntity(data, datasetId){
|
|
|
if(!data || !data[0]){
|
|
|
Potree.Log('平面图无数据','red')
|
|
|
return
|
|
@@ -116,6 +114,7 @@ export class MapLayer extends THREE.EventDispatcher{ // 包括了 MapLayerBase S
|
|
|
this.maps.push(t)
|
|
|
//this.view.invalidateScene()
|
|
|
this.needUpdate = true
|
|
|
+ this.viewer.mapChanged = true
|
|
|
}
|
|
|
|
|
|
removeMap(t){
|
|
@@ -126,10 +125,9 @@ export class MapLayer extends THREE.EventDispatcher{ // 包括了 MapLayerBase S
|
|
|
}
|
|
|
|
|
|
/* this.view.invalidateScene() */
|
|
|
- this.needUpdate = true
|
|
|
- this.viewer.dispatchEvent({
|
|
|
- type:'content_changed'
|
|
|
- })
|
|
|
+ this.needUpdate = true
|
|
|
+ this.viewer.mapChanged = true
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -152,34 +150,25 @@ export class MapLayer extends THREE.EventDispatcher{ // 包括了 MapLayerBase S
|
|
|
e[t].removeFromSceneGroup(this.sceneGroup)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- onAfterRenderViewport(e){
|
|
|
- var n = this;
|
|
|
-
|
|
|
- /* this.isVisibleInViewport(e) && (this.updateTimer || this.loadingInProgress || (this.updateTimer = window.setTimeout((function(){
|
|
|
- n.update(e).then((function (t){
|
|
|
- t && n.loadComplete.emit(!0)
|
|
|
- }
|
|
|
- )).catch(u.handleWarning)
|
|
|
- }
|
|
|
- ), 100))) */
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
update(){
|
|
|
this.needUpdate = false
|
|
|
if(this.disabled || !this.maps.find(e=>!e.disabled) || !this.maps.find(e=>e.objectGroup.visible) )return //add
|
|
|
-
|
|
|
+ this.viewer.mapChanged = true
|
|
|
|
|
|
var e, n, i, r, o;
|
|
|
|
|
|
this.updateTimer = void 0,
|
|
|
e = this.viewport.camera,
|
|
|
- n = e.projectionMatrix.clone(),
|
|
|
+ n = e.projectionMatrix.clone()
|
|
|
+
|
|
|
+ let expandRatio = 1.3
|
|
|
+ n.elements[0] /= expandRatio
|
|
|
+ n.elements[5] /= expandRatio // 为了缓存吗,使边界处也提前加载,扩大显示区域
|
|
|
|
|
|
- n.elements[0] /= 1.5,
|
|
|
- n.elements[5] /= 1.5,
|
|
|
+
|
|
|
this.frustumMatrix.multiplyMatrices(n, e.matrixWorldInverse),
|
|
|
this.frustum.setFromProjectionMatrix(this.frustumMatrix),
|
|
|
this.frustum.planes[4].setComponents(0, 0, 0, 0),
|
|
@@ -197,13 +186,7 @@ export class MapLayer extends THREE.EventDispatcher{ // 包括了 MapLayerBase S
|
|
|
|
|
|
}
|
|
|
|
|
|
- getAttributions(){
|
|
|
- for (var t = {}, e = 0, n = this.maps; e < n.length; e++){
|
|
|
- n[e].fillAttributions(t)
|
|
|
- }
|
|
|
- return t
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
updateProjection(){
|
|
|
for (var t = 0, e = this.maps; t < e.length; t++){
|
|
|
var n = e[t];
|
|
@@ -211,6 +194,9 @@ export class MapLayer extends THREE.EventDispatcher{ // 包括了 MapLayerBase S
|
|
|
n.updateObjectGroup()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -236,7 +222,7 @@ export class TiledMapBase extends THREE.EventDispatcher{
|
|
|
this.objectGroup = new THREE.Object3D;
|
|
|
this.objectGroup.name = name
|
|
|
this.objectGroupAdded = !1,
|
|
|
- this.baseTile = new MapTile(this,/* this.mapLayer, */this.objectGroup,this.tileColor),
|
|
|
+ this.baseTile = new MapTile(this, this.objectGroup, this.tileColor, null, '0'),
|
|
|
this.isTileVisibleBox = new THREE.Box3,
|
|
|
this.isTileVisibleVec = new THREE.Vector3
|
|
|
|
|
@@ -244,6 +230,12 @@ export class TiledMapBase extends THREE.EventDispatcher{
|
|
|
this.projection = projection
|
|
|
this._zoomLevel = 0;//1-20
|
|
|
|
|
|
+
|
|
|
+ this.objectGroup.addEventListener('isVisible',()=>{
|
|
|
+ this.mapLayer.viewer.mapChanged = true
|
|
|
+ })
|
|
|
+
|
|
|
+ this.computeCount = 0
|
|
|
}
|
|
|
|
|
|
get zoomLevel(){
|
|
@@ -266,29 +258,32 @@ export class TiledMapBase extends THREE.EventDispatcher{
|
|
|
}
|
|
|
|
|
|
updateProjection(){
|
|
|
- //this.transformMapToLocal || (this.transformMapToLocal = this.TransformService.getTransform(this.projection, this.TransformService.crsLocal))
|
|
|
+
|
|
|
if(!this.transformMapToLocal){
|
|
|
- if(proj4.defs("NAVVIS:TMERC")){
|
|
|
- if(this.projection == "EPSG:4550"){
|
|
|
+ if(proj4.defs("LOCAL_MAP")){
|
|
|
+ /* if(this.projection == "EPSG:4550"){
|
|
|
this.transformMapToLocal = {
|
|
|
forward:(e)=>{
|
|
|
var a = viewer.transform.lonlatTo4550.inverse(e)
|
|
|
return viewer.transform.lonlatToLocal.forward(a)
|
|
|
},
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }else{
|
|
|
- this.transformMapToLocal = proj4(this.projection, "NAVVIS:TMERC")
|
|
|
- }
|
|
|
- //this.transformMapToLocal = proj4(this.projection, "NAVVIS:TMERC")
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
+ }else{ */
|
|
|
+
|
|
|
+ this.transformMapToLocal = proj4(this.projection, "LOCAL_MAP")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //}
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ clearProjection(){
|
|
|
+ this.transformMapToLocal = void 0
|
|
|
+ this.projection !== 'LOCAL_MAP' && this.baseTile.remove()
|
|
|
+ }
|
|
|
+
|
|
|
setEnable(enable){//add
|
|
|
if(!this.disabled == enable)return
|
|
|
if(enable){
|
|
@@ -296,30 +291,24 @@ export class TiledMapBase extends THREE.EventDispatcher{
|
|
|
}
|
|
|
this.disabled = !enable
|
|
|
|
|
|
- viewer.updateVisible(this.objectGroup, 'setEnable', enable)
|
|
|
+ Potree.Utils.updateVisible(this.objectGroup, 'setEnable', enable)
|
|
|
|
|
|
if(!enable){
|
|
|
this.baseTile.remove()
|
|
|
}else{
|
|
|
this.mapLayer.needUpdate = true
|
|
|
}
|
|
|
-
|
|
|
- this.mapLayer.viewer.dispatchEvent({
|
|
|
- type:'content_changed'
|
|
|
- })
|
|
|
+
|
|
|
+
|
|
|
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
- /* clearProjection(){
|
|
|
- this.transformMapToLocal = void 0,
|
|
|
- this.projection.name !== this.TransformService.NAVVIS_LOCAL && this.baseTile.remove()
|
|
|
- } */
|
|
|
-
|
|
|
+
|
|
|
update(e, n){
|
|
|
-
|
|
|
+ this.computeCount = 0
|
|
|
var unavailable = (this.disabled || !this.objectGroup.visible)//地图即使不显示也要获得zoomlevel
|
|
|
if(this.name != 'map' && unavailable)return
|
|
|
|
|
@@ -327,7 +316,7 @@ export class TiledMapBase extends THREE.EventDispatcher{
|
|
|
|
|
|
if(!this.transformMapToLocal)return
|
|
|
|
|
|
- if (!this.isTileVisible(new THREE.Vector3(0,0,0), this.mapSizeM, e))
|
|
|
+ if (!this.isTileVisible(new THREE.Vector3(0,0,0), this.mapSizeM, e))
|
|
|
return this.removeFromSceneGroup(n), !0;
|
|
|
|
|
|
let viewport = this.mapLayer.viewport
|
|
@@ -346,12 +335,33 @@ export class TiledMapBase extends THREE.EventDispatcher{
|
|
|
i.x *= a / 2,
|
|
|
i.y *= s / 2;
|
|
|
|
|
|
- var c = this.tileSizePx / i.length()
|
|
|
+
|
|
|
+ //add 高纬度的因倾斜而造成tile较小,所以放大些,否则会造成显示的tile过多而卡
|
|
|
+ let lonlat = viewer.transform.lonlatToLocal.inverse(viewport.camera.position.clone())
|
|
|
+ let cos = Math.cos(THREE.Math.degToRad(lonlat.y)); //越小就在纬度上越高,tile表现越小
|
|
|
+ //为什么lonlat.y会超出90?
|
|
|
+ if(lonlat.y>90){
|
|
|
+ console.log('lonlat.y>90',lonlat.y)
|
|
|
+ }
|
|
|
+
|
|
|
+ cos = THREE.Math.clamp(cos, 0,1)
|
|
|
+ let lonShift = Math.abs(viewer.mapViewer.camera.position.x / this.mapSizeM * 16 ) //越大就在经度离中心越远,tile表现越大 。
|
|
|
+ lonShift = THREE.Math.clamp(lonShift, 0, Math.PI)
|
|
|
+ lonShift = (1 - Math.sin( 1/2 * lonShift + Math.PI/2 )) * Math.PI // 0-Math.PI sin增速向上
|
|
|
+
|
|
|
+ let scale = 0.5 * cos * (1+lonShift) + 0.5 * Math.pow(cos, lonShift)
|
|
|
+ var c = this.tileSizePx / i.length() / scale //多除以一个scale缩放因子,scale越大level越小
|
|
|
, level = Math.ceil(-Math.log(c) / Math.log(2) - this.bias);
|
|
|
+
|
|
|
level = Math.max(level, 0)
|
|
|
- level = Math.min(level, void 0 === this.maxDepth ? 1 / 0 : this.maxDepth)
|
|
|
+ level = Math.min(level, void 0 === this.maxDepth ? 1 / 0 : this.maxDepth)
|
|
|
this.zoomLevel = level//add
|
|
|
- //console.log(level)
|
|
|
+
|
|
|
+
|
|
|
+ /* if(isNaN(this.zoomLevel )){
|
|
|
+ console.log(level, cos , scale , lonlat )
|
|
|
+ } */
|
|
|
+
|
|
|
if(!unavailable){
|
|
|
this.addToSceneGroup(n)
|
|
|
return this.baseTile.update(this, e, level, this.mapSizeM, 0, 0, "")
|
|
@@ -361,10 +371,12 @@ export class TiledMapBase extends THREE.EventDispatcher{
|
|
|
|
|
|
|
|
|
|
|
|
- isTileVisible(e, n, i){
|
|
|
- if (n > HALF_WORLD_SIZE) return !0;
|
|
|
+ isTileVisible(e, n, i){
|
|
|
+ if (n > HALF_WORLD_SIZE) return !0;
|
|
|
var r = .5 * n;
|
|
|
- this.transformMapToLocal.forward(e)
|
|
|
+
|
|
|
+ //简单版:
|
|
|
+ this.transformMapToLocal.forward(e) //e转化为local
|
|
|
this.isTileVisibleBox.makeEmpty()
|
|
|
this.isTileVisibleVec.set(e.x - r, e.y - r, e.z).applyMatrix4(this.objectGroup.matrixWorld)
|
|
|
this.isTileVisibleBox.expandByPoint(this.isTileVisibleVec)
|
|
@@ -373,8 +385,41 @@ export class TiledMapBase extends THREE.EventDispatcher{
|
|
|
this.isTileVisibleVec.set(e.x + r, e.y - r, e.z).applyMatrix4(this.objectGroup.matrixWorld)
|
|
|
this.isTileVisibleBox.expandByPoint(this.isTileVisibleVec)
|
|
|
this.isTileVisibleVec.set(e.x + r, e.y + r, e.z).applyMatrix4(this.objectGroup.matrixWorld)
|
|
|
+ this.isTileVisibleBox.expandByPoint(this.isTileVisibleVec)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //仿造createMesh写的准确版,但会因为大的tile非矩形,而视口是矩形,若视口刚好在tile的曲线边缘外却识别为可见,就会创建冗余tile。 但上面那个简单版在zoomlevel低的时候地球边缘容易有识别不到的tile,造成黑色三角形。
|
|
|
+ //容易出现奇怪的mesh
|
|
|
+ /* this.isTileVisibleBox.makeEmpty()
|
|
|
+ this.isTileVisibleVec.set(e.x - r, e.y - r, e.z)
|
|
|
+ this.transformMapToLocal.forward(this.isTileVisibleVec)
|
|
|
+ this.isTileVisibleVec.applyMatrix4(this.objectGroup.matrixWorld)
|
|
|
this.isTileVisibleBox.expandByPoint(this.isTileVisibleVec)
|
|
|
- return i.intersectsBox(this.isTileVisibleBox)
|
|
|
+
|
|
|
+ this.isTileVisibleVec.set(e.x - r, e.y + r, e.z)
|
|
|
+ this.transformMapToLocal.forward(this.isTileVisibleVec)
|
|
|
+ this.isTileVisibleVec.applyMatrix4(this.objectGroup.matrixWorld)
|
|
|
+ this.isTileVisibleBox.expandByPoint(this.isTileVisibleVec)
|
|
|
+
|
|
|
+ this.isTileVisibleVec.set(e.x + r, e.y - r, e.z)
|
|
|
+ this.transformMapToLocal.forward(this.isTileVisibleVec)
|
|
|
+ this.isTileVisibleVec.applyMatrix4(this.objectGroup.matrixWorld)
|
|
|
+ this.isTileVisibleBox.expandByPoint(this.isTileVisibleVec)
|
|
|
+
|
|
|
+ this.isTileVisibleVec.set(e.x + r, e.y + r, e.z)
|
|
|
+ this.transformMapToLocal.forward(this.isTileVisibleVec)
|
|
|
+ this.isTileVisibleVec.applyMatrix4(this.objectGroup.matrixWorld)
|
|
|
+ this.isTileVisibleBox.expandByPoint(this.isTileVisibleVec) */
|
|
|
+
|
|
|
+
|
|
|
+ return i.intersectsBox(this.isTileVisibleBox)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
addToSceneGroup(t){
|
|
@@ -392,9 +437,10 @@ export class TiledMapBase extends THREE.EventDispatcher{
|
|
|
}
|
|
|
|
|
|
export class MapTile{
|
|
|
- constructor(map,/* t, */ e, n){
|
|
|
+ constructor(map, e, n, parent, name){
|
|
|
this.map = map;
|
|
|
- //this.mapLayer = t,
|
|
|
+ this.name = name;
|
|
|
+ this.parent = parent;
|
|
|
this.objectGroup = e,
|
|
|
this.tileColor = n,
|
|
|
this.meshAdded = !1,
|
|
@@ -420,7 +466,7 @@ export class MapTile{
|
|
|
if(this.textureLoaded){
|
|
|
this.removeChildren()
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return this.textureLoaded
|
|
|
}
|
|
|
|
|
@@ -438,9 +484,11 @@ export class MapTile{
|
|
|
var f = a + u[p]
|
|
|
, m = s + d[p];
|
|
|
tempVector.set(f, m, 0);
|
|
|
- if (entity.isTileVisible(tempVector, .5 * o, n)){
|
|
|
-
|
|
|
- this.children[p] || (this.children[p] = new MapTile(this.map, this.objectGroup,this.tileColor))
|
|
|
+ this.map.computeCount ++
|
|
|
+ //console.log(this.map.computeCount, this.name, 'level:',level)
|
|
|
+
|
|
|
+ if (entity.isTileVisible(tempVector, .5 * o, n)){
|
|
|
+ this.children[p] || (this.children[p] = new MapTile(this.map, this.objectGroup,this.tileColor, this, this.name+p ))
|
|
|
l = this.children[p].update(entity, n, level - 1, .5 * o, f, m, h) && l
|
|
|
} else {
|
|
|
if (this.children[p]){
|
|
@@ -449,7 +497,7 @@ export class MapTile{
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
return l && this.removeObject3D(),
|
|
@@ -466,10 +514,16 @@ export class MapTile{
|
|
|
, u = n / e + .5 * (c - 1)
|
|
|
, d = -a / e + .5 * (c - 1)
|
|
|
, p = t.getTileUrl(Math.round(l), Math.round(u), Math.round(d));
|
|
|
- viewer.setObjectLayers(this.mesh, 'map' )
|
|
|
+ Potree.Utils.setObjectLayers(this.mesh, 'map' )
|
|
|
this.mesh.renderOrder = -(1e6 - l - 100 * (t.zIndex || 0));
|
|
|
+ this.mesh.name = this.name //add
|
|
|
var h = this.mesh.material;
|
|
|
|
|
|
+ /* let area = math.getArea(this.mesh.geometry.vertices.slice(0,3));
|
|
|
+ if(area >0){
|
|
|
+ this.mesh.visible = false
|
|
|
+ console.log('area>0',this.mesh.name)
|
|
|
+ } */
|
|
|
|
|
|
var loadDone = ()=>{
|
|
|
this.map.mapLayer.loadingInProgress--
|
|
@@ -483,10 +537,8 @@ export class MapTile{
|
|
|
this.textureLoaded = true
|
|
|
this.mesh.material.opacity = 1
|
|
|
//this.mapLayer.view.invalidateScene()
|
|
|
-
|
|
|
- this.map.mapLayer.viewer.dispatchEvent({
|
|
|
- type:'content_changed'
|
|
|
- })
|
|
|
+
|
|
|
+ this.map.mapLayer.viewer.mapChanged = true
|
|
|
this.map.mapLayer.needUpdate = true //表示还要继续update(以removeChildren)
|
|
|
}else{
|
|
|
tex.dispose()
|
|
@@ -498,9 +550,10 @@ export class MapTile{
|
|
|
this.mesh.material.dispose() //o.disposeMeshMaterial(this.mesh)
|
|
|
this.mesh.material = errorMaterial
|
|
|
//this.map.mapLayer.view.invalidateScene())
|
|
|
- this.map.mapLayer.viewer.dispatchEvent({
|
|
|
- type:'content_changed'
|
|
|
- })
|
|
|
+
|
|
|
+ this.map.mapLayer.viewer.mapChanged = true
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
loadDone()
|
|
|
}))
|
|
@@ -535,10 +588,21 @@ export class MapTile{
|
|
|
depthWrite: !1,
|
|
|
depthTest: !0,
|
|
|
opacity: 0,
|
|
|
- side: THREE.DoubleSide
|
|
|
+ side: THREE.DoubleSide,
|
|
|
+
|
|
|
});
|
|
|
- return t.color = this.tileColor ? this.tileColor : new THREE.Color(16777215),
|
|
|
- t
|
|
|
+ if(Potree.settings.isTest) {
|
|
|
+ var colorHue = Math.random()
|
|
|
+ t.color = new THREE.Color().setHSL(colorHue, 0.6, 0.92)
|
|
|
+ }else{
|
|
|
+ t.color = this.tileColor ? this.tileColor : new THREE.Color(16777215)
|
|
|
+ }
|
|
|
+
|
|
|
+ return t
|
|
|
+ }
|
|
|
+
|
|
|
+ traverse(f){//add
|
|
|
+ return THREE.Mesh.prototype.traverse.call(this,f)
|
|
|
}
|
|
|
|
|
|
remove(){
|
|
@@ -575,21 +639,39 @@ export class MapTile{
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
proj4.defs("EPSG:3857", "+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs")
|
|
|
//这里地图世界的中心是不是lon:0,lat:0
|
|
|
|
|
|
export class TiledMapOpenStreetMap extends TiledMapBase{
|
|
|
constructor(mapLayer, tileColor){
|
|
|
- super('map', mapLayer, tileColor, /* "EPSG:4550" */ "EPSG:3857" ) //EPSG projection
|
|
|
+
|
|
|
+ let baseUrl, attribution, projection, maxDepth;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if(Potree.settings.mapCompany == 'google'){
|
|
|
+ projection = "EPSG:900913"//"EPSG:4326"//4550
|
|
|
+ baseUrl = "https://mt2.google.com/vt/lyrs=m@159000000&hl=zh-CN&gl=cn&x=${x}&y=${y}&z=${z}&s=mt1" /* "http://mt2.google.cn/vt/lyrs=m@177000000&hl=zh-CN&gl=cn&src=app&x=${x}&y=${y}&z=${z}" */ //最高只到19
|
|
|
+ attribution = "© PopSmart, © 谷歌地图"
|
|
|
+ maxDepth = 22
|
|
|
+ }else{
|
|
|
+ projection = "EPSG:3857"
|
|
|
+ baseUrl = "https://wprd04.is.autonavi.com/appmaptile?lang=zh_cn&style=7&x=${x}&y=${y}&z=${z}" //最高只到19
|
|
|
+ attribution = "© PopSmart, © 高德地图"
|
|
|
+ maxDepth = 19
|
|
|
+ }
|
|
|
+
|
|
|
+ super('map', mapLayer, tileColor, projection ) //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.baseUrl = "https://wprd04.is.autonavi.com/appmaptile?lang=zh_cn&style=7&x=${x}&y=${y}&z=${z}" //最高只到19
|
|
|
-
|
|
|
- this.attribution = "© PopSmart, © 高德地图",
|
|
|
+ this.maxDepth = maxDepth
|
|
|
+ this.baseUrl = baseUrl;
|
|
|
+ this.attribution = attribution
|
|
|
this.tileSizePx = 256
|
|
|
- this.mapSizeM = 40075017
|
|
|
- this.maxDepth = 19//20
|
|
|
+ this.mapSizeM = 40075017 //总占据多少米(地球赤道周长) 和三维空间的不一样 - -, 空间上的是直径,地图上的是半个圆周
|
|
|
+
|
|
|
this.bias = 0.5
|
|
|
|
|
|
|
|
@@ -598,24 +680,15 @@ export class TiledMapOpenStreetMap extends TiledMapBase{
|
|
|
|
|
|
getTileUrl(t, e, n){
|
|
|
return this.baseUrl.replace(/\${z}/, t.toString(10)).replace(/\${x}/, e.toString(10)).replace(/\${y}/, n.toString(10))
|
|
|
- }
|
|
|
-
|
|
|
- fillAttributions(t){
|
|
|
- t[this.attribution] = {
|
|
|
- score: 50
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+//yrs=y为混合地图,s为卫星地图,m为普通地图。我们使用谷歌地图的瓦片图层的时候默认采用的是lyrs=s,也就是普通的卫星图层,现在我们希望包含路网信息,只需要设置lyrs=y就OK了。
|
|
|
|
|
|
|
|
|
export class TiledMapFromEntity extends TiledMapBase{
|
|
|
constructor(mapLayer, tileColor, data){
|
|
|
- super('floorplan', mapLayer, tileColor, "NAVVIS:TMERC" /* "EPSG:3857" *//* "WGS84" */) //直接就是本地坐标,没有projec
|
|
|
+ super('floorplan', mapLayer, tileColor, "LOCAL" /* "EPSG:3857" *//* "WGS84" */) //直接就是本地坐标,没有projec
|
|
|
|
|
|
|
|
|
let entity = this.tiledMapEntity = this.fillFromData(data)
|
|
@@ -635,7 +708,7 @@ export class TiledMapFromEntity extends TiledMapBase{
|
|
|
let data = {}
|
|
|
|
|
|
data.id = e.id
|
|
|
- data.globalLocation = Potree.Utils.VectorFactory.fromArray3(e.location),
|
|
|
+ data.globalLocation = Potree.Utils.VectorFactory.fromArray3(e.location)
|
|
|
data.orientation = Potree.Utils.QuaternionFactory.fromArray(e.orientation)
|
|
|
//if(Potree.fileServer){
|
|
|
data.filePath = `${Potree.settings.urls.prefix1}${e.file_path}`
|
|
@@ -660,8 +733,15 @@ export class TiledMapFromEntity extends TiledMapBase{
|
|
|
|
|
|
|
|
|
computeLocalCoordinates(){
|
|
|
- if(proj4.defs("NAVVIS:TMERC")){
|
|
|
- this.tiledMapEntity.location = new THREE.Vector3().copy(viewer.transform.lonlatToLocal.forward(this.tiledMapEntity.globalLocation))
|
|
|
+ if(proj4.defs("LOCAL_MAP")){
|
|
|
+
|
|
|
+ let lonlat = this.tiledMapEntity.globalLocation
|
|
|
+ /* if(window.AMapWith84){//需要转换
|
|
|
+ lonlat = AMapWith84.wgs84ToAMap(lonlat)
|
|
|
+ } */
|
|
|
+ lonlat = viewer.transform.lonlatToLocal.forward(lonlat)
|
|
|
+
|
|
|
+ this.tiledMapEntity.location = new THREE.Vector3().copy(lonlat)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -691,13 +771,7 @@ export class TiledMapFromEntity extends TiledMapBase{
|
|
|
return i += "?t=" + this.postStamp
|
|
|
//this.RestService.addAuthorizationQueryParameter(i) //????
|
|
|
}
|
|
|
-
|
|
|
- fillAttributions(t) {
|
|
|
- t.NavVis = {
|
|
|
- score: 100
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -742,36 +816,46 @@ export class TiledMapFromEntity extends TiledMapBase{
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-/* {
|
|
|
- "bundle_id": 1, //t-CwfhfqJ
|
|
|
- "file_name": "$DEPTH/$X/$Y.png",
|
|
|
- "file_path": "data/bundle_t-CwfhfqJ/building_1/map_tiles/11",
|
|
|
- "floor_id": 11,
|
|
|
- "id": 1,
|
|
|
- "location": [
|
|
|
- 113.5957510575092,
|
|
|
- 22.366605927999239,
|
|
|
- 0.0
|
|
|
- ],
|
|
|
- "map_size_m": 61.44,
|
|
|
- "max_depth": 3,
|
|
|
- "orientation": [
|
|
|
- 0.7071067811865476,
|
|
|
- 0.0,
|
|
|
- 0.0,
|
|
|
- 0.7071067811865475
|
|
|
- ],
|
|
|
- "quadtree": "fe5f7c7fcffff7f53",
|
|
|
- "sceneCode": "t-CwfhfqJ",
|
|
|
- "tile_size_px": 256,
|
|
|
- "type": "TILED_PYRAMID"
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
- */
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ /*
|
|
|
+ note:
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 目前缩小了能看出形态是一个地球。相机在高空朝下观测,地球平放着。
|
|
|
+ 所以越靠近赤道和地球朝上的那面所在的中央经度(也就是local 0,0,0所对应的初始经度),tile越接近正方形。
|
|
|
+
|
|
|
+ 所以在两极地区要怎么显示?
|
|
|
+ 注册地理坐标时需要滚动地球吗?(修改初始经度、重定义NAVVIS:TMERC, 就需要更新所有三维世界中的物体位置)
|
|
|
+
|
|
|
+
|
|
|
+ 切换中心点:
|
|
|
+ var locationLonLat = viewer.transform.lonlatToLocal.inverse(viewer.mapViewer.camera.position.clone())
|
|
|
+ proj4.defs("LOCAL_MAP", "+proj=tmerc +ellps=WGS84 +lon_0=" + locationLonLat.x.toPrecision(15) + " +lat_0=" + locationLonLat.y.toPrecision(15));
|
|
|
+ viewer.mapViewer.mapLayer.maps[0].transformMapToLocal = null
|
|
|
|
|
|
|
|
|
+
|
|
|
+ 地理注册部分地图上的1和2标记有两层意思。当地图全屏展示时,标记的是当前右侧经纬度的位置;当地图为小窗时,标记的是对应场景里三维位置。(所以感觉最好换一个ui?)且在2023.2.1之前才改好,之前都是后者。
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 为什么边缘总是有奇怪的mesh,是因为有顶点到背面了吗
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ https://lbs.amap.com/tools/picker 高德坐标拾取器,但和这里展示的不一样, 要转成84。
|
|
|
+ https://www.google.com/maps/@77.7730021,-34.4952712,4z google取点
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 打印所有mapTile的名字,字符串最长的代表有显示的mesh。
|
|
|
+ viewer.mapViewer.mapLayer.maps[0].baseTile.traverse(function(e){console.log(e.name)})
|
|
|
+
|
|
|
+
|
|
|
+ 能查看有几个显示的mesh
|
|
|
+ viewer.mapViewer.mapLayer.maps[0].objectGroup.children
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ */
|