调整馆内模型初始化视角

This commit is contained in:
lyf
2026-07-10 14:31:21 +08:00
parent 3a8afa8d93
commit 130458e97e

View File

@@ -134,11 +134,29 @@ const SGS_VISUAL_RENDER_CONFIG = {
} as const
const OVERVIEW_INITIAL_CAMERA_PARAMS = {
position: new THREE.Vector3(496.3356, 708.6058, 137.501),
position: new THREE.Vector3(305.4812, 441.3596, 205.0497),
target: new THREE.Vector3(-4.1432, -31.3659, 3.3982),
zoom: 1
} as const
const getIndoorInitialCameraDirection = () => (
OVERVIEW_INITIAL_CAMERA_PARAMS.position
.clone()
.sub(OVERVIEW_INITIAL_CAMERA_PARAMS.target)
.normalize()
)
const INDOOR_INITIAL_MODEL_PARAMS = {
position: new THREE.Vector3(0, 0, 0),
rotation: new THREE.Euler(
THREE.MathUtils.degToRad(0),
THREE.MathUtils.degToRad(0),
THREE.MathUtils.degToRad(0),
'XYZ'
),
scale: new THREE.Vector3(1, 1, 1)
} as const
const MODEL_ADJUST_IDLE_REPORT_DELAY_MS = 800
const degToRad = (degrees: number) => THREE.MathUtils.degToRad(degrees)
@@ -3430,7 +3448,7 @@ const fitCameraToObject = (object: THREE.Object3D, preset: CameraPreset = 'obliq
? new THREE.Vector3(0.02, 1, 0.02)
: activeView.value === 'overview'
? new THREE.Vector3(0.76, 0.48, 1)
: new THREE.Vector3(0.85, 0.62, 1)
: getIndoorInitialCameraDirection()
const overviewFitOptions: CameraFitOptions = activeView.value === 'overview'
? {
distanceFactor: 0.9,
@@ -3448,6 +3466,13 @@ const fitCameraToObject = (object: THREE.Object3D, preset: CameraPreset = 'obliq
setCameraView(center, maxDim, direction, overviewFitOptions)
}
const applyIndoorInitialModelTransform = (model: THREE.Object3D) => {
model.position.copy(INDOOR_INITIAL_MODEL_PARAMS.position)
model.rotation.copy(INDOOR_INITIAL_MODEL_PARAMS.rotation)
model.scale.copy(INDOOR_INITIAL_MODEL_PARAMS.scale)
model.updateMatrixWorld(true)
}
const applyOverviewInitialCamera = () => {
if (!camera || !controls) return
@@ -3576,7 +3601,9 @@ const loadOverview = async () => {
if (!targetScene) throw createStaleModelLoadError()
activeModel = cachedOverviewModel
activeModel.name = 'GuideOverviewModel'
activeModel.visible = true
applyIndoorInitialModelTransform(activeModel)
applyModelVisibilityForView(activeModel, 'overview')
cacheAutoSwitchOverviewMaxDim(activeModel)
targetScene.add(activeModel)
@@ -3606,6 +3633,7 @@ const loadOverview = async () => {
activeModel = gltf.scene
activeModel.name = 'GuideOverviewModel'
prepareModel(activeModel)
applyIndoorInitialModelTransform(activeModel)
applyModelVisibilityForView(activeModel, 'overview')
cacheAutoSwitchOverviewMaxDim(activeModel)
cachedOverviewModel = activeModel
@@ -3644,6 +3672,7 @@ const prepareFloorScene = async (
model.name = `GuideFloorModel_${requestedFloorId}`
model.userData.floorId = requestedFloorId
model.visible = true
applyIndoorInitialModelTransform(model)
applyModelVisibilityForView(model, 'floor', requestedFloorId)
} else {
if (!options.suppressProgress) {
@@ -3668,6 +3697,7 @@ const prepareFloorScene = async (
model.name = `GuideFloorModel_${requestedFloorId}`
model.userData.floorId = requestedFloorId
prepareModel(model)
applyIndoorInitialModelTransform(model)
applyModelVisibilityForView(model, 'floor', requestedFloorId)
cacheAsSharedModel = Boolean(floor.sharedModelAsset)