@pascal-app/nodes 1.0.0 → 1.0.1

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.
Files changed (154) hide show
  1. package/dist/box-vent/panel.js +4 -4
  2. package/dist/cabinet/appliance-layout.d.ts +26 -0
  3. package/dist/cabinet/appliance-layout.d.ts.map +1 -0
  4. package/dist/cabinet/appliance-layout.js +52 -0
  5. package/dist/cabinet/countertop-layout.d.ts +173 -0
  6. package/dist/cabinet/countertop-layout.d.ts.map +1 -0
  7. package/dist/cabinet/countertop-layout.js +80 -0
  8. package/dist/cabinet/definition.d.ts.map +1 -1
  9. package/dist/cabinet/definition.js +15 -8
  10. package/dist/cabinet/geometry/cooktop.d.ts.map +1 -1
  11. package/dist/cabinet/geometry/cooktop.js +2 -2
  12. package/dist/cabinet/geometry/run.d.ts.map +1 -1
  13. package/dist/cabinet/geometry/run.js +10 -71
  14. package/dist/cabinet/geometry/sink.d.ts +2 -12
  15. package/dist/cabinet/geometry/sink.d.ts.map +1 -1
  16. package/dist/cabinet/geometry/sink.js +8 -39
  17. package/dist/cabinet/hosted-resize.d.ts +8 -0
  18. package/dist/cabinet/hosted-resize.d.ts.map +1 -0
  19. package/dist/cabinet/hosted-resize.js +158 -0
  20. package/dist/cabinet/run-layout.d.ts +8 -1
  21. package/dist/cabinet/run-layout.d.ts.map +1 -1
  22. package/dist/cabinet/run-layout.js +22 -14
  23. package/dist/cabinet/run-ops.d.ts +3 -3
  24. package/dist/cabinet/run-ops.js +3 -3
  25. package/dist/cabinet/run-panel.d.ts +1 -1
  26. package/dist/cabinet/run-panel.d.ts.map +1 -1
  27. package/dist/cabinet/run-panel.js +16 -7
  28. package/dist/cabinet/surfaces.d.ts +4 -0
  29. package/dist/cabinet/surfaces.d.ts.map +1 -0
  30. package/dist/cabinet/surfaces.js +101 -0
  31. package/dist/cabinet/tree-structure.d.ts.map +1 -1
  32. package/dist/cabinet/tree-structure.js +10 -9
  33. package/dist/ceiling/definition.js +1 -1
  34. package/dist/ceiling/floorplan-affordances.d.ts +4 -4
  35. package/dist/ceiling/panel.js +1 -1
  36. package/dist/chimney/panel.js +9 -9
  37. package/dist/cupola/panel.js +1 -1
  38. package/dist/door/panel.js +12 -12
  39. package/dist/dormer/panel-position-section.js +2 -2
  40. package/dist/dormer/panel.js +1 -1
  41. package/dist/duct-segment/parametrics.d.ts.map +1 -1
  42. package/dist/duct-segment/parametrics.js +5 -1
  43. package/dist/duct-segment/tool.d.ts +1 -0
  44. package/dist/duct-segment/tool.d.ts.map +1 -1
  45. package/dist/duct-segment/tool.js +10 -8
  46. package/dist/eyebrow-vent/panel.js +1 -1
  47. package/dist/fence/inspector-editors.js +1 -1
  48. package/dist/imported-mesh/definition.d.ts +5 -0
  49. package/dist/imported-mesh/definition.d.ts.map +1 -0
  50. package/dist/imported-mesh/definition.js +38 -0
  51. package/dist/imported-mesh/floorplan.d.ts +4 -0
  52. package/dist/imported-mesh/floorplan.d.ts.map +1 -0
  53. package/dist/imported-mesh/floorplan.js +34 -0
  54. package/dist/imported-mesh/geometry.d.ts +5 -0
  55. package/dist/imported-mesh/geometry.d.ts.map +1 -0
  56. package/dist/imported-mesh/geometry.js +34 -0
  57. package/dist/imported-mesh/index.d.ts +4 -0
  58. package/dist/imported-mesh/index.d.ts.map +1 -0
  59. package/dist/imported-mesh/index.js +3 -0
  60. package/dist/imported-mesh/schema.d.ts +2 -0
  61. package/dist/imported-mesh/schema.d.ts.map +1 -0
  62. package/dist/imported-mesh/schema.js +1 -0
  63. package/dist/index.d.ts +2 -0
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +8 -0
  66. package/dist/item/floorplan-move.d.ts +9 -1
  67. package/dist/item/floorplan-move.d.ts.map +1 -1
  68. package/dist/item/floorplan-move.js +55 -2
  69. package/dist/item/floorplan.d.ts.map +1 -1
  70. package/dist/item/floorplan.js +11 -0
  71. package/dist/item/move-tool.js +1 -1
  72. package/dist/item/panel.js +1 -1
  73. package/dist/pipe-segment/parametrics.d.ts.map +1 -1
  74. package/dist/pipe-segment/parametrics.js +5 -1
  75. package/dist/procedural-item/definition.d.ts +4 -0
  76. package/dist/procedural-item/definition.d.ts.map +1 -0
  77. package/dist/procedural-item/definition.js +254 -0
  78. package/dist/procedural-item/geometry.d.ts +31 -0
  79. package/dist/procedural-item/geometry.d.ts.map +1 -0
  80. package/dist/procedural-item/geometry.js +88 -0
  81. package/dist/procedural-item/index.d.ts +3 -0
  82. package/dist/procedural-item/index.d.ts.map +1 -0
  83. package/dist/procedural-item/index.js +2 -0
  84. package/dist/procedural-item/move-session.d.ts +15 -0
  85. package/dist/procedural-item/move-session.d.ts.map +1 -0
  86. package/dist/procedural-item/move-session.js +197 -0
  87. package/dist/procedural-item/move-tool.d.ts +5 -0
  88. package/dist/procedural-item/move-tool.d.ts.map +1 -0
  89. package/dist/procedural-item/move-tool.js +193 -0
  90. package/dist/procedural-item/renderer.d.ts +5 -0
  91. package/dist/procedural-item/renderer.d.ts.map +1 -0
  92. package/dist/procedural-item/renderer.js +66 -0
  93. package/dist/ridge-vent/panel.js +4 -4
  94. package/dist/roof/panel.d.ts.map +1 -1
  95. package/dist/roof/panel.js +7 -5
  96. package/dist/roof-segment/panel.d.ts.map +1 -1
  97. package/dist/roof-segment/panel.js +5 -5
  98. package/dist/shared/automatic-run-end-cap.d.ts +1 -0
  99. package/dist/shared/automatic-run-end-cap.d.ts.map +1 -1
  100. package/dist/shared/automatic-run-end-cap.js +10 -0
  101. package/dist/shared/distribution-run-tool.d.ts +10 -0
  102. package/dist/shared/distribution-run-tool.d.ts.map +1 -1
  103. package/dist/shared/distribution-run-tool.js +56 -11
  104. package/dist/shared/panel-fields.d.ts +15 -0
  105. package/dist/shared/panel-fields.d.ts.map +1 -0
  106. package/dist/shared/panel-fields.js +31 -0
  107. package/dist/shared/resting-surface-plan.d.ts +3 -0
  108. package/dist/shared/resting-surface-plan.d.ts.map +1 -0
  109. package/dist/shared/resting-surface-plan.js +28 -0
  110. package/dist/shelf/definition.d.ts.map +1 -1
  111. package/dist/shelf/definition.js +2 -1
  112. package/dist/shelf/floorplan-affordances.d.ts.map +1 -1
  113. package/dist/shelf/floorplan-affordances.js +5 -3
  114. package/dist/shelf/floorplan-move.d.ts.map +1 -1
  115. package/dist/shelf/floorplan-move.js +3 -2
  116. package/dist/shelf/geometry.d.ts.map +1 -1
  117. package/dist/shelf/geometry.js +2 -10
  118. package/dist/skylight/panel.js +6 -6
  119. package/dist/slab/panel.js +1 -1
  120. package/dist/solar-panel/panel.js +2 -2
  121. package/dist/spawn/panel.js +1 -1
  122. package/dist/stair/panel.d.ts.map +1 -1
  123. package/dist/stair/panel.js +9 -7
  124. package/dist/stair-segment/panel.js +4 -4
  125. package/dist/turbine-vent/panel.js +1 -1
  126. package/dist/unit/definition.d.ts +10 -0
  127. package/dist/unit/definition.d.ts.map +1 -0
  128. package/dist/unit/definition.js +38 -0
  129. package/dist/unit/index.d.ts +2 -0
  130. package/dist/unit/index.d.ts.map +1 -0
  131. package/dist/unit/index.js +1 -0
  132. package/dist/unit/parametrics.d.ts +3 -0
  133. package/dist/unit/parametrics.d.ts.map +1 -0
  134. package/dist/unit/parametrics.js +4 -0
  135. package/dist/unit/schema.d.ts +2 -0
  136. package/dist/unit/schema.d.ts.map +1 -0
  137. package/dist/unit/schema.js +1 -0
  138. package/dist/unit/unit-panel.d.ts +5 -0
  139. package/dist/unit/unit-panel.d.ts.map +1 -0
  140. package/dist/unit/unit-panel.js +61 -0
  141. package/dist/window/panel.js +6 -6
  142. package/dist/zone/definition.d.ts.map +1 -1
  143. package/dist/zone/definition.js +7 -1
  144. package/dist/zone/floorplan.d.ts +1 -3
  145. package/dist/zone/floorplan.d.ts.map +1 -1
  146. package/dist/zone/floorplan.js +43 -28
  147. package/dist/zone/quantities-panel.d.ts.map +1 -1
  148. package/dist/zone/quantities-panel.js +33 -29
  149. package/dist/zone/renderer.d.ts.map +1 -1
  150. package/dist/zone/renderer.js +20 -6
  151. package/dist/zone/unit-membership.d.ts +12 -0
  152. package/dist/zone/unit-membership.d.ts.map +1 -0
  153. package/dist/zone/unit-membership.js +22 -0
  154. package/package.json +14 -8
