|
|
@@ -401,8 +401,8 @@ var start = function(dom, mapDom, number, fileServer, webSite){ //t-Zvd3w0m
|
|
|
|
|
|
|
|
|
let tilesetUrls = [
|
|
|
- //{fromCesium:1, url:'http://192.168.0.125:1804/oss/manage/media-library/result/bb0d27fa79724b5f96cbb03e80f679a0/tileset.json'}, //港湾一号
|
|
|
- {fromCesium:1, url:'http://192.168.0.125:1804/oss/manage/media-library/result/0e68916bb02143a7afb9fed4561720a1/tileset.json'}, //ENU坐标 和地图对不上
|
|
|
+ {fromCesium:1, url:'http://192.168.0.125:1804/oss/manage/media-library/result/bb0d27fa79724b5f96cbb03e80f679a0/tileset.json'}, //港湾一号
|
|
|
+ {fromCesium:1, url:'http://192.168.0.125:1804/oss/manage/media-library/result/0e68916bb02143a7afb9fed4561720a1/tileset.json'}, //新疆的模型
|
|
|
//`${Potree.resourcePath}/models/3dtiles/test/tileset.json`,
|
|
|
//'http://192.168.0.25/oss/manage/media-library/result/test/tileset.json',
|
|
|
'https://4dkk.4dage.com/scene_view_data/SG-t-GvKLWIKfJGC/images/3dtiles/tileset.json?_=1742785956443',
|
|
|
@@ -481,11 +481,30 @@ var start = function(dom, mapDom, number, fileServer, webSite){ //t-Zvd3w0m
|
|
|
Potree.resourcePath+'/models/obj/53M/output_00',
|
|
|
], objIndex = 0
|
|
|
|
|
|
+ //initializeTransformation(lonlat)
|
|
|
+ // // 1. 定义 CGCS2000 (EPSG:4490) 和 地心坐标系 (EPSG:4978)
|
|
|
+ // // EPSG:4490 是经纬度坐标系 3d-tiles就是使用这个坐标系
|
|
|
+ proj4.defs("EPSG:4490", "+proj=longlat +ellps=GRS80 +no_defs +type=crs");
|
|
|
+ // // EPSG:4978 是 WGS84/CGCS2000 的地心笛卡尔坐标系 (X, Y, Z 米)
|
|
|
+ proj4.defs("EPSG:4978", "+proj=geocent +datum=WGS84 +units=m +no_defs +type=crs" );
|
|
|
|
|
|
-
|
|
|
- let lonlat = [83.0246,41.715012] /* 113.60,22.36 */
|
|
|
+ let lonlat = Potree.browser.urlHasValue('lonlat',true).split(',')
|
|
|
+ lonlat = lonlat.length == 2 ? lonlat.map(e=>parseFloat(e)) : [113.60,22.36 ]
|
|
|
+ //[83.0246,41.715012] /* */
|
|
|
+ Potree.settings.useRectProj = Potree.browser.urlHasValue('rectProj')
|
|
|
Potree.setLonlat(...lonlat)
|
|
|
- initializeTransformation(lonlat)
|
|
|
+
|
|
|
+ /* proj4.defs(
|
|
|
+ "center",
|
|
|
+ `+proj=tmerc +lat_0=${lonlat[1]} +lon_0=${lonlat[0]} +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs`
|
|
|
+ ); */
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
createCesiumMap()
|
|
|
|
|
|
@@ -516,10 +535,17 @@ var start = function(dom, mapDom, number, fileServer, webSite){ //t-Zvd3w0m
|
|
|
if(fromCesium){
|
|
|
let center = new THREE.Vector3().fromArray(model.runtime.getTileset().tileset.root.transform.slice(12,15))
|
|
|
|
|
|
- let pos = Potree.math.fromCes(center)
|
|
|
+ let pos = Potree.math.fromCes(center)
|
|
|
model.position.copy(pos)
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ let pos2 = ecefToLngLat(center)
|
|
|
+ //pos2 = viewer.transform.lonlatToLocal.forward(new THREE.Vector3(pos2.x,pos2.y,0))
|
|
|
+ pos2 = proj4("EPSG:4326", "center", pos2),
|
|
|
+ model.position.x = pos2.x, model.position.y = pos2.y
|
|
|
//viewer.modules.MergeEditor.moveBoundCenterTo( model, new THREE.Vector3().fromArray(pos) )
|
|
|
- //因为bound中心在原点所以上面两句都可以
|
|
|
+ //因为bound中心在原点所以上面两句都可以 */
|
|
|
|
|
|
model.hasLonLat = true
|
|
|
}
|
|
|
@@ -993,13 +1019,14 @@ var start = function(dom, mapDom, number, fileServer, webSite){ //t-Zvd3w0m
|
|
|
function updateMap(){
|
|
|
|
|
|
if (Potree.settings.showCesium && Potree.settings.displayMode == 'showPointCloud') {
|
|
|
- let camera = MergeEditor.split ? viewer.viewports.find(e=>e.name == 'top').camera : viewer.mainViewport.camera
|
|
|
+ let viewport = MergeEditor.split ? viewer.viewports.find(e=>e.name == 'top') : viewer.mainViewport
|
|
|
+ let camera = viewport.camera
|
|
|
let pPos = new THREE.Vector3(0, 0, 0).applyMatrix4(camera.matrixWorld);
|
|
|
|
|
|
let orientation
|
|
|
|
|
|
let cPos = Potree.math.toCes(pPos);
|
|
|
- //let pos2 = convertThreeToCesium(pPos)
|
|
|
+ //let pos2 = convertThreeToCesium(pPos)
|
|
|
|
|
|
if(MergeEditor.split){
|
|
|
pPos.y = 5408190 //为什么很高的时候会变位置,所以固定下
|
|
|
@@ -1039,19 +1066,25 @@ var start = function(dom, mapDom, number, fileServer, webSite){ //t-Zvd3w0m
|
|
|
let cTarget = Potree.math.toCes(pTarget);
|
|
|
|
|
|
let cDir = Cesium.Cartesian3.subtract(cTarget, cPos, new Cesium.Cartesian3());
|
|
|
- let cUp = Cesium.Cartesian3.subtract(cUpTarget, cPos, new Cesium.Cartesian3());
|
|
|
-
|
|
|
+ let cUp = Cesium.Cartesian3.subtract(cUpTarget, cPos, new Cesium.Cartesian3());
|
|
|
+
|
|
|
cDir = Cesium.Cartesian3.normalize(cDir, new Cesium.Cartesian3());
|
|
|
cUp = Cesium.Cartesian3.normalize(cUp, new Cesium.Cartesian3());
|
|
|
//console.log('ces', 'cPos', cPos, 'cDir',cDir, 'cUp', cUp)
|
|
|
|
|
|
//关键:计算始终朝北的向上向量
|
|
|
- //cUp = computeNorthUpVector(pos2, cDir); //
|
|
|
-
|
|
|
+ //cUp = computeNorthUpVector(pos2, cDir); //
|
|
|
orientation = {
|
|
|
direction: cDir,
|
|
|
up: cUp
|
|
|
- }
|
|
|
+ }
|
|
|
+ /* orientation = {
|
|
|
+ heading: -viewport.view.yaw, // 航向角(0=北,90=东)
|
|
|
+ pitch: viewport.view.pitch, // 俯仰角(-90=垂直向下,0=水平)
|
|
|
+ roll: 0.0 // 翻滚角(通常为0)
|
|
|
+ } */
|
|
|
+
|
|
|
+
|
|
|
let aspect = cesAspect || camera.aspect;
|
|
|
//console.log('updateMap', aspect)
|
|
|
|
|
|
@@ -1076,7 +1109,21 @@ var start = function(dom, mapDom, number, fileServer, webSite){ //t-Zvd3w0m
|
|
|
cesiumViewer.render(); //立即render,否则会和点云render不同步而错位
|
|
|
}//cesium测试沙盒 https://sandcastle.cesium.com/
|
|
|
}
|
|
|
-
|
|
|
+ function ecefToLngLat(position ) {
|
|
|
+ position = proj4("EPSG:4978", "EPSG:4326", position);
|
|
|
+ [position.x, position.y] = wgs84togcj02(
|
|
|
+ position.x,
|
|
|
+ position.y
|
|
|
+ );
|
|
|
+ return position;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/*
|
|
|
function computeNorthUpVector(position,direction_){//计算始终指向地理北的向上向量
|
|
|
// 方法1:使用当前位置的ENU矩阵
|