@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.
- package/dist/events/bus.d.ts +74 -4
- package/dist/events/bus.d.ts.map +1 -1
- package/dist/events/bus.js +1 -1
- package/dist/hooks/scene-registry/scene-registry.d.ts +2 -0
- package/dist/hooks/scene-registry/scene-registry.d.ts.map +1 -1
- package/dist/hooks/scene-registry/scene-registry.js +2 -0
- package/dist/hooks/spatial-grid/spatial-grid-manager.d.ts.map +1 -1
- package/dist/hooks/spatial-grid/spatial-grid-manager.js +164 -6
- package/dist/hooks/spatial-grid/spatial-grid.d.ts +2 -0
- package/dist/hooks/spatial-grid/spatial-grid.d.ts.map +1 -1
- package/dist/hooks/spatial-grid/spatial-grid.js +43 -20
- package/dist/index.d.ts +9 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -11
- package/dist/lib/door-operation.d.ts +7 -0
- package/dist/lib/door-operation.d.ts.map +1 -0
- package/dist/lib/door-operation.js +25 -0
- package/dist/lib/polygon-geometry.d.ts +3 -0
- package/dist/lib/polygon-geometry.d.ts.map +1 -0
- package/dist/lib/polygon-geometry.js +90 -0
- package/dist/lib/slab-polygon.d.ts +3 -0
- package/dist/lib/slab-polygon.d.ts.map +1 -0
- package/dist/lib/slab-polygon.js +58 -0
- package/dist/lib/space-detection.d.ts +10 -17
- package/dist/lib/space-detection.d.ts.map +1 -1
- package/dist/lib/space-detection.js +666 -453
- package/dist/material-library.d.ts +20 -0
- package/dist/material-library.d.ts.map +1 -0
- package/dist/material-library.js +580 -0
- package/dist/schema/asset-url.d.ts +34 -0
- package/dist/schema/asset-url.d.ts.map +1 -0
- package/dist/schema/asset-url.js +79 -0
- package/dist/schema/asset-url.test.d.ts +2 -0
- package/dist/schema/asset-url.test.d.ts.map +1 -0
- package/dist/schema/asset-url.test.js +138 -0
- package/dist/schema/index.d.ts +14 -7
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +10 -7
- package/dist/schema/material.d.ts +112 -2
- package/dist/schema/material.d.ts.map +1 -1
- package/dist/schema/material.js +55 -1
- package/dist/schema/nodes/ceiling.d.ts +11 -1
- package/dist/schema/nodes/ceiling.d.ts.map +1 -1
- package/dist/schema/nodes/ceiling.js +6 -0
- package/dist/schema/nodes/column.d.ts +520 -0
- package/dist/schema/nodes/column.d.ts.map +1 -0
- package/dist/schema/nodes/column.js +385 -0
- package/dist/schema/nodes/door.d.ts +74 -1
- package/dist/schema/nodes/door.d.ts.map +1 -1
- package/dist/schema/nodes/door.js +39 -2
- package/dist/schema/nodes/fence.d.ts +34 -0
- package/dist/schema/nodes/fence.d.ts.map +1 -1
- package/dist/schema/nodes/fence.js +5 -0
- package/dist/schema/nodes/guide.d.ts +17 -0
- package/dist/schema/nodes/guide.d.ts.map +1 -1
- package/dist/schema/nodes/guide.js +11 -1
- package/dist/schema/nodes/item.d.ts +10 -2
- package/dist/schema/nodes/item.d.ts.map +1 -1
- package/dist/schema/nodes/item.js +18 -1
- package/dist/schema/nodes/level.d.ts +1 -1
- package/dist/schema/nodes/level.d.ts.map +1 -1
- package/dist/schema/nodes/level.js +6 -0
- package/dist/schema/nodes/roof-segment.d.ts +3 -1
- package/dist/schema/nodes/roof-segment.d.ts.map +1 -1
- package/dist/schema/nodes/roof-segment.js +1 -0
- package/dist/schema/nodes/roof.d.ts +108 -0
- package/dist/schema/nodes/roof.d.ts.map +1 -1
- package/dist/schema/nodes/roof.js +58 -2
- package/dist/schema/nodes/scan.d.ts.map +1 -1
- package/dist/schema/nodes/scan.js +2 -1
- package/dist/schema/nodes/site.d.ts +2 -1
- package/dist/schema/nodes/site.d.ts.map +1 -1
- package/dist/schema/nodes/slab.d.ts +11 -1
- package/dist/schema/nodes/slab.d.ts.map +1 -1
- package/dist/schema/nodes/slab.js +7 -0
- package/dist/schema/nodes/spawn.d.ts +24 -0
- package/dist/schema/nodes/spawn.d.ts.map +1 -0
- package/dist/schema/nodes/spawn.js +8 -0
- package/dist/schema/nodes/stair-segment.d.ts +3 -1
- package/dist/schema/nodes/stair-segment.d.ts.map +1 -1
- package/dist/schema/nodes/stair-segment.js +1 -0
- package/dist/schema/nodes/stair.d.ts +122 -2
- package/dist/schema/nodes/stair.d.ts.map +1 -1
- package/dist/schema/nodes/stair.js +72 -2
- package/dist/schema/nodes/surface-hole-metadata.d.ts +10 -0
- package/dist/schema/nodes/surface-hole-metadata.d.ts.map +1 -0
- package/dist/schema/nodes/surface-hole-metadata.js +5 -0
- package/dist/schema/nodes/wall.d.ts +87 -1
- package/dist/schema/nodes/wall.d.ts.map +1 -1
- package/dist/schema/nodes/wall.js +45 -4
- package/dist/schema/nodes/window.d.ts +57 -1
- package/dist/schema/nodes/window.d.ts.map +1 -1
- package/dist/schema/nodes/window.js +29 -0
- package/dist/schema/types.d.ts +653 -12
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/schema/types.js +4 -0
- package/dist/store/actions/node-actions.d.ts +1 -1
- package/dist/store/actions/node-actions.d.ts.map +1 -1
- package/dist/store/actions/node-actions.js +181 -5
- package/dist/store/history-control.d.ts +14 -0
- package/dist/store/history-control.d.ts.map +1 -0
- package/dist/store/history-control.js +22 -0
- package/dist/store/use-interactive.d.ts +43 -0
- package/dist/store/use-interactive.d.ts.map +1 -1
- package/dist/store/use-interactive.js +66 -0
- package/dist/store/use-scene.d.ts.map +1 -1
- package/dist/store/use-scene.js +307 -3
- package/dist/systems/ceiling/ceiling-system.d.ts.map +1 -1
- package/dist/systems/ceiling/ceiling-system.js +7 -0
- package/dist/systems/fence/fence-system.d.ts.map +1 -1
- package/dist/systems/fence/fence-system.js +106 -39
- package/dist/systems/roof/roof-system.d.ts.map +1 -1
- package/dist/systems/roof/roof-system.js +31 -1
- package/dist/systems/slab/slab-system.d.ts.map +1 -1
- package/dist/systems/slab/slab-system.js +45 -8
- package/dist/systems/stair/stair-opening-sync.d.ts +6 -0
- package/dist/systems/stair/stair-opening-sync.d.ts.map +1 -0
- package/dist/systems/stair/stair-opening-sync.js +576 -0
- package/dist/systems/stair/stair-opening-sync.test.d.ts +2 -0
- package/dist/systems/stair/stair-opening-sync.test.d.ts.map +1 -0
- package/dist/systems/stair/stair-opening-sync.test.js +65 -0
- package/dist/systems/stair/stair-system.d.ts.map +1 -1
- package/dist/systems/stair/stair-system.js +119 -2
- package/dist/systems/wall/wall-curve.d.ts +43 -0
- package/dist/systems/wall/wall-curve.d.ts.map +1 -0
- package/dist/systems/wall/wall-curve.js +176 -0
- package/dist/systems/wall/wall-footprint.d.ts.map +1 -1
- package/dist/systems/wall/wall-footprint.js +16 -2
- package/dist/systems/wall/wall-mitering.d.ts +7 -0
- package/dist/systems/wall/wall-mitering.d.ts.map +1 -1
- package/dist/systems/wall/wall-mitering.js +76 -3
- package/dist/systems/wall/wall-system.d.ts.map +1 -1
- package/dist/systems/wall/wall-system.js +202 -2
- 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 =
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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); // v1 — floor 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"}
|