@@ -0,0 +1,34 @@
1
+ /** A compact plan proxy for imported geometry, derived from its XZ bounds. */
2
+ export function buildImportedMeshFloorplan(node, ctx) {
3
+ let minX = Number.POSITIVE_INFINITY;
4
+ let maxX = Number.NEGATIVE_INFINITY;
5
+ let minZ = Number.POSITIVE_INFINITY;
6
+ let maxZ = Number.NEGATIVE_INFINITY;
7
+ for (const primitive of node.primitives) {
8
+ for (let i = 0; i + 2 < primitive.positions.length; i += 3) {
9
+ minX = Math.min(minX, primitive.positions[i]);
10
+ maxX = Math.max(maxX, primitive.positions[i]);
11
+ minZ = Math.min(minZ, primitive.positions[i + 2]);
12
+ maxZ = Math.max(maxZ, primitive.positions[i + 2]);
13
+ }
14
+ }
15
+ if (![minX, maxX, minZ, maxZ].every(Number.isFinite))
16
+ return null;
17
+ const yaw = node.rotation[1];
18
+ const cos = Math.cos(-yaw);
19
+ const sin = Math.sin(-yaw);
20
+ const toPlan = (x, z) => [
21
+ node.position[0] + x * cos - z * sin,
22
+ node.position[2] + x * sin + z * cos,
23
+ ];
24
+ const selected = Boolean(ctx.viewState?.selected || ctx.viewState?.highlighted);
25
+ return {
26
+ kind: 'polygon',
27
+ points: [toPlan(minX, minZ), toPlan(maxX, minZ), toPlan(maxX, maxZ), toPlan(minX, maxZ)],
28
+ fill: '#94a3b8',
29
+ fillOpacity: selected ? 0.28 : 0.14,
30
+ stroke: selected ? (ctx.viewState?.palette?.selectedStroke ?? '#f97316') : '#64748b',
31
+ strokeWidth: selected ? 0.04 : 0.025,
32
+ vectorEffect: 'non-scaling-stroke',
33
+ };
34
+ }
@@ -0,0 +1,5 @@
1
+ import type { ImportedMeshNode } from '@pascal-app/core';
2
+ import { Group } from 'three';
3
+ /** Build serialized imported triangle buffers without source-format coupling. */
4
+ export declare function buildImportedMeshGeometry(node: ImportedMeshNode): Group;
5
+ //# sourceMappingURL=geometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/imported-mesh/geometry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAIL,KAAK,EAGN,MAAM,OAAO,CAAA;AAEd,iFAAiF;AACjF,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,gBAAgB,GAAG,KAAK,CA6BvE"}
@@ -0,0 +1,34 @@
1
+ import { BufferGeometry, Float32BufferAttribute, FrontSide, Group, Mesh, MeshStandardMaterial, } from 'three';
2
+ /** Build serialized imported triangle buffers without source-format coupling. */
3
+ export function buildImportedMeshGeometry(node) {
4
+ const group = new Group();
5
+ for (const [primitiveIndex, primitive] of node.primitives.entries()) {
6
+ if (primitive.positions.length < 9)
7
+ continue;
8
+ const geometry = new BufferGeometry();
9
+ geometry.setAttribute('position', new Float32BufferAttribute(primitive.positions, 3));
10
+ if (primitive.normals?.length === primitive.positions.length) {
11
+ geometry.setAttribute('normal', new Float32BufferAttribute(primitive.normals, 3));
12
+ }
13
+ else {
14
+ geometry.computeVertexNormals();
15
+ }
16
+ if (primitive.indices.length >= 3)
17
+ geometry.setIndex(primitive.indices);
18
+ geometry.computeBoundingBox();
19
+ geometry.computeBoundingSphere();
20
+ const material = new MeshStandardMaterial({
21
+ color: primitive.color,
22
+ opacity: primitive.opacity,
23
+ transparent: primitive.opacity < 1,
24
+ depthWrite: primitive.opacity >= 1,
25
+ metalness: 0.05,
26
+ roughness: 0.8,
27
+ side: FrontSide,
28
+ });
29
+ const mesh = new Mesh(geometry, material);
30
+ mesh.name = `${node.name ?? 'Imported mesh'} primitive ${primitiveIndex + 1}`;
31
+ group.add(mesh);
32
+ }
33
+ return group;
34
+ }
@@ -0,0 +1,4 @@
1
+ export { importedMeshDefinition } from './definition';
2
+ export { buildImportedMeshGeometry } from './geometry';
3
+ export { ImportedMeshNode } from './schema';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/imported-mesh/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { importedMeshDefinition } from './definition';
2
+ export { buildImportedMeshGeometry } from './geometry';
3
+ export { ImportedMeshNode } from './schema';
@@ -0,0 +1,2 @@
1
+ export { ImportedMeshNode } from '@pascal-app/core';
2
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/imported-mesh/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1 @@
1
+ export { ImportedMeshNode } from '@pascal-app/core';
package/dist/index.d.ts CHANGED
@@ -38,6 +38,7 @@ export { fenceDefinition } from './fence';
38
38
  export { guideDefinition } from './guide';
