Files
editor/packages/nodes/src/cabinet/resize-limits.ts
T
6cc10c929e editor: improve cabinet resizing and wall alignment (#503)
* Add roof surface placement support for items

Items (e.g. solar panels) can now be placed on sloped roof surfaces.
The placement system computes euler rotation from the roof surface
normal so items sit flush on the slope instead of going inside.

- Add roofStrategy to placement-strategies with enter/move/click/leave
- Wire roof:enter/move/click/leave events in the placement coordinator
- Add calculateRoofRotation in placement-math using surface normals
- Support full 3D cursor rotation for sloped surfaces
- Items on roofs are parented to the level with world-space rotation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fixed conflict

* fix wall treatment miter geometry

* fix cabinet group resizing and corner alignment

* fix cabinet corner depth resizing

* fix(cabinet): stabilize modular preset changes

* fix(cabinet): stabilize corner resizing and wall alignment

* fix(nodes): stabilize wall cabinet depth resizing

* fix(editor): hide cabinet arrows for module selection

* feat(cabinet): add individual width resize handles

* feat(cabinet): improve wall cabinet editing

* fix(cabinet): harden wall cabinet resizing

* fix(cabinet): correct wall drag and depth handles

* fix(cabinet): refine individual depth resizing

* fix(cabinet): preserve context-aware corner depth behavior

* fix(editor): respect snapping modes for resize handles

* fix(editor): harden cabinet resize interactions

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Aymeric Rabot <aymeric.rabot@gmail.com>
2026-07-19 17:33:57 +02:00

32 lines
936 B
TypeScript

export const MIN_CABINET_WIDTH = 0.3
export const MIN_CABINET_DEPTH = 0.3
export const MAX_CABINET_WIDTH = 1.2
export const MAX_CABINET_DEPTH = 0.8
export function cabinetResizeUpperBound(currentValue: number, limit: number) {
return Math.max(currentValue, limit)
}
export function connectedCabinetDepthUpperBound(currentDepth: number, sourceWidth?: number) {
return cabinetConnectedDepthBounds(
currentDepth,
typeof sourceWidth === 'number' ? [sourceWidth] : [],
).max
}
export function cabinetConnectedDepthBounds(
currentDepth: number,
compensatedWidths: readonly number[],
) {
let min = MIN_CABINET_DEPTH
let max = MAX_CABINET_DEPTH
for (const width of compensatedWidths) {
min = Math.max(min, currentDepth - (MAX_CABINET_WIDTH - width))
max = Math.min(max, currentDepth + width - MIN_CABINET_WIDTH)
}
return {
min: Math.min(currentDepth, min),
max: Math.max(currentDepth, max),
}
}