fix(export): snap levels to stacked positions before GLB export
exportSceneToGlb now calls snapLevelsToTruePositions() (the same clean stacked presentation thumbnail capture uses) before snapshotting the scene, so the GLB always reflects the stacked building regardless of the live levelMode (exploded/solo) or an unsettled level lerp. Fixes baked GLBs where a level was captured at a stray offset (e.g. ~ -100k Y), which inflated the bounding box and made the model unframable / invisible in third-party glTF viewers. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
c8bd29e909
commit
0629c7d3e3
@@ -7,7 +7,7 @@ import {
|
|||||||
type WindowNode,
|
type WindowNode,
|
||||||
type ZoneNode,
|
type ZoneNode,
|
||||||
} from '@pascal-app/core'
|
} from '@pascal-app/core'
|
||||||
import { poseWindowMovingParts, SCENE_LAYER } from '@pascal-app/viewer'
|
import { poseWindowMovingParts, SCENE_LAYER, snapLevelsToTruePositions } from '@pascal-app/viewer'
|
||||||
import type { Object3D } from 'three'
|
import type { Object3D } from 'three'
|
||||||
import * as THREE from 'three'
|
import * as THREE from 'three'
|
||||||
import { GLTFExporter } from 'three/examples/jsm/exporters/GLTFExporter.js'
|
import { GLTFExporter } from 'three/examples/jsm/exporters/GLTFExporter.js'
|
||||||
@@ -36,10 +36,16 @@ export async function exportSceneToGlb(
|
|||||||
nodes: Record<string, AnyNode>,
|
nodes: Record<string, AnyNode>,
|
||||||
): Promise<ArrayBuffer> {
|
): Promise<ArrayBuffer> {
|
||||||
emitter.emit('thumbnail:before-capture', undefined)
|
emitter.emit('thumbnail:before-capture', undefined)
|
||||||
|
// Snap levels to their true stacked positions (like thumbnail capture) so the
|
||||||
|
// export always reflects the clean stacked building, regardless of the live
|
||||||
|
// levelMode (exploded/solo) or an unsettled level lerp that could otherwise
|
||||||
|
// bake a level at a stray offset.
|
||||||
|
const restoreLevels = snapLevelsToTruePositions()
|
||||||
let prepared: ReturnType<typeof prepareSceneForExport>
|
let prepared: ReturnType<typeof prepareSceneForExport>
|
||||||
try {
|
try {
|
||||||
prepared = prepareSceneForExport(sceneGroup, nodes)
|
prepared = prepareSceneForExport(sceneGroup, nodes)
|
||||||
} finally {
|
} finally {
|
||||||
|
restoreLevels()
|
||||||
emitter.emit('thumbnail:after-capture', undefined)
|
emitter.emit('thumbnail:after-capture', undefined)
|
||||||
}
|
}
|
||||||
const { scene: exportScene, animations } = prepared
|
const { scene: exportScene, animations } = prepared
|
||||||
|
|||||||
Reference in New Issue
Block a user