39
39
  export { gutterDefinition } from './gutter';
40
40
  export { hvacEquipmentDefinition } from './hvac-equipment';
41
+ export { importedMeshDefinition } from './imported-mesh';
41
42
  export { itemDefinition } from './item';
42
43
  export { leanToExtensionDefinition } from './lean-to-extension';
43
44
  export { levelDefinition } from './level';
@@ -61,6 +62,7 @@ export { stairDefinition } from './stair';
61
62
  export { stairSegmentDefinition } from './stair-segment';
62
63
  export { structuralGridDefinition } from './structural-grid';
63
64
  export { turbineVentDefinition } from './turbine-vent';
65
+ export { unitDefinition } from './unit';
64
66
  export { wallDefinition } from './wall';
65
67
  export { windowDefinition } from './window';
66
68
  export { zoneDefinition } from './zone';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":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qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,KAAK,yBAAyB,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAA;AAC/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA"}
package/dist/index.js CHANGED
@@ -19,6 +19,7 @@ import { fenceDefinition } from './fence';
19
19
  import { guideDefinition } from './guide';
20
20
  import { gutterDefinition } from './gutter';
21
21
  import { hvacEquipmentDefinition } from './hvac-equipment';
22
+ import { importedMeshDefinition } from './imported-mesh';
22
23
  import { itemDefinition } from './item';
23
24
  import { leanToExtensionDefinition } from './lean-to-extension';
24
25
  import { levelDefinition } from './level';
@@ -28,6 +29,7 @@ import { measurementDefinition } from './measurement';
28
29
  import { pipeFittingDefinition } from './pipe-fitting';
29
30
  import { pipeSegmentDefinition } from './pipe-segment';
30
31
  import { pipeTrapDefinition } from './pipe-trap';
32
+ import { proceduralItemDefinition } from './procedural-item/definition';
31
33
  import { ridgeVentDefinition } from './ridge-vent';
32
34
  import { roofDefinition } from './roof';
33
35
  import { roofSegmentDefinition } from './roof-segment';
@@ -42,6 +44,7 @@ import { stairDefinition } from './stair';
42
44
  import { stairSegmentDefinition } from './stair-segment';
43
45
  import { structuralGridDefinition } from './structural-grid';
44
46
  import { turbineVentDefinition } from './turbine-vent';
47
+ import { unitDefinition } from './unit';
45
48
  import { wallDefinition } from './wall';
46
49
  import { windowDefinition } from './window';
47
50
  import { zoneDefinition } from './zone';
