@pascal-app/core 0.9.1 → 1.0.0-beta.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 (378) hide show
  1. package/README.md +17 -10
  2. package/dist/events/bus.d.ts +49 -2
  3. package/dist/events/bus.d.ts.map +1 -1
  4. package/dist/hooks/scene-registry/item-clip-registry.d.ts +18 -0
  5. package/dist/hooks/scene-registry/item-clip-registry.d.ts.map +1 -0
  6. package/dist/hooks/scene-registry/item-clip-registry.js +10 -0
  7. package/dist/hooks/scene-registry/scene-registry.d.ts +8 -1
  8. package/dist/hooks/scene-registry/scene-registry.d.ts.map +1 -1
  9. package/dist/hooks/scene-registry/scene-registry.js +27 -1
  10. package/dist/hooks/spatial-grid/floor-placed-elevation.d.ts +17 -1
  11. package/dist/hooks/spatial-grid/floor-placed-elevation.d.ts.map +1 -1
  12. package/dist/hooks/spatial-grid/floor-placed-elevation.js +61 -8
  13. package/dist/hooks/spatial-grid/spatial-grid-manager.d.ts +135 -28
  14. package/dist/hooks/spatial-grid/spatial-grid-manager.d.ts.map +1 -1
  15. package/dist/hooks/spatial-grid/spatial-grid-manager.js +427 -271
  16. package/dist/hooks/spatial-grid/spatial-grid-sync.d.ts +46 -1
  17. package/dist/hooks/spatial-grid/spatial-grid-sync.d.ts.map +1 -1
  18. package/dist/hooks/spatial-grid/spatial-grid-sync.js +208 -9
  19. package/dist/hooks/spatial-grid/support-host-id.d.ts +3 -0
  20. package/dist/hooks/spatial-grid/support-host-id.d.ts.map +1 -0
  21. package/dist/hooks/spatial-grid/support-host-id.js +2 -0
  22. package/dist/hooks/spatial-grid/support-host-patch.d.ts +51 -0
  23. package/dist/hooks/spatial-grid/support-host-patch.d.ts.map +1 -0
  24. package/dist/hooks/spatial-grid/support-host-patch.js +164 -0
  25. package/dist/index.d.ts +33 -11
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +32 -10
  28. package/dist/lib/level-name.d.ts +4 -0
  29. package/dist/lib/level-name.d.ts.map +1 -0
  30. package/dist/lib/level-name.js +10 -0
  31. package/dist/lib/measurement-geometry.d.ts +23 -0
  32. package/dist/lib/measurement-geometry.d.ts.map +1 -0
  33. package/dist/lib/measurement-geometry.js +249 -0
  34. package/dist/lib/polygon-geometry.d.ts +0 -1
  35. package/dist/lib/polygon-geometry.d.ts.map +1 -1
  36. package/dist/lib/polygon-geometry.js +0 -18
  37. package/dist/lib/selection-proxy.d.ts +4 -0
  38. package/dist/lib/selection-proxy.d.ts.map +1 -0
  39. package/dist/lib/selection-proxy.js +12 -0
  40. package/dist/lib/slab-polygon.d.ts +31 -2
  41. package/dist/lib/slab-polygon.d.ts.map +1 -1
  42. package/dist/lib/slab-polygon.js +557 -31
  43. package/dist/lib/slots.d.ts +14 -0
  44. package/dist/lib/slots.d.ts.map +1 -0
  45. package/dist/lib/slots.js +26 -0
  46. package/dist/lib/space-detection.d.ts +40 -6
  47. package/dist/lib/space-detection.d.ts.map +1 -1
  48. package/dist/lib/space-detection.js +574 -192
  49. package/dist/lib/terrain-brush.d.ts +163 -0
  50. package/dist/lib/terrain-brush.d.ts.map +1 -0
  51. package/dist/lib/terrain-brush.js +359 -0
  52. package/dist/lib/terrain-codec.d.ts +51 -0
  53. package/dist/lib/terrain-codec.d.ts.map +1 -0
  54. package/dist/lib/terrain-codec.js +167 -0
  55. package/dist/lib/terrain-field.d.ts +150 -0
  56. package/dist/lib/terrain-field.d.ts.map +1 -0
  57. package/dist/lib/terrain-field.js +248 -0
  58. package/dist/lib/terrain-raycast.d.ts +44 -0
  59. package/dist/lib/terrain-raycast.d.ts.map +1 -0
  60. package/dist/lib/terrain-raycast.js +188 -0
  61. package/dist/lib/terrain-source.d.ts +60 -0
  62. package/dist/lib/terrain-source.d.ts.map +1 -0
  63. package/dist/lib/terrain-source.js +90 -0
  64. package/dist/lib/terrain-support.d.ts +60 -0
  65. package/dist/lib/terrain-support.d.ts.map +1 -0
  66. package/dist/lib/terrain-support.js +150 -0
  67. package/dist/lib/wall-distance.d.ts +60 -0
  68. package/dist/lib/wall-distance.d.ts.map +1 -0
  69. package/dist/lib/wall-distance.js +85 -0
  70. package/dist/lib/zone-quantities.d.ts +21 -0
  71. package/dist/lib/zone-quantities.d.ts.map +1 -0
  72. package/dist/lib/zone-quantities.js +428 -0
  73. package/dist/material-library.d.ts +28 -1
  74. package/dist/material-library.d.ts.map +1 -1
  75. package/dist/material-library.js +2233 -441
  76. package/dist/registry/handles.d.ts +91 -3
  77. package/dist/registry/handles.d.ts.map +1 -1
  78. package/dist/registry/index.d.ts +3 -3
  79. package/dist/registry/index.d.ts.map +1 -1
  80. package/dist/registry/index.js +1 -1
  81. package/dist/registry/registry.d.ts +46 -3
  82. package/dist/registry/registry.d.ts.map +1 -1
  83. package/dist/registry/registry.js +82 -1
  84. package/dist/registry/subtree.d.ts.map +1 -1
  85. package/dist/registry/subtree.js +8 -1
  86. package/dist/registry/types.d.ts +781 -39
  87. package/dist/registry/types.d.ts.map +1 -1
  88. package/dist/schema/index.d.ts +27 -8
  89. package/dist/schema/index.d.ts.map +1 -1
  90. package/dist/schema/index.js +23 -6
  91. package/dist/schema/material.d.ts +3 -2
  92. package/dist/schema/material.d.ts.map +1 -1
  93. package/dist/schema/material.js +7 -5
  94. package/dist/schema/nodes/box-vent.d.ts +2 -2
  95. package/dist/schema/nodes/cabinet.d.ts +536 -0
  96. package/dist/schema/nodes/cabinet.d.ts.map +1 -0
  97. package/dist/schema/nodes/cabinet.js +139 -0
  98. package/dist/schema/nodes/ceiling.d.ts +4 -3
  99. package/dist/schema/nodes/ceiling.d.ts.map +1 -1
  100. package/dist/schema/nodes/ceiling.js +11 -1
  101. package/dist/schema/nodes/chimney.d.ts +4 -4
  102. package/dist/schema/nodes/column.d.ts +4 -2
  103. package/dist/schema/nodes/column.d.ts.map +1 -1
  104. package/dist/schema/nodes/column.js +5 -0
  105. package/dist/schema/nodes/construction-dimension.d.ts +195 -0
  106. package/dist/schema/nodes/construction-dimension.d.ts.map +1 -0
  107. package/dist/schema/nodes/construction-dimension.js +151 -0
  108. package/dist/schema/nodes/cupola.d.ts +2 -2
  109. package/dist/schema/nodes/door.d.ts +42 -5
  110. package/dist/schema/nodes/door.d.ts.map +1 -1
  111. package/dist/schema/nodes/door.js +32 -0
  112. package/dist/schema/nodes/dormer.d.ts +8 -8
  113. package/dist/schema/nodes/dormer.js +1 -1
  114. package/dist/schema/nodes/downspout.d.ts +2 -2
  115. package/dist/schema/nodes/duct-fitting.d.ts +91 -0
  116. package/dist/schema/nodes/duct-fitting.d.ts.map +1 -0
  117. package/dist/schema/nodes/duct-fitting.js +92 -0
  118. package/dist/schema/nodes/duct-segment.d.ts +61 -0
  119. package/dist/schema/nodes/duct-segment.d.ts.map +1 -0
  120. package/dist/schema/nodes/duct-segment.js +73 -0
  121. package/dist/schema/nodes/duct-terminal.d.ts +58 -0
  122. package/dist/schema/nodes/duct-terminal.d.ts.map +1 -0
  123. package/dist/schema/nodes/duct-terminal.js +53 -0
  124. package/dist/schema/nodes/elevator.d.ts +3 -2
  125. package/dist/schema/nodes/elevator.d.ts.map +1 -1
  126. package/dist/schema/nodes/elevator.js +3 -0
  127. package/dist/schema/nodes/eyebrow-vent.d.ts +2 -2
  128. package/dist/schema/nodes/fence.d.ts +20 -2
  129. package/dist/schema/nodes/fence.d.ts.map +1 -1
  130. package/dist/schema/nodes/fence.js +33 -2
  131. package/dist/schema/nodes/gutter.d.ts +2 -2
  132. package/dist/schema/nodes/hvac-equipment.d.ts +64 -0
  133. package/dist/schema/nodes/hvac-equipment.d.ts.map +1 -0
  134. package/dist/schema/nodes/hvac-equipment.js +57 -0
  135. package/dist/schema/nodes/item.d.ts +9 -0
  136. package/dist/schema/nodes/item.d.ts.map +1 -1
  137. package/dist/schema/nodes/item.js +24 -0
  138. package/dist/schema/nodes/level.d.ts +2 -1
  139. package/dist/schema/nodes/level.d.ts.map +1 -1
  140. package/dist/schema/nodes/level.js +12 -31
  141. package/dist/schema/nodes/lineset.d.ts +42 -0
  142. package/dist/schema/nodes/lineset.d.ts.map +1 -0
  143. package/dist/schema/nodes/lineset.js +38 -0
  144. package/dist/schema/nodes/liquid-line.d.ts +34 -0
  145. package/dist/schema/nodes/liquid-line.d.ts.map +1 -0
  146. package/dist/schema/nodes/liquid-line.js +24 -0
  147. package/dist/schema/nodes/measurement.d.ts +306 -0
  148. package/dist/schema/nodes/measurement.d.ts.map +1 -0
  149. package/dist/schema/nodes/measurement.js +87 -0
  150. package/dist/schema/nodes/pipe-fitting.d.ts +56 -0
  151. package/dist/schema/nodes/pipe-fitting.d.ts.map +1 -0
  152. package/dist/schema/nodes/pipe-fitting.js +45 -0
  153. package/dist/schema/nodes/pipe-segment.d.ts +48 -0
  154. package/dist/schema/nodes/pipe-segment.d.ts.map +1 -0
  155. package/dist/schema/nodes/pipe-segment.js +36 -0
  156. package/dist/schema/nodes/pipe-trap.d.ts +43 -0
  157. package/dist/schema/nodes/pipe-trap.d.ts.map +1 -0
  158. package/dist/schema/nodes/pipe-trap.js +36 -0
  159. package/dist/schema/nodes/ridge-vent.d.ts +18 -3
  160. package/dist/schema/nodes/ridge-vent.d.ts.map +1 -1
  161. package/dist/schema/nodes/ridge-vent.js +221 -3
  162. package/dist/schema/nodes/roof-segment-shape.d.ts +90 -0
  163. package/dist/schema/nodes/roof-segment-shape.d.ts.map +1 -0
  164. package/dist/schema/nodes/roof-segment-shape.js +318 -0
  165. package/dist/schema/nodes/roof-segment-walls.d.ts +101 -0
  166. package/dist/schema/nodes/roof-segment-walls.d.ts.map +1 -0
  167. package/dist/schema/nodes/roof-segment-walls.js +330 -0
  168. package/dist/schema/nodes/roof-segment.d.ts +84 -8
  169. package/dist/schema/nodes/roof-segment.d.ts.map +1 -1
  170. package/dist/schema/nodes/roof-segment.js +290 -5
  171. package/dist/schema/nodes/roof.d.ts +8 -8
  172. package/dist/schema/nodes/shelf.d.ts +4 -2
  173. package/dist/schema/nodes/shelf.d.ts.map +1 -1
  174. package/dist/schema/nodes/shelf.js +8 -0
  175. package/dist/schema/nodes/site.d.ts +9 -0
  176. package/dist/schema/nodes/site.d.ts.map +1 -1
  177. package/dist/schema/nodes/site.js +8 -6
  178. package/dist/schema/nodes/skylight.d.ts +10 -10
  179. package/dist/schema/nodes/slab.d.ts +8 -2
  180. package/dist/schema/nodes/slab.d.ts.map +1 -1
  181. package/dist/schema/nodes/slab.js +18 -2
  182. package/dist/schema/nodes/solar-panel.d.ts +4 -4
  183. package/dist/schema/nodes/spawn.d.ts +1 -0
  184. package/dist/schema/nodes/spawn.d.ts.map +1 -1
  185. package/dist/schema/nodes/spawn.js +2 -0
  186. package/dist/schema/nodes/stair-segment.d.ts +4 -4
  187. package/dist/schema/nodes/stair.d.ts +16 -13
  188. package/dist/schema/nodes/stair.d.ts.map +1 -1
  189. package/dist/schema/nodes/stair.js +11 -1
  190. package/dist/schema/nodes/structural-grid.d.ts +27 -0
  191. package/dist/schema/nodes/structural-grid.d.ts.map +1 -0
  192. package/dist/schema/nodes/structural-grid.js +17 -0
  193. package/dist/schema/nodes/turbine-vent.d.ts +2 -2
  194. package/dist/schema/nodes/wall.d.ts +248 -6
  195. package/dist/schema/nodes/wall.d.ts.map +1 -1
  196. package/dist/schema/nodes/wall.js +266 -0
  197. package/dist/schema/nodes/window.d.ts +40 -3
  198. package/dist/schema/nodes/window.d.ts.map +1 -1
  199. package/dist/schema/nodes/window.js +30 -0
  200. package/dist/schema/nodes/zone.d.ts +22 -0
  201. package/dist/schema/nodes/zone.d.ts.map +1 -1
  202. package/dist/schema/nodes/zone.js +21 -0
  203. package/dist/schema/scene-material.d.ts +41 -0
  204. package/dist/schema/scene-material.d.ts.map +1 -0
  205. package/dist/schema/scene-material.js +9 -0
  206. package/dist/schema/terrain.d.ts +28 -0
  207. package/dist/schema/terrain.d.ts.map +1 -0
  208. package/dist/schema/terrain.js +30 -0
  209. package/dist/schema/types.d.ts +1300 -97
  210. package/dist/schema/types.d.ts.map +1 -1
  211. package/dist/schema/types.js +27 -0
  212. package/dist/services/__fixtures__/wall-plane-top-boundary-repro.d.ts +80 -0
  213. package/dist/services/__fixtures__/wall-plane-top-boundary-repro.d.ts.map +1 -0
  214. package/dist/services/__fixtures__/wall-plane-top-boundary-repro.js +89 -0
  215. package/dist/services/alignment-anchors.d.ts.map +1 -1
  216. package/dist/services/alignment-anchors.js +30 -1
  217. package/dist/services/alignment.d.ts +5 -0
  218. package/dist/services/alignment.d.ts.map +1 -1
  219. package/dist/services/alignment.js +2 -0
  220. package/dist/services/hosting.d.ts +8 -0
  221. package/dist/services/hosting.d.ts.map +1 -1
  222. package/dist/services/hosting.js +13 -4
  223. package/dist/services/index.d.ts +9 -2
  224. package/dist/services/index.d.ts.map +1 -1
  225. package/dist/services/index.js +9 -2
  226. package/dist/services/level-height.d.ts +27 -0
  227. package/dist/services/level-height.d.ts.map +1 -0
  228. package/dist/services/level-height.js +94 -0
  229. package/dist/services/opening-guides.d.ts +141 -0
  230. package/dist/services/opening-guides.d.ts.map +1 -0
  231. package/dist/services/opening-guides.js +267 -0
  232. package/dist/services/port-connectivity.d.ts +115 -0
  233. package/dist/services/port-connectivity.d.ts.map +1 -0
  234. package/dist/services/port-connectivity.js +300 -0
  235. package/dist/services/riser-diagram.d.ts +40 -0
  236. package/dist/services/riser-diagram.d.ts.map +1 -0
  237. package/dist/services/riser-diagram.js +110 -0
  238. package/dist/services/snap.d.ts +9 -1
  239. package/dist/services/snap.d.ts.map +1 -1
  240. package/dist/services/snap.js +21 -1
  241. package/dist/services/storey.d.ts +103 -0
  242. package/dist/services/storey.d.ts.map +1 -0
  243. package/dist/services/storey.js +296 -0
  244. package/dist/services/system-graph.d.ts +30 -0
  245. package/dist/services/system-graph.d.ts.map +1 -0
  246. package/dist/services/system-graph.js +164 -0
  247. package/dist/services/validate-dwv.d.ts +32 -0
  248. package/dist/services/validate-dwv.d.ts.map +1 -0
  249. package/dist/services/validate-dwv.js +118 -0
  250. package/dist/store/actions/node-actions.d.ts.map +1 -1
  251. package/dist/store/actions/node-actions.js +141 -4
  252. package/dist/store/history-control.d.ts +31 -0
  253. package/dist/store/history-control.d.ts.map +1 -1
  254. package/dist/store/history-control.js +130 -0
  255. package/dist/store/use-live-terrain.d.ts +65 -0
  256. package/dist/store/use-live-terrain.d.ts.map +1 -0
  257. package/dist/store/use-live-terrain.js +31 -0
  258. package/dist/store/use-live-transforms.d.ts +8 -0
  259. package/dist/store/use-live-transforms.d.ts.map +1 -1
  260. package/dist/store/use-scene.d.ts +47 -3
  261. package/dist/store/use-scene.d.ts.map +1 -1
  262. package/dist/store/use-scene.js +992 -55
  263. package/dist/systems/elevator/elevator-opening-system.d.ts +1 -0
  264. package/dist/systems/elevator/elevator-opening-system.d.ts.map +1 -1
  265. package/dist/systems/elevator/elevator-opening-system.js +27 -21
  266. package/dist/systems/elevator/elevator-service.d.ts +0 -2
  267. package/dist/systems/elevator/elevator-service.d.ts.map +1 -1
  268. package/dist/systems/elevator/elevator-service.js +2 -24
  269. package/dist/systems/fence/fence-centerline.d.ts +12 -0
  270. package/dist/systems/fence/fence-centerline.d.ts.map +1 -0
  271. package/dist/systems/fence/fence-centerline.js +37 -0
  272. package/dist/systems/fence/fence-spline.d.ts +39 -0
  273. package/dist/systems/fence/fence-spline.d.ts.map +1 -0
  274. package/dist/systems/fence/fence-spline.js +196 -0
  275. package/dist/systems/slab/slab-placement.d.ts +11 -0
  276. package/dist/systems/slab/slab-placement.d.ts.map +1 -0
  277. package/dist/systems/slab/slab-placement.js +14 -0
  278. package/dist/systems/slab/slab-support.d.ts +137 -0
  279. package/dist/systems/slab/slab-support.d.ts.map +1 -0
  280. package/dist/systems/slab/slab-support.js +557 -0
  281. package/dist/systems/stair/stair-footprint.d.ts.map +1 -1
  282. package/dist/systems/stair/stair-footprint.js +21 -11
  283. package/dist/systems/stair/stair-opening-preview.d.ts +1300 -505
  284. package/dist/systems/stair/stair-opening-preview.d.ts.map +1 -1
  285. package/dist/systems/stair/stair-opening-sync.d.ts.map +1 -1
  286. package/dist/systems/stair/stair-opening-sync.js +19 -33
  287. package/dist/systems/stair/stair-opening-system.d.ts.map +1 -1
  288. package/dist/systems/stair/stair-opening-system.js +32 -4
  289. package/dist/systems/stair/stair-rise.d.ts +22 -0
  290. package/dist/systems/stair/stair-rise.d.ts.map +1 -0
  291. package/dist/systems/stair/stair-rise.js +79 -0
  292. package/dist/systems/wall/wall-curve.d.ts +10 -0
  293. package/dist/systems/wall/wall-curve.d.ts.map +1 -1
  294. package/dist/systems/wall/wall-curve.js +1 -1
  295. package/dist/systems/wall/wall-mitering.d.ts.map +1 -1
  296. package/dist/systems/wall/wall-mitering.js +44 -8
  297. package/dist/systems/wall/wall-top.d.ts +40 -0
  298. package/dist/systems/wall/wall-top.d.ts.map +1 -0
  299. package/dist/systems/wall/wall-top.js +46 -0
  300. package/dist/utils/clone-scene-graph.d.ts +1 -0
  301. package/dist/utils/clone-scene-graph.d.ts.map +1 -1
  302. package/dist/utils/clone-scene-graph.js +56 -5
  303. package/dist/utils/heal-scene-graph.d.ts +18 -0
  304. package/dist/utils/heal-scene-graph.d.ts.map +1 -0
  305. package/dist/utils/heal-scene-graph.js +106 -0
  306. package/dist/validation/validate-build-json.d.ts +3 -0
  307. package/dist/validation/validate-build-json.d.ts.map +1 -1
  308. package/dist/validation/validate-build-json.js +90 -5
  309. package/package.json +4 -4
  310. package/dist/hooks/spatial-grid/floor-placed-elevation.test.d.ts +0 -2
  311. package/dist/hooks/spatial-grid/floor-placed-elevation.test.d.ts.map +0 -1
  312. package/dist/hooks/spatial-grid/floor-placed-elevation.test.js +0 -273
  313. package/dist/lib/space-detection-pause.test.d.ts +0 -2
  314. package/dist/lib/space-detection-pause.test.d.ts.map +0 -1
  315. package/dist/lib/space-detection-pause.test.js +0 -42
  316. package/dist/lib/space-detection.test.d.ts +0 -2
  317. package/dist/lib/space-detection.test.d.ts.map +0 -1
  318. package/dist/lib/space-detection.test.js +0 -77
  319. package/dist/registry/registry.test.d.ts +0 -2
  320. package/dist/registry/registry.test.d.ts.map +0 -1
  321. package/dist/registry/registry.test.js +0 -183
  322. package/dist/registry/relations-resolver.test.d.ts +0 -2
  323. package/dist/registry/relations-resolver.test.d.ts.map +0 -1
  324. package/dist/registry/relations-resolver.test.js +0 -183
  325. package/dist/registry/scene-api.test.d.ts +0 -2
  326. package/dist/registry/scene-api.test.d.ts.map +0 -1
  327. package/dist/registry/scene-api.test.js +0 -183
  328. package/dist/registry/subtree.test.d.ts +0 -2
  329. package/dist/registry/subtree.test.d.ts.map +0 -1
  330. package/dist/registry/subtree.test.js +0 -133
  331. package/dist/schema/asset-url.test.d.ts +0 -2
  332. package/dist/schema/asset-url.test.d.ts.map +0 -1
  333. package/dist/schema/asset-url.test.js +0 -134
  334. package/dist/services/alignment-anchors.test.d.ts +0 -2
  335. package/dist/services/alignment-anchors.test.d.ts.map +0 -1
  336. package/dist/services/alignment-anchors.test.js +0 -383
  337. package/dist/services/alignment.test.d.ts +0 -2
  338. package/dist/services/alignment.test.d.ts.map +0 -1
  339. package/dist/services/alignment.test.js +0 -92
  340. package/dist/services/drag-session.test.d.ts +0 -2
  341. package/dist/services/drag-session.test.d.ts.map +0 -1
  342. package/dist/services/drag-session.test.js +0 -219
  343. package/dist/services/hosting.test.d.ts +0 -2
  344. package/dist/services/hosting.test.d.ts.map +0 -1
  345. package/dist/services/hosting.test.js +0 -199
  346. package/dist/services/movement.test.d.ts +0 -2
  347. package/dist/services/movement.test.d.ts.map +0 -1
  348. package/dist/services/movement.test.js +0 -133
  349. package/dist/services/single-undo-dance.test.d.ts +0 -2
  350. package/dist/services/single-undo-dance.test.d.ts.map +0 -1
  351. package/dist/services/single-undo-dance.test.js +0 -210
  352. package/dist/services/snap.test.d.ts +0 -2
  353. package/dist/services/snap.test.d.ts.map +0 -1
  354. package/dist/services/snap.test.js +0 -95
  355. package/dist/store/actions/node-mutation-sanitize.test.d.ts +0 -2
  356. package/dist/store/actions/node-mutation-sanitize.test.d.ts.map +0 -1
  357. package/dist/store/actions/node-mutation-sanitize.test.js +0 -147
  358. package/dist/store/actions/reparent.test.d.ts +0 -2
  359. package/dist/store/actions/reparent.test.d.ts.map +0 -1
  360. package/dist/store/actions/reparent.test.js +0 -212
  361. package/dist/store/use-scene-elevator-migration.test.d.ts +0 -2
  362. package/dist/store/use-scene-elevator-migration.test.d.ts.map +0 -1
  363. package/dist/store/use-scene-elevator-migration.test.js +0 -109
  364. package/dist/systems/elevator/elevator-opening-sync.test.d.ts +0 -2
  365. package/dist/systems/elevator/elevator-opening-sync.test.d.ts.map +0 -1
  366. package/dist/systems/elevator/elevator-opening-sync.test.js +0 -146
  367. package/dist/systems/elevator/elevator-runtime.test.d.ts +0 -2
  368. package/dist/systems/elevator/elevator-runtime.test.d.ts.map +0 -1
  369. package/dist/systems/elevator/elevator-runtime.test.js +0 -64
  370. package/dist/systems/stair/stair-opening-preview.test.d.ts +0 -2
  371. package/dist/systems/stair/stair-opening-preview.test.d.ts.map +0 -1
  372. package/dist/systems/stair/stair-opening-preview.test.js +0 -80
  373. package/dist/systems/stair/stair-opening-sync.test.d.ts +0 -2
  374. package/dist/systems/stair/stair-opening-sync.test.d.ts.map +0 -1
  375. package/dist/systems/stair/stair-opening-sync.test.js +0 -446
  376. package/dist/utils/clone-scene-graph.test.d.ts +0 -2
  377. package/dist/utils/clone-scene-graph.test.d.ts.map +0 -1
  378. package/dist/utils/clone-scene-graph.test.js +0 -59
