@pascal-app/core 1.0.0 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/capture/index.d.ts +2 -2
- package/dist/capture/index.js +2 -2
- package/dist/capture/schema.d.ts.map +1 -1
- package/dist/capture/schema.js +2 -0
- package/dist/capture/source.d.ts +1 -1
- package/dist/capture/source.js +1 -1
- package/dist/events/bus.d.ts +6 -3
- package/dist/events/bus.d.ts.map +1 -1
- package/dist/hooks/spatial-grid/floor-placed-elevation.d.ts +4 -4
- package/dist/hooks/spatial-grid/floor-placed-elevation.d.ts.map +1 -1
- package/dist/hooks/spatial-grid/floor-placed-elevation.js +7 -12
- package/dist/hooks/spatial-grid/floor-placed-footprints.d.ts +4 -0
- package/dist/hooks/spatial-grid/floor-placed-footprints.d.ts.map +1 -0
- package/dist/hooks/spatial-grid/floor-placed-footprints.js +7 -0
- package/dist/hooks/spatial-grid/spatial-grid-manager.d.ts +5 -8
- package/dist/hooks/spatial-grid/spatial-grid-manager.d.ts.map +1 -1
- package/dist/hooks/spatial-grid/spatial-grid-manager.js +23 -106
- package/dist/hooks/spatial-grid/spatial-grid-sync.d.ts +263 -84
- package/dist/hooks/spatial-grid/spatial-grid-sync.d.ts.map +1 -1
- package/dist/hooks/spatial-grid/spatial-grid-sync.js +77 -13
- package/dist/hooks/spatial-grid/support-host-patch.d.ts +1 -1
- package/dist/hooks/spatial-grid/support-host-patch.js +6 -6
- package/dist/hooks/spatial-grid/use-spatial-query.d.ts +1 -1
- package/dist/hooks/spatial-grid/use-spatial-query.js +1 -1
- package/dist/index.d.ts +77 -72
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +74 -69
- package/dist/lib/door-operation.d.ts +1 -1
- package/dist/lib/item-polygon-overlap.d.ts +6 -0
- package/dist/lib/item-polygon-overlap.d.ts.map +1 -0
- package/dist/lib/item-polygon-overlap.js +67 -0
- package/dist/lib/level-name.d.ts +1 -1
- package/dist/lib/measurement-geometry.d.ts +4 -4
- package/dist/lib/node-visibility.d.ts +12 -0
- package/dist/lib/node-visibility.d.ts.map +1 -0
- package/dist/lib/node-visibility.js +12 -0
- package/dist/lib/plan-footprint.d.ts +41 -0
- package/dist/lib/plan-footprint.d.ts.map +1 -0
- package/dist/lib/plan-footprint.js +58 -0
- package/dist/lib/room-topology-index.d.ts +1 -1
- package/dist/lib/room-topology-index.js +1 -1
- package/dist/lib/selection-proxy.d.ts +1 -1
- package/dist/lib/slab-polygon.d.ts +2 -2
- package/dist/lib/slab-polygon.js +2 -2
- package/dist/lib/space-detection.d.ts +1 -1
- package/dist/lib/space-detection.d.ts.map +1 -1
- package/dist/lib/space-detection.js +16 -11
- package/dist/lib/terrain-brush.d.ts +1 -1
- package/dist/lib/terrain-brush.js +1 -1
- package/dist/lib/terrain-codec.d.ts +2 -2
- package/dist/lib/terrain-codec.js +1 -1
- package/dist/lib/terrain-raycast.d.ts +1 -1
- package/dist/lib/terrain-raycast.js +1 -1
- package/dist/lib/terrain-source.d.ts +3 -3
- package/dist/lib/terrain-source.js +3 -3
- package/dist/lib/terrain-support.d.ts +1 -1
- package/dist/lib/terrain-support.js +3 -3
- package/dist/lib/unit-containment.d.ts +19 -0
- package/dist/lib/unit-containment.d.ts.map +1 -0
- package/dist/lib/unit-containment.js +158 -0
- package/dist/lib/unit-report.d.ts +19 -0
- package/dist/lib/unit-report.d.ts.map +1 -0
- package/dist/lib/unit-report.js +36 -0
- package/dist/lib/wall-distance.d.ts +2 -2
- package/dist/lib/wall-distance.js +1 -1
- package/dist/lib/zone-quantities.d.ts +1 -1
- package/dist/lib/zone-quantities.js +7 -7
- package/dist/material-library.d.ts +1 -1
- package/dist/material-library.js +1 -1
- package/dist/procedural-items/fixtures.d.ts +261 -0
- package/dist/procedural-items/fixtures.d.ts.map +1 -0
- package/dist/procedural-items/fixtures.js +349 -0
- package/dist/procedural-items/index.d.ts +10 -0
- package/dist/procedural-items/index.d.ts.map +1 -0
- package/dist/procedural-items/index.js +9 -0
- package/dist/procedural-items/integration.d.ts +92 -0
- package/dist/procedural-items/integration.d.ts.map +1 -0
- package/dist/procedural-items/integration.js +19 -0
- package/dist/procedural-items/library-colors.d.ts +56 -0
- package/dist/procedural-items/library-colors.d.ts.map +1 -0
- package/dist/procedural-items/library-colors.js +84 -0
- package/dist/procedural-items/materials.d.ts +5 -0
- package/dist/procedural-items/materials.d.ts.map +1 -0
- package/dist/procedural-items/materials.js +47 -0
- package/dist/procedural-items/node.d.ts +280 -0
- package/dist/procedural-items/node.d.ts.map +1 -0
- package/dist/procedural-items/node.js +71 -0
- package/dist/procedural-items/placement.d.ts +7 -0
- package/dist/procedural-items/placement.d.ts.map +1 -0
- package/dist/procedural-items/placement.js +48 -0
- package/dist/procedural-items/query.d.ts +51 -0
- package/dist/procedural-items/query.d.ts.map +1 -0
- package/dist/procedural-items/query.js +342 -0
- package/dist/procedural-items/recipe.d.ts +144 -0
- package/dist/procedural-items/recipe.d.ts.map +1 -0
- package/dist/procedural-items/recipe.js +372 -0
- package/dist/procedural-items/spatial.d.ts +19 -0
- package/dist/procedural-items/spatial.d.ts.map +1 -0
- package/dist/procedural-items/spatial.js +39 -0
- package/dist/registry/__bench__/relations-resolver.bench.js +2 -2
- package/dist/registry/handles.d.ts +40 -5
- package/dist/registry/handles.d.ts.map +1 -1
- package/dist/registry/index.d.ts +6 -6
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +4 -4
- package/dist/registry/registry.d.ts +1 -1
- package/dist/registry/relations-resolver.d.ts +2 -2
- package/dist/registry/relations-resolver.js +1 -1
- package/dist/registry/scene-api.d.ts +2 -2
- package/dist/registry/scene-api.js +2 -2
- package/dist/registry/subtree.d.ts +1 -1
- package/dist/registry/subtree.d.ts.map +1 -1
- package/dist/registry/subtree.js +8 -2
- package/dist/registry/types.d.ts +32 -10
- package/dist/registry/types.d.ts.map +1 -1
- package/dist/registry/use-registry-version.js +1 -1
- package/dist/registry/validate-relations.d.ts +4 -0
- package/dist/registry/validate-relations.d.ts.map +1 -0
- package/dist/registry/validate-relations.js +22 -0
- package/dist/schema/__bench__/node-parsers.bench.js +3 -3
- package/dist/schema/__fixtures__/node-fixtures.d.ts +1 -1
- package/dist/schema/__fixtures__/node-fixtures.d.ts.map +1 -1
- package/dist/schema/__fixtures__/node-fixtures.js +4 -2
- package/dist/schema/base.js +1 -1
- package/dist/schema/collections.d.ts +1 -1
- package/dist/schema/collections.js +1 -1
- package/dist/schema/compiled-node-parsers.d.ts +1 -1
- package/dist/schema/compiled-node-parsers.js +1 -1
- package/dist/schema/index.d.ts +74 -70
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +65 -61
- package/dist/schema/material.d.ts +1 -1
- package/dist/schema/material.js +1 -1
- package/dist/schema/nodes/automatic-downspout.d.ts +4 -4
- package/dist/schema/nodes/automatic-downspout.js +5 -5
- package/dist/schema/nodes/block.d.ts +3 -3
- package/dist/schema/nodes/block.d.ts.map +1 -1
- package/dist/schema/nodes/block.js +24 -12
- package/dist/schema/nodes/box-vent.js +2 -2
- package/dist/schema/nodes/building.d.ts +1 -1
- package/dist/schema/nodes/building.d.ts.map +1 -1
- package/dist/schema/nodes/building.js +8 -5
- package/dist/schema/nodes/cabinet.d.ts +4 -4
- package/dist/schema/nodes/cabinet.js +4 -4
- package/dist/schema/nodes/ceiling.d.ts +1 -1
- package/dist/schema/nodes/ceiling.js +5 -5
- package/dist/schema/nodes/chimney.js +2 -2
- package/dist/schema/nodes/column.d.ts +1 -0
- package/dist/schema/nodes/column.d.ts.map +1 -1
- package/dist/schema/nodes/column.js +3 -2
- package/dist/schema/nodes/construction-dimension.d.ts +3 -3
- package/dist/schema/nodes/construction-dimension.js +2 -2
- package/dist/schema/nodes/cupola.d.ts +1 -1
- package/dist/schema/nodes/cupola.js +2 -2
- package/dist/schema/nodes/curtain-wall.d.ts +129 -0
- package/dist/schema/nodes/curtain-wall.d.ts.map +1 -0
- package/dist/schema/nodes/curtain-wall.js +49 -0
- package/dist/schema/nodes/door.d.ts +2 -2
- package/dist/schema/nodes/door.js +2 -2
- package/dist/schema/nodes/dormer.d.ts +3 -3
- package/dist/schema/nodes/dormer.js +4 -4
- package/dist/schema/nodes/downspout.js +2 -2
- package/dist/schema/nodes/duct-fitting.js +1 -1
- package/dist/schema/nodes/duct-segment.js +2 -2
- package/dist/schema/nodes/duct-terminal.js +1 -1
- package/dist/schema/nodes/elevator.js +2 -2
- package/dist/schema/nodes/eyebrow-vent.js +2 -2
- package/dist/schema/nodes/fence.js +2 -2
- package/dist/schema/nodes/guide.js +2 -2
- package/dist/schema/nodes/gutter.d.ts +1 -1
- package/dist/schema/nodes/gutter.js +4 -4
- package/dist/schema/nodes/hvac-equipment.js +1 -1
- package/dist/schema/nodes/imported-mesh.d.ts +40 -0
- package/dist/schema/nodes/imported-mesh.d.ts.map +1 -0
- package/dist/schema/nodes/imported-mesh.js +27 -0
- package/dist/schema/nodes/item.d.ts +3 -3
- package/dist/schema/nodes/item.js +3 -3
- package/dist/schema/nodes/lean-to-extension.js +4 -4
- package/dist/schema/nodes/level.d.ts +1 -1
- package/dist/schema/nodes/level.d.ts.map +1 -1
- package/dist/schema/nodes/level.js +1 -1
- package/dist/schema/nodes/lineset.js +1 -1
- package/dist/schema/nodes/liquid-line.js +1 -1
- package/dist/schema/nodes/measurement.js +2 -2
- package/dist/schema/nodes/pipe-fitting.d.ts +1 -1
- package/dist/schema/nodes/pipe-fitting.js +1 -1
- package/dist/schema/nodes/pipe-segment.d.ts +1 -1
- package/dist/schema/nodes/pipe-segment.js +2 -2
- package/dist/schema/nodes/pipe-trap.d.ts +1 -1
- package/dist/schema/nodes/pipe-trap.js +1 -1
- package/dist/schema/nodes/ridge-vent.d.ts +1 -1
- package/dist/schema/nodes/ridge-vent.js +3 -3
- package/dist/schema/nodes/roof-segment-shape.d.ts +1 -1
- package/dist/schema/nodes/roof-segment-shape.js +1 -1
- package/dist/schema/nodes/roof-segment-walls.d.ts +1 -1
- package/dist/schema/nodes/roof-segment-walls.js +1 -1
- package/dist/schema/nodes/roof-segment.d.ts +2 -2
- package/dist/schema/nodes/roof-segment.js +2 -2
- package/dist/schema/nodes/roof.d.ts +1 -1
- package/dist/schema/nodes/roof.js +3 -3
- package/dist/schema/nodes/scan.js +3 -3
- package/dist/schema/nodes/shelf.d.ts +1 -1
- package/dist/schema/nodes/shelf.d.ts.map +1 -1
- package/dist/schema/nodes/shelf.js +3 -4
- package/dist/schema/nodes/site.js +2 -2
- package/dist/schema/nodes/skylight.d.ts +4 -4
- package/dist/schema/nodes/skylight.js +2 -2
- package/dist/schema/nodes/slab.js +3 -3
- package/dist/schema/nodes/solar-panel.js +3 -3
- package/dist/schema/nodes/spawn.js +1 -1
- package/dist/schema/nodes/stair-segment.js +2 -2
- package/dist/schema/nodes/stair.d.ts +1 -1
- package/dist/schema/nodes/stair.js +3 -3
- package/dist/schema/nodes/structural-grid.js +1 -1
- package/dist/schema/nodes/turbine-vent.d.ts +1 -1
- package/dist/schema/nodes/turbine-vent.js +2 -2
- package/dist/schema/nodes/unit.d.ts +33 -0
- package/dist/schema/nodes/unit.d.ts.map +1 -0
- package/dist/schema/nodes/unit.js +13 -0
- package/dist/schema/nodes/wall.d.ts +75 -2
- package/dist/schema/nodes/wall.d.ts.map +1 -1
- package/dist/schema/nodes/wall.js +10 -6
- package/dist/schema/nodes/window.js +2 -2
- package/dist/schema/nodes/zone.js +1 -1
- package/dist/schema/scene-material.js +2 -2
- package/dist/schema/types.d.ts +417 -22
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/schema/types.js +56 -49
- package/dist/services/__fixtures__/hosting.d.ts +3 -0
- package/dist/services/__fixtures__/hosting.d.ts.map +1 -0
- package/dist/services/__fixtures__/hosting.js +9 -0
- package/dist/services/__fixtures__/shelf-surface-rows.d.ts +4 -0
- package/dist/services/__fixtures__/shelf-surface-rows.d.ts.map +1 -0
- package/dist/services/__fixtures__/shelf-surface-rows.js +18 -0
- package/dist/services/alignment-anchors.d.ts +6 -11
- package/dist/services/alignment-anchors.d.ts.map +1 -1
- package/dist/services/alignment-anchors.js +7 -34
- package/dist/services/drag-session.d.ts +4 -4
- package/dist/services/drag-session.js +1 -1
- package/dist/services/hosting.d.ts +5 -8
- package/dist/services/hosting.d.ts.map +1 -1
- package/dist/services/hosting.js +25 -18
- package/dist/services/index.d.ts +16 -13
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +16 -13
- package/dist/services/level-height.d.ts +2 -2
- package/dist/services/level-height.js +3 -3
- package/dist/services/movement.d.ts +3 -3
- package/dist/services/movement.js +2 -2
- package/dist/services/port-connectivity.d.ts +1 -1
- package/dist/services/port-connectivity.js +1 -1
- package/dist/services/riser-diagram.d.ts +1 -1
- package/dist/services/shelf-board.d.ts +5 -0
- package/dist/services/shelf-board.d.ts.map +1 -0
- package/dist/services/shelf-board.js +15 -0
- package/dist/services/snap.d.ts +3 -0
- package/dist/services/snap.d.ts.map +1 -1
- package/dist/services/snap.js +11 -0
- package/dist/services/storey.d.ts +2 -2
- package/dist/services/storey.js +2 -2
- package/dist/services/surface-hosting-procedural-parity.fixtures.d.ts +13 -0
- package/dist/services/surface-hosting-procedural-parity.fixtures.d.ts.map +1 -0
- package/dist/services/surface-hosting-procedural-parity.fixtures.js +4691 -0
- package/dist/services/surface-hosting-shelf-parity.fixtures.d.ts +1060 -0
- package/dist/services/surface-hosting-shelf-parity.fixtures.d.ts.map +1 -0
- package/dist/services/surface-hosting-shelf-parity.fixtures.js +3127 -0
- package/dist/services/surface-hosting.d.ts +92 -0
- package/dist/services/surface-hosting.d.ts.map +1 -0
- package/dist/services/surface-hosting.js +305 -0
- package/dist/services/surface-region.d.ts +8 -0
- package/dist/services/surface-region.d.ts.map +1 -0
- package/dist/services/surface-region.js +44 -0
- package/dist/services/system-graph.d.ts +2 -2
- package/dist/services/system-graph.js +2 -2
- package/dist/services/validate-dwv.d.ts +1 -1
- package/dist/services/validate-dwv.js +1 -1
- package/dist/store/actions/node-actions.d.ts +2 -2
- package/dist/store/actions/node-actions.d.ts.map +1 -1
- package/dist/store/actions/node-actions.js +50 -104
- package/dist/store/history-control.d.ts +3 -3
- package/dist/store/history-invalidation.d.ts +1 -1
- package/dist/store/history-invalidation.js +1 -1
- package/dist/store/use-interactive.d.ts +2 -2
- package/dist/store/use-live-terrain.d.ts +1 -1
- package/dist/store/use-scene.d.ts +4 -4
- package/dist/store/use-scene.d.ts.map +1 -1
- package/dist/store/use-scene.js +50 -32
- package/dist/systems/elevator/elevator-dispatch.d.ts +2 -2
- package/dist/systems/elevator/elevator-dispatch.js +1 -1
- package/dist/systems/elevator/elevator-geometry.d.ts +1 -1
- package/dist/systems/elevator/elevator-opening-sync.d.ts +1 -1
- package/dist/systems/elevator/elevator-opening-sync.js +2 -2
- package/dist/systems/elevator/elevator-opening-system.js +3 -3
- package/dist/systems/elevator/elevator-runtime.d.ts +3 -3
- package/dist/systems/elevator/elevator-runtime.js +3 -3
- package/dist/systems/elevator/elevator-service.d.ts +1 -1
- package/dist/systems/elevator/elevator-service.js +1 -1
- package/dist/systems/fence/fence-centerline.d.ts +2 -2
- package/dist/systems/fence/fence-centerline.js +2 -2
- package/dist/systems/fence/fence-spline.d.ts +2 -2
- package/dist/systems/roof/roof-elevation-system.js +3 -3
- package/dist/systems/roof/roof-elevation.d.ts +2 -2
- package/dist/systems/roof/roof-elevation.js +6 -6
- package/dist/systems/roof/roof-footprint.d.ts +1 -1
- package/dist/systems/roof/roof-footprint.js +3 -3
- package/dist/systems/slab/slab-placement.d.ts +1 -1
- package/dist/systems/slab/slab-support.d.ts +1 -1
- package/dist/systems/slab/slab-support.js +4 -4
- package/dist/systems/stair/stair-flight.d.ts +2 -2
- package/dist/systems/stair/stair-flight.js +2 -2
- package/dist/systems/stair/stair-footprint.d.ts +1 -1
- package/dist/systems/stair/stair-opening-preview.d.ts +248 -87
- package/dist/systems/stair/stair-opening-preview.d.ts.map +1 -1
- package/dist/systems/stair/stair-opening-preview.js +2 -2
- package/dist/systems/stair/stair-opening-sync.d.ts +1 -1
- package/dist/systems/stair/stair-opening-sync.js +6 -6
- package/dist/systems/stair/stair-opening-system.js +8 -8
- package/dist/systems/stair/stair-rise.d.ts +1 -1
- package/dist/systems/stair/stair-rise.js +3 -3
- package/dist/systems/wall/wall-curve.d.ts +2 -2
- package/dist/systems/wall/wall-footprint.d.ts +3 -3
- package/dist/systems/wall/wall-footprint.js +3 -3
- package/dist/systems/wall/wall-merge.d.ts +38 -0
- package/dist/systems/wall/wall-merge.d.ts.map +1 -0
- package/dist/systems/wall/wall-merge.js +240 -0
- package/dist/systems/wall/wall-mitering.d.ts +1 -1
- package/dist/systems/wall/wall-mitering.js +1 -1
- package/dist/systems/wall/wall-move.d.ts +1 -1
- package/dist/systems/wall/wall-operations.d.ts +28 -0
- package/dist/systems/wall/wall-operations.d.ts.map +1 -0
- package/dist/systems/wall/wall-operations.js +145 -0
- package/dist/systems/wall/wall-top.d.ts +1 -1
- package/dist/systems/wall/wall-topology.d.ts +9 -2
- package/dist/systems/wall/wall-topology.d.ts.map +1 -1
- package/dist/systems/wall/wall-topology.js +57 -9
- package/dist/utils/clone-scene-graph.d.ts +3 -3
- package/dist/utils/clone-scene-graph.d.ts.map +1 -1
- package/dist/utils/clone-scene-graph.js +9 -3
- package/dist/utils/scene-migrations.d.ts +3 -3
- package/dist/utils/scene-migrations.js +3 -3
- package/dist/utils/vertical-scene-migration.js +5 -5
- package/dist/validation/validate-build-json.d.ts +5 -2
- package/dist/validation/validate-build-json.d.ts.map +1 -1
- package/dist/validation/validate-build-json.js +57 -4
- package/package.json +15 -4
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { getMaterialPresetByRef, parseMaterialRef, toSceneMaterialRef } from '../material-library.js';
|
|
2
|
+
import { generateSceneMaterialId, } from '../schema/scene-material.js';
|
|
3
|
+
import { runAsSingleSceneHistoryStep } from '../store/history-control.js';
|
|
4
|
+
import useScene from '../store/use-scene.js';
|
|
5
|
+
import { proceduralFinishLibraryColor } from './library-colors.js';
|
|
6
|
+
import { isProceduralItem } from './query.js';
|
|
7
|
+
export function proceduralSlotColor(ref, fallback, materials) {
|
|
8
|
+
if (ref?.startsWith('#'))
|
|
9
|
+
return ref;
|
|
10
|
+
const parsed = parseMaterialRef(ref);
|
|
11
|
+
if (parsed?.kind === 'scene')
|
|
12
|
+
return materials[parsed.id]?.material.properties?.color ?? fallback;
|
|
13
|
+
return ref
|
|
14
|
+
? (proceduralFinishLibraryColor(ref) ??
|
|
15
|
+
getMaterialPresetByRef(ref)?.mapProperties?.color ??
|
|
16
|
+
fallback)
|
|
17
|
+
: fallback;
|
|
18
|
+
}
|
|
19
|
+
export function setProceduralMaterial(nodeId, slotId, ref, material) {
|
|
20
|
+
const state = useScene.getState(), node = state.nodes[nodeId];
|
|
21
|
+
if (state.readOnly || !isProceduralItem(node))
|
|
22
|
+
return;
|
|
23
|
+
if (!node.recipe.slots.some((s) => s.id === slotId))
|
|
24
|
+
throw new Error('Unknown material slot');
|
|
25
|
+
let created;
|
|
26
|
+
if (material && !ref) {
|
|
27
|
+
const match = Object.values(state.materials).find((m) => JSON.stringify(m.material) === JSON.stringify(material));
|
|
28
|
+
created = match
|
|
29
|
+
? undefined
|
|
30
|
+
: {
|
|
31
|
+
id: generateSceneMaterialId(),
|
|
32
|
+
name: node.recipe.slots.find((s) => s.id === slotId).label,
|
|
33
|
+
material,
|
|
34
|
+
};
|
|
35
|
+
ref = toSceneMaterialRef((match ?? created).id);
|
|
36
|
+
}
|
|
37
|
+
const slots = { ...node.slots };
|
|
38
|
+
if (ref)
|
|
39
|
+
slots[slotId] = ref;
|
|
40
|
+
else
|
|
41
|
+
delete slots[slotId];
|
|
42
|
+
runAsSingleSceneHistoryStep(useScene, () => {
|
|
43
|
+
state.updateNode(nodeId, { slots });
|
|
44
|
+
if (created)
|
|
45
|
+
useScene.getState().addSceneMaterial(created);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type Recipe } from './recipe.js';
|
|
3
|
+
export declare const ProceduralItemNode: z.ZodObject<{
|
|
4
|
+
object: z.ZodDefault<z.ZodLiteral<"node">>;
|
|
5
|
+
name: z.ZodOptional<z.ZodString>;
|
|
6
|
+
parentId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
7
|
+
visible: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
8
|
+
camera: z.ZodOptional<z.ZodObject<{
|
|
9
|
+
position: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
10
|
+
target: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
11
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
12
|
+
perspective: "perspective";
|
|
13
|
+
orthographic: "orthographic";
|
|
14
|
+
}>>;
|
|
15
|
+
fov: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
zoom: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
}, z.core.$strip>>;
|
|
18
|
+
metadata: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
19
|
+
id: z.ZodDefault<z.ZodTemplateLiteral<`procedural-item_${string}`>>;
|
|
20
|
+
type: z.ZodDefault<z.ZodLiteral<"procedural-item">>;
|
|
21
|
+
recipe: z.ZodPipe<z.ZodCustom<{
|
|
22
|
+
version: 1;
|
|
23
|
+
name: string;
|
|
24
|
+
description: string;
|
|
25
|
+
parameters: {
|
|
26
|
+
id: string;
|
|
27
|
+
label: string;
|
|
28
|
+
default: number;
|
|
29
|
+
min: number;
|
|
30
|
+
max: number;
|
|
31
|
+
step: number;
|
|
32
|
+
unit: "count" | "m" | "rad";
|
|
33
|
+
part?: string | undefined;
|
|
34
|
+
axis?: "x" | "y" | "z" | undefined;
|
|
35
|
+
}[];
|
|
36
|
+
slots: {
|
|
37
|
+
id: string;
|
|
38
|
+
label: string;
|
|
39
|
+
color: string;
|
|
40
|
+
finish?: "wood" | "glass" | "metal" | undefined;
|
|
41
|
+
}[];
|
|
42
|
+
parts: {
|
|
43
|
+
id: string;
|
|
44
|
+
label: string;
|
|
45
|
+
count: import("./recipe.js").Expr;
|
|
46
|
+
shapes: {
|
|
47
|
+
id: string;
|
|
48
|
+
primitive: "box" | "roundedBox" | "cylinder";
|
|
49
|
+
slot: string;
|
|
50
|
+
size: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr];
|
|
51
|
+
position: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr];
|
|
52
|
+
rotation?: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr] | undefined;
|
|
53
|
+
radius?: import("./recipe.js").Expr | undefined;
|
|
54
|
+
support?: boolean | undefined;
|
|
55
|
+
}[];
|
|
56
|
+
}[];
|
|
57
|
+
constraints: {
|
|
58
|
+
left: import("./recipe.js").Expr;
|
|
59
|
+
relation: "lte" | "gte";
|
|
60
|
+
right: import("./recipe.js").Expr;
|
|
61
|
+
message: string;
|
|
62
|
+
}[];
|
|
63
|
+
classification?: {
|
|
64
|
+
category: string;
|
|
65
|
+
functionTags: string[];
|
|
66
|
+
tags: string[];
|
|
67
|
+
} | undefined;
|
|
68
|
+
mounting?: {
|
|
69
|
+
attachTo: "ceiling" | "wall-side";
|
|
70
|
+
reference: string;
|
|
71
|
+
} | undefined;
|
|
72
|
+
surfaces?: {
|
|
73
|
+
id: string;
|
|
74
|
+
label: string;
|
|
75
|
+
position: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr];
|
|
76
|
+
size: [import("./recipe.js").Expr, import("./recipe.js").Expr];
|
|
77
|
+
part?: string | undefined;
|
|
78
|
+
rotation?: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr] | undefined;
|
|
79
|
+
}[] | undefined;
|
|
80
|
+
}, {
|
|
81
|
+
version: 1;
|
|
82
|
+
name: string;
|
|
83
|
+
description: string;
|
|
84
|
+
parameters: {
|
|
85
|
+
id: string;
|
|
86
|
+
label: string;
|
|
87
|
+
default: number;
|
|
88
|
+
min: number;
|
|
89
|
+
max: number;
|
|
90
|
+
step: number;
|
|
91
|
+
unit: "count" | "m" | "rad";
|
|
92
|
+
part?: string | undefined;
|
|
93
|
+
axis?: "x" | "y" | "z" | undefined;
|
|
94
|
+
}[];
|
|
95
|
+
slots: {
|
|
96
|
+
id: string;
|
|
97
|
+
label: string;
|
|
98
|
+
color: string;
|
|
99
|
+
finish?: "wood" | "glass" | "metal" | undefined;
|
|
100
|
+
}[];
|
|
101
|
+
parts: {
|
|
102
|
+
id: string;
|
|
103
|
+
label: string;
|
|
104
|
+
count: import("./recipe.js").Expr;
|
|
105
|
+
shapes: {
|
|
106
|
+
id: string;
|
|
107
|
+
primitive: "box" | "roundedBox" | "cylinder";
|
|
108
|
+
slot: string;
|
|
109
|
+
size: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr];
|
|
110
|
+
position: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr];
|
|
111
|
+
rotation?: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr] | undefined;
|
|
112
|
+
radius?: import("./recipe.js").Expr | undefined;
|
|
113
|
+
support?: boolean | undefined;
|
|
114
|
+
}[];
|
|
115
|
+
}[];
|
|
116
|
+
constraints: {
|
|
117
|
+
left: import("./recipe.js").Expr;
|
|
118
|
+
relation: "lte" | "gte";
|
|
119
|
+
right: import("./recipe.js").Expr;
|
|
120
|
+
message: string;
|
|
121
|
+
}[];
|
|
122
|
+
classification?: {
|
|
123
|
+
category: string;
|
|
124
|
+
functionTags: string[];
|
|
125
|
+
tags: string[];
|
|
126
|
+
} | undefined;
|
|
127
|
+
mounting?: {
|
|
128
|
+
attachTo: "ceiling" | "wall-side";
|
|
129
|
+
reference: string;
|
|
130
|
+
} | undefined;
|
|
131
|
+
surfaces?: {
|
|
132
|
+
id: string;
|
|
133
|
+
label: string;
|
|
134
|
+
position: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr];
|
|
135
|
+
size: [import("./recipe.js").Expr, import("./recipe.js").Expr];
|
|
136
|
+
part?: string | undefined;
|
|
137
|
+
rotation?: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr] | undefined;
|
|
138
|
+
}[] | undefined;
|
|
139
|
+
}>, z.ZodTransform<{
|
|
140
|
+
version: 1;
|
|
141
|
+
name: string;
|
|
142
|
+
description: string;
|
|
143
|
+
parameters: {
|
|
144
|
+
id: string;
|
|
145
|
+
label: string;
|
|
146
|
+
default: number;
|
|
147
|
+
min: number;
|
|
148
|
+
max: number;
|
|
149
|
+
step: number;
|
|
150
|
+
unit: "count" | "m" | "rad";
|
|
151
|
+
part?: string | undefined;
|
|
152
|
+
axis?: "x" | "y" | "z" | undefined;
|
|
153
|
+
}[];
|
|
154
|
+
slots: {
|
|
155
|
+
id: string;
|
|
156
|
+
label: string;
|
|
157
|
+
color: string;
|
|
158
|
+
finish?: "wood" | "glass" | "metal" | undefined;
|
|
159
|
+
}[];
|
|
160
|
+
parts: {
|
|
161
|
+
id: string;
|
|
162
|
+
label: string;
|
|
163
|
+
count: import("./recipe.js").Expr;
|
|
164
|
+
shapes: {
|
|
165
|
+
id: string;
|
|
166
|
+
primitive: "box" | "roundedBox" | "cylinder";
|
|
167
|
+
slot: string;
|
|
168
|
+
size: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr];
|
|
169
|
+
position: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr];
|
|
170
|
+
rotation?: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr] | undefined;
|
|
171
|
+
radius?: import("./recipe.js").Expr | undefined;
|
|
172
|
+
support?: boolean | undefined;
|
|
173
|
+
}[];
|
|
174
|
+
}[];
|
|
175
|
+
constraints: {
|
|
176
|
+
left: import("./recipe.js").Expr;
|
|
177
|
+
relation: "lte" | "gte";
|
|
178
|
+
right: import("./recipe.js").Expr;
|
|
179
|
+
message: string;
|
|
180
|
+
}[];
|
|
181
|
+
classification?: {
|
|
182
|
+
category: string;
|
|
183
|
+
functionTags: string[];
|
|
184
|
+
tags: string[];
|
|
185
|
+
} | undefined;
|
|
186
|
+
mounting?: {
|
|
187
|
+
attachTo: "ceiling" | "wall-side";
|
|
188
|
+
reference: string;
|
|
189
|
+
} | undefined;
|
|
190
|
+
surfaces?: {
|
|
191
|
+
id: string;
|
|
192
|
+
label: string;
|
|
193
|
+
position: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr];
|
|
194
|
+
size: [import("./recipe.js").Expr, import("./recipe.js").Expr];
|
|
195
|
+
part?: string | undefined;
|
|
196
|
+
rotation?: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr] | undefined;
|
|
197
|
+
}[] | undefined;
|
|
198
|
+
}, {
|
|
199
|
+
version: 1;
|
|
200
|
+
name: string;
|
|
201
|
+
description: string;
|
|
202
|
+
parameters: {
|
|
203
|
+
id: string;
|
|
204
|
+
label: string;
|
|
205
|
+
default: number;
|
|
206
|
+
min: number;
|
|
207
|
+
max: number;
|
|
208
|
+
step: number;
|
|
209
|
+
unit: "count" | "m" | "rad";
|
|
210
|
+
part?: string | undefined;
|
|
211
|
+
axis?: "x" | "y" | "z" | undefined;
|
|
212
|
+
}[];
|
|
213
|
+
slots: {
|
|
214
|
+
id: string;
|
|
215
|
+
label: string;
|
|
216
|
+
color: string;
|
|
217
|
+
finish?: "wood" | "glass" | "metal" | undefined;
|
|
218
|
+
}[];
|
|
219
|
+
parts: {
|
|
220
|
+
id: string;
|
|
221
|
+
label: string;
|
|
222
|
+
count: import("./recipe.js").Expr;
|
|
223
|
+
shapes: {
|
|
224
|
+
id: string;
|
|
225
|
+
primitive: "box" | "roundedBox" | "cylinder";
|
|
226
|
+
slot: string;
|
|
227
|
+
size: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr];
|
|
228
|
+
position: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr];
|
|
229
|
+
rotation?: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr] | undefined;
|
|
230
|
+
radius?: import("./recipe.js").Expr | undefined;
|
|
231
|
+
support?: boolean | undefined;
|
|
232
|
+
}[];
|
|
233
|
+
}[];
|
|
234
|
+
constraints: {
|
|
235
|
+
left: import("./recipe.js").Expr;
|
|
236
|
+
relation: "lte" | "gte";
|
|
237
|
+
right: import("./recipe.js").Expr;
|
|
238
|
+
message: string;
|
|
239
|
+
}[];
|
|
240
|
+
classification?: {
|
|
241
|
+
category: string;
|
|
242
|
+
functionTags: string[];
|
|
243
|
+
tags: string[];
|
|
244
|
+
} | undefined;
|
|
245
|
+
mounting?: {
|
|
246
|
+
attachTo: "ceiling" | "wall-side";
|
|
247
|
+
reference: string;
|
|
248
|
+
} | undefined;
|
|
249
|
+
surfaces?: {
|
|
250
|
+
id: string;
|
|
251
|
+
label: string;
|
|
252
|
+
position: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr];
|
|
253
|
+
size: [import("./recipe.js").Expr, import("./recipe.js").Expr];
|
|
254
|
+
part?: string | undefined;
|
|
255
|
+
rotation?: [import("./recipe.js").Expr, import("./recipe.js").Expr, import("./recipe.js").Expr] | undefined;
|
|
256
|
+
}[] | undefined;
|
|
257
|
+
}>>;
|
|
258
|
+
parameters: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
259
|
+
slots: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
260
|
+
position: z.ZodDefault<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
|
|
261
|
+
rotation: z.ZodDefault<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
|
|
262
|
+
wallId: z.ZodOptional<z.ZodString>;
|
|
263
|
+
side: z.ZodOptional<z.ZodEnum<{
|
|
264
|
+
front: "front";
|
|
265
|
+
back: "back";
|
|
266
|
+
}>>;
|
|
267
|
+
supportSlabId: z.ZodOptional<z.ZodString>;
|
|
268
|
+
children: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
269
|
+
attachments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
270
|
+
}, z.core.$strip>;
|
|
271
|
+
export type ProceduralItemNode = z.infer<typeof ProceduralItemNode>;
|
|
272
|
+
export declare function parameterPatch(node: ProceduralItemNode, id: string, value: number): {
|
|
273
|
+
parameters: {
|
|
274
|
+
[x: string]: number;
|
|
275
|
+
};
|
|
276
|
+
} | null;
|
|
277
|
+
export declare function snapParameters(recipe: Recipe, values: Record<string, number>): {
|
|
278
|
+
[x: string]: number;
|
|
279
|
+
};
|
|
280
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/procedural-items/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAA+B,KAAK,MAAM,EAAE,MAAM,UAAU,CAAA;AAanE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoCmD,CAAA;AAClF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AACnE,wBAAgB,cAAc,CAAC,IAAI,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;;;;SAIjF;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;EAS5E"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseNode, nodeType, objectId } from '../schema/base.js';
|
|
3
|
+
import { validateProceduralRelations } from './query.js';
|
|
4
|
+
import { evaluateRecipe, parseRecipe } from './recipe.js';
|
|
5
|
+
const recipe = z.custom().transform((value, ctx) => {
|
|
6
|
+
try {
|
|
7
|
+
return parseRecipe(value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
ctx.addIssue({
|
|
11
|
+
code: 'custom',
|
|
12
|
+
message: error instanceof Error ? error.message : 'Invalid recipe',
|
|
13
|
+
});
|
|
14
|
+
return z.NEVER;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export const ProceduralItemNode = BaseNode.extend({
|
|
18
|
+
id: objectId('procedural-item'),
|
|
19
|
+
type: nodeType('procedural-item'),
|
|
20
|
+
recipe,
|
|
21
|
+
parameters: z.record(z.string(), z.number().finite()).default({}),
|
|
22
|
+
slots: z
|
|
23
|
+
.record(z.string(), z.string().regex(/^(#[0-9a-fA-F]{6}|(?:scene|library):[^\s]+)$/))
|
|
24
|
+
.default({}),
|
|
25
|
+
position: z
|
|
26
|
+
.tuple([z.number().finite(), z.number().finite(), z.number().finite()])
|
|
27
|
+
.default([0, 0, 0]),
|
|
28
|
+
rotation: z
|
|
29
|
+
.tuple([z.number().finite(), z.number().finite(), z.number().finite()])
|
|
30
|
+
.default([0, 0, 0]),
|
|
31
|
+
wallId: z.string().optional(),
|
|
32
|
+
side: z.enum(['front', 'back']).optional(),
|
|
33
|
+
supportSlabId: z.string().optional(),
|
|
34
|
+
children: z.array(z.string()).default([]),
|
|
35
|
+
attachments: z.record(z.string(), z.string()).default({}),
|
|
36
|
+
})
|
|
37
|
+
.superRefine((node, ctx) => {
|
|
38
|
+
try {
|
|
39
|
+
const result = evaluateRecipe(node.recipe, node.parameters);
|
|
40
|
+
for (const slot of Object.keys(node.slots))
|
|
41
|
+
if (!node.recipe.slots.some((s) => s.id === slot))
|
|
42
|
+
throw new Error(`Unknown slot ${slot}`);
|
|
43
|
+
for (const [childId, surfaceId] of Object.entries(node.attachments)) {
|
|
44
|
+
if (node.children.includes(childId) && !result.surfaces.some((s) => s.id === surfaceId))
|
|
45
|
+
throw new Error('Remove the hosted item before removing its support surface');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
ctx.addIssue({
|
|
50
|
+
code: 'custom',
|
|
51
|
+
message: error instanceof Error ? error.message : 'Invalid parameters',
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
.meta({ strictMutations: true, validateRelations: validateProceduralRelations });
|
|
56
|
+
export function parameterPatch(node, id, value) {
|
|
57
|
+
const parameters = { ...node.parameters, [id]: value };
|
|
58
|
+
const parsed = ProceduralItemNode.safeParse({ ...node, parameters });
|
|
59
|
+
return parsed.success ? { parameters } : null;
|
|
60
|
+
}
|
|
61
|
+
export function snapParameters(recipe, values) {
|
|
62
|
+
const result = { ...values };
|
|
63
|
+
for (const p of recipe.parameters) {
|
|
64
|
+
const value = values[p.id];
|
|
65
|
+
if (value === undefined)
|
|
66
|
+
continue;
|
|
67
|
+
const snapped = p.min + Math.round((value - p.min) / p.step) * p.step;
|
|
68
|
+
result[p.id] = Number(Math.max(p.min, Math.min(p.max, snapped)).toFixed(10));
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CeilingNode } from '../schema/nodes/ceiling.js';
|
|
2
|
+
import type { WallNode } from '../schema/nodes/wall.js';
|
|
3
|
+
import type { ProceduralItemNode } from './node.js';
|
|
4
|
+
import { type QueryNodes } from './query.js';
|
|
5
|
+
export declare function resolveProceduralWallPlacement(node: ProceduralItemNode, wall: WallNode, x: number, y: number, side: 'front' | 'back', nodes: QueryNodes): ProceduralItemNode | null;
|
|
6
|
+
export declare function resolveProceduralCeilingPlacement(node: ProceduralItemNode, ceiling: CeilingNode, x: number, z: number, yaw?: number): ProceduralItemNode;
|
|
7
|
+
//# sourceMappingURL=placement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"placement.d.ts","sourceRoot":"","sources":["../../src/procedural-items/placement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAChD,OAAO,EAAuB,KAAK,UAAU,EAA+B,MAAM,SAAS,CAAA;AAI3F,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,kBAAkB,EACxB,IAAI,EAAE,QAAQ,EACd,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,IAAI,EAAE,OAAO,GAAG,MAAM,EACtB,KAAK,EAAE,UAAU,GAChB,kBAAkB,GAAG,IAAI,CA+B3B;AAED,wBAAgB,iCAAiC,CAC/C,IAAI,EAAE,kBAAkB,EACxB,OAAO,EAAE,WAAW,EACpB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,GAAG,SAAmB,GACrB,kBAAkB,CAWpB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { proceduralLocalPose, validateProceduralRelations } from './query.js';
|
|
2
|
+
import { evaluateRecipe } from './recipe.js';
|
|
3
|
+
import { boundsOf, boxCorners, frame, transformPoint } from './spatial.js';
|
|
4
|
+
export function resolveProceduralWallPlacement(node, wall, x, y, side, nodes) {
|
|
5
|
+
if (node.recipe.mounting?.attachTo !== 'wall-side' || wall.curveOffset)
|
|
6
|
+
return null;
|
|
7
|
+
const candidate = {
|
|
8
|
+
...node,
|
|
9
|
+
parentId: wall.id,
|
|
10
|
+
wallId: wall.id,
|
|
11
|
+
side,
|
|
12
|
+
position: [0, 0, 0],
|
|
13
|
+
rotation: [0, 0, 0],
|
|
14
|
+
visible: true,
|
|
15
|
+
};
|
|
16
|
+
const e = evaluateRecipe(node.recipe, node.parameters);
|
|
17
|
+
const pose = proceduralLocalPose(candidate, nodes);
|
|
18
|
+
const b = boundsOf(boxCorners(e.min, e.max).map((p) => transformPoint(frame(pose.position, pose.rotation), p)));
|
|
19
|
+
const level = wall.parentId ? nodes[wall.parentId] : undefined;
|
|
20
|
+
const height = wall.height ?? (level?.type === 'level' ? level.height : 2.5) ?? 2.5;
|
|
21
|
+
const length = Math.hypot(wall.end[0] - wall.start[0], wall.end[1] - wall.start[1]);
|
|
22
|
+
if (b.dimensions[0] > length || b.dimensions[1] > height)
|
|
23
|
+
return null;
|
|
24
|
+
candidate.position = [
|
|
25
|
+
Math.min(length - b.max[0], Math.max(-b.min[0], x)),
|
|
26
|
+
Math.min(height - b.max[1], Math.max(-b.min[1], y)),
|
|
27
|
+
0,
|
|
28
|
+
];
|
|
29
|
+
try {
|
|
30
|
+
validateProceduralRelations(candidate, nodes);
|
|
31
|
+
return candidate;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function resolveProceduralCeilingPlacement(node, ceiling, x, z, yaw = node.rotation[1]) {
|
|
38
|
+
return {
|
|
39
|
+
...node,
|
|
40
|
+
parentId: ceiling.id,
|
|
41
|
+
wallId: undefined,
|
|
42
|
+
side: undefined,
|
|
43
|
+
supportSlabId: undefined,
|
|
44
|
+
position: [x, 0, z],
|
|
45
|
+
rotation: [0, yaw, 0],
|
|
46
|
+
visible: true,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ItemNode } from '../schema/nodes/item.js';
|
|
2
|
+
import type { AnyNode } from '../schema/types.js';
|
|
3
|
+
import type { ProceduralItemNode } from './node.js';
|
|
4
|
+
import { type Vec3 } from './recipe.js';
|
|
5
|
+
import { type Frame } from './spatial.js';
|
|
6
|
+
export type QueryNodes = Readonly<Record<string, AnyNode | ProceduralItemNode>>;
|
|
7
|
+
export declare function isProceduralItem(node: unknown): node is ProceduralItemNode;
|
|
8
|
+
export declare function proceduralLocalPose(node: ProceduralItemNode, nodes: QueryNodes): {
|
|
9
|
+
position: Vec3;
|
|
10
|
+
rotation: Vec3;
|
|
11
|
+
};
|
|
12
|
+
export declare function proceduralFootprint(node: ProceduralItemNode): {
|
|
13
|
+
position: Vec3;
|
|
14
|
+
rotation: [number, number, number];
|
|
15
|
+
dimensions: Vec3;
|
|
16
|
+
};
|
|
17
|
+
export declare function nodeLevelFrame(id: string, nodes: QueryNodes, seen?: Set<string>): Frame;
|
|
18
|
+
export declare function attachmentBounds(child: ProceduralItemNode | ItemNode): import("./spatial.js").Bounds;
|
|
19
|
+
export declare function attachmentRegionsOverlap(a: ReturnType<typeof attachmentBounds>, b: ReturnType<typeof attachmentBounds>): boolean;
|
|
20
|
+
export declare function validateProceduralRelations(raw: AnyNode | ProceduralItemNode, nodes: QueryNodes): void;
|
|
21
|
+
export declare function queryProceduralItem(node: ProceduralItemNode, nodes: QueryNodes): {
|
|
22
|
+
id: `procedural-item_${string}`;
|
|
23
|
+
kind: "procedural-item";
|
|
24
|
+
classification: {
|
|
25
|
+
category: string;
|
|
26
|
+
functionTags: string[];
|
|
27
|
+
tags: string[];
|
|
28
|
+
} | null;
|
|
29
|
+
hostId: string | null;
|
|
30
|
+
wallId: string | null;
|
|
31
|
+
parameters: Record<string, number>;
|
|
32
|
+
localBounds: {
|
|
33
|
+
min: Vec3;
|
|
34
|
+
max: Vec3;
|
|
35
|
+
dimensions: Vec3;
|
|
36
|
+
};
|
|
37
|
+
levelBounds: import("./spatial.js").Bounds;
|
|
38
|
+
frame: Frame;
|
|
39
|
+
footprint: number[][];
|
|
40
|
+
surfaces: {
|
|
41
|
+
frame: Frame;
|
|
42
|
+
id: string;
|
|
43
|
+
label: string;
|
|
44
|
+
position: Vec3;
|
|
45
|
+
rotation: Vec3;
|
|
46
|
+
normal: Vec3;
|
|
47
|
+
size: [number, number];
|
|
48
|
+
}[];
|
|
49
|
+
children: string[];
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/procedural-items/query.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAIpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAM9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAChD,OAAO,EAAgC,KAAK,IAAI,EAAE,MAAM,UAAU,CAAA;AAClE,OAAO,EAIL,KAAK,KAAK,EAIX,MAAM,WAAW,CAAA;AAElB,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,kBAAkB,CAAC,CAAC,CAAA;AAC/E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,kBAAkB,CAI1E;AAQD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,UAAU;;;EA6B9E;AACD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,kBAAkB;;;;EAK3D;AAyFD,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,cAAoB,GAAG,KAAK,CA0F7F;AAMD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,kBAAkB,GAAG,QAAQ,8BAKpE;AACD,wBAAgB,wBAAwB,CACtC,CAAC,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,EACtC,CAAC,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,WAQvC;AA0BD,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,OAAO,GAAG,kBAAkB,EAAE,KAAK,EAAE,UAAU,QAkG/F;AACD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0B9E"}
|