@pascal-app/core 0.5.1 → 0.7.0

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 (134) hide show
  1. package/dist/events/bus.d.ts +74 -4
  2. package/dist/events/bus.d.ts.map +1 -1
  3. package/dist/events/bus.js +1 -1
  4. package/dist/hooks/scene-registry/scene-registry.d.ts +2 -0
  5. package/dist/hooks/scene-registry/scene-registry.d.ts.map +1 -1
  6. package/dist/hooks/scene-registry/scene-registry.js +2 -0
  7. package/dist/hooks/spatial-grid/spatial-grid-manager.d.ts.map +1 -1
  8. package/dist/hooks/spatial-grid/spatial-grid-manager.js +164 -6
  9. package/dist/hooks/spatial-grid/spatial-grid.d.ts +2 -0
  10. package/dist/hooks/spatial-grid/spatial-grid.d.ts.map +1 -1
  11. package/dist/hooks/spatial-grid/spatial-grid.js +43 -20
  12. package/dist/index.d.ts +9 -13
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +7 -11
  15. package/dist/lib/door-operation.d.ts +7 -0
  16. package/dist/lib/door-operation.d.ts.map +1 -0
  17. package/dist/lib/door-operation.js +25 -0
  18. package/dist/lib/polygon-geometry.d.ts +3 -0
  19. package/dist/lib/polygon-geometry.d.ts.map +1 -0
  20. package/dist/lib/polygon-geometry.js +90 -0
  21. package/dist/lib/slab-polygon.d.ts +3 -0
  22. package/dist/lib/slab-polygon.d.ts.map +1 -0
  23. package/dist/lib/slab-polygon.js +58 -0
  24. package/dist/lib/space-detection.d.ts +10 -17
  25. package/dist/lib/space-detection.d.ts.map +1 -1
  26. package/dist/lib/space-detection.js +666 -453
  27. package/dist/material-library.d.ts +20 -0
  28. package/dist/material-library.d.ts.map +1 -0
  29. package/dist/material-library.js +580 -0
  30. package/dist/schema/asset-url.d.ts +34 -0
  31. package/dist/schema/asset-url.d.ts.map +1 -0
  32. package/dist/schema/asset-url.js +79 -0
  33. package/dist/schema/asset-url.test.d.ts +2 -0
  34. package/dist/schema/asset-url.test.d.ts.map +1 -0
  35. package/dist/schema/asset-url.test.js +138 -0
  36. package/dist/schema/index.d.ts +14 -7
  37. package/dist/schema/index.d.ts.map +1 -1
  38. package/dist/schema/index.js +10 -7
  39. package/dist/schema/material.d.ts +112 -2
  40. package/dist/schema/material.d.ts.map +1 -1
  41. package/dist/schema/material.js +55 -1
  42. package/dist/schema/nodes/ceiling.d.ts +11 -1
  43. package/dist/schema/nodes/ceiling.d.ts.map +1 -1
  44. package/dist/schema/nodes/ceiling.js +6 -0
  45. package/dist/schema/nodes/column.d.ts +520 -0
  46. package/dist/schema/nodes/column.d.ts.map +1 -0
  47. package/dist/schema/nodes/column.js +385 -0
  48. package/dist/schema/nodes/door.d.ts +74 -1
  49. package/dist/schema/nodes/door.d.ts.map +1 -1
  50. package/dist/schema/nodes/door.js +39 -2
  51. package/dist/schema/nodes/fence.d.ts +34 -0
  52. package/dist/schema/nodes/fence.d.ts.map +1 -1
  53. package/dist/schema/nodes/fence.js +5 -0
  54. package/dist/schema/nodes/guide.d.ts +17 -0
  55. package/dist/schema/nodes/guide.d.ts.map +1 -1
  56. package/dist/schema/nodes/guide.js +11 -1
  57. package/dist/schema/nodes/item.d.ts +10 -2
  58. package/dist/schema/nodes/item.d.ts.map +1 -1
  59. package/dist/schema/nodes/item.js +18 -1
  60. package/dist/schema/nodes/level.d.ts +1 -1
  61. package/dist/schema/nodes/level.d.ts.map +1 -1
  62. package/dist/schema/nodes/level.js +6 -0
  63. package/dist/schema/nodes/roof-segment.d.ts +3 -1
  64. package/dist/schema/nodes/roof-segment.d.ts.map +1 -1
  65. package/dist/schema/nodes/roof-segment.js +1 -0
  66. package/dist/schema/nodes/roof.d.ts +108 -0
  67. package/dist/schema/nodes/roof.d.ts.map +1 -1
  68. package/dist/schema/nodes/roof.js +58 -2
  69. package/dist/schema/nodes/scan.d.ts.map +1 -1
  70. package/dist/schema/nodes/scan.js +2 -1
  71. package/dist/schema/nodes/site.d.ts +2 -1
  72. package/dist/schema/nodes/site.d.ts.map +1 -1
  73. package/dist/schema/nodes/slab.d.ts +11 -1
  74. package/dist/schema/nodes/slab.d.ts.map +1 -1
  75. package/dist/schema/nodes/slab.js +7 -0
  76. package/dist/schema/nodes/spawn.d.ts +24 -0
  77. package/dist/schema/nodes/spawn.d.ts.map +1 -0
  78. package/dist/schema/nodes/spawn.js +8 -0
  79. package/dist/schema/nodes/stair-segment.d.ts +3 -1
  80. package/dist/schema/nodes/stair-segment.d.ts.map +1 -1
  81. package/dist/schema/nodes/stair-segment.js +1 -0
  82. package/dist/schema/nodes/stair.d.ts +122 -2
  83. package/dist/schema/nodes/stair.d.ts.map +1 -1
  84. package/dist/schema/nodes/stair.js +72 -2
  85. package/dist/schema/nodes/surface-hole-metadata.d.ts +10 -0
  86. package/dist/schema/nodes/surface-hole-metadata.d.ts.map +1 -0
  87. package/dist/schema/nodes/surface-hole-metadata.js +5 -0
  88. package/dist/schema/nodes/wall.d.ts +87 -1
  89. package/dist/schema/nodes/wall.d.ts.map +1 -1
  90. package/dist/schema/nodes/wall.js +45 -4
  91. package/dist/schema/nodes/window.d.ts +57 -1
  92. package/dist/schema/nodes/window.d.ts.map +1 -1
  93. package/dist/schema/nodes/window.js +29 -0
  94. package/dist/schema/types.d.ts +653 -12
  95. package/dist/schema/types.d.ts.map +1 -1
  96. package/dist/schema/types.js +4 -0
  97. package/dist/store/actions/node-actions.d.ts +1 -1
  98. package/dist/store/actions/node-actions.d.ts.map +1 -1
  99. package/dist/store/actions/node-actions.js +181 -5
  100. package/dist/store/history-control.d.ts +14 -0
  101. package/dist/store/history-control.d.ts.map +1 -0
  102. package/dist/store/history-control.js +22 -0
  103. package/dist/store/use-interactive.d.ts +43 -0
  104. package/dist/store/use-interactive.d.ts.map +1 -1
  105. package/dist/store/use-interactive.js +66 -0
  106. package/dist/store/use-scene.d.ts.map +1 -1
  107. package/dist/store/use-scene.js +307 -3
  108. package/dist/systems/ceiling/ceiling-system.d.ts.map +1 -1
  109. package/dist/systems/ceiling/ceiling-system.js +7 -0
  110. package/dist/systems/fence/fence-system.d.ts.map +1 -1
  111. package/dist/systems/fence/fence-system.js +106 -39
  112. package/dist/systems/roof/roof-system.d.ts.map +1 -1
  113. package/dist/systems/roof/roof-system.js +31 -1
  114. package/dist/systems/slab/slab-system.d.ts.map +1 -1
  115. package/dist/systems/slab/slab-system.js +45 -8
  116. package/dist/systems/stair/stair-opening-sync.d.ts +6 -0
  117. package/dist/systems/stair/stair-opening-sync.d.ts.map +1 -0
  118. package/dist/systems/stair/stair-opening-sync.js +576 -0
  119. package/dist/systems/stair/stair-opening-sync.test.d.ts +2 -0
  120. package/dist/systems/stair/stair-opening-sync.test.d.ts.map +1 -0
  121. package/dist/systems/stair/stair-opening-sync.test.js +65 -0
  122. package/dist/systems/stair/stair-system.d.ts.map +1 -1
  123. package/dist/systems/stair/stair-system.js +119 -2
  124. package/dist/systems/wall/wall-curve.d.ts +43 -0
  125. package/dist/systems/wall/wall-curve.d.ts.map +1 -0
  126. package/dist/systems/wall/wall-curve.js +176 -0
  127. package/dist/systems/wall/wall-footprint.d.ts.map +1 -1
  128. package/dist/systems/wall/wall-footprint.js +16 -2
  129. package/dist/systems/wall/wall-mitering.d.ts +7 -0
  130. package/dist/systems/wall/wall-mitering.d.ts.map +1 -1
  131. package/dist/systems/wall/wall-mitering.js +76 -3
  132. package/dist/systems/wall/wall-system.d.ts.map +1 -1
  133. package/dist/systems/wall/wall-system.js +202 -2
  134. package/package.json +33 -5
