基于 engine 封装的复合查看器,整合 3D Viewer、全景查看器(PanoramaViewer)和 2D 地图(OpenLayers Map)于一体,通过模式切换实现多种视图间的无缝协调。
| 属性 | 类型 | 说明 |
|---|---|---|
id |
EntityId |
实体唯一标识,默认使用 UUID v7 自动生成 |
eventDispatcher |
EventDispatcher<CompositeViewerEventMap> |
事件分发器,用于事件监听与派发 |
componentManager |
ComponentManager<CompositeViewer> |
组件管理器,管理挂载在 Viewer 上的组件 |
app |
ViewerApp |
所属的 ViewerApp 实例 |
isPanoLoaded |
boolean |
全景是否已加载 |
gameMode |
{ type: string; model: GLTFModel | null } |
游戏模式配置(默认 { type: "fly", model: null }) |
currentPano |
PanoPoint | null |
当前打开的全景点(getter/setter) |
mode |
CompositeViewerMode |
当前 Viewer 模式(只读) |
viewer |
Viewer | null |
3D Viewer 实例(只读) |
panoViewer |
PanoramaViewer | null |
全景查看器实例(只读) |
map2d |
Map | null |
2D 地图实例(只读) |
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
app |
ViewerApp |
是 | 所属的 ViewerApp 实例 |
options.id |
EntityId |
否 | 自定义实体 ID,不传则自动生成 UUID v7 |
options.mode |
CompositeViewerMode |
是 | 初始视图模式 |
构造时自动挂载以下内建组件:
BaseMapComponentLayerComponentDrawingComponentFlyThroughComponentIdentifyComponent销毁当前 CompositeViewer,从 ViewerApp.compositeViewers 列表中移除自身。
切换视图模式。切换时会派发 modeChange 事件;若从全景模式退出(PANO / PANO_3D → 其他模式),还会派发 exitPano 事件并重置 currentPano。
| 参数 | 类型 | 说明 |
|---|---|---|
mode |
CompositeViewerMode |
目标模式 |
添加一个已有的 3D Viewer 实例。如果已存在则打印警告并返回现有实例。添加后自动绑定以下原生事件并转发到 eventDispatcher:
click → viewerClickmove → viewerMouseMoveidentify → viewerIdentify / viewerIdentifyMap / viewerIdentifyPointCloud / viewerIdentifyBimcameramoveprecise → viewerCameramoveprecisebimFeatureTypeLoad → bimFeatureTypeLoad| 参数 | 类型 | 说明 |
|---|---|---|
viewer |
Viewer |
3D Viewer 实例 |
返回值: Viewer — 添加的 Viewer 实例。
创建并添加 3D Viewer 实例。
| 参数 | 类型 | 说明 |
|---|---|---|
containerId |
string |
容器元素 ID |
options |
ViewerOptions |
Viewer 配置项 |
返回值: Viewer — 新创建的 Viewer 实例。
添加一个已有的全景查看器实例。如果已存在则打印警告并返回现有实例。添加后自动绑定以下原生事件并转发到 eventDispatcher:
render → panoViewerRenderpanoLoad → panoLoadpanoClick → panoClickidentify → panoViewerIdentifypinpointStart → panoPinpointStartpinpointStop → panoPinpointStop| 参数 | 类型 | 说明 |
|---|---|---|
panoViewer |
PanoramaViewer |
全景查看器实例 |
返回值: PanoramaViewer — 添加的全景查看器实例。
创建并添加全景查看器实例。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
containerId |
string |
是 | 容器元素 ID |
options |
PanoViewerOptions |
否 | 全景查看器配置项 |
返回值: PanoramaViewer — 新创建的全景查看器实例。
创建 2D 地图(基于 OpenLayers)。默认使用香港地政总署底图,支持 EPSG:2326 投影。创建时会自动监听容器大小变化并更新地图尺寸。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
containerId |
string |
是 | 容器元素 ID |
mapUrl |
string |
否 | 瓦片地图 URL 模板,不传则使用默认底图 |
返回值: Map | null — 创建的 OpenLayers Map 实例。
获取全景查看器当前的透明度值。
返回值: number | undefined — 透明度值(0-1),若无全景查看器则返回 undefined。
设置全景查看器的透明度。设置成功后派发 panoOpacityChange 事件。
| 参数 | 类型 | 说明 |
|---|---|---|
opacity |
number |
透明度值,范围 0 - 1 |
跳转到指定全景点。首次加载时调用 loadPano,后续切换时调用 switchPano。跳转后派发 switchPano 事件,并在非全景模式下自动切换到 PANO 模式。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
targetPano |
PanoPoint |
是 | 目标全景点 |
nearbyPanoList |
PanoPoint[] |
是 | 附近全景点列表 |
config |
{ heading?: number; pitch?: number } |
否 | 初始视角配置(仅首次加载生效) |
通过 eventDispatcher.addEventListener(type, callback) 监听。
| 事件名 | 触发时机 | data 类型 |
|---|---|---|
modeChange |
视图模式切换 | CompositeViewerMode |
exitPano |
退出全景模式 | {} |
viewerClick |
3D Viewer 点击 | { position, obj, event } |
viewerMouseMove |
3D Viewer 鼠标移动 | { position, obj, event } |
viewerIdentify |
要素识别(通用) | { identifyData: IdentifyData } |
viewerIdentifyMap |
地图要素识别 | { identifyData: IdentifyMapData } |
viewerIdentifyPointCloud |
点云要素识别 | { identifyData: IdentifyPointCloudData } |
viewerIdentifyBim |
BIM 要素识别 | { identifyData: IdentifyBimData } |
viewerCameramoveprecise |
相机精确移动 | { pos: { x, y, z, heading, pitch } } |
bimFeatureTypeLoad |
BIM 要素类型加载 | { json, id } |
panoViewerRender |
全景查看器渲染 | { pos: { x, y, z, heading, pitch, fov } } |
panoLoad |
全景加载完成 | {} |
panoClick |
全景点击 | { panoId, panoViewer } |
switchPano |
全景切换 | { panoPoint: PanoPoint } |
panoViewerIdentify |
全景要素识别 | { featureInfo: IdentifyData } |
panoPinpointStart |
全景定点开始 | {} |
panoPinpointStop |
全景定点结束 | {} |
panoOpacityChange |
全景透明度变化 | { opacity: number } |