# Cesium integration into Fes and Vite Type: research Status: resolved Labels: wayfinder:research Blocked by: None ## 进度:100% 已关闭。结论见下方 Answer;调研资产 [cesium-fes-vite.md](../research/cesium-fes-vite.md)。 ## Question 在当前 TvT.js / Fes.js / Vite 工程里,怎样引入原生 CesiumJS,才能支撑常驻 `MapCanvas`、替换默认相机,并且不把驾驶舱做成插件? 必须查清: - `package.json` 目前没有 `cesium`;应使用哪个包和哪个加载方式 - 与现有 TresJS / Three.js / Vite federation / publicPath `./` 的冲突 - worker、静态资源、`CESIUM_BASE_URL` 如何配置 - 现有 `simpleGIS` 等插件案例哪些可参考、哪些不能当驾驶舱主体依赖 - 对实现票 02、03、21 的约束(结论,不是实现) 发现写入本票链接的调研资产,不要改生产代码。 ## Answer Add official npm package `cesium` and ESM-import it from a cockpit map service under `src/modules/cockpit` — not a TvT plugin, not CDN, not `vue-cesium`, not `vite-plugin-cesium` as the primary path. Copy `node_modules/cesium/Build/Cesium/{Workers,ThirdParty,Assets,Widgets}` to `cesium/` and set `window.CESIUM_BASE_URL` **before** importing `cesium`, resolved from `publicPath: './'` (Fes → Vite `base`) with a trailing slash. Under qiankun, use `__INJECTED_PUBLIC_PATH_BY_QIANKUN__`. Do not hardcode `/cesium/`. Hash routing (Fes default) keeps `./cesium/` valid; do not add `cesium` to federation `shared`. MapCanvas is a persistent DOM host for one `Viewer`; it is not a `TresCanvas`. `simpleGIS` / `geokit` / `3d-tiles-renderer` / `three-tile` are reference-only. `simpleGIS` `cesiumIon` is 3d-tiles-renderer plus a hardcoded Ion token — forbidden as runtime. Constraints: **02** create Viewer once, `resize()` on panel layout, `destroy()` only on leaving `/cockpit`. **03** turn off SSCC `enableRotate/Zoom/Tilt/Look` (defaults are left-drag rotate, wheel/right-drag zoom) and own spring-arm via `lookAtTransform` + `HeadingPitchRange`. **21** `Cesium3DTileset.fromUrl` / `CesiumTerrainProvider.fromUrl` from config; no `Terrain.fromWorldTerrain` / Ion token. Asset: [cesium-fes-vite.md](../research/cesium-fes-vite.md) on branch `research/cesium-fes-vite`.