Skip to content
Open
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
7 changes: 4 additions & 3 deletions apps/editor/components/build-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
useTerraceDraft,
useWallDrawVariant,
} from '@pascal-app/editor'
import { useLiquidLineToolOptions } from '@pascal-app/nodes'
import { RoofTypeThumbnail, useLiquidLineToolOptions } from '@pascal-app/nodes'
import { useViewer } from '@pascal-app/viewer'
import Image from 'next/image'
import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react'
Expand Down Expand Up @@ -268,14 +268,14 @@ export function BuildTab() {
<div className="px-0.5 pt-1 font-medium text-muted-foreground text-xs">
Roof type
</div>
<div className="grid grid-cols-2 gap-1.5">
<div className="grid grid-cols-4 gap-1.5">
{ROOF_TYPE_OPTIONS.map((roofType) => {
const active = activeTool === 'roof' && activeRoofType === roofType.value
return (
<button
aria-pressed={active}
className={cn(
'rounded-lg px-2.5 py-2 text-left font-medium text-xs transition-colors',
'flex flex-col items-center gap-1 rounded-lg px-2.5 py-2 text-center font-medium text-xs transition-colors',
active
? 'bg-primary/10 text-primary ring-1 ring-primary/50'
: 'bg-muted/40 text-muted-foreground hover:bg-muted hover:text-foreground',
Expand All @@ -288,6 +288,7 @@ export function BuildTab() {
onMouseEnter={() => triggerSFX('sfx:menu-hover')}
type="button"
>
<RoofTypeThumbnail type={roofType.value} />
{roofType.label}
</button>
)
Expand Down
1 change: 1 addition & 0 deletions apps/editor/lib/build-tab-state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ test('roof creation exposes every supported roof type', () => {
'dutch',
'mansard',
'conical',
'barrel',
])
})
1 change: 1 addition & 0 deletions apps/editor/lib/build-tab-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const ROOF_TYPE_OPTIONS: ReadonlyArray<{ label: string; value: RoofType }
{ label: 'Dutch', value: 'dutch' },
{ label: 'Mansard', value: 'mansard' },
{ label: 'Conical', value: 'conical' },
{ label: 'Barrel', value: 'barrel' },
]

export function getActiveRoofFeatureId(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/editor/public/icons/roof-types/barrel.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/editor/public/icons/roof-types/conical.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/editor/public/icons/roof-types/dutch.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/editor/public/icons/roof-types/flat.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/editor/public/icons/roof-types/gable.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/editor/public/icons/roof-types/gambrel.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/editor/public/icons/roof-types/hip.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/editor/public/icons/roof-types/mansard.webp
Binary file added apps/editor/public/icons/roof-types/shed.webp
2 changes: 1 addition & 1 deletion apps/ifc-converter/AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- BEGIN:nextjs-agent-rules -->

# This is NOT the Next.js you know
## This is NOT the Next.js you know

This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` (resolved from this file's directory; in monorepos the `next` package may not be visible from the repo root) before writing any code. Heed deprecation notices.

Expand Down
1 change: 0 additions & 1 deletion packages/core/src/contracts/reference-inventory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,6 @@ export const METADATA_NON_REFERENCES: readonly { path: string; reason: string }[
'porch',
'renderPass',
'role',
'showTrimPlanes',
'storyShell',
'suppressedDimensionSegmentIndexes',
]),
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,9 @@ export {
} from './store/use-scene'
export { resolveElevatorDispatchTarget } from './systems/elevator/elevator-dispatch'
export {
ELEVATOR_MIN_CAB_DIMENSION,
ELEVATOR_MIN_CAB_HEIGHT,
ELEVATOR_MIN_WALL_THICKNESS,
type ElevatorDoorSide,
getElevatorCabCenterZ,
getElevatorCabDepth,
Expand All @@ -701,6 +704,8 @@ export {
getResolvedElevatorDoorPanelStyle,
getResolvedElevatorDoorStyle,
getResolvedElevatorShaftStyle,
normalizeElevatorDimensions,
resolveElevatorDimensions,
} from './systems/elevator/elevator-geometry'
export { syncAutoElevatorOpenings } from './systems/elevator/elevator-opening-sync'
export { ElevatorOpeningSystem } from './systems/elevator/elevator-opening-system'
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/node-slots/column.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import type { ColumnNode } from '../schema/nodes/column'

export type ColumnSlotId = 'shaft' | 'base' | 'capital' | 'frame'

export const COLUMN_SHAFT_DEFAULT = 'library:concrete-plaster'
export const COLUMN_BASE_DEFAULT = 'library:concrete-plaster'
export const COLUMN_CAPITAL_DEFAULT = 'library:concrete-plaster'
export const COLUMN_FRAME_DEFAULT = 'library:metal-steel'
export const COLUMN_SHAFT_DEFAULT = 'library:preset-white'
export const COLUMN_BASE_DEFAULT = 'library:preset-white'
export const COLUMN_CAPITAL_DEFAULT = 'library:preset-white'
export const COLUMN_FRAME_DEFAULT = 'library:preset-white'

export function columnSlots(node: ColumnNode): SlotDeclaration[] {
if (node.source)
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/registry/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2232,6 +2232,12 @@ export type CapabilityCtx = { node: AnyNode }
export type CutsContext = { nodes: Readonly<Record<AnyNodeId, AnyNode>> }

export type MovableConfig = {
/** Resolve the stored pose after snapping, during preview and again on commit. */
resolvePosition?: (args: {
node: AnyNode
position: [number, number, number]
nodes: Readonly<Record<string, AnyNode>>
}) => [number, number, number]
axes: ReadonlyArray<'x' | 'y' | 'z'>
gridSnap?: boolean
/** Keep an existing floor-placed node on its current level and visual elevation while dragging. */
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ export {
getSegmentSlopeFrame,
hasSegmentMaterialOverride,
isBandedShedSegment,
MAX_ROOF_PITCH,
MIN_ROOF_SEGMENT_DIMENSION,
MIN_ROOF_SEGMENT_TRIM_SPAN,
normalizeRoofSegmentTrim,
ROOF_SHAPE_DEFAULTS,
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/schema/nodes/roof-segment-resize.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
getActiveRoofHeight,
getPitchFromActiveRoofHeight,
MAX_ROOF_PITCH,
type RoofSegmentNode,
} from './roof-segment'

Expand All @@ -25,5 +26,5 @@ export function getRoofSegmentResizePatch(
if (node.roofType === 'barrel')
return { depth: dimension, barrelRise: Math.min(dimension / 2, rise), position }
const pitch = getPitchFromActiveRoofHeight({ ...node, depth: dimension, roofHeight: rise })
return { depth: dimension, pitch: Math.max(0, Math.min(85, pitch)), position }
return { depth: dimension, pitch: Math.max(0, Math.min(MAX_ROOF_PITCH, pitch)), position }
}
46 changes: 45 additions & 1 deletion packages/core/src/schema/nodes/roof-segment-surface.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { describe, expect, test } from 'bun:test'
import { getRoofSegmentSurfaceY, ROOF_SHAPE_DEFAULTS, RoofSegmentNode } from './roof-segment'
import {
getActiveRoofHeight,
getRoofSegmentSurfaceY,
ROOF_SHAPE_DEFAULTS,
RoofSegmentNode,
} from '@pascal-app/core'

describe('getRoofSegmentSurfaceY', () => {
test('falls linearly from a conical apex in every radial direction', () => {
Expand Down Expand Up @@ -79,3 +84,42 @@ describe('getRoofSegmentSurfaceY', () => {
expect(getRoofSegmentSurfaceY(segment, localX, localZ)).toBeCloseTo(expected, 6)
})
})

test('gambrel surface follows its lower and upper slopes across the kink', () => {
const node = RoofSegmentNode.parse({
roofType: 'gambrel',
width: 10,
depth: 8,
wallHeight: 0,
pitch: 45,
})
const peak = getActiveRoofHeight(node)
expect(getRoofSegmentSurfaceY(node, 0, 3)).toBeCloseTo(1, 6)
expect(getRoofSegmentSurfaceY(node, 0, 2)).toBeCloseTo(2, 6)
expect(getRoofSegmentSurfaceY(node, 0, 1)).toBeCloseTo((peak + 2) / 2, 6)
})

test('mansard surface includes the shoulder and a ridge on rectangular footprints', () => {
const node = RoofSegmentNode.parse({
roofType: 'mansard',
width: 12,
depth: 8,
wallHeight: 0,
pitch: 45,
})
const peak = getActiveRoofHeight(node)
expect(getRoofSegmentSurfaceY(node, 0, 3.4)).toBeCloseTo(0.6, 6)
expect(getRoofSegmentSurfaceY(node, 0, 2.8)).toBeCloseTo(1.2, 6)
expect(getRoofSegmentSurfaceY(node, 1, 0)).toBeCloseTo(peak, 6)
expect(getRoofSegmentSurfaceY(node, 5.4, 0)).toBeCloseTo(0.6, 6)
})

test('rectangular hip surface stays at crown height along the ridge in either orientation', () => {
for (const [width, depth, x, z] of [
[10, 6, 1, 0],
[6, 10, 0, 1],
]) {
const node = RoofSegmentNode.parse({ roofType: 'hip', width, depth, wallHeight: 0, pitch: 45 })
expect(getRoofSegmentSurfaceY(node, x!, z!)).toBeCloseTo(3, 6)
}
})
40 changes: 38 additions & 2 deletions packages/core/src/schema/nodes/roof-segment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import type { MaterialSchema as MaterialSchemaType } from '../material'
import { MaterialSchema } from '../material'
import { getBarrelRoofProfile } from './barrel-roof'
import { RoofGlazing, RoofSystemType } from './roof-glazing'
import { getRoofModuleFaces, getRoofShapeRatios } from './roof-segment-shape'
import { RoofType } from './roof-types'

export { RoofType } from './roof-types'
export const MIN_ROOF_SEGMENT_TRIM_SPAN = 0.1
export const MIN_ROOF_SEGMENT_DIMENSION = 0.5
export const MAX_ROOF_PITCH = 85
const DEFAULT_ROOF_SEGMENT_WIDTH = 8
const DEFAULT_ROOF_SEGMENT_DEPTH = 6

Expand Down Expand Up @@ -133,7 +136,7 @@ export const RoofSegmentNode = BaseNode.extend({
// For gable/hip/shed this is the only slope; for gambrel/mansard/dutch
// it is the steep (lower) slope. The overall peak height is derived
// from pitch + footprint + roofType via getActiveRoofHeight().
pitch: z.number().min(0).max(85).default(40),
pitch: z.number().min(0).max(MAX_ROOF_PITCH).default(40),
// Structure thicknesses
wallThickness: z.number().default(0.1),
deckThickness: z.number().default(0.1),
Expand Down Expand Up @@ -767,7 +770,40 @@ export function getRoofSegmentSurfaceY(
const peakY = node.wallHeight + activeRh
if (activeRh === 0) return node.wallHeight

if (node.roofType === 'gable' || node.roofType === 'gambrel' || node.roofType === 'mansard') {
if (node.roofType === 'gambrel' || node.roofType === 'mansard' || node.roofType === 'hip') {
const faces = getRoofModuleFaces({
type: node.roofType,
w: node.width,
d: node.depth,
wh: node.wallHeight,
rh: activeRh,
baseY: node.wallHeight - 1,
baseW: node.width,
baseD: node.depth,
tanTheta: slopeFrame.tanTheta,
insets: {},
shapeRatios: getRoofShapeRatios(node),
})
let top: number | undefined
for (const face of faces) {
const a = face[0]
if (!a) continue
for (let i = 1; i + 1 < face.length; i++) {
const b = face[i]!,
c = face[i + 1]!
const determinant = (b.z - c.z) * (a.x - c.x) + (c.x - b.x) * (a.z - c.z)
if (Math.abs(determinant) < 1e-10) continue
const u = ((b.z - c.z) * (localX - c.x) + (c.x - b.x) * (localZ - c.z)) / determinant
const v = ((c.z - a.z) * (localX - c.x) + (a.x - c.x) * (localZ - c.z)) / determinant
if (u < -1e-8 || v < -1e-8 || u + v > 1 + 1e-8) continue
const y = u * a.y + v * b.y + (1 - u - v) * c.y
top = top === undefined ? y : Math.max(top, y)
}
}
if (top !== undefined) return top
}

if (node.roofType === 'gable') {
const t = node.depth > 0 ? Math.abs(localZ) / (node.depth / 2) : 0
return peakY - t * activeRh
}
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/services/drag-session.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, mock, test } from 'bun:test'
import { afterEach, beforeEach, describe, expect, mock, test } from 'bun:test'
import { z } from 'zod'
import { nodeRegistry, registerNode } from '../registry/registry'
import type { AnyNodeDefinition, DragAction, Relations, SceneApi } from '../registry/types'
Expand Down Expand Up @@ -81,9 +81,12 @@ function makeAction(): DragAction<{ id: AnyNodeId }, { x: number }> {
}

describe('createDragSession', () => {
let restoreRegistry = () => {}
beforeEach(() => {
restoreRegistry = nodeRegistry._snapshot()
nodeRegistry._reset()
})
afterEach(() => restoreRegistry())

test('start pauses history; commit resumes', () => {
const scene = makeSpyScene()
Expand Down
54 changes: 45 additions & 9 deletions packages/core/src/systems/elevator/elevator-geometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import type {
export type ElevatorDoorSide = 'left' | 'right'

const DEFAULT_ELEVATOR_SHAFT_WALL_THICKNESS = 0.09
export const ELEVATOR_MIN_CAB_DIMENSION = 0.8
export const ELEVATOR_MIN_CAB_HEIGHT = 1.8
export const ELEVATOR_MIN_WALL_THICKNESS = 0.04

export function getResolvedElevatorDoorStyle(
doorStyle: ElevatorNode['doorStyle'] | undefined,
Expand Down Expand Up @@ -43,13 +46,14 @@ export function getElevatorDoorLeafX(
doorStyle: ElevatorNode['doorStyle'] | undefined,
) {
const resolvedDoorStyle = getResolvedElevatorDoorStyle(doorStyle)
const amount = Math.min(1, Math.max(0, doorOpen))
const leafWidth = getElevatorDoorLeafWidth(openingWidth, doorStyle)
const openCenter = (openingWidth + leafWidth) / 2
if (resolvedDoorStyle === 'center-opening') {
const direction = side === 'left' ? -1 : 1
return direction * (openingWidth / 4 + doorOpen * openingWidth * 0.34)
return direction * (openingWidth / 4 + amount * (openCenter - openingWidth / 4))
}

const direction = resolvedDoorStyle === 'single-left' ? -1 : 1
return direction * doorOpen * openingWidth * 0.68
return (resolvedDoorStyle === 'single-left' ? -1 : 1) * amount * openCenter
}

export function getElevatorDoorLeafWidth(
Expand All @@ -62,25 +66,57 @@ export function getElevatorDoorLeafWidth(
}

export function getElevatorCabWidth(node: ElevatorNode) {
return Math.max(node.width, 0.8)
return Math.max(node.width, ELEVATOR_MIN_CAB_DIMENSION)
}

export function getElevatorCabDepth(node: ElevatorNode) {
return Math.max(node.depth, 0.8)
return Math.max(node.depth, ELEVATOR_MIN_CAB_DIMENSION)
}

export function getElevatorShaftWallThickness(node: ElevatorNode) {
return Math.max(node.shaftWallThickness ?? DEFAULT_ELEVATOR_SHAFT_WALL_THICKNESS, 0.04)
return Math.max(
node.shaftWallThickness ?? DEFAULT_ELEVATOR_SHAFT_WALL_THICKNESS,
ELEVATOR_MIN_WALL_THICKNESS,
)
}

export function getElevatorShaftWidth(node: ElevatorNode, cabWidth = getElevatorCabWidth(node)) {
return Math.max(node.shaftWidth ?? cabWidth, cabWidth, 0.8)
return Math.max(node.shaftWidth ?? cabWidth, cabWidth, ELEVATOR_MIN_CAB_DIMENSION)
}

export function getElevatorShaftDepth(node: ElevatorNode, cabDepth = getElevatorCabDepth(node)) {
return Math.max(node.shaftDepth ?? cabDepth, cabDepth, 0.8)
return Math.max(node.shaftDepth ?? cabDepth, cabDepth, ELEVATOR_MIN_CAB_DIMENSION)
}

export function getElevatorCabCenterZ(node: ElevatorNode) {
return -getElevatorShaftDepth(node) / 2 + getElevatorCabDepth(node) / 2
}

/** Shared effective dimensions keep legacy scenes readable without rewriting stored data. */
export function resolveElevatorDimensions(node: ElevatorNode) {
const width = getElevatorCabWidth(node)
const depth = getElevatorCabDepth(node)
const cabHeight = Math.max(node.cabHeight, ELEVATOR_MIN_CAB_HEIGHT)
const shaftWidth = getElevatorShaftWidth(node, width)
const shaftDepth = getElevatorShaftDepth(node, depth)
return {
width,
depth,
cabHeight,
shaftWidth,
shaftDepth,
shaftWallThickness: getElevatorShaftWallThickness(node),
doorWidth: Math.min(Math.max(node.doorWidth, 0.45), width - 0.18, shaftWidth - 0.18),
doorHeight: Math.min(Math.max(node.doorHeight, 1.2), cabHeight - 0.1),
}
}

/** Apply on dimension edits only; absent shaft dimensions retain automatic cab sizing. */
export function normalizeElevatorDimensions(node: ElevatorNode) {
const dimensions = resolveElevatorDimensions(node)
return {
...dimensions,
shaftWidth: node.shaftWidth === undefined ? undefined : dimensions.shaftWidth,
shaftDepth: node.shaftDepth === undefined ? undefined : dimensions.shaftDepth,
}
}
Loading
Loading