@@ -79,10 +82,13 @@ export const builtinPlugin = {
79
82
  cabinetDefinition,
80
83
  cabinetModuleDefinition,
81
84
  itemDefinition,
85
+ proceduralItemDefinition,
86
+ importedMeshDefinition,
82
87
  // Stage A — wrap-exports the legacy renderer + system. Legacy
83
88
  // panels / move tools / floorplan branches still serve these.
84
89
  columnDefinition,
85
90
  elevatorDefinition,
91
+ unitDefinition,
86
92
  roofDefinition,
87
93
  roofSegmentDefinition,
88
94
  stairDefinition,
@@ -143,6 +149,7 @@ export { fenceDefinition } from './fence';
143
149
  export { guideDefinition } from './guide';
144
150
  export { gutterDefinition } from './gutter';
145
151
  export { hvacEquipmentDefinition } from './hvac-equipment';
152
+ export { importedMeshDefinition } from './imported-mesh';
146
153
  export { itemDefinition } from './item';
147
154
  export { leanToExtensionDefinition } from './lean-to-extension';
148
155
  export { levelDefinition } from './level';
@@ -166,6 +173,7 @@ export { stairDefinition } from './stair';
166
173
  export { stairSegmentDefinition } from './stair-segment';
167
174
  export { structuralGridDefinition } from './structural-grid';
168
175
  export { turbineVentDefinition } from './turbine-vent';
176
+ export { unitDefinition } from './unit';
169
177
  export { wallDefinition } from './wall';
170
178
  export { windowDefinition } from './window';
171
179
  export { zoneDefinition } from './zone';
@@ -1,3 +1,11 @@
1
- import { type FloorplanMoveTarget, type ItemNode } from '@pascal-app/core';
1
+ import { type AnyNode, type AnyNodeId, type CeilingNode, type FloorplanMoveTarget, type ItemNode } from '@pascal-app/core';
2
2
  export declare const itemFloorplanMoveTarget: FloorplanMoveTarget<ItemNode>;
3
+ /**
4
+ * Walk every ceiling under the level and return the first one whose
5
+ * polygon contains the pointer. Holes are honoured — a point inside a
6
+ * hole counts as not inside the surface. Slabs are intentionally NOT a
7
+ * valid target: floor items are parented to the level, not the slab,
8
+ * because slabs don't carry a `children` field on their schema.
9
+ */
10
+ export declare function findContainingSurface(point: readonly [number, number], nodes: Record<AnyNodeId, AnyNode>, parentLevelId: AnyNodeId | null, targetKind: 'ceiling'): CeilingNode | null;
3
11
  //# sourceMappingURL=floorplan-move.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"floorplan-move.d.ts","sourceRoot":"","sources":["../../src/item/floorplan-move.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,mBAAmB,EAKxB,KAAK,QAAQ,EAMd,MAAM,kBAAkB,CAAA;AAsKzB,eAAO,MAAM,uBAAuB,EAAE,mBAAmB,CAAC,QAAQ,CA+BjE,CAAA"}
1
+ {"version":3,"file":"floorplan-move.d.ts","sourceRoot":"","sources":["../../src/item/floorplan-move.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,WAAW,EAGhB,KAAK,mBAAmB,EAKxB,KAAK,QAAQ,EAQd,MAAM,kBAAkB,CAAA;AAkLzB,eAAO,MAAM,uBAAuB,EAAE,mBAAmB,CAAC,QAAQ,CA+BjE,CAAA;AAoOD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,EACjC,aAAa,EAAE,SAAS,GAAG,IAAI,EAC/B,UAAU,EAAE,SAAS,GACpB,WAAW,GAAG,IAAI,CAwBpB"}
@@ -1,6 +1,8 @@
1
- import { collectAlignmentAnchors, getBlockFaceFrame, getRoofWallFaceFrame, getScaledDimensions, movingFootprintAnchors, roofFacePointToSegment, useLiveNodeOverrides, useScene, } from '@pascal-app/core';
1
+ import { collectAlignmentAnchors, createSceneApi, getBlockFaceFrame, getRoofWallFaceFrame, getScaledDimensions, movingFootprintAnchors, nodeRegistry, resolveSurfacePlacement, roofFacePointToSegment, useLiveNodeOverrides, useScene, } from '@pascal-app/core';
2
+ import { boundsOf, boxCorners, frame, transformPoint } from '@pascal-app/core/procedural-items';
2
3
  import { applyFloorplanAlignment, isGridSnapActive, isMagneticSnapActive, useEditor, } from '@pascal-app/editor';
3
4
  import { createFloorplanCursorResolver } from '../shared/floorplan-cursor';
5
+ import { restingNodePlanFrame } from '../shared/resting-surface-plan';
4
6
  import { findClosestWallInPlan, snapLocalXToNeighbors } from '../shared/wall-attach-target';
5
7
  function rotateVec(x, z, rotationY) {
6
8
  const c = Math.cos(rotationY);
@@ -28,6 +30,15 @@ function resolveItemPlanTransform(item, nodes, cache = new Map()) {
28
30
  rotation: wallRotation + localRotation,
29
31
  };
30
32
  }
33
+ else if (parent?.type === 'cabinet' ||
34
+ parent?.type === 'cabinet-module' ||
35
+ parent?.type === 'procedural-item') {
36
+ const f = restingNodePlanFrame(item, (id) => nodes[id]);
37
+ result = {
38
+ point: [f.position[0], f.position[2]],
39
+ rotation: Math.atan2(f.axes[2][0], f.axes[2][2]),
40
+ };
41
+ }
31
42
  else if (parent?.type === 'shelf') {
32
43
  const shelf = parent;
33
44
  const [offsetX, offsetZ] = rotateVec(item.position[0], item.position[2], shelf.rotation[1] ?? 0);
@@ -219,6 +230,48 @@ function buildFloorItemSession(node, startLevelId, nodes) {
219
230
  // guides are DISPLAYED in every snapping mode; the magnetic pull onto them
220
231
  // is applied only in "lines" mode (`applySnap`).
221
232
  const { point: snapped } = applyFloorplanAlignment(gridSnapped, movingFootprintAnchors(node, gridSnapped[0], gridSnapped[1], rotationY), candidates, { applySnap: isMagneticSnapActive() });
233
+ const host = node.parentId ? nodes[node.parentId] : undefined;
234
+ if (host?.type === 'cabinet' || host?.type === 'shelf') {
235
+ const hostFrame = restingNodePlanFrame(host, (id) => useScene.getState().nodes[id]);
236
+ const dx = snapped[0] - hostFrame.position[0];
237
+ const dz = snapped[1] - hostFrame.position[2];
238
+ const local = [
239
+ dx * hostFrame.axes[0][0] + dz * hostFrame.axes[0][2],
240
+ node.position[1],
241
+ dx * hostFrame.axes[2][0] + dz * hostFrame.axes[2][2],
242
+ ];
243
+ const bounds = nodeRegistry.get(node.type)?.capabilities.dragBounds?.(node, nodes);
244
+ const dimensions = bounds?.size ?? getScaledDimensions(node);
245
+ const center = bounds?.center;
246
+ const localBounds = center
247
+ ? {
248
+ min: center.map((v, i) => v - dimensions[i] / 2),
249
+ max: center.map((v, i) => v + dimensions[i] / 2),
250
+ }
251
+ : undefined;
252
+ const projected = boundsOf(boxCorners(localBounds?.min ?? [-dimensions[0] / 2, 0, -dimensions[2] / 2], localBounds?.max ?? [dimensions[0] / 2, dimensions[1], dimensions[2] / 2]).map((p) => transformPoint(frame(local, node.rotation), p)));
253
+ const pose = resolveSurfacePlacement({
254
+ host,
255
+ childKind: node.type,
256
+ childFootprint: { size: dimensions, rotationY, rotation: node.rotation, localBounds },
257
+ hit: {
258
+ point: [
259
+ (projected.min[0] + projected.max[0]) / 2,
260
+ projected.min[1],
261
+ (projected.min[2] + projected.max[2]) / 2,
262
+ ],
263
+ normalWorldY: 1,
264
+ },
265
+ origin: local,
266
+ scene: createSceneApi(useScene),
267
+ });
268
+ if (pose && Math.abs(pose.position[1] - node.position[1]) < 1e-5) {
269
+ lastPatch = { parentId: host.id, position: [...pose.position], supportSlabId: undefined };
270
+ useLiveNodeOverrides.getState().set(node.id, lastPatch);
271
+ useScene.getState().markDirty(node.id);
272
+ return;
273
+ }
274
+ }
222
275
  const sourceY = node.position[1];
223
276
  const nextPosition = [snapped[0], sourceY, snapped[1]];
224
277
  lastPatch = {
@@ -286,7 +339,7 @@ function buildSurfaceItemSession(node, startLevelId, targetKind) {
286
339
  * valid target: floor items are parented to the level, not the slab,
287
340
  * because slabs don't carry a `children` field on their schema.
288
341
  */
289
- function findContainingSurface(point, nodes, parentLevelId, targetKind) {
342
+ export function findContainingSurface(point, nodes, parentLevelId, targetKind) {
290
343
  if (!parentLevelId)
291
344
  return null;
292
345
  const level = nodes[parentLevelId];
@@ -1 +1 @@
1
- {"version":3,"file":"floorplan.d.ts","sourceRoot":"","sources":["../../src/item/floorplan.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iBAAiB,EAEtB,KAAK,eAAe,EAIpB,KAAK,QAAQ,EAId,MAAM,kBAAkB,CAAA;AAsKzB,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,QAAQ,EACd,GAAG,EAAE,eAAe,GACnB,iBAAiB,GAAG,IAAI,CA+C1B;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,eAAe,GAAG,iBAAiB,GAAG,IAAI,CAmGjG"}
1
+ {"version":3,"file":"floorplan.d.ts","sourceRoot":"","sources":["../../src/item/floorplan.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iBAAiB,EAEtB,KAAK,eAAe,EAIpB,KAAK,QAAQ,EAId,MAAM,kBAAkB,CAAA;AAkLzB,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,QAAQ,EACd,GAAG,EAAE,eAAe,GACnB,iBAAiB,GAAG,IAAI,CA+C1B;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,eAAe,GAAG,iBAAiB,GAAG,IAAI,CAmGjG"}
@@ -1,5 +1,6 @@
1
1
  import { getBlockFaceFrame, getRoofWallFaceFrame, getScaledDimensions, roofFacePointToSegment, useLiveTransforms, } from '@pascal-app/core';
2
2
  import { formatLinearMeasurement, readFloorplanMetricNotationOverride } from '@pascal-app/editor';
3
+ import { restingNodePlanFrame } from '../shared/resting-surface-plan';
3
4
  // Plan-space rotation convention used by the legacy `rotatePlanVector`
4
5
  // in `editor/src/lib/floorplan/geometry.ts`. This is a CLOCKWISE rotation
5
6
  // — the registry-side equivalent of the canonical floor-plan transform
@@ -47,6 +48,16 @@ function resolveItemTransform(item, ctx, cache = new Map()) {
47
48
  };
48
49
  }
49
50
  }
51
+ else if (parentNode?.type === 'cabinet' ||
52
+ parentNode?.type === 'cabinet-module' ||
53
+ parentNode?.type === 'procedural-item') {
54
+ const f = restingNodePlanFrame(item, ctx.resolve);
55
+ result = {
56
+ x: f.position[0],
57
+ y: f.position[2],
58
+ rotation: Math.atan2(f.axes[2][0], f.axes[2][2]),
59
+ };
60
+ }
50
61
  else if (parentNode?.type === 'shelf') {
51
62
  // Shelf-hosted item: `item.position` is in shelf-local coords. The
52
63
  // shelf has its own `position` + `rotation[1]` in its parent (level)
@@ -78,7 +78,7 @@ export function getInitialState(node, parent = node.parentId
78
78
  // handler — which preserves the grab offset — instead of a fresh `enter()`
79
79
  // that snaps the item's origin under the cursor. Without this the item
80
80
  // teleports the instant it's grabbed.
81
- if (parent?.type === 'item') {
81
+ if (parent?.type === 'item' || parent?.type === 'cabinet' || parent?.type === 'procedural-item') {
82
82
  return {
83
83
  surface: 'item-surface',
84
84
  wallId: null,
@@ -78,7 +78,7 @@ export default function ItemPanel() {
78
78
  }, [selectedId, deleteNode, setSelection]);
79
79
  if (!(node && node.type === 'item' && selectedId))
80
80
  return null;
81
- return (_jsxs(PanelWrapper, { icon: node.asset.thumbnail || '/icons/item.webp', onClose: handleClose, title: node.name || node.asset.name, width: 300, children: [_jsxs(PanelSection, { title: "Position", children: [_jsx(SliderControl, { label: _jsxs(_Fragment, { children: ["X", _jsx("sub", { className: "ml-[1px] text-[11px] opacity-70", children: "pos" })] }), max: node.position[0] + 2, min: node.position[0] - 2, onChange: (value) => handleUpdate({ position: [value, node.position[1], node.position[2]] }), precision: 2, step: 0.01, unit: "m", value: Math.round(node.position[0] * 100) / 100 }), _jsx(SliderControl, { label: _jsxs(_Fragment, { children: ["Y", _jsx("sub", { className: "ml-[1px] text-[11px] opacity-70", children: "pos" })] }), max: node.position[1] + 2, min: node.position[1] - 2, onChange: (value) => handleUpdate({ position: [node.position[0], value, node.position[2]] }), precision: 2, step: 0.01, unit: "m", value: Math.round(node.position[1] * 100) / 100 }), _jsx(SliderControl, { label: _jsxs(_Fragment, { children: ["Z", _jsx("sub", { className: "ml-[1px] text-[11px] opacity-70", children: "pos" })] }), max: node.position[2] + 2, min: node.position[2] - 2, onChange: (value) => handleUpdate({ position: [node.position[0], node.position[1], value] }), precision: 2, step: 0.01, unit: "m", value: Math.round(node.position[2] * 100) / 100 })] }), _jsxs(PanelSection, { title: "Rotation", children: [_jsx(SliderControl, { label: _jsxs(_Fragment, { children: ["Y", _jsx("sub", { className: "ml-[1px] text-[11px] opacity-70", children: "rot" })] }), max: Math.round((node.rotation[1] * 180) / Math.PI) + 45, min: Math.round((node.rotation[1] * 180) / Math.PI) - 45, onChange: (degrees) => {
81
+ return (_jsxs(PanelWrapper, { icon: node.asset.thumbnail || '/icons/item.webp', onClose: handleClose, title: node.name || node.asset.name, width: 300, children: [_jsxs(PanelSection, { title: "Position", children: [_jsx(SliderControl, { label: _jsxs(_Fragment, { children: ["X", _jsx("sub", { className: "ml-[1px] text-[11px] opacity-70", children: "pos" })] }), max: node.position[0] + 2, min: node.position[0] - 2, onChange: (value) => handleUpdate({ position: [value, node.position[1], node.position[2]] }), precision: 2, step: 0.01, unit: "m", value: node.position[0] }), _jsx(SliderControl, { label: _jsxs(_Fragment, { children: ["Y", _jsx("sub", { className: "ml-[1px] text-[11px] opacity-70", children: "pos" })] }), max: node.position[1] + 2, min: node.position[1] - 2, onChange: (value) => handleUpdate({ position: [node.position[0], value, node.position[2]] }), precision: 2, step: 0.01, unit: "m", value: node.position[1] }), _jsx(SliderControl, { label: _jsxs(_Fragment, { children: ["Z", _jsx("sub", { className: "ml-[1px] text-[11px] opacity-70", children: "pos" })] }), max: node.position[2] + 2, min: node.position[2] - 2, onChange: (value) => handleUpdate({ position: [node.position[0], node.position[1], value] }), precision: 2, step: 0.01, unit: "m", value: node.position[2] })] }), _jsxs(PanelSection, { title: "Rotation", children: [_jsx(SliderControl, { label: _jsxs(_Fragment, { children: ["Y", _jsx("sub", { className: "ml-[1px] text-[11px] opacity-70", children: "rot" })] }), max: Math.round((node.rotation[1] * 180) / Math.PI) + 45, min: Math.round((node.rotation[1] * 180) / Math.PI) - 45, onChange: (degrees) => {
82
82
  const radians = (degrees * Math.PI) / 180;
83
83
  handleUpdate({ rotation: [node.rotation[0], radians, node.rotation[2]] });
84
84
  }, precision: 0, step: 1, unit: "\u00B0", value: Math.round((node.rotation[1] * 180) / Math.PI) }), _jsxs("div", { className: "flex gap-1.5 px-1 pt-2 pb-1", children: [_jsx(ActionButton, { label: "-45\u00B0", onClick: () => {
@@ -1 +1 @@
1
- {"version":3,"file":"parametrics.d.ts","sourceRoot":"","sources":["../../src/pipe-segment/parametrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAE5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,eAAO,MAAM,sBAAsB,EAAE,oBAAoB,CAAC,eAAe,CAmFxE,CAAA"}
1
+ {"version":3,"file":"parametrics.d.ts","sourceRoot":"","sources":["../../src/pipe-segment/parametrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAG5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,eAAO,MAAM,sBAAsB,EAAE,oBAAoB,CAAC,eAAe,CAqFxE,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { findAutomaticRunEndCapIds } from '../shared/automatic-run-end-cap';
1
2
  import { fittingDeletionPlansForRun } from '../shared/fitting-deletion-cleanup';
2
3
  export const pipeSegmentParametrics = {
3
4
  derive: (next) => next.autoHangers
@@ -8,7 +9,10 @@ export const pipeSegmentParametrics = {
8
9
  }
9
10
  : {},
10
11
  onDelete: (pipe, nodes, _pendingDeleteIds, requestedDeleteIds) => fittingDeletionPlansForRun(pipe, nodes, requestedDeleteIds, true).flatMap((plan) => plan.updates),
11
- onDeleteCascade: (pipe, nodes, _pendingDeleteIds, requestedDeleteIds) => fittingDeletionPlansForRun(pipe, nodes, requestedDeleteIds, false).flatMap((plan) => plan.deleteFitting ? [plan.fittingId, ...plan.cascadeDeleteIds] : []),
12
+ onDeleteCascade: (pipe, nodes, _pendingDeleteIds, requestedDeleteIds) => [
13
+ ...findAutomaticRunEndCapIds(pipe.id, nodes, 'pipe-fitting'),
14
+ ...fittingDeletionPlansForRun(pipe, nodes, requestedDeleteIds, false).flatMap((plan) => plan.deleteFitting ? [plan.fittingId, ...plan.cascadeDeleteIds] : []),
15
+ ],
12
16
  trailingSection: () => import('../shared/run-hanger-inspector'),
13
17
  groups: [
14
18
  {
@@ -0,0 +1,4 @@
1
+ import type { NodeDefinition } from '@pascal-app/core';
2
+ import { ProceduralItemNode } from '@pascal-app/core/procedural-items';
3
+ export declare const proceduralItemDefinition: NodeDefinition<typeof ProceduralItemNode>;
4
+ //# sourceMappingURL=definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/procedural-item/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgD,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEpG,OAAO,EAKL,kBAAkB,EAWnB,MAAM,mCAAmC,CAAA;AA6D1C,eAAO,MAAM,wBAAwB,EAAE,cAAc,CAAC,OAAO,kBAAkB,CAmO9E,CAAA"}
@@ -0,0 +1,254 @@
1
+ import { useScene } from '@pascal-app/core';
2
+ import { boundsOf, boxCorners, evaluateRecipe, frame, ProceduralItemNode, parameterPatch, proceduralFootprint, proceduralSlotColor, queryProceduralItem, resolveProceduralWallPlacement, setProceduralMaterial, shelfRecipe, snapParameters, transformPoint, validateProceduralRelations, } from '@pascal-app/core/procedural-items';
3
+ import { itemPaint } from '../item/paint';
4
+ import { proceduralFloorplanMoveTarget } from './move-session';
5
+ const GIZMO_SIDE_OFFSET = 0.3;
6
+ const GIZMO_FRONT_OFFSET = 0.3;
7
+ const ROTATE_RING_OFFSET = 0.06;
8
+ function handleBounds(node, part) {
9
+ const e = evaluateRecipe(node.recipe, node.parameters);
10
+ const shapes = part ? e.shapes.filter((shape) => shape.partId === part) : [];
11
+ return shapes.length
12
+ ? boundsOf(shapes.flatMap((shape) => boxCorners(shape.size.map((v) => -v / 2), shape.size.map((v) => v / 2)).map((point) => transformPoint(frame(shape.position, shape.rotation), point))))
13
+ : e;
14
+ }
15
+ function proceduralRotateHandle() {
16
+ return {
17
+ kind: 'arc-resize',
18
+ axis: 'angular',
19
+ shape: 'rotate',
20
+ apply: (initial, delta) => {
21
+ const [rx, ry, rz] = initial.rotation;
22
+ return { rotation: [rx, ry - delta, rz] };
23
+ },
24
+ placement: {
25
+ position: (n) => {
26
+ const b = evaluateRecipe(n.recipe, n.parameters);
27
+ return [
28
+ b.max[0] + GIZMO_SIDE_OFFSET,
29
+ (b.min[1] + b.max[1]) / 2,
30
+ b.max[2] + GIZMO_FRONT_OFFSET,
31
+ ];
32
+ },
33
+ rotationY: () => -Math.PI / 4,
34
+ },
35
+ decoration: {
36
+ kind: 'ring',
37
+ center: (n) => {
38
+ const b = evaluateRecipe(n.recipe, n.parameters);
39
+ return b.min.map((v, i) => (v + b.max[i]) / 2);
40
+ },
41
+ radius: (n) => {
42
+ const b = evaluateRecipe(n.recipe, n.parameters);
43
+ return Math.hypot(b.dimensions[0] / 2, b.dimensions[2] / 2) + ROTATE_RING_OFFSET;
44
+ },
45
+ y: (n) => {
46
+ const b = evaluateRecipe(n.recipe, n.parameters);
47
+ return (b.min[1] + b.max[1]) / 2;
48
+ },
49
+ },
50
+ };
51
+ }
52
+ export const proceduralItemDefinition = {
53
+ kind: 'procedural-item',
54
+ schemaVersion: 1,
55
+ schema: ProceduralItemNode,
56
+ category: 'furnish',
57
+ snapProfile: 'item',
58
+ surfaceRole: 'furnishing',
59
+ defaults: () => ({
60
+ object: 'node',
61
+ parentId: null,
62
+ visible: true,
63
+ metadata: {},
64
+ recipe: shelfRecipe,
65
+ parameters: {},
66
+ slots: {},
67
+ children: [],
68
+ attachments: {},
69
+ position: [0, 0, 0],
70
+ rotation: [0, 0, 0],
71
+ }),
72
+ capabilities: {
73
+ selectable: { hitVolume: 'bbox' },
74
+ dragBounds: (n) => {
75
+ const node = n;
76
+ const e = evaluateRecipe(node.recipe, node.parameters);
77
+ return {
78
+ size: e.dimensions,
79
+ center: e.min.map((v, i) => (v + e.max[i]) / 2),
80
+ };
81
+ },
82
+ hostable: {
83
+ parents: ['level', 'wall', 'ceiling', 'procedural-item', 'item', 'shelf'],
84
+ align: 'face',
85
+ },
86
+ hostRefFields: ['wallId', 'side', 'supportSlabId'],
87
+ floorPlaced: {
88
+ footprint: (n) => proceduralFootprint(n),
89
+ applies: (n) => !n.recipe.mounting,
90
+ collides: true,
91
+ },
92
+ movable: { axes: ['x', 'z'], gridSnap: true },
93
+ rotatable: { axes: ['y'], snapAngles: [0, Math.PI / 4, Math.PI / 2, Math.PI] },
94
+ duplicable: true,
95
+ deletable: true,
96
+ slots: (n) => {
97
+ const node = n;
98
+ return node.recipe.slots.map((s) => ({ slotId: s.id, label: s.label, default: s.color }));
99
+ },
100
+ surfaces: {
101
+ custom: (n) => evaluateRecipe(n.recipe, n.parameters).surfaces.map((s) => ({
102
+ id: s.id,
103
+ position: s.position,
104
+ normal: s.normal,
105
+ rotation: s.rotation,
106
+ size: s.size,
107
+ })),
108
+ },
109
+ paint: {
110
+ ...itemPaint,
111
+ commit: ({ node, role, material, materialPreset }) => setProceduralMaterial(node.id, role, materialPreset, material),
112
+ },
113
+ },
114
+ relations: { hosts: ['item', 'procedural-item'], cascadeDelete: 'descendants' },
115
+ renderer: { kind: 'parametric', module: () => import('./renderer') },
116
+ parametrics: { groups: [], customPanel: () => import('@pascal-app/editor/procedural-items') },
117
+ affordanceTools: { move: () => import('./move-tool') },
118
+ floorplanMoveTarget: proceduralFloorplanMoveTarget,
119
+ keyboardActions: {
120
+ r: {
121
+ appliesTo: (n) => Boolean(n.wallId),
122
+ run: (n) => {
123
+ const node = n;
124
+ const nodes = useScene.getState().nodes;
125
+ const wall = nodes[node.wallId];
126
+ if (wall?.type !== 'wall')
127
+ return;
128
+ const next = resolveProceduralWallPlacement(node, wall, node.position[0], node.position[1], node.side === 'back' ? 'front' : 'back', nodes);
129
+ if (next)
130
+ useScene.getState().updateNode(node.id, {
131
+ side: next.side,
132
+ position: [next.position[0], next.position[1], node.position[2]],
133
+ });
134
+ },
135
+ },
136
+ },
137
+ handles: (node) => {
138
+ const result = [];
139
+ for (const p of node.recipe.parameters) {
140
+ if (!p.axis)
141
+ continue;
142
+ const axis = p.axis, index = axis === 'x' ? 0 : axis === 'y' ? 1 : 2;
143
+ const downward = axis === 'y' && node.recipe.mounting?.attachTo === 'ceiling';
144
+ result.push({
145
+ kind: 'linear-resize',
146
+ latchGroup: p.part,
147
+ faceNormal: Boolean(node.wallId),
148
+ portal: node.recipe.mounting ? 'grandparent' : 'self',
149
+ axis,
150
+ direction: downward ? -1 : undefined,
151
+ anchor: axis === 'y' ? (downward ? 'max' : 'min') : 'center',
152
+ min: p.min,
153
+ max: p.max,
154
+ currentValue: (n) => n.parameters[p.id] ?? p.default,
155
+ apply: (n, v, scene) => {
156
+ const patch = parameterPatch(n, p.id, Math.min(p.max, Math.max(p.min, v)));
157
+ if (!patch)
158
+ return {};
159
+ try {
160
+ validateProceduralRelations({ ...n, ...patch }, scene.nodes());
161
+ validateProceduralRelations({ ...n, parameters: snapParameters(n.recipe, patch.parameters) }, scene.nodes());
162
+ return patch;
163
+ }
164
+ catch {
165
+ return {};
166
+ }
167
+ },
168
+ commit: (n, patch, scene) => {
169
+ const parameters = snapParameters(n.recipe, patch.parameters ?? n.parameters);
170
+ validateProceduralRelations({ ...n, parameters }, scene.nodes());
171
+ scene.update(n.id, { parameters });
172
+ },
173
+ placement: {
174
+ clearance: {
175
+ edge: (n) => handleBounds(n, p.part)[downward ? 'min' : 'max'][index],
176
+ distance: 0.4,
177
+ },
178
+ position: (n) => {
179
+ const b = handleBounds(n, p.part);
180
+ const pos = b.max.map((v, i) => (i === index ? v + 0.15 : (b.min[i] + v) / 2));
181
+ if (downward)
182
+ pos[index] = b.min[index] - 0.15;
183
+ return pos;
184
+ },
185
+ },
186
+ });
187
+ }
188
+ if (node.recipe.mounting?.attachTo !== 'wall-side')
189
+ result.push({
190
+ ...proceduralRotateHandle(),
191
+ portal: node.recipe.mounting ? 'grandparent' : 'self',
192
+ });
193
+ return result;
194
+ },
195
+ floorplan: (node, ctx) => {
196
+ const chain = { [node.id]: node };
197
+ let current = node.parentId, depth = 0;
198
+ while (current && depth++ < 32) {
199
+ const parent = ctx.resolve(current);
200
+ if (!parent)
201
+ break;
202
+ chain[current] = parent;
203
+ current = parent.parentId;
204
+ }
205
+ const q = queryProceduralItem(node, chain), b = q.levelBounds;
206
+ const floorPlanUrl = node.metadata.floorPlanUrl;
207
+ if (typeof floorPlanUrl === 'string' && floorPlanUrl.trim()) {
208
+ const local = q.localBounds;
209
+ const center = transformPoint(q.frame, local.min.map((v, i) => (v + local.max[i]) / 2));
210
+ const points = [
211
+ [local.min[0], local.min[2]],
212
+ [local.max[0], local.min[2]],
213
+ [local.max[0], local.max[2]],
214
+ [local.min[0], local.max[2]],
215
+ ].map(([x, z]) => {
216
+ const point = transformPoint(q.frame, [x, 0, z]);
217
+ return [point[0], point[2]];
218
+ });
219
+ const selected = ctx.viewState?.selected || ctx.viewState?.highlighted;
220
+ const stroke = selected ? (ctx.viewState?.palette?.selectedStroke ?? '#3b82f6') : '#92400e';
221
+ const strokeWidth = selected ? 0.035 : 0.012;
222
+ const children = [
223
+ { kind: 'polygon', points, fill: 'transparent', stroke, strokeWidth, opacity: 0.85 },
224
+ {
225
+ kind: 'image',
226
+ url: floorPlanUrl,
227
+ center: [center[0], center[2]],
228
+ width: local.dimensions[0],
229
+ height: local.dimensions[2],
230
+ rotation: Math.atan2(q.frame.axes[0][2], q.frame.axes[0][0]),
231
+ },
232
+ ];
233
+ if (selected)
234
+ children.push({ kind: 'polygon', points, fill: 'none', stroke, strokeWidth });
235
+ return { kind: 'group', children };
236
+ }
237
+ return {
238
+ kind: 'rect',
239
+ x: b.min[0],
240
+ y: b.min[2],
241
+ width: b.dimensions[0],
242
+ height: b.dimensions[2],
243
+ fill: proceduralSlotColor(node.slots[node.recipe.slots[0].id], node.recipe.slots[0].color, ctx.materials ?? {}),
244
+ stroke: '#44403c',
245
+ strokeWidth: 0.01,
246
+ };
247
+ },
248
+ presentation: {
249
+ label: 'Procedural item',
250
+ description: 'Experimental editable recipe',
251
+ icon: { kind: 'iconify', name: 'lucide:boxes' },
252
+ },
253
+ mcp: { description: 'Experimental procedural item with a validated recipe.' },
254
+ };