@@ -1,7 +1,14 @@
1
1
  import { useFrame } from '@react-three/fiber';
2
2
  import * as THREE from 'three';
3
3
  import { sceneRegistry } from '../../hooks/scene-registry/scene-registry';
4
+ import { insetPolygonFromCentroid, simplifyClosedPolygon } from '../../lib/polygon-geometry';
4
5
  import useScene from '../../store/use-scene';
6
+ function ensureUv2Attribute(geometry) {
7
+ const uv = geometry.getAttribute('uv');
8
+ if (!uv)
9
+ return;
10
+ geometry.setAttribute('uv2', new THREE.Float32BufferAttribute(Array.from(uv.array), 2));
11
+ }
5
12
  // ============================================================================
6
13
  // SLAB SYSTEM
7
14
  // ============================================================================
@@ -32,6 +39,7 @@ export const SlabSystem = () => {
32
39
  */
33
40
  function updateSlabGeometry(node, mesh) {
34
41
  const newGeo = generateSlabGeometry(node);
42
+ ensureUv2Attribute(newGeo);
35
43
  mesh.geometry.dispose();
36
44
  mesh.geometry = newGeo;
37
45
  // For negative elevation, shift the mesh down so the top face sits at Y=elevation
@@ -41,6 +49,13 @@ function updateSlabGeometry(node, mesh) {
41
49
  }
42
50
  /** Half of default wall thickness — used to extend slab geometry under walls */
43
51
  const SLAB_OUTSET = 0.05;
52
+ const AUTO_SLAB_INSET = 0.02;
53
+ const AUTO_SLAB_SIMPLIFY_TOLERANCE = 0.08;
54
+ function getRenderableSlabPolygon(slabNode) {
55
+ return slabNode.autoFromWalls
56
+ ? simplifyClosedPolygon(insetPolygonFromCentroid(slabNode.polygon, AUTO_SLAB_INSET), AUTO_SLAB_SIMPLIFY_TOLERANCE)
57
+ : outsetPolygon(slabNode.polygon, SLAB_OUTSET);
58
+ }
44
59
  /**
45
60
  * Expand a polygon outward by a uniform distance.
46
61
  * Offsets each edge outward then intersects consecutive offset edges.
@@ -100,7 +115,7 @@ export function generateSlabGeometry(slabNode) {
100
115
  * Standard slab: flat extrusion upward from Y=0 by elevation thickness.
101
116
  */
102
117
  function generatePositiveSlabGeometry(slabNode) {
103
- const polygon = outsetPolygon(slabNode.polygon, SLAB_OUTSET);
118
+ const polygon = getRenderableSlabPolygon(slabNode);
104
119
  const elevation = slabNode.elevation ?? 0.05;
105
120
  if (polygon.length < 3)
106
121
  return new THREE.BufferGeometry();
@@ -134,21 +149,41 @@ function generatePositiveSlabGeometry(slabNode) {
134
149
  * - walls from Y=0 to Y=depth, inward-facing normals (visible from inside pool)
135
150
  */
136
151
  function generatePoolGeometry(slabNode) {
137
- const polygon = outsetPolygon(slabNode.polygon, SLAB_OUTSET);
152
+ const polygon = getRenderableSlabPolygon(slabNode);
138
153
  const depth = Math.abs(slabNode.elevation ?? 0.05);
139
154
  if (polygon.length < 3)
140
155
  return new THREE.BufferGeometry();
141
156
  const positions = [];
157
+ const uvs = [];
142
158
  const indices = [];
143
159
  const n = polygon.length;
160
+ const bounds = new THREE.Box2();
161
+ for (const [x, z] of polygon) {
162
+ bounds.expandByPoint(new THREE.Vector2(x, z));
163
+ }
164
+ for (const hole of slabNode.holes ?? []) {
165
+ for (const [x, z] of hole) {
166
+ bounds.expandByPoint(new THREE.Vector2(x, z));
167
+ }
168
+ }
169
+ const floorWidth = Math.max(bounds.max.x - bounds.min.x, 0.001);
170
+ const floorHeight = Math.max(bounds.max.y - bounds.min.y, 0.001);
171
+ const pushFloorVertex = (x, y, z) => {
172
+ positions.push(x, y, z);
173
+ uvs.push((x - bounds.min.x) / floorWidth, (z - bounds.min.y) / floorHeight);
174
+ };
175
+ const pushWallVertex = (x, y, z, u, v) => {
176
+ positions.push(x, y, z);
177
+ uvs.push(u, v);
178
+ };
144
179
  // --- Floor at Y=0 ---
145
180
  for (const [x, z] of polygon)
146
- positions.push(x, 0, z);
181
+ pushFloorVertex(x, 0, z);
147
182
  const pts2d = polygon.map(([x, z]) => new THREE.Vector2(x, z));
148
183
  const holesPts2d = (slabNode.holes ?? []).map((h) => h.map(([x, z]) => new THREE.Vector2(x, z)));
149
184
  for (const hole of slabNode.holes ?? []) {
150
185
  for (const [x, z] of hole)
151
- positions.push(x, 0, z);
186
+ pushFloorVertex(x, 0, z);
152
187
  }
153
188
  const floorTris = THREE.ShapeUtils.triangulateShape(pts2d, holesPts2d);
154
189
  for (const tri of floorTris) {
@@ -162,15 +197,17 @@ function generatePoolGeometry(slabNode) {
162
197
  const [x0, z0] = polygon[i];
163
198
  const [x1, z1] = polygon[j];
164
199
  const vBase = positions.length / 3;
165
- positions.push(x0, 0, z0); // v0 — floor level
166
- positions.push(x1, 0, z1); // v1 — floor level
167
- positions.push(x1, depth, z1); // v2ground level
168
- positions.push(x0, depth, z0); // v3 — ground level
200
+ const segmentLength = Math.max(Math.hypot(x1 - x0, z1 - z0), 0.001);
201
+ pushWallVertex(x0, 0, z0, 0, 0); // v0 — floor level
202
+ pushWallVertex(x1, 0, z1, segmentLength, 0); // v1floor level
203
+ pushWallVertex(x1, depth, z1, segmentLength, depth); // v2 — ground level
204
+ pushWallVertex(x0, depth, z0, 0, depth); // v3 — ground level
169
205
  indices.push(vBase, vBase + 1, vBase + 2);
170
206
  indices.push(vBase, vBase + 2, vBase + 3);
171
207
  }
172
208
  const geo = new THREE.BufferGeometry();
173
209
  geo.setAttribute('position', new THREE.Float32BufferAttribute(positions, 3));
210
+ geo.setAttribute('uv', new THREE.Float32BufferAttribute(uvs, 2));
174
211
  geo.setIndex(indices);
175
212
  geo.computeVertexNormals();
176
213
  return geo;
@@ -0,0 +1,6 @@
1
+ import type { AnyNode, AnyNodeId, CeilingNode, SlabNode } from '../../schema';
2
+ export declare function syncAutoStairOpenings(nodes: Record<string, AnyNode>): {
3
+ id: AnyNodeId;
4
+ data: Partial<SlabNode | CeilingNode>;
5
+ }[];
6
+ //# sourceMappingURL=stair-opening-sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stair-opening-sync.d.ts","sourceRoot":"","sources":["../../../src/systems/stair/stair-opening-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,SAAS,EACT,WAAW,EAEX,QAAQ,EAGT,MAAM,cAAc,CAAA;AAitBrB,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;QAQvC,SAAS;UAAQ,OAAO,CAAC,QAAQ,GAAG,WAAW,CAAC;IAyG5E"}