|
@@ -9,16 +9,16 @@ export default {
|
|
return {
|
|
return {
|
|
// viewer3DTiles实例《systemConfig.data3DTiles keys,tile》
|
|
// viewer3DTiles实例《systemConfig.data3DTiles keys,tile》
|
|
viewer3DTiles: {},
|
|
viewer3DTiles: {},
|
|
- // 3DTiles url集合《systemConfig.data3DTiles keys,url》
|
|
|
|
- keysByUrl: {},
|
|
|
|
|
|
+ // 3DTiles options集合《systemConfig.data3DTiles keys,options》
|
|
|
|
+ keysByOptions: {},
|
|
};
|
|
};
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
window.SkySceneryConfig = {};
|
|
window.SkySceneryConfig = {};
|
|
for (let tileName in systemConfig.data3DTiles) {
|
|
for (let tileName in systemConfig.data3DTiles) {
|
|
for (let key in systemConfig.data3DTiles[tileName]) {
|
|
for (let key in systemConfig.data3DTiles[tileName]) {
|
|
- let url = systemConfig.data3DTiles[tileName][key];
|
|
|
|
- this.keysByUrl[tileName + key] = url;
|
|
|
|
|
|
+ let options = systemConfig.data3DTiles[tileName][key];
|
|
|
|
+ this.keysByOptions[tileName + key] = options;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.getToken();
|
|
this.getToken();
|
|
@@ -125,6 +125,10 @@ export default {
|
|
systemConfig.imageryProviders.forEach((url) => {
|
|
systemConfig.imageryProviders.forEach((url) => {
|
|
that.loadTheWorldMapImage(url);
|
|
that.loadTheWorldMapImage(url);
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ // 设置地表透明度为 0.5(值在 0 到 1 之间,0 为完全透明,1 为不透明)
|
|
|
|
+ // viewer.scene.globe.translucency.enabled = true;
|
|
|
|
+ // viewer.scene.globe.baseColor = new SkyScenery.Color(1.0, 1.0, 1.0, 0.1);
|
|
viewer.camera.setView({
|
|
viewer.camera.setView({
|
|
destination: SkyScenery.Cartesian3.fromDegrees(
|
|
destination: SkyScenery.Cartesian3.fromDegrees(
|
|
121.29818074250946,
|
|
121.29818074250946,
|
|
@@ -134,8 +138,8 @@ export default {
|
|
orientation: {
|
|
orientation: {
|
|
heading: SkyScenery.Math.toRadians(356.03124515798294), // 方向
|
|
heading: SkyScenery.Math.toRadians(356.03124515798294), // 方向
|
|
pitch: SkyScenery.Math.toRadians(-45.31422437550821), // 倾斜角度
|
|
pitch: SkyScenery.Math.toRadians(-45.31422437550821), // 倾斜角度
|
|
- roll: SkyScenery.Math.toRadians(0.0047792745453184024)
|
|
|
|
- }
|
|
|
|
|
|
+ roll: SkyScenery.Math.toRadians(0.0047792745453184024),
|
|
|
|
+ },
|
|
});
|
|
});
|
|
|
|
|
|
this.$store.commit("createdMap", true);
|
|
this.$store.commit("createdMap", true);
|
|
@@ -366,6 +370,7 @@ export default {
|
|
* @param {*} flyto 是否自动飞行到3Dtiles
|
|
* @param {*} flyto 是否自动飞行到3Dtiles
|
|
*/
|
|
*/
|
|
add3DTiles(keys, flyto) {
|
|
add3DTiles(keys, flyto) {
|
|
|
|
+ let that = this;
|
|
if (this.viewer3DTiles[keys]) {
|
|
if (this.viewer3DTiles[keys]) {
|
|
this.viewer3DTiles[keys].show = true;
|
|
this.viewer3DTiles[keys].show = true;
|
|
if (flyto) {
|
|
if (flyto) {
|
|
@@ -373,7 +378,7 @@ export default {
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
let option = {
|
|
let option = {
|
|
- url: this.keysByUrl[keys] + "/tileset.json",
|
|
|
|
|
|
+ url: this.keysByOptions[keys].url + "/tileset.json",
|
|
skipLevelOfDetail: true, //开启跳级加载
|
|
skipLevelOfDetail: true, //开启跳级加载
|
|
maximumMemoryUsage: 1024, //最大内存占用 推荐显存的一般
|
|
maximumMemoryUsage: 1024, //最大内存占用 推荐显存的一般
|
|
preferLeaves: true,
|
|
preferLeaves: true,
|
|
@@ -383,16 +388,144 @@ export default {
|
|
var tile = new SkyScenery.Cesium3DTileset(option);
|
|
var tile = new SkyScenery.Cesium3DTileset(option);
|
|
viewer.scene.primitives.add(tile);
|
|
viewer.scene.primitives.add(tile);
|
|
|
|
|
|
- if (flyto) {
|
|
|
|
- tile.readyPromise.then(function () {
|
|
|
|
|
|
+ tile.readyPromise.then(function () {
|
|
|
|
+ // 设置相机视角
|
|
|
|
+ if (flyto) {
|
|
viewer.zoomTo(tile);
|
|
viewer.zoomTo(tile);
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ });
|
|
this.viewer3DTiles[keys] = tile;
|
|
this.viewer3DTiles[keys] = tile;
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ this.update3DTilesStyleByKeys(
|
|
|
|
+ this.viewer3DTiles[keys],
|
|
|
|
+ Object.assign({}, this.keysByOptions[keys])
|
|
|
|
+ );
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ /**
|
|
|
|
+ * 修改3DTiles样式
|
|
|
|
+ */
|
|
|
|
+ update3DTilesStyleByKeys(tileset, options) {
|
|
|
|
+ try {
|
|
|
|
+ console.log("update3DTilesStyleByKeys options", tileset, options);
|
|
|
|
+ tileset.readyPromise.then(function () {
|
|
|
|
+ // 设置样式
|
|
|
|
+ var cartographic = SkyScenery.Cartographic.fromCartesian(
|
|
|
|
+ tileset.boundingSphere.center
|
|
|
|
+ );
|
|
|
|
+ var lon = SkyScenery.Math.toDegrees(cartographic.longitude);
|
|
|
|
+ var lat = SkyScenery.Math.toDegrees(cartographic.latitude);
|
|
|
|
+ var height = cartographic.height;
|
|
|
|
+ var surface = SkyScenery.Cartesian3.fromDegrees(lon, lat, height);
|
|
|
|
+ var offset = SkyScenery.Cartesian3.fromDegrees(
|
|
|
|
+ lon + options.lon,
|
|
|
|
+ lat + options.lat,
|
|
|
|
+ height + options.height
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ var translation = SkyScenery.Cartesian3.subtract(
|
|
|
|
+ offset,
|
|
|
|
+ surface,
|
|
|
|
+ new SkyScenery.Cartesian3()
|
|
|
|
+ );
|
|
|
|
+ tileset.modelMatrix = SkyScenery.Matrix4.fromTranslation(translation);
|
|
|
|
+
|
|
|
|
+ var m = tileset._root.transform;
|
|
|
|
+
|
|
|
|
+ if (options.rx != 0) {
|
|
|
|
+ const mx = SkyScenery.Matrix3.fromRotationX(
|
|
|
|
+ SkyScenery.Math.toRadians(options.rx)
|
|
|
|
+ );
|
|
|
|
+ const rotate = SkyScenery.Matrix4.fromRotationTranslation(mx);
|
|
|
|
+ SkyScenery.Matrix4.multiply(m, rotate, m);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (options.ry != 0) {
|
|
|
|
+ const my = SkyScenery.Matrix3.fromRotationY(
|
|
|
|
+ SkyScenery.Math.toRadians(options.ry)
|
|
|
|
+ );
|
|
|
|
+ const rotate = SkyScenery.Matrix4.fromRotationTranslation(my);
|
|
|
|
+ SkyScenery.Matrix4.multiply(m, rotate, m);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (options.rz != 0) {
|
|
|
|
+ const mz = SkyScenery.Matrix3.fromRotationZ(
|
|
|
|
+ SkyScenery.Math.toRadians(options.rz)
|
|
|
|
+ );
|
|
|
|
+ const rotate = SkyScenery.Matrix4.fromRotationTranslation(mz);
|
|
|
|
+ SkyScenery.Matrix4.multiply(m, rotate, m);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (options.scale != 1) {
|
|
|
|
+ const _scale = SkyScenery.Matrix4.fromUniformScale(options.scale);
|
|
|
|
+ SkyScenery.Matrix4.multiply(m, _scale, m);
|
|
|
|
+ }
|
|
|
|
+ tileset._root.transform = m;
|
|
|
|
+ });
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error(error);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ /**
|
|
|
|
+ * 修改3DTiles样式(测试)
|
|
|
|
+ */
|
|
|
|
+ update3DTilesStyle(keys, options) {
|
|
|
|
+ if (this.viewer3DTiles[keys]) {
|
|
|
|
+ let tileset = this.viewer3DTiles[keys];
|
|
|
|
+ this.update3DTilesStyleByKeys(tileset, options);
|
|
|
|
+ } else {
|
|
|
|
+ console.log("update3DTilesStyle未找到3DTiles模型实例!keys:", keys);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ adjust3DTilesPosition(tileset, options) {
|
|
|
|
+ var cartographic = Cesium.Cartographic.fromCartesian(tileset.boundingSphere.center);
|
|
|
|
+ var lon = Cesium.Math.toDegrees(cartographic.longitude);
|
|
|
|
+ var lat = Cesium.Math.toDegrees(cartographic.latitude);
|
|
|
|
+ var height = cartographic.height;
|
|
|
|
+ var surface = Cesium.Cartesian3.fromDegrees(lon, lat, height);
|
|
|
|
+ var offset = Cesium.Cartesian3.fromDegrees(
|
|
|
|
+ lon + options.lon,
|
|
|
|
+ lat + options.lat,
|
|
|
|
+ height + options.height
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ var translation = Cesium.Cartesian3.subtract(
|
|
|
|
+ offset,
|
|
|
|
+ surface,
|
|
|
|
+ new Cesium.Cartesian3()
|
|
|
|
+ );
|
|
|
|
+ tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
|
|
|
|
+
|
|
|
|
+ // var m = Cesium.Transforms.eastNorthUpToFixedFrame(surface);
|
|
|
|
+ var m = tileset._root.transform;
|
|
|
|
+
|
|
|
|
+ if (options.rx != 0) {
|
|
|
|
+ const mx = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(options.rx));
|
|
|
|
+ const rotate = Cesium.Matrix4.fromRotationTranslation(mx);
|
|
|
|
+ Cesium.Matrix4.multiply(m, rotate, m);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (options.ry != 0) {
|
|
|
|
+ const my = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(options.ry));
|
|
|
|
+ const rotate = Cesium.Matrix4.fromRotationTranslation(my);
|
|
|
|
+ Cesium.Matrix4.multiply(m, rotate, m);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (options.rz != 0) {
|
|
|
|
+ const mz = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(options.rz));
|
|
|
|
+ const rotate = Cesium.Matrix4.fromRotationTranslation(mz);
|
|
|
|
+ Cesium.Matrix4.multiply(m, rotate, m);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (options.scale != 1) {
|
|
|
|
+ const _scale = Cesium.Matrix4.fromUniformScale(options.scale);
|
|
|
|
+ Cesium.Matrix4.multiply(m, _scale, m);
|
|
}
|
|
}
|
|
|
|
+ tileset._root.transform = m;
|
|
},
|
|
},
|
|
/**
|
|
/**
|
|
- * 删除3DTiles(测试)
|
|
|
|
|
|
+ * 删除3DTiles
|
|
* @author LiuMengxiang
|
|
* @author LiuMengxiang
|
|
* @param tiles 3DTiles实例
|
|
* @param tiles 3DTiles实例
|
|
*/
|
|
*/
|
|
@@ -424,7 +557,7 @@ export default {
|
|
homeVs.push(item[0] + item[1]);
|
|
homeVs.push(item[0] + item[1]);
|
|
});
|
|
});
|
|
// 遍历所有的3Dtiles
|
|
// 遍历所有的3Dtiles
|
|
- for (let keys in this.keysByUrl) {
|
|
|
|
|
|
+ for (let keys in this.keysByOptions) {
|
|
// 如果选中的话
|
|
// 如果选中的话
|
|
if (homeVs.length > 0 && homeVs.indexOf(keys) != -1) {
|
|
if (homeVs.length > 0 && homeVs.indexOf(keys) != -1) {
|
|
this.add3DTiles(keys, true);
|
|
this.add3DTiles(keys, true);
|