|
@@ -22072,29 +22072,75 @@
|
|
|
var loadDone = model => {
|
|
|
model.dataset_id = prop.id; //唯一标识
|
|
|
|
|
|
- if (prop.position) {
|
|
|
- if (prop.position.x != 0 || prop.position.y != 0 || prop.position.z != 0) {
|
|
|
- //移动过后使用移动后的坐标
|
|
|
- model.position.copy(prop.position);
|
|
|
- } else {
|
|
|
- //用户没设置位置(首次添加后没按保存)
|
|
|
- if (!model.isPointcloud && prop.raw.wgs84) {
|
|
|
- //有经纬度
|
|
|
- var locationLonLat = prop.raw.wgs84.split(',').map(e => parseFloat(e));
|
|
|
- var location = viewer.transform.lonlatToLocal.forward(locationLonLat);
|
|
|
- MergeEditor.moveBoundCenterTo(model, new Vector3().fromArray(location));
|
|
|
+ {
|
|
|
+ //设置下默认经纬度位置,当点击恢复默认时要恢复到此位置
|
|
|
+
|
|
|
+ if (!model.isPointcloud) {
|
|
|
+ //有经纬度 3dtiles
|
|
|
+ model.rotation.copy(prop.baseRotation); //有的需要翻转90度
|
|
|
+ var lonlat = prop.raw.wgs84 || prop.raw.rtkLocation; //前者为素材库的osgb的
|
|
|
+ if (lonlat) {
|
|
|
+ var locationLonLat = lonlat.split(',').map(e => parseFloat(e));
|
|
|
+ var location = new Vector3().fromArray(viewer.transform.lonlatToLocal.forward(locationLonLat));
|
|
|
model.hasLonLat = true;
|
|
|
- model.lonLatPos = model.position.clone();
|
|
|
- }
|
|
|
- if (model.fileType == 'shp') {
|
|
|
- if (model.prjNotSure) {
|
|
|
- MergeEditor.moveBoundCenterTo(model, new Vector3()); //因为不确定坐标类型,而点坐标可能几万米,所以放原点好一些
|
|
|
+ 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(); //此时和点云没有旋转平移时一样。
|
|
|
+ var rotMatrix = new Matrix4().makeRotationAxis(new Vector3(0, 0, 1), parseFloat(prop.raw.orientation));
|
|
|
+ var pos2Matrix = new Matrix4().setPosition(location); //最后是平移
|
|
|
+ var matrix = new Matrix4().multiplyMatrices(pos2Matrix, rotMatrix);
|
|
|
+ model.matrix.premultiply(matrix);
|
|
|
+ model.matrix.decompose(model.position, model.quaternion, model.scale);
|
|
|
+ } else {
|
|
|
+ model.position.add(location);
|
|
|
+ }
|
|
|
} else {
|
|
|
- model.hasLonLat = true;
|
|
|
- model.lonLatPos = model.position.clone();
|
|
|
+ MergeEditor.moveBoundCenterTo(model, location);
|
|
|
+ if (prop.raw.orientation) {
|
|
|
+ model.rotation.y = parseFloat(prop.raw.orientation);
|
|
|
+ }
|
|
|
+ if (model.is4dkkModel) {
|
|
|
+ console.warn('遇到is4dkkModel的且有经纬度的mesh,但不是3dtiles! 位置估计不准', model);
|
|
|
+ /* if(model.panos?.length){//只能通过漫游点经纬度来校准
|
|
|
+ //但这时候panos还没加载。。。。
|
|
|
+ let sceneCode = ...从url中解析
|
|
|
+ Potree.loadDatasets((data)=>{ //获取datasetId
|
|
|
+ let originDataset = data.find(e=>e.sceneCode == sceneCode);//只加载初始数据集
|
|
|
+ Potree.loadPanos(originDataset.datasetId)
|
|
|
+
|
|
|
+ }, sceneCode, (e)=>{
|
|
|
+ console.log(e)
|
|
|
+ } , prop.prefix)
|
|
|
+
|
|
|
+
|
|
|
+ } */
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- MergeEditor.setModelBtmHeight(model, 0.1); // 离地高度为0 (因为不想在地图下方所以高程不管了,都在地面上即可)
|
|
|
+ }
|
|
|
+ if (model.fileType == 'shp') {
|
|
|
+ if (model.prjNotSure) {
|
|
|
+ MergeEditor.moveBoundCenterTo(model, new Vector3()); //因为不确定坐标类型,而点坐标可能几万米,所以放原点好一些
|
|
|
+ }
|
|
|
+ model.hasLonLat = true;
|
|
|
+ }
|
|
|
+ MergeEditor.setModelBtmHeight(model, 0); // 离地高度为0 (因为不想在地图下方所以高程不管了,都在地面上即可)
|
|
|
+
|
|
|
+ if (model.hasLonLat) {
|
|
|
+ model.lonLatPos = model.position.clone();
|
|
|
+ model.lonLatRot = model.rotation.clone();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (prop.position) {
|
|
|
+ if (prop.position.x != 0 || prop.position.y != 0 || prop.position.z != 0) {
|
|
|
+ //移动过后使用移动后的坐标
|
|
|
+ model.position.copy(prop.position);
|
|
|
+ } else {//用户没设置位置(首次添加后没按保存)
|
|
|
}
|
|
|
}
|
|
|
if (prop.rotation && (prop.rotation.x != 0 || prop.rotation.y != 0 || prop.rotation.z != 0)) {
|
|
@@ -22289,7 +22335,6 @@
|
|
|
pointcloud.matrixAutoUpdate = true;
|
|
|
if (pointcloud.hasLonLat) {
|
|
|
pointcloud.matrix.decompose(pointcloud.position, pointcloud.quaternion, pointcloud.scale); //将数据集的经纬度和旋转应用到rotation和position (注意position和translateUser并不一样)
|
|
|
- pointcloud.lonLatPos = pointcloud.position.clone();
|
|
|
} else if (!prop.isFirstLoad) {
|
|
|
//点云一般加载后position都不是0, 但后台初始化为0所以先归零要不然撤销后容易错
|
|
|
pointcloud.position.set(0, 0, 0);
|