Fix floor item placement cursor height
This commit is contained in:
@@ -33,7 +33,6 @@ import type {
|
||||
const DEFAULT_DIMENSIONS: [number, number, number] = [1, 1, 1]
|
||||
const LOW_PROFILE_ITEM_SURFACE_MAX_HEIGHT = 0.1
|
||||
const UPWARD_SURFACE_NORMAL_MIN_Y = 0.75
|
||||
const AUTO_SURFACE_MIN_LOCAL_Y = 0.1
|
||||
|
||||
function isLowProfileItemSurface(item: ItemNode): boolean {
|
||||
if (item.asset.attachTo) return false
|
||||
@@ -64,7 +63,7 @@ function getSurfacePlacementHeight(surfaceItem: ItemNode, event: ItemEvent, loca
|
||||
return surfaceItem.asset.surface.height * surfaceItem.scale[1]
|
||||
}
|
||||
|
||||
if (localPos.y < AUTO_SURFACE_MIN_LOCAL_Y) return null
|
||||
if (!Number.isFinite(localPos.y)) return null
|
||||
return localPos.y
|
||||
}
|
||||
|
||||
|
||||
@@ -514,6 +514,10 @@ export function usePlacementCoordinator(config: PlacementCoordinatorConfig): Rea
|
||||
ceilingId: null,
|
||||
surfaceItemId: null,
|
||||
}
|
||||
if (!asset.attachTo && placementState.current.surface === 'floor') {
|
||||
gridPosition.current.y = 0
|
||||
cursorGroupRef.current.position.y = 0
|
||||
}
|
||||
|
||||
// ---- Helpers ----
|
||||
|
||||
@@ -641,9 +645,11 @@ export function usePlacementCoordinator(config: PlacementCoordinatorConfig): Rea
|
||||
|
||||
previousGridPos = [...result.gridPosition]
|
||||
gridPosition.current.set(...result.gridPosition)
|
||||
// Only update X and Z for cursor - useFrame will handle Y (slab elevation)
|
||||
cursorGroupRef.current.position.x = result.cursorPosition[0]
|
||||
cursorGroupRef.current.position.z = result.cursorPosition[2]
|
||||
cursorGroupRef.current.position.set(
|
||||
result.cursorPosition[0],
|
||||
result.cursorPosition[1],
|
||||
result.cursorPosition[2],
|
||||
)
|
||||
|
||||
const draft = draftNode.current
|
||||
if (draft) draft.position = result.gridPosition
|
||||
|
||||
Reference in New Issue
Block a user