feat: wire guide data source and POI focus UI

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
lyf
2026-06-12 09:25:22 +08:00
parent a6bfda30e1
commit 2055b13b90
58 changed files with 5768 additions and 1898 deletions

View File

@@ -0,0 +1,64 @@
import type {
GuideModelFloorAsset,
GuideModelRenderPackage,
GuideModelSource,
GuideRenderPoi
} from '@/domain/guideModel'
import {
formatNavFloorLabel
} from '@/data/adapters/navAssetsAdapter'
import {
defaultStaticNavAssetsProvider,
type StaticNavAssetsProvider,
type StaticNavPoiPayload
} from '@/data/providers/staticNavAssetsProvider'
const toRenderPoi = (poi: StaticNavPoiPayload): GuideRenderPoi => ({
id: poi.id,
name: poi.name,
floorId: poi.floorId,
primaryCategory: poi.primaryCategory,
primaryCategoryZh: poi.primaryCategoryZh,
iconType: poi.iconType || poi.primaryCategory,
positionGltf: poi.positionGltf
})
export interface GuideModelRepository extends GuideModelSource {}
export class StaticGuideModelRepository implements GuideModelRepository {
constructor(private readonly provider: StaticNavAssetsProvider = defaultStaticNavAssetsProvider) {}
async loadPackage(): Promise<GuideModelRenderPackage> {
const [manifest, floorIndex] = await Promise.all([
this.provider.loadManifest(),
this.provider.loadFloorIndex()
])
const floors: GuideModelFloorAsset[] = [...floorIndex.floors]
.sort((a, b) => a.order - b.order)
.map((floor) => ({
floorId: floor.floorId,
label: formatNavFloorLabel(floor.floorId),
order: floor.order,
modelUrl: this.provider.assetUrl(floor.modelAsset)
}))
return {
overviewModelUrl: this.provider.assetUrl(manifest.assets.overviewModel.asset),
floors
}
}
async loadFloorPois(floorId: string) {
const floorIndex = await this.provider.loadFloorIndex()
const floor = floorIndex.floors.find((item) => item.floorId === floorId)
if (!floor) return []
const pois = await this.provider.loadFloorPois(floor.poiDataAsset)
return pois
.map(toRenderPoi)
.filter((poi) => Array.isArray(poi.positionGltf) && poi.positionGltf.length === 3)
}
}
export const guideModelRepository = new StaticGuideModelRepository()