更改切换二三维代码
This commit is contained in:
parent
57a5a2f79e
commit
6694ce6c51
|
|
@ -373,35 +373,52 @@ async function obtainViewer(id: string, opt?: InitViewerOptions): Promise<Cesium
|
||||||
return window.cesView3D[id]?.map;
|
return window.cesView3D[id]?.map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function defined(value: any): boolean {
|
||||||
|
return value !== undefined && value !== null;
|
||||||
|
}
|
||||||
|
function defaultValue(value: any, fallback: any) {
|
||||||
|
return defined(value) ? value : fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 设置二三维切换
|
* @description 设置二三维切换
|
||||||
* @param {string} viewerID 视图容器id
|
* @param {string} viewerID 视图容器id
|
||||||
* @param {string} modelType 模式
|
* @param {string} modelType 模式
|
||||||
*/
|
*/
|
||||||
function set2DModelOr3DModel(viewerID: any, modelType: any, duration: any, callback: any) {
|
function set2DModelOr3DModel(
|
||||||
if (!Cesium.defined(viewerID) || !Cesium.defined(modelType))
|
viewerID: any,
|
||||||
return;
|
modelType: any,
|
||||||
|
duration: any,
|
||||||
|
callback: any
|
||||||
|
) {
|
||||||
|
// 替换 Cesium.defined
|
||||||
|
if (!defined(viewerID) || !defined(modelType)) return;
|
||||||
|
|
||||||
obtainViewer(viewerID).then((viewer: any) => {
|
obtainViewer(viewerID).then((viewer: any) => {
|
||||||
if (!Cesium.defined(viewer))
|
if (!defined(viewer)) return;
|
||||||
return;
|
|
||||||
duration = Cesium.defaultValue(duration, 2.0);
|
// 替换 Cesium.Core.defaultValue
|
||||||
if (modelType === '3D') {
|
duration = defaultValue(duration, 2.0);
|
||||||
|
|
||||||
|
if (modelType === "3D") {
|
||||||
viewer.scene.morphTo3D(duration);
|
viewer.scene.morphTo3D(duration);
|
||||||
}
|
} else if (modelType === "2D") {
|
||||||
else if (modelType === '2D') {
|
|
||||||
viewer.scene.morphTo2D(duration);
|
viewer.scene.morphTo2D(duration);
|
||||||
}
|
} else if (modelType === "2.5D") {
|
||||||
else if (modelType === '2.5D') {
|
|
||||||
viewer.scene.morphToColumbusView(duration);
|
viewer.scene.morphToColumbusView(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callback instanceof Function) {
|
if (callback instanceof Function) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
callback();
|
callback();
|
||||||
}, duration + 1);
|
}, (duration + 1) * 1000); // 注意:duration单位是秒,setTimeout是毫秒!这里你原有代码有BUG
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function updateViewOnZoom(viewer: any, key: any) {
|
function updateViewOnZoom(viewer: any, key: any) {
|
||||||
// 获取当前镜头位置的笛卡尔坐标
|
// 获取当前镜头位置的笛卡尔坐标
|
||||||
let cameraPos = viewer.camera.position;
|
let cameraPos = viewer.camera.position;
|
||||||
|
|
@ -737,6 +754,7 @@ function controlEntityVisibilityByType(type: any, isShow: any) {
|
||||||
console.warn(`无此类型的Entity:${type}`);
|
console.warn(`无此类型的Entity:${type}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.log(entityTypeMap,"2222222222222")
|
||||||
// 遍历同类型所有Entity,修改show属性
|
// 遍历同类型所有Entity,修改show属性
|
||||||
entityTypeMap[type].forEach((entity: any) => {
|
entityTypeMap[type].forEach((entity: any) => {
|
||||||
// 同时控制billboard和label的显隐(也可单独控制)
|
// 同时控制billboard和label的显隐(也可单独控制)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user