Fix item surface placement and remove item height annotations
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { AnyNode, CeilingNode, ItemNode, SlabNode, WallNode } from '../../schema'
|
||||
import { getScaledDimensions } from '../../schema'
|
||||
import { getScaledDimensions, isLowProfileItemSurface } from '../../schema'
|
||||
import useScene from '../../store/use-scene'
|
||||
import { SpatialGrid } from './spatial-grid'
|
||||
import { WallSpatialGrid } from './wall-spatial-grid'
|
||||
@@ -582,6 +582,7 @@ export class SpatialGridManager {
|
||||
if (node.type !== 'item') continue
|
||||
const item = node as ItemNode
|
||||
if (item.asset.attachTo) continue
|
||||
if (isLowProfileItemSurface(item)) continue
|
||||
if (ignoreSet.has(item.id)) continue
|
||||
if (resolveNodeLevelId(item, nodes) !== levelId) continue
|
||||
|
||||
|
||||
@@ -55,7 +55,12 @@ export type {
|
||||
TemperatureControl,
|
||||
ToggleControl,
|
||||
} from './nodes/item'
|
||||
export { getScaledDimensions, ItemNode } from './nodes/item'
|
||||
export {
|
||||
getScaledDimensions,
|
||||
ItemNode,
|
||||
isLowProfileItemSurface,
|
||||
LOW_PROFILE_ITEM_SURFACE_MAX_HEIGHT,
|
||||
} from './nodes/item'
|
||||
export { LevelNode } from './nodes/level'
|
||||
export type { RoofSurfaceMaterialRole, RoofSurfaceMaterialSpec } from './nodes/roof'
|
||||
export { getEffectiveRoofSurfaceMaterial, RoofNode } from './nodes/roof'
|
||||
|
||||
@@ -135,6 +135,20 @@ export const ItemNode = BaseNode.extend({
|
||||
|
||||
export type ItemNode = z.infer<typeof ItemNode>
|
||||
|
||||
export const LOW_PROFILE_ITEM_SURFACE_MAX_HEIGHT = 0.1
|
||||
|
||||
/**
|
||||
* Low, floor-resting items like rugs and parking mats can receive items visually,
|
||||
* but should not become item parents or block normal floor placement.
|
||||
*/
|
||||
export function isLowProfileItemSurface(item: ItemNode): boolean {
|
||||
if (item.asset.attachTo) return false
|
||||
const surfaceHeight = item.asset.surface
|
||||
? item.asset.surface.height * item.scale[1]
|
||||
: getScaledDimensions(item)[1]
|
||||
return surfaceHeight <= LOW_PROFILE_ITEM_SURFACE_MAX_HEIGHT
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the effective world-space dimensions of an item after applying its scale.
|
||||
* Use this everywhere item.asset.dimensions is used for spatial calculations.
|
||||
|
||||
Reference in New Issue
Block a user