@@ -1,2 +1,3 @@
1
+ export declare function initializeElevatorOpeningSync(): () => void;
1
2
  export declare const ElevatorOpeningSystem: () => null;
2
3
  //# sourceMappingURL=elevator-opening-system.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"elevator-opening-system.d.ts","sourceRoot":"","sources":["../../../src/systems/elevator/elevator-opening-system.tsx"],"names":[],"mappings":"AAkCA,eAAO,MAAM,qBAAqB,YAuBjC,CAAA"}
1
+ {"version":3,"file":"elevator-opening-system.d.ts","sourceRoot":"","sources":["../../../src/systems/elevator/elevator-opening-system.tsx"],"names":[],"mappings":"AAmCA,wBAAgB,6BAA6B,eAsB5C;AAED,eAAO,MAAM,qBAAqB,YAIjC,CAAA"}
@@ -1,5 +1,6 @@
1
1
  'use client';
2
- import { useEffect, useRef } from 'react';
2
+ import { useEffect } from 'react';
3
+ import { pauseSceneHistory, resumeSceneHistory } from '../../store/history-control';
3
4
  import useScene from '../../store/use-scene';
4
5
  import { syncAutoElevatorOpenings } from './elevator-opening-sync';
5
6
  function isOpeningRelevantNode(node) {
@@ -23,26 +24,31 @@ function hasOpeningRelevantNodeChange(nextNodes, prevNodes) {
23
24
  }
24
25
  return false;
25
26
  }
