feat(editor): precise item dimensions — static bounding boxes, placement-math, remove item-mesh-metadata system
- Replace runtime mesh-based bounding-box computation with static dimension-based polygons for item footprints - Add snapUpToGridStep() and getGridAlignedDimensions() to placement-math for grid-cell-aligned placement wireframes - Add expandBoundsToGrid() to use-placement-coordinator for consistent wireframe snapping - Add currentCursorRotationY to PlacementContext; preserve world orientation across item-surface transitions - Fix item detach from surface: use worldToBuildingLocal() instead of event.localPosition to avoid coordinate-space jump - Subscribe to useLiveTransforms in FloorplanPanel during placement so R/T keyboard rotation refreshes the 2D overlay immediately - Fix FloorplanItemImage rotation (+180° to account for top-down camera capture orientation) - Simplify spatial-grid-manager: single dimension-based getItemLocalBounds(), removes runtime mesh-metadata path - Remove item-mesh-metadata system (compute-item-mesh-metadata, item-mesh-metadata-system, sync-request)
This commit is contained in:
@@ -66,7 +66,7 @@ type ItemParentAabb = {
|
||||
maxZ: number
|
||||
}
|
||||
|
||||
function getFallbackItemLocalBounds(item: ItemNode): ItemLocalBounds {
|
||||
function getItemLocalBounds(item: ItemNode): ItemLocalBounds {
|
||||
const [width, height, depth] = getScaledDimensions(item)
|
||||
const minZ = item.asset.attachTo === 'wall-side' ? -depth : -depth / 2
|
||||
const maxZ = item.asset.attachTo === 'wall-side' ? 0 : depth / 2
|
||||
@@ -76,41 +76,6 @@ function getFallbackItemLocalBounds(item: ItemNode): ItemLocalBounds {
|
||||
}
|
||||
}
|
||||
|
||||
function getItemLocalBounds(item: ItemNode): ItemLocalBounds {
|
||||
const metadata =
|
||||
typeof item.metadata === 'object' && item.metadata !== null && !Array.isArray(item.metadata)
|
||||
? (item.metadata as Record<string, unknown>)
|
||||
: null
|
||||
const rawBounds =
|
||||
typeof metadata?.meshLocalBounds === 'object' &&
|
||||
metadata.meshLocalBounds !== null &&
|
||||
!Array.isArray(metadata.meshLocalBounds)
|
||||
? (metadata.meshLocalBounds as Record<string, unknown>)
|
||||
: null
|
||||
const min = rawBounds?.min
|
||||
const max = rawBounds?.max
|
||||
|
||||
if (
|
||||
Array.isArray(min) &&
|
||||
min.length >= 3 &&
|
||||
Array.isArray(max) &&
|
||||
max.length >= 3 &&
|
||||
typeof min[0] === 'number' &&
|
||||
typeof min[1] === 'number' &&
|
||||
typeof min[2] === 'number' &&
|
||||
typeof max[0] === 'number' &&
|
||||
typeof max[1] === 'number' &&
|
||||
typeof max[2] === 'number'
|
||||
) {
|
||||
return {
|
||||
min: [min[0], min[1], min[2]],
|
||||
max: [max[0], max[1], max[2]],
|
||||
}
|
||||
}
|
||||
|
||||
return getFallbackItemLocalBounds(item)
|
||||
}
|
||||
|
||||
function getItemParentAabb(item: ItemNode): ItemParentAabb {
|
||||
const bounds = getItemLocalBounds(item)
|
||||
const corners: Array<[number, number, number]> = [
|
||||
|
||||
Reference in New Issue
Block a user