大屏添加cesium
This commit is contained in:
164
src/views/largeScreen/components/newMap/initMapData.ts
Normal file
164
src/views/largeScreen/components/newMap/initMapData.ts
Normal file
@ -0,0 +1,164 @@
|
||||
import { leftClick } from './entityClick';
|
||||
// import {leftClick} from '@/views/projectLarge/ProjectScreen/components/newMap/entityClick';
|
||||
|
||||
export const initMapData = async (type, data, cd) => {
|
||||
let entityObject: any;
|
||||
let options: any;
|
||||
const baseURL = import.meta.env.VITE_APP_MAP_API;
|
||||
|
||||
switch (type) {
|
||||
case 'groundText':
|
||||
entityObject = new window['YJ'].Obj.GroundText(window['Earth1'], data);
|
||||
break;
|
||||
case 'standText':
|
||||
entityObject = new window['YJ'].Obj.StandText(window['Earth1'], data);
|
||||
break;
|
||||
case 'point':
|
||||
case 'linkImage':
|
||||
case 'vrImage':
|
||||
entityObject = new window['YJ'].Obj.BillboardObject(window['Earth1'], data);
|
||||
// entityObject.options.billboard.defaultImage = ''
|
||||
// entityObject.flyTo();
|
||||
break;
|
||||
case 'line':
|
||||
entityObject = await new window['YJ'].Obj.PolylineObject(window['Earth1'], data);
|
||||
break;
|
||||
case 'curve':
|
||||
entityObject = await new window['YJ'].Obj.CurvelineObject(window['Earth1'], data);
|
||||
break;
|
||||
case 'panel':
|
||||
case 'rectangle':
|
||||
entityObject = new window['YJ'].Obj.PolygonObject(window['Earth1'], data);
|
||||
break;
|
||||
case 'rendezvous':
|
||||
entityObject = new window['YJ'].Obj.AssembleObject(window['Earth1'], data);
|
||||
break;
|
||||
case 'attackArrow':
|
||||
entityObject = new window['YJ'].Obj.AttackArrowObject(window['Earth1'], data);
|
||||
break;
|
||||
case 'pincerArrow':
|
||||
entityObject = new window['YJ'].Obj.PincerArrowObject(window['Earth1'], data);
|
||||
break;
|
||||
case 'circle':
|
||||
entityObject = new window['YJ'].Obj.CircleObject(window['Earth1'], data);
|
||||
break;
|
||||
case 'ellipse':
|
||||
entityObject = new window['YJ'].Obj.EllipseObject(window['Earth1'], data);
|
||||
break;
|
||||
case 'model':
|
||||
entityObject = new window['YJ'].Obj.Model(window['Earth1'], data);
|
||||
break;
|
||||
case 'military':
|
||||
entityObject = new window['YJ'].Obj.GroundSvg(window['Earth1'], data);
|
||||
entityObject.load(() => {});
|
||||
break;
|
||||
case 'terrain':
|
||||
data.host = baseURL;
|
||||
console.log('terrain的data', data);
|
||||
entityObject = new window['YJ'].Obj.Terrain(window['Earth1'], data);
|
||||
break;
|
||||
case 'layer':
|
||||
data.host = baseURL;
|
||||
entityObject = new window['YJ'].Obj.Layer(window['Earth1'], data);
|
||||
// entityObject.flyTo();
|
||||
break;
|
||||
case 'tileset':
|
||||
data.host = baseURL;
|
||||
entityObject = new window['YJ'].Obj.Tileset(window['Earth1'], data);
|
||||
entityObject.load((res) => {
|
||||
if (cd) {
|
||||
cd(entityObject);
|
||||
}
|
||||
// 等模型加载完后再加载压平模型
|
||||
if (window['pressModelMap'])
|
||||
Array.from((window as any).pressModelMap.keys()).forEach((key: any) => {
|
||||
if (key.indexOf('_' + data.id) > -1) {
|
||||
const nodes = (window as any).pressModelMap.get(key);
|
||||
if (nodes) {
|
||||
if (nodes.isShow == 1) {
|
||||
// nodeType[nodes.source_type].render(nodes);
|
||||
const flatData = JSON.parse(nodes.params);
|
||||
const entity = window['Earth1'].entityMap.get(flatData.modelId).entity;
|
||||
const flat: any = new window['YJ'].Analysis.Flat(window['Earth1'], entity, {
|
||||
positions: flatData.positions,
|
||||
height: flatData.height,
|
||||
name: nodes.sourceName
|
||||
});
|
||||
(window as any).pressModelEntities.set(nodes.id, flat);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
break;
|
||||
case 'path':
|
||||
entityObject = new window['YJ'].Obj.TrajectoryMotion(window['Earth1'], data);
|
||||
break;
|
||||
case 'wallStereoscopic':
|
||||
entityObject = new window['YJ'].Obj.WallStereoscopic(window['Earth1'], data);
|
||||
break;
|
||||
case 'entityWall':
|
||||
entityObject = new window['YJ'].Obj.WallRealStereoscopic(window['Earth1'], data);
|
||||
break;
|
||||
case 'diffuseScan':
|
||||
entityObject = new window['YJ'].Obj.CircleDiffuse(window['Earth1'], data);
|
||||
break;
|
||||
case 'radarScan':
|
||||
entityObject = new window['YJ'].Obj.RadarScan(window['Earth1'], data);
|
||||
break;
|
||||
case 'scanStereoscopic':
|
||||
entityObject = new window['YJ'].Obj.RadarScanStereoscopic(window['Earth1'], data);
|
||||
break;
|
||||
case 'textBox':
|
||||
entityObject = new window['YJ'].Obj.TextBox(window['Earth1'], data, () => {});
|
||||
break;
|
||||
case 'polyhedronObject':
|
||||
entityObject = new window['YJ'].Obj.PolyhedronObject(window['Earth1'], data);
|
||||
break;
|
||||
case 'water':
|
||||
entityObject = new window['YJ'].Obj.WaterSurface(window['Earth1'], data);
|
||||
break;
|
||||
case 'fountain':
|
||||
entityObject = new window['YJ'].Obj.Fountain(window['Earth1'], data);
|
||||
break;
|
||||
case 'fire':
|
||||
entityObject = new window['YJ'].Obj.Flame(window['Earth1'], data);
|
||||
break;
|
||||
case 'smoke':
|
||||
entityObject = new window['YJ'].Obj.Smoke(window['Earth1'], data);
|
||||
break;
|
||||
case 'waterL':
|
||||
entityObject = new window['YJ'].Obj.Spout(window['Earth1'], data);
|
||||
break;
|
||||
case 'flyLine':
|
||||
entityObject = new window['YJ'].Obj.FlowLine(window['Earth1'], data);
|
||||
break;
|
||||
case 'explosion':
|
||||
entityObject = new window['YJ'].Obj.Explosion(window['Earth1'], data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (entityObject) {
|
||||
options = structuredClone(entityObject.options);
|
||||
delete options.host;
|
||||
switch (type) {
|
||||
case 'textBox':
|
||||
delete options.name;
|
||||
break;
|
||||
case 'fountain':
|
||||
case 'fire':
|
||||
case 'smoke':
|
||||
case 'waterL':
|
||||
delete options.url;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// /鼠标左键点击事件
|
||||
entityObject.onClick = () => {
|
||||
leftClick(options);
|
||||
};
|
||||
}
|
||||
return options;
|
||||
};
|
||||
Reference in New Issue
Block a user