Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/core/src/hooks/spatial-grid/spatial-grid-manager.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
14 changes: 14 additions & 0 deletions packages/core/src/schema/nodes/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type FloorplanActionMenuLayerProps = {
slab: FloorplanActionMenuEntry
ceiling: FloorplanActionMenuEntry
opening: FloorplanActionMenuEntry
spawn: FloorplanActionMenuEntry
stair: FloorplanActionMenuEntry
roof: FloorplanActionMenuEntry
offsetY?: number
Expand All @@ -38,6 +39,7 @@ export const FloorplanActionMenuLayer = memo(function FloorplanActionMenuLayer({
slab,
ceiling,
opening,
spawn,
stair,
roof,
offsetY = 10,
Expand All @@ -59,6 +61,7 @@ export const FloorplanActionMenuLayer = memo(function FloorplanActionMenuLayer({
slab,
ceiling,
opening,
spawn,
stair,
roof,
]
Expand Down
8 changes: 3 additions & 5 deletions packages/editor/src/components/editor-2d/svg-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import type { Point2D } from '@pascal-app/core'

function toSvgX(value: number) {
return -value
return value
}

function toSvgY(value: number) {
return -value
return value
}

function toSvgPoint(point: Point2D) {
Expand Down Expand Up @@ -100,9 +100,7 @@ export function buildSvgAnnularSectorPath(
}

export function formatSvgPolygonPoints(points: Point2D[]) {
return points
.map((point) => `${toSvgX(point.x)},${toSvgY(point.y)}`)
.join(' ')
return points.map((point) => `${toSvgX(point.x)},${toSvgY(point.y)}`).join(' ')
}

export function buildSvgArrowHeadPoints(point: Point2D, angle: number, size: number) {
Expand Down
Loading
Loading