26
- export const ElevatorOpeningSystem = () => {
27
- const syncingAutoOpeningsRef = useRef(false);
28
- useEffect(() => {
29
- const applyUpdates = (updates) => {
30
- if (updates.length === 0)
31
- return;
32
- syncingAutoOpeningsRef.current = true;
27
+ export function initializeElevatorOpeningSync() {
28
+ let syncingAutoOpenings = false;
29
+ const applyUpdates = (updates) => {
30
+ if (updates.length === 0)
31
+ return;
32
+ syncingAutoOpenings = true;
33
+ pauseSceneHistory(useScene);
34
+ try {
33
35
  useScene.getState().updateNodes(updates);
34
- queueMicrotask(() => {
35
- syncingAutoOpeningsRef.current = false;
36
- });
37
- };
38
- applyUpdates(syncAutoElevatorOpenings(useScene.getState().nodes));
39
- return useScene.subscribe((state, prevState) => {
40
- if (syncingAutoOpeningsRef.current)
41
- return;
42
- if (!hasOpeningRelevantNodeChange(state.nodes, prevState.nodes))
43
- return;
44
- applyUpdates(syncAutoElevatorOpenings(state.nodes));
45
- });
46
- }, []);
36
+ }
37
+ finally {
38
+ resumeSceneHistory(useScene);
39
+ syncingAutoOpenings = false;
40
+ }
41
+ };
42
+ applyUpdates(syncAutoElevatorOpenings(useScene.getState().nodes));
43
+ return useScene.subscribe((state, prevState) => {
44
+ if (syncingAutoOpenings)
45
+ return;
46
+ if (!hasOpeningRelevantNodeChange(state.nodes, prevState.nodes))
47
+ return;
48
+ applyUpdates(syncAutoElevatorOpenings(state.nodes));
49
+ });
50
+ }
51
+ export const ElevatorOpeningSystem = () => {
52
+ useEffect(() => initializeElevatorOpeningSync(), []);
47
53
  return null;
48
54
  };
@@ -1,5 +1,4 @@
1
1
  import type { AnyNode, ElevatorNode, LevelNode } from '../../schema';
2
- export declare const DEFAULT_ELEVATOR_LEVEL_HEIGHT = 2.5;
3
2
  export type ElevatorLevelEntry = {
4
3
  id: LevelNode['id'];
5
4
  label: string;
@@ -8,7 +7,6 @@ export type ElevatorLevelEntry = {
8
7
  export declare function resolveElevatorBuildingLevels(elevator: ElevatorNode, nodes: Record<string, AnyNode>): LevelNode[];
9
8
  export declare function resolveElevatorServiceLevelIds(elevator: ElevatorNode, nodes: Record<string, AnyNode>): string[];
10
9
  export declare function resolveElevatorServiceLevels(elevator: ElevatorNode, nodes: Record<string, AnyNode>): LevelNode[];
11
- export declare function getElevatorLevelHeight(levelId: string, nodes: Record<string, AnyNode>): number;
12
10
  export declare function resolveElevatorLevels(elevator: ElevatorNode, nodes: Record<string, AnyNode>): {
13
11
  entries: ElevatorLevelEntry[];
14
12
  defaultEntry: ElevatorLevelEntry | null;
@@ -1 +1 @@
1
- {"version":3,"file":"elevator-service.d.ts","sourceRoot":"","sources":["../../../src/systems/elevator/elevator-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAGP,YAAY,EACZ,SAAS,EAEV,MAAM,cAAc,CAAA;AAErB,eAAO,MAAM,6BAA6B,MAAM,CAAA;AAEhD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,EAAE,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AA2BD,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,SAAS,EAAE,CAEb;AAED,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,YAAY,EACt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EAAE,YAAY,EACtB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,SAAS,EAAE,CAsBb;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B;IACD,OAAO,EAAE,kBAAkB,EAAE,CAAA;IAC7B,YAAY,EAAE,kBAAkB,GAAG,IAAI,CAAA;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;CACpB,CA0CA"}
@@ -1,4 +1,4 @@
1
- export const DEFAULT_ELEVATOR_LEVEL_HEIGHT = 2.5;
1
+ import { getStoredLevelHeight } from '../../services/storey';
2
2
  function getBuildingLevels(elevator, nodes) {
3
3
  const building = elevator.parentId && nodes[elevator.parentId]?.type === 'building'
4
4
  ? nodes[elevator.parentId]
@@ -49,35 +49,13 @@ export function resolveElevatorServiceLevels(elevator, nodes) {
49
49
  const maxIndex = Math.max(fromIndex, resolvedToIndex);
50
50
  return levels.slice(minIndex, maxIndex + 1);
51
51
  }
52
- export function getElevatorLevelHeight(levelId, nodes) {
53
- const level = nodes[levelId];
54
- if (!level || level.type !== 'level')
55
- return DEFAULT_ELEVATOR_LEVEL_HEIGHT;
56
- let maxTop = 0;
57
- for (const childId of level.children) {
58
- const child = nodes[childId];
59
- if (!child)
60
- continue;
61
- if (child.type === 'ceiling') {
62
- const height = child.height ?? DEFAULT_ELEVATOR_LEVEL_HEIGHT;
63
- if (height > maxTop)
64
- maxTop = height;
65
- }
66
- else if (child.type === 'wall') {
67
- const height = child.height ?? DEFAULT_ELEVATOR_LEVEL_HEIGHT;
68
- if (height > maxTop)
69
- maxTop = height;
70
- }
71
- }
72
- return maxTop > 0 ? maxTop : DEFAULT_ELEVATOR_LEVEL_HEIGHT;
73
- }
74
52
  export function resolveElevatorLevels(elevator, nodes) {
75
53
  const allLevels = resolveElevatorBuildingLevels(elevator, nodes);
76
54
  const baseYByLevelId = new Map();
77
55
  let cumulativeY = 0;
78
56
  for (const level of allLevels) {
79
57
  baseYByLevelId.set(level.id, cumulativeY);
80
- cumulativeY += getElevatorLevelHeight(level.id, nodes);
58
+ cumulativeY += getStoredLevelHeight(level);
81
59
  }
82
60
  const serviceLevels = resolveElevatorServiceLevels(elevator, nodes);
83
61
  const entries = serviceLevels.map((level) => ({
@@ -0,0 +1,12 @@
1
+ import type { FenceNode } from '../../schema';
2
+ import type { Point2D } from '../wall/wall-mitering';
3
+ type CurveFrame = {
4
+ point: Point2D;
5
+ tangent: Point2D;
6
+ normal: Point2D;
7
+ };
8
+ export declare function getFenceCenterlineFrameAt(fence: FenceNode, t: number): CurveFrame;
9
+ export declare function sampleFenceCenterline(fence: FenceNode, segments?: number): Point2D[];
10
+ export declare function getFenceCenterlineLength(fence: FenceNode, segments?: number): number;
11
+ export {};
12
+ //# sourceMappingURL=fence-centerline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fence-centerline.d.ts","sourceRoot":"","sources":["../../../src/systems/fence/fence-centerline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAqBpD,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,OAAO,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU,CAKjF;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,SAAS,EAChB,QAAQ,SAA0B,GACjC,OAAO,EAAE,CASX;AAED,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,SAAS,EAChB,QAAQ,SAA0B,GACjC,MAAM,CAOR"}
@@ -0,0 +1,37 @@
1
+ import { getWallCurveFrameAt, getWallCurveLength, sampleWallCenterline } from '../wall/wall-curve';
2
+ import { getFenceSplineFrameAt, getFenceSplineLength, isSplineFence, sampleFenceSpline, } from './fence-spline';
3
+ /**
4
+ * Unified fence centerline accessors. A fence is either:
5
+ * - a spline fence (`path` of >= 2 control points) → smooth Catmull-Rom, or
6
+ * - a straight / single-arc fence (`start`/`end` + optional `curveOffset`).
7
+ *
8
+ * These wrappers branch on `isSplineFence` and return the SAME shapes the wall
9
+ * arc helpers return, so every consumer (3D geometry, 2D floor-plan, length,
10
+ * handles) can sample the centerline without caring which kind it is. Wall arc
11
+ * math in `wall-curve.ts` is untouched — walls never carry a `path`.
12
+ */
13
+ const DEFAULT_SAMPLE_SEGMENTS = 96;
14
+ export function getFenceCenterlineFrameAt(fence, t) {
15
+ if (isSplineFence(fence) && fence.path) {
16
+ return getFenceSplineFrameAt(fence.path, t, fence.tangents);
17
+ }
18
+ return getWallCurveFrameAt(fence, t);
19
+ }
20
+ export function sampleFenceCenterline(fence, segments = DEFAULT_SAMPLE_SEGMENTS) {
21
+ if (isSplineFence(fence) && fence.path) {
22
+ // Spread the requested sample budget across the spans so a long path still
23
+ // reads smoothly without exploding the point count.
24
+ const spanCount = Math.max(1, fence.path.length - 1);
25
+ const perSpan = Math.max(2, Math.ceil(segments / spanCount));
26
+ return sampleFenceSpline(fence.path, fence.tangents, perSpan);
27
+ }
28
+ return sampleWallCenterline(fence, segments);
29
+ }
30
+ export function getFenceCenterlineLength(fence, segments = DEFAULT_SAMPLE_SEGMENTS) {
31
+ if (isSplineFence(fence) && fence.path) {
32
+ const spanCount = Math.max(1, fence.path.length - 1);
33
+ const perSpan = Math.max(2, Math.ceil(segments / spanCount));
34
+ return getFenceSplineLength(fence.path, fence.tangents, perSpan);
35
+ }
36
+ return getWallCurveLength(fence, segments);
37
+ }
@@ -0,0 +1,39 @@
1
+ import type { FenceNode } from '../../schema';
2
+ import type { Point2D } from '../wall/wall-mitering';
3
+ type FenceSplineLike = Pick<FenceNode, 'path'>;
4
+ type TangentList = ReadonlyArray<readonly [number, number] | null> | undefined;
5
+ export declare function isSplineFence(fence: FenceSplineLike): boolean;
6
+ type CurveFrame = {
7
+ point: Point2D;
8
+ tangent: Point2D;
9
+ normal: Point2D;
10
+ };
11
+ /**
12
+ * OUT-handle offset vector for control point `index` — the stored tangent if
13
+ * the user has adjusted it, otherwise the automatic distance-aware tangent
14
+ * (endpoints duplicate the neighbour so the ends stay tangent to their single
15
+ * span). The IN handle is the negation of this.
16
+ *
17
+ * Exported so the editing UI can draw the tangent line / handle dots at the
18
+ * right place even before the user has dragged them.
19
+ */
20
+ export declare function getFenceControlHandle(path: ReadonlyArray<readonly [number, number]>, tangents: TangentList, index: number): Point2D;
21
+ export declare function getTwoPointFenceCurveTangents(path: ReadonlyArray<readonly [number, number]>): Array<[number, number] | null> | undefined;
22
+ /**
23
+ * Sample the spline centerline into a polyline. Control points are honored as
24
+ * on-curve anchors; `segmentsPerSpan` controls smoothness between them.
25
+ * Returns `(segmentsPerSpan * spanCount) + 1` points, first == path[0],
26
+ * last == path[-1].
27
+ */
28
+ export declare function sampleFenceSpline(path: ReadonlyArray<readonly [number, number]>, tangents?: TangentList, segmentsPerSpan?: number): Point2D[];
29
+ /**
30
+ * Frame (point + tangent + normal) at parameter `t` in [0, 1] along the spline
31
+ * centerline. Same return shape as `getWallCurveFrameAt` so it is a drop-in for
32
+ * the arc branch. `t` is uniform over the sampled polyline (arc length is not
33
+ * reparameterised — adequate for marching posts / rails and far cheaper).
34
+ */
35
+ export declare function getFenceSplineFrameAt(path: ReadonlyArray<readonly [number, number]>, t: number, tangents?: TangentList, segmentsPerSpan?: number): CurveFrame;
36
+ /** Total polyline length of the sampled spline centerline. */
37
+ export declare function getFenceSplineLength(path: ReadonlyArray<readonly [number, number]>, tangents?: TangentList, segmentsPerSpan?: number): number;
38
+ export {};
39
+ //# sourceMappingURL=fence-spline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3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AAC,EAAE,MAAM,EACT,QAAQ,CAAC,EAAE,WAAW,EACtB,eAAe,SAA4B,GAC1C,UAAU,CAEZ;AAED,8DAA8D;AAC9D,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC9C,QAAQ,CAAC,EAAE,WAAW,EACtB,eAAe,SAA4B,GAC1C,MAAM,CAOR"}
@@ -0,0 +1,196 @@
1
+ /**
2
+ * Pure 2D spline sampling for fences whose centerline is defined by a `path`
3
+ * of control points (the "flying path" curved fence).
4
+ *
5
+ * Each control point carries an OUT-handle offset vector. When the user has
6
+ * not adjusted it, the handle defaults to a distance-aware Catmull-Rom-style
7
+ * tangent: direction comes from neighbouring points, while length is capped by
8
+ * the shorter adjacent span. When the user drags a tangent handle (stored in
9
+ * `tangents[i]`), that point's handle becomes the stored vector and the IN
10
+ * handle is its mirror, so the curve stays smooth (C1) through the point but
11
+ * bends to taste. Each span is then a cubic Bézier between consecutive points
12
+ * using their handles.
13
+ *
14
+ * Lives in `@pascal-app/core` and imports NO Three.js — the same `CurveFrame`
15
+ * shape that `wall-curve.ts` returns (point / tangent / normal) is produced
16
+ * here so the spline branch is a drop-in for the arc branch in every consumer.
17
+ */
18
+ const EPSILON = 1e-6;
19
+ const DEFAULT_SEGMENTS_PER_SPAN = 32;
20
+ const TWO_POINT_CURVE_SAGITTA_RATIO = 0.18;
21
+ const TWO_POINT_CURVE_MIN_SAGITTA = 0.18;
22
+ const TWO_POINT_CURVE_MAX_SAGITTA = 1.2;
23
+ export function isSplineFence(fence) {
24
+ return Array.isArray(fence.path) && fence.path.length >= 2;
25
+ }
26
+ function toPoints(path) {
27
+ return path.map(([x, y]) => ({ x, y }));
28
+ }
29
+ function distance(a, b) {
30
+ return Math.hypot(b.x - a.x, b.y - a.y);
31
+ }
32
+ function clamp01(value) {
33
+ return Math.max(0, Math.min(1, value));
34
+ }
35
+ function clamp(value, min, max) {
36
+ return Math.max(min, Math.min(max, value));
37
+ }
38
+ /**
39
+ * OUT-handle offset vector for control point `index` — the stored tangent if
40
+ * the user has adjusted it, otherwise the automatic distance-aware tangent
41
+ * (endpoints duplicate the neighbour so the ends stay tangent to their single
42
+ * span). The IN handle is the negation of this.
43
+ *
44
+ * Exported so the editing UI can draw the tangent line / handle dots at the
45
+ * right place even before the user has dragged them.
46
+ */
47
+ export function getFenceControlHandle(path, tangents, index) {
48
+ const stored = tangents?.[index];
49
+ if (stored) {
50
+ return { x: stored[0], y: stored[1] };
51
+ }
52
+ const prev = path[index - 1] ?? path[index];
53
+ const next = path[index + 1] ?? path[index];
54
+ const prevDistance = distance({ x: path[index][0], y: path[index][1] }, {
55
+ x: prev[0],
56
+ y: prev[1],
57
+ });
58
+ const nextDistance = distance({ x: path[index][0], y: path[index][1] }, {
59
+ x: next[0],
60
+ y: next[1],
61
+ });
62
+ const handleLength = Math.min(prevDistance || nextDistance, nextDistance || prevDistance) / 3;
63
+ const vx = next[0] - prev[0];
64
+ const vy = next[1] - prev[1];
65
+ const len = Math.hypot(vx, vy);
66
+ if (len < EPSILON || handleLength < EPSILON) {
67
+ return { x: 0, y: 0 };
68
+ }
69
+ return {
70
+ x: (vx / len) * handleLength,
71
+ y: (vy / len) * handleLength,
72
+ };
73
+ }
74
+ export function getTwoPointFenceCurveTangents(path) {
75
+ if (path.length !== 2)
76
+ return undefined;
77
+ const start = path[0];
78
+ const end = path[1];
79
+ const dx = end[0] - start[0];
80
+ const dy = end[1] - start[1];
81
+ const chordLength = Math.hypot(dx, dy);
82
+ if (chordLength < EPSILON)
83
+ return undefined;
84
+ const tangentX = dx / 3;
85
+ const tangentY = dy / 3;
86
+ const normalX = -dy / chordLength;
87
+ const normalY = dx / chordLength;
88
+ const sagitta = clamp(chordLength * TWO_POINT_CURVE_SAGITTA_RATIO, TWO_POINT_CURVE_MIN_SAGITTA, TWO_POINT_CURVE_MAX_SAGITTA);
89
+ const bendX = normalX * sagitta * (4 / 3);
90
+ const bendY = normalY * sagitta * (4 / 3);
91
+ return [
92
+ [tangentX + bendX, tangentY + bendY],
93
+ [tangentX - bendX, tangentY - bendY],
94
+ ];
95
+ }
96
+ function cubicBezier(p0, p1, p2, p3, u) {
97
+ const mu = 1 - u;
98
+ const a = mu * mu * mu;
99
+ const b = 3 * mu * mu * u;
100
+ const c = 3 * mu * u * u;
101
+ const d = u * u * u;
102
+ return {
103
+ x: a * p0.x + b * p1.x + c * p2.x + d * p3.x,
104
+ y: a * p0.y + b * p1.y + c * p2.y + d * p3.y,
105
+ };
106
+ }
107
+ function hasAnyTangent(tangents) {
108
+ return Array.isArray(tangents) && tangents.some((t) => t != null);
109
+ }
110
+ /**
111
+ * Sample the spline centerline into a polyline. Control points are honored as
112
+ * on-curve anchors; `segmentsPerSpan` controls smoothness between them.
113
+ * Returns `(segmentsPerSpan * spanCount) + 1` points, first == path[0],
114
+ * last == path[-1].
115
+ */
116
+ export function sampleFenceSpline(path, tangents, segmentsPerSpan = DEFAULT_SEGMENTS_PER_SPAN) {
117
+ const pts = toPoints(path);
118
+ if (pts.length === 0)
119
+ return [];
120
+ if (pts.length === 1)
121
+ return [pts[0]];
122
+ // Two points with no adjusted tangents is a straight segment.
123
+ if (pts.length === 2 && !hasAnyTangent(tangents))
124
+ return [pts[0], pts[1]];
125
+ const steps = Math.max(1, Math.floor(segmentsPerSpan));
126
+ const result = [pts[0]];
127
+ for (let i = 0; i < pts.length - 1; i += 1) {
128
+ const p1 = pts[i];
129
+ const p2 = pts[i + 1];
130
+ const outHandle = getFenceControlHandle(path, tangents, i);
131
+ const nextHandle = getFenceControlHandle(path, tangents, i + 1);
132
+ // Bézier controls: leave p1 along its OUT handle, arrive at p2 along its
133
+ // IN handle (= negated OUT handle).
134
+ const c1 = { x: p1.x + outHandle.x, y: p1.y + outHandle.y };
135
+ const c2 = { x: p2.x - nextHandle.x, y: p2.y - nextHandle.y };
136
+ for (let s = 1; s <= steps; s += 1) {
137
+ result.push(cubicBezier(p1, c1, c2, p2, s / steps));
138
+ }
139
+ }
140
+ return result;
141
+ }
142
+ function frameFromPolyline(points, t) {
143
+ if (points.length === 0) {
144
+ return {
145
+ point: { x: 0, y: 0 },
146
+ tangent: { x: 1, y: 0 },
147
+ normal: { x: 0, y: 1 },
148
+ };
149
+ }
150
+ if (points.length === 1) {
151
+ return {
152
+ point: points[0],
153
+ tangent: { x: 1, y: 0 },
154
+ normal: { x: 0, y: 1 },
155
+ };
156
+ }
157
+ const clamped = clamp01(t);
158
+ const lastIndex = points.length - 1;
159
+ const scaled = clamped * lastIndex;
160
+ const lower = Math.min(lastIndex - 1, Math.floor(scaled));
161
+ const upper = lower + 1;
162
+ const localU = scaled - lower;
163
+ const a = points[lower];
164
+ const b = points[upper];
165
+ const point = {
166
+ x: a.x + (b.x - a.x) * localU,
167
+ y: a.y + (b.y - a.y) * localU,
168
+ };
169
+ const dx = b.x - a.x;
170
+ const dy = b.y - a.y;
171
+ const len = Math.hypot(dx, dy);
172
+ const tangent = len < EPSILON ? { x: 1, y: 0 } : { x: dx / len, y: dy / len };
173
+ return {
174
+ point,
175
+ tangent,
176
+ normal: { x: -tangent.y, y: tangent.x },
177
+ };
178
+ }
179
+ /**
180
+ * Frame (point + tangent + normal) at parameter `t` in [0, 1] along the spline
181
+ * centerline. Same return shape as `getWallCurveFrameAt` so it is a drop-in for
182
+ * the arc branch. `t` is uniform over the sampled polyline (arc length is not
183
+ * reparameterised — adequate for marching posts / rails and far cheaper).
184
+ */
185
+ export function getFenceSplineFrameAt(path, t, tangents, segmentsPerSpan = DEFAULT_SEGMENTS_PER_SPAN) {
186
+ return frameFromPolyline(sampleFenceSpline(path, tangents, segmentsPerSpan), t);
187
+ }
188
+ /** Total polyline length of the sampled spline centerline. */
189
+ export function getFenceSplineLength(path, tangents, segmentsPerSpan = DEFAULT_SEGMENTS_PER_SPAN) {
190
+ const points = sampleFenceSpline(path, tangents, segmentsPerSpan);
191
+ let total = 0;
192
+ for (let i = 1; i < points.length; i += 1) {
193
+ total += distance(points[i - 1], points[i]);
194
+ }
195
+ return total;
196
+ }
@@ -0,0 +1,11 @@
1
+ import type { SlabNode } from '../../schema';
2
+ /**
3
+ * Translate a solid slab's authored vertical interval onto a chosen base plane.
4
+ *
5
+ * `slab.elevation` is the authored top relative to the placement plane and
6
+ * `thickness` grows downward. Adding the base therefore preserves both the
7
+ * thickness and any intentional clearance in a preset. Recessed slabs keep
8
+ * their level-relative depth because their rim is defined by the level plane.
9
+ */
10
+ export declare function resolveSlabPlacementElevation(slab: Pick<SlabNode, 'elevation' | 'recessed'>, baseElevation: number | null | undefined): number;
11
+ //# sourceMappingURL=slab-placement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slab-placement.d.ts","sourceRoot":"","sources":["../../../src/systems/slab/slab-placement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE5C;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,WAAW,GAAG,UAAU,CAAC,EAC9C,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACvC,MAAM,CAKR"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Translate a solid slab's authored vertical interval onto a chosen base plane.
3
+ *
4
+ * `slab.elevation` is the authored top relative to the placement plane and
5
+ * `thickness` grows downward. Adding the base therefore preserves both the
6
+ * thickness and any intentional clearance in a preset. Recessed slabs keep
7
+ * their level-relative depth because their rim is defined by the level plane.
8
+ */
9
+ export function resolveSlabPlacementElevation(slab, baseElevation) {
10
+ if (slab.recessed || baseElevation == null || !Number.isFinite(baseElevation)) {
11
+ return slab.elevation;
12
+ }
13
+ return slab.elevation + baseElevation;
14
+ }
@@ -0,0 +1,137 @@
1
+ import type { SlabNode, WallNode } from '../../schema';
2
+ export type SlabElevationClamp = {
3
+ elevation: number;
4
+ clamped: boolean;
5
+ };
6
+ /**
7
+ * Clamp-never-ask upper bound for a slab's elevation. A plane-bound wall
8
+ * (no stored `height`) keeps its top at the storey plane, so a slab that
9
+ * rises past `storeyHeight - MIN_WALL_HEIGHT` while electing as that
10
+ * wall's base would squeeze the wall body below its minimum (and at the
11
+ * plane, to nothing). Walls with explicit heights don't constrain — their
12
+ * top rides the elected base, not the plane. Negative proposals (the
13
+ * drag-through-zero path that commits the `recessed` intent) pass
14
+ * through untouched: this is a purely numeric upper bound.
15
+ *
16
+ * The election runs against `levelSlabs` with `proposedElevation`
17
+ * substituted into `slab`, so a slab that would only WIN the election at
18
+ * the proposed elevation still clamps, and a slab out-elected by a
19
+ * sibling doesn't. Pure.
20
+ */
21
+ export declare function clampSlabElevationForWalls(proposedElevation: number, slab: SlabNode, levelWalls: WallNode[], levelSlabs: readonly SlabNode[], storeyHeight: number): SlabElevationClamp;
22
+ /**
23
+ * Static upper bound for a slab-elevation drag: probe the election with
24
+ * the slab raised above every sibling and the storey plane. If any
25
+ * plane-bound wall would elect it there, the drag may not pass
26
+ * `storeyHeight - MIN_WALL_HEIGHT`; otherwise it is unbounded above.
27
+ */
28
+ export declare function getSlabElevationUpperBound(slab: SlabNode, levelWalls: WallNode[], levelSlabs: readonly SlabNode[], storeyHeight: number): number;
29
+ /**
30
+ * Point-in-polygon test using ray casting algorithm.
31
+ */
32
+ export declare function pointInPolygon(px: number, pz: number, polygon: Array<[number, number]>): boolean;
33
+ export declare function pointOnPolygonBoundary(px: number, pz: number, polygon: Array<[number, number]>): boolean;
34
+ export type WallOverlapInput = {
35
+ start: [number, number];
36
+ end: [number, number];
37
+ curveOffset?: number;
38
+ thickness?: number;
39
+ };
40
+ /**
41
+ * Test whether a wall overlaps a slab polygon along a segment of its length.
42
+ *
43
+ * The wall's centerline and both face lines are clipped against the polygon;
44
+ * the wall overlaps when the longest clipped inside-or-on-boundary length
45
+ * exceeds a threshold (5cm, halved for very short walls). Because interval
46
+ * midpoints classify "on the boundary" as inside explicitly (never by
47
+ * ray-cast tie-breaking), a wall sitting exactly on a slab edge resolves
48
+ * identically on every side of the slab.
49
+ *
50
+ * A wall that only touches the polygon at a point — a perpendicular wall
51
+ * butting into a room's edge, or a corner-to-corner touch — clips to ~zero
52
+ * length and does NOT overlap.
53
+ */
54
+ export declare function wallOverlapsPolygon(startOrWall: [number, number] | WallOverlapInput, endOrPolygon: [number, number] | Array<[number, number]>, polygonArg?: Array<[number, number]>): boolean;
55
+ /**
56
+ * {@link wallOverlapsPolygon} with the slab's stored holes subtracted from
57
+ * the covered length: a wall whose band only reaches the polygon inside a
58
+ * hole does not overlap. Hole boundaries keep coverage (rim convention —
59
+ * see {@link computeWallSlabSupport}). Polygon boundary contact counts as
60
+ * covered, so a wall sitting exactly on a slab edge resolves identically
61
+ * on every side of the slab. Pure.
62
+ */
63
+ export declare function wallOverlapsSlabFootprint(wallLike: WallOverlapInput, polygon: Array<[number, number]>, holes?: ReadonlyArray<Array<[number, number]>>): boolean;
64
+ /**
65
+ * Tolerance for the pointer-decided support cap: a slab still counts as
66
+ * "the surface you're pointing at (or below)" when its walking surface is
67
+ * within this many meters ABOVE the pointed elevation. Absorbs elevation
68
+ * noise between the ray hit and slab tops without letting a deck hanging
69
+ * clearly above the hit point capture the election. Defined here (rather
70
+ * than in the spatial-grid manager, which re-exports it) so the wall
71
+ * election below can honour the same cap without an import cycle.
72
+ */
73
+ export declare const SUPPORT_ELEVATION_EPSILON = 0.05;
74
+ /**
75
+ * Base elevation for a wall, decided by which slabs actually SUPPORT it.
76
+ *
77
+ * Support is measured as covered length: the wall's centerline and face
78
+ * lines are clipped against each slab's RENDERED footprint
79
+ * (`getRenderableSlabPolygon` with the level walls + siblings, not the
80
+ * stored polygon — legacy polygons stored at wall faces or with old
81
+ * baked offsets fall short of the wall body, but their band-adopted
82
+ * rendered edge reaches the wall's outer face) minus the slab's stored
83
+ * holes (holes are data, never render-offset). A slab supporting less
84
+ * than `WALL_SLAB_MIN_OVERLAP` of the wall is ignored entirely (point
85
+ * contact, endpoint grazes).
86
+ *
87
+ * Same-elevation slabs pool their coverage. `elevation` is elected from
88
+ * the wall's carrying profile: per arc segment, the highest support on
89
+ * each face, then the min across supported faces — so a slab that only
90
+ * brushes one face (e.g. an elevated deck adjacent along the outer face)
91
+ * never lifts the wall origin. The highest carrying elevation covering
92
+ * at least `WALL_SLAB_SUPPORT_MAJORITY` of the wall wins, or the
93
+ * best-covered carrying elevation when none reaches majority.
94
+ * `baseElevation` only fills down
95
+ * where a lower support remains exposed on a wall face after higher,
96
+ * overlapping support is accounted for. Coincident floor/platform slabs
97
+ * therefore keep the wall on the platform, while slabs on opposite wall
98
+ * sides bridge correctly. A slab touching only one endpoint never enters
99
+ * either result. Pure;
100
+ * exported for tests.
101
+ */
102
+ export type WallSlabSupport = {
103
+ /** Existing wall-relative floor elevation used by hosted children and wall height. */
104
+ elevation: number;
105
+ /** Slab whose elevation won the election, or null when the wall has no support. */
106
+ electedSlabId: string | null;
107
+ /** Lowest exposed adjacent support; wall geometry fills down to this elevation. */
108
+ baseElevation: number;
109
+ /** Piecewise bottom elevation along the wall centerline, in normalized arc-length units. */
110
+ baseSegments: WallSlabSupportSegment[];
111
+ };
112
+ export type WallSlabSupportSegment = {
113
+ start: number;
114
+ end: number;
115
+ elevation: number;
116
+ };
117
+ /**
118
+ * `preferredSlabId` is a persisted support host (`wall.supportSlabId`):
119
+ * while that slab is still in the candidate set (still overlaps the wall
120
+ * band with enough covered length), the elected `elevation` is pinned to
121
+ * it instead of the majority/best-coverage election. `baseSegments` /
122
+ * `baseElevation` (fill-down) still derive from ALL supporting slabs
123
+ * unchanged. A preferred slab that no longer qualifies is silently
124
+ * ignored — deliberately never cleared here, so the host resumes if the
125
+ * slab's polygon returns (only slab deletion strips the stored field).
126
+ *
127
+ * `maxElevation` is the pointer-decided support cap (level-local Y, same
128
+ * semantics as the item election): when set, elevation groups whose
129
+ * walking surface sits above `maxElevation + SUPPORT_ELEVATION_EPSILON`
130
+ * are excluded from the majority/best election — a deck hanging above the
131
+ * surface the cursor ray actually hit never captures the elected base.
132
+ * `baseSegments` / `baseElevation` stay uncapped (geometry fill-down), and
133
+ * an explicit `preferredSlabId` still wins over the cap.
134
+ */
135
+ export declare function computeWallSlabSupport(wallLike: WallOverlapInput, slabs: readonly SlabNode[], levelWalls: WallNode[], preferredSlabId?: string | null, maxElevation?: number | null): WallSlabSupport;
136
+ export declare function computeWallSlabElevation(wallLike: WallOverlapInput, slabs: readonly SlabNode[], levelWalls: WallNode[]): number;
137
+ //# sourceMappingURL=slab-support.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slab-support.d.ts","sourceRoot":"","sources":["../../../src/systems/slab/slab-support.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAKtD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CACxC,iBAAiB,EAAE,MAAM,EACzB,IAAI,EAAE,QAAQ,EACd,UAAU,EAAE,QAAQ,EAAE,EACtB,UAAU,EAAE,SAAS,QAAQ,EAAE,EAC/B,YAAY,EAAE,MAAM,GACnB,kBAAkB,CA6BpB;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,QAAQ,EACd,UAAU,EAAE,QAAQ,EAAE,EACtB,UAAU,EAAE,SAAS,QAAQ,EAAE,EAC/B,YAAY,EAAE,MAAM,GACnB,MAAM,CAMR;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,OAAO,CAchG;AA0BD,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,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