diff --git a/src/pages/views/WatershedOneMap/modalPart/Mapbox.vue b/src/pages/views/WatershedOneMap/modalPart/Mapbox.vue index 232a470..7f2dd0d 100644 --- a/src/pages/views/WatershedOneMap/modalPart/Mapbox.vue +++ b/src/pages/views/WatershedOneMap/modalPart/Mapbox.vue @@ -175,6 +175,47 @@ } + function transCoordinate(tileset,ltd,lat,hei){ + let position = Cesium.Cartesian3.fromDegrees(ltd, lat,hei); + let m = Cesium.Transforms.eastNorthUpToFixedFrame(position); + // 旋转 + const rx = 0, + ry = 0, + rz = 0; + var mx = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(rx)); + var my = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(ry)); + var mz = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(rz)); + var rotationX = Cesium.Matrix4.fromRotationTranslation(mx); + var rotationY = Cesium.Matrix4.fromRotationTranslation(my); + var rotationZ = Cesium.Matrix4.fromRotationTranslation(mz); + //旋转、平移矩阵相乘 + Cesium.Matrix4.multiply(m, rotationX, m); + Cesium.Matrix4.multiply(m, rotationY, m); + Cesium.Matrix4.multiply(m, rotationZ, m); + tileset && (tileset.root.transform = m); + }; + function onReady0(tileset, viewer) { + transCoordinate(tileset,114.229731, 30.669991,-20.0) + debugger; + viewer.zoomTo(tileset); + }; + function onReady1(tileset, viewer) { + transCoordinate(114.225460, 30.647908,-20.0) + debugger; + }; + function onReady2(tileset, viewer) { + transCoordinate(tileset,114.280809,30.633398,-20.0) + debugger; + }; + function onReady3(tileset, viewer) { + transCoordinate(tileset, 114.301790, 30.662891, - 20.0); + debugger; + }; + function onReady4(tileset, viewer) { + transCoordinate(tileset, 114.300507, 30.673361, - 20.0); + debugger; + // 缩放视图以查看 Tileset + }; // 地图初始化 function initMap() { @@ -232,18 +273,28 @@ newfiberMap.loadCesium3DTileSet({ id: 'XQGBZ', url: '/3dtiles/与数公基平台对接3dtiles/西渠钢坝闸/tileset.json', + callback:onReady1 }); newfiberMap.loadCesium3DTileSet({ id: 'TLQBZ', url: '/3dtiles/与数公基平台对接3dtiles/常青路泵站/tileset.json', + callback:onReady0 + }); + // 铁路桥泵站,目前地址为172.16.238.79,待更改!! + newfiberMap.loadCesium3DTileSet({ + id: 'TLQBZ', + url: 'http://172.16.238.79/3dtiles/%E4%B8%8E%E6%95%B0%E5%85%AC%E5%9F%BA%E5%B9%B3%E5%8F%B0%E5%AF%B9%E6%8E%A53dtiles/%E9%93%81%E8%B7%AF%E6%A1%A5%E6%B3%B5%E7%AB%99/tileset.json', + callback:onReady2 }); newfiberMap.loadCesium3DTileSet({ id: 'HXHCSO', url: '/3dtiles/与数公基平台对接3dtiles/黄孝河CSO/tileset.json', + callback:onReady3 }); newfiberMap.loadCesium3DTileSet({ id: 'HXHQHCLSS', url: '/3dtiles/与数公基平台对接3dtiles/黄孝河强化处理设施/tileset.json', + callback:onReady4 }); newfiberMap.loadCesium3DTileSet({ id: 'HXHGBZ', diff --git a/src/pages/views/WatershedOneMap/modalPart/Mapbox.vue b/src/pages/views/WatershedOneMap/modalPart/Mapbox.vue index 232a470..7f2dd0d 100644 --- a/src/pages/views/WatershedOneMap/modalPart/Mapbox.vue +++ b/src/pages/views/WatershedOneMap/modalPart/Mapbox.vue @@ -175,6 +175,47 @@ } + function transCoordinate(tileset,ltd,lat,hei){ + let position = Cesium.Cartesian3.fromDegrees(ltd, lat,hei); + let m = Cesium.Transforms.eastNorthUpToFixedFrame(position); + // 旋转 + const rx = 0, + ry = 0, + rz = 0; + var mx = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(rx)); + var my = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(ry)); + var mz = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(rz)); + var rotationX = Cesium.Matrix4.fromRotationTranslation(mx); + var rotationY = Cesium.Matrix4.fromRotationTranslation(my); + var rotationZ = Cesium.Matrix4.fromRotationTranslation(mz); + //旋转、平移矩阵相乘 + Cesium.Matrix4.multiply(m, rotationX, m); + Cesium.Matrix4.multiply(m, rotationY, m); + Cesium.Matrix4.multiply(m, rotationZ, m); + tileset && (tileset.root.transform = m); + }; + function onReady0(tileset, viewer) { + transCoordinate(tileset,114.229731, 30.669991,-20.0) + debugger; + viewer.zoomTo(tileset); + }; + function onReady1(tileset, viewer) { + transCoordinate(114.225460, 30.647908,-20.0) + debugger; + }; + function onReady2(tileset, viewer) { + transCoordinate(tileset,114.280809,30.633398,-20.0) + debugger; + }; + function onReady3(tileset, viewer) { + transCoordinate(tileset, 114.301790, 30.662891, - 20.0); + debugger; + }; + function onReady4(tileset, viewer) { + transCoordinate(tileset, 114.300507, 30.673361, - 20.0); + debugger; + // 缩放视图以查看 Tileset + }; // 地图初始化 function initMap() { @@ -232,18 +273,28 @@ newfiberMap.loadCesium3DTileSet({ id: 'XQGBZ', url: '/3dtiles/与数公基平台对接3dtiles/西渠钢坝闸/tileset.json', + callback:onReady1 }); newfiberMap.loadCesium3DTileSet({ id: 'TLQBZ', url: '/3dtiles/与数公基平台对接3dtiles/常青路泵站/tileset.json', + callback:onReady0 + }); + // 铁路桥泵站,目前地址为172.16.238.79,待更改!! + newfiberMap.loadCesium3DTileSet({ + id: 'TLQBZ', + url: 'http://172.16.238.79/3dtiles/%E4%B8%8E%E6%95%B0%E5%85%AC%E5%9F%BA%E5%B9%B3%E5%8F%B0%E5%AF%B9%E6%8E%A53dtiles/%E9%93%81%E8%B7%AF%E6%A1%A5%E6%B3%B5%E7%AB%99/tileset.json', + callback:onReady2 }); newfiberMap.loadCesium3DTileSet({ id: 'HXHCSO', url: '/3dtiles/与数公基平台对接3dtiles/黄孝河CSO/tileset.json', + callback:onReady3 }); newfiberMap.loadCesium3DTileSet({ id: 'HXHQHCLSS', url: '/3dtiles/与数公基平台对接3dtiles/黄孝河强化处理设施/tileset.json', + callback:onReady4 }); newfiberMap.loadCesium3DTileSet({ id: 'HXHGBZ', diff --git a/src/utils/gis/NewfiberMap.js b/src/utils/gis/NewfiberMap.js index 312542e..a539489 100644 --- a/src/utils/gis/NewfiberMap.js +++ b/src/utils/gis/NewfiberMap.js @@ -95,7 +95,7 @@ } //添加3Dtiles async loadCesium3DTileSet(e = {}) { - let { url: o, id: a = _.uniqueId(), style: l = {}, show: i = !0, customShader: s = void 0 } = e; + let { url: o, id: a = _.uniqueId(), style: l = {}, show: i = !0, customShader: s = void 0 ,callback} = e; // e = this.map.scene.primitives.add( // new Cesium.Cesium3DTileset({ // url: o, @@ -151,7 +151,12 @@ const _scale = Cesium.Matrix4.fromUniformScale(4) Cesium.Matrix4.multiply(tileset._root.transform, _scale, m) tileset._root.transform = m; - this.map.zoomTo(tileset) + if(callback){ + callback(tileset,this.map) + } + //不能每个模型都跳一此,首次缩放改为所选的回调 + // this.map.zoomTo(tileset) + // return ( // (e.key = a), // e.readyPromise.then(function (e) {