@floless/app 0.132.0 → 0.132.2
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/floless-server.cjs +473 -51
- package/dist/skills/floless-app-onboarding/SKILL.md +12 -2
- package/dist/skills/floless-app-queue/SKILL.md +2 -2
- package/dist/web/aware.js +59 -3
- package/dist/web/commands-shell.js +2 -2
- package/dist/web/commands-steel.js +18 -0
- package/dist/web/index.html +1 -1
- package/dist/web/instructor.js +78 -19
- package/dist/web/steel-3d-core.js +127 -35
- package/dist/web/steel-3d-view.js +113 -64
- package/dist/web/steel-catalog-picker.js +624 -0
- package/dist/web/steel-editor.html +146 -34
- package/dist/web/workspaces.js +3 -1
- package/package.json +2 -1
|
@@ -315,6 +315,62 @@ export function sectionOutlinePts(kind, w, d, thk) {
|
|
|
315
315
|
/** How many segments approximate a circle for the consumers that need a polygon. */
|
|
316
316
|
export const ROUND_SEGMENTS = 48;
|
|
317
317
|
|
|
318
|
+
/**
|
|
319
|
+
* Editor display topology. A component owns one outer path and zero or more holes; multiple components
|
|
320
|
+
* still belong to one logical member (2L), so the Three adapter can extrude them into one mesh.
|
|
321
|
+
*/
|
|
322
|
+
export function sectionTopology(displaySection, w, d, fallbackKind = 'BOX') {
|
|
323
|
+
const polygon = (points) => ({ kind: 'polygon', points });
|
|
324
|
+
const circle = (radius) => ({ kind: 'circle', cx: 0, cy: 0, radius });
|
|
325
|
+
const component = (outer, holes = []) => ({ outer, holes });
|
|
326
|
+
const xs = displaySection || null;
|
|
327
|
+
|
|
328
|
+
if (xs?.shape === 'chs') {
|
|
329
|
+
const od = Number(xs.od) > 0 ? Number(xs.od) : Math.min(w, d);
|
|
330
|
+
const t = Number(xs.t);
|
|
331
|
+
const radius = od / 2;
|
|
332
|
+
return [component(circle(radius), t > 0 && t < radius ? [circle(radius - t)] : [])];
|
|
333
|
+
}
|
|
334
|
+
if (xs?.shape === 'solid-circle') {
|
|
335
|
+
const diameter = Number(xs.diameter) > 0 ? Number(xs.diameter) : Math.min(w, d);
|
|
336
|
+
return [component(circle(diameter / 2))];
|
|
337
|
+
}
|
|
338
|
+
if (xs?.shape === 'tee') {
|
|
339
|
+
const hw = w / 2, hd = d / 2;
|
|
340
|
+
const tf = Math.min(Math.max(Number(xs.tf) || d * 0.1, 0.1), d);
|
|
341
|
+
const tw = Math.min(Math.max(Number(xs.tw) || w * 0.1, 0.1), w);
|
|
342
|
+
return [component(polygon([[-hw, hd], [hw, hd], [hw, hd - tf], [tw / 2, hd - tf], [tw / 2, -hd], [-tw / 2, -hd], [-tw / 2, hd - tf], [-hw, hd - tf]]))];
|
|
343
|
+
}
|
|
344
|
+
if (xs?.shape === 'double-angle') {
|
|
345
|
+
const longBack = String(xs.orientation).toLowerCase() !== 'slbb';
|
|
346
|
+
const legDepth = Number(xs.d);
|
|
347
|
+
const legWidth = Number(xs.b);
|
|
348
|
+
const t = Math.min(Number(xs.t), legDepth, legWidth);
|
|
349
|
+
const gap = Math.max(Number(xs.gap) || 0, 0);
|
|
350
|
+
if (!(legDepth > 0 && legWidth > 0 && t > 0)) return [];
|
|
351
|
+
const hd = d / 2, hg = gap / 2;
|
|
352
|
+
if (longBack) {
|
|
353
|
+
const left = [[-hg - legWidth, hd - t], [-hg - t, hd - t], [-hg - t, -hd], [-hg, -hd], [-hg, hd], [-hg - legWidth, hd]];
|
|
354
|
+
const right = [[hg, -hd], [hg + t, -hd], [hg + t, hd - t], [hg + legWidth, hd - t], [hg + legWidth, hd], [hg, hd]];
|
|
355
|
+
return [component(polygon(left)), component(polygon(right))];
|
|
356
|
+
}
|
|
357
|
+
const hw = w / 2;
|
|
358
|
+
const lower = [[-hw, -hd], [-hw + t, -hd], [-hw + t, -hg - t], [hw, -hg - t], [hw, -hg], [-hw, -hg]];
|
|
359
|
+
const upper = [[hw, hd], [hw - t, hd], [hw - t, hg + t], [-hw, hg + t], [-hw, hg], [hw, hg]];
|
|
360
|
+
return [component(polygon(lower)), component(polygon(upper))];
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const shapeKind = xs?.shape === 'i' ? 'I'
|
|
364
|
+
: xs?.shape === 'channel' ? 'C'
|
|
365
|
+
: xs?.shape === 'angle' ? 'L'
|
|
366
|
+
: xs?.shape === 'rhs' ? 'TUBE'
|
|
367
|
+
: fallbackKind;
|
|
368
|
+
const outlined = sectionOutlinePts(shapeKind, w, d, {
|
|
369
|
+
tw: xs?.tw, tf: xs?.tf, t: xs?.t,
|
|
370
|
+
});
|
|
371
|
+
return [component(polygon(outlined.outer), outlined.hole ? [polygon(outlined.hole)] : [])];
|
|
372
|
+
}
|
|
373
|
+
|
|
318
374
|
/**
|
|
319
375
|
* Place a section outline (local px, centred on the origin, section x = width / y = depth) into a plan
|
|
320
376
|
* sheet's display px, for a member rolled `rotDeg`.
|
|
@@ -1167,9 +1223,10 @@ export function dim3dGeom(a, b, axis, axisDir) {
|
|
|
1167
1223
|
// above already ended the CLASSIFIER's copies, and these end the OUTLINE's.
|
|
1168
1224
|
|
|
1169
1225
|
/**
|
|
1170
|
-
* AWARE's inclusive
|
|
1171
|
-
*
|
|
1172
|
-
* the
|
|
1226
|
+
* AWARE's inclusive raw cross-multiplied near-vertical predicate,
|
|
1227
|
+
* `|d − dot(d, up) up|² ≤ 1e−6 |d|²`. The literal operation shape is part of the floating-point contract:
|
|
1228
|
+
* normalizing `d`, subtracting from one, or dividing the sides moves the seam. Its visible `sin θ`
|
|
1229
|
+
* boundary is 1e−3.
|
|
1173
1230
|
*/
|
|
1174
1231
|
export const FRAME_DEGENERATE_SQ = 1e-6;
|
|
1175
1232
|
export const FRAME_DEGENERATE = Math.sqrt(FRAME_DEGENERATE_SQ);
|
|
@@ -1302,28 +1359,21 @@ export function faceOffset(named, lo, hi) {
|
|
|
1302
1359
|
* `z = frame.yAxis` literally, as an earlier draft did, builds a LEFT-handed frame for the antiparallel
|
|
1303
1360
|
* case, in which `rot` turns the wrong way for a column whose ends happen to be stored top→base.
|
|
1304
1361
|
*
|
|
1305
|
-
* THE RENDERER
|
|
1306
|
-
*
|
|
1307
|
-
* `
|
|
1308
|
-
* every
|
|
1309
|
-
*
|
|
1310
|
-
*
|
|
1311
|
-
*
|
|
1312
|
-
*
|
|
1313
|
-
*
|
|
1314
|
-
*
|
|
1315
|
-
*
|
|
1316
|
-
*
|
|
1317
|
-
*
|
|
1318
|
-
*
|
|
1319
|
-
*
|
|
1320
|
-
* shipped shape, so a flipped axis lands the ENVELOPE on the same world line either way: no steel moves,
|
|
1321
|
-
* and the export is unaffected. What differs is an ASYMMETRIC section's internal facing — which leg of an
|
|
1322
|
-
* L, which side a C's web falls on — drawn mirrored in the 3D view for those two bands only.
|
|
1323
|
-
*
|
|
1324
|
-
* Unifying `orientMember` onto this frame is the real fix and is filed separately; it is a quaternion
|
|
1325
|
-
* change to the render path that wants its own 3D verification, not a rider on this one. Slice 2 makes
|
|
1326
|
-
* the frame load-bearing (`positionBasis`), so it should land first there.
|
|
1362
|
+
* THE RENDERER READS THIS FRAME (#770). `orientMember` (`web/steel-3d-view.js`) used to derive its own
|
|
1363
|
+
* basis from `setFromUnitVectors(+Z, dir)` plus a corrective roll; it now builds its quaternion from
|
|
1364
|
+
* `memberMeshAxes` below, which is this frame with the axes reordered into the geometry's local order. It
|
|
1365
|
+
* agreed with this rule for every ordinary member — which is why the divergence shipped unnoticed — and
|
|
1366
|
+
* differed by a full 180° for a member stored top→base, where three.js's arbitrary antiparallel tie-break
|
|
1367
|
+
* yielded (−x̂, +ŷ) against this rule's (+x̂, −ŷ). A second band at the near-plumb cut is kept closed by
|
|
1368
|
+
* the shared literal raw cross-multiplied predicate.
|
|
1369
|
+
*
|
|
1370
|
+
* WHAT THAT COST WHILE IT LASTED, since it bounds what the fix can change. The renderer centres the mesh
|
|
1371
|
+
* on the line the BAKE already offset (`placeMember`: `mesh.position` is the midpoint of `el.from`/
|
|
1372
|
+
* `el.to`), so it chooses orientation only, never position. `sectionExtents` is the outline's bounding box
|
|
1373
|
+
* and is symmetric (±w/2, ±d/2) for every shipped shape, so a flipped axis landed the ENVELOPE on the same
|
|
1374
|
+
* world line either way: no steel moved, and the export was unaffected. What differed was an ASYMMETRIC
|
|
1375
|
+
* section's internal facing — which leg of an L, which side a C's web falls on — drawn turned about the
|
|
1376
|
+
* reference line for top→base members only. That is exactly what unifying the frames corrects.
|
|
1327
1377
|
*
|
|
1328
1378
|
* @param {number[]} from
|
|
1329
1379
|
* @param {number[]} to
|
|
@@ -1333,9 +1383,8 @@ export function faceOffset(named, lo, hi) {
|
|
|
1333
1383
|
*/
|
|
1334
1384
|
export function partFrame(from, to, up = [0, 0, 1], upX = [1, 0, 0]) {
|
|
1335
1385
|
const d = [to[0] - from[0], to[1] - from[1], to[2] - from[2]];
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
const len = Math.sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
|
|
1386
|
+
const dSq = (d[0] * d[0] + d[1] * d[1]) + d[2] * d[2];
|
|
1387
|
+
const len = Math.sqrt(dSq);
|
|
1339
1388
|
if (!(len > 0) || !isFinite(len)) return null;
|
|
1340
1389
|
const x = [d[0] / len, d[1] / len, d[2] / len];
|
|
1341
1390
|
const unit = (v, label, min = 0) => {
|
|
@@ -1344,9 +1393,12 @@ export function partFrame(from, to, up = [0, 0, 1], upX = [1, 0, 0]) {
|
|
|
1344
1393
|
return [v[0] / l, v[1] / l, v[2] / l];
|
|
1345
1394
|
};
|
|
1346
1395
|
const u = unit(up, 'up');
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
const
|
|
1396
|
+
// Match AWARE #435 literally. These raw operands and the cross-multiplied comparison are deliberate:
|
|
1397
|
+
// algebraically equivalent normalized/cancelling/quotient forms disagree in the IEEE-754 seam.
|
|
1398
|
+
const rawUpDot = (u[0] * d[0] + u[1] * d[1]) + u[2] * d[2];
|
|
1399
|
+
const q = [d[0] - rawUpDot * u[0], d[1] - rawUpDot * u[1], d[2] - rawUpDot * u[2]];
|
|
1400
|
+
const qSq = (q[0] * q[0] + q[1] * q[1]) + q[2] * q[2];
|
|
1401
|
+
const degenerate = qSq <= FRAME_DEGENERATE_SQ * dSq;
|
|
1350
1402
|
if (degenerate) {
|
|
1351
1403
|
// Same projected +X seed rule as AWARE's scene_roll::member_frame. `upX` is intentionally validated
|
|
1352
1404
|
// only here: an ordinary +X beam legitimately has an unused +X seed with a zero member-plane projection.
|
|
@@ -1355,6 +1407,7 @@ export function partFrame(from, to, up = [0, 0, 1], upX = [1, 0, 0]) {
|
|
|
1355
1407
|
return { x, y, z: cross3(x, y), degenerate };
|
|
1356
1408
|
}
|
|
1357
1409
|
// Canonical ordinary branch: depth is projected up; width is depth × member axis (not its sign reverse).
|
|
1410
|
+
const upDot = u[0] * x[0] + u[1] * x[1] + u[2] * x[2];
|
|
1358
1411
|
const z = unit([u[0] - upDot * x[0], u[1] - upDot * x[1], u[2] - upDot * x[2]], 'up projection');
|
|
1359
1412
|
return { x, y: cross3(z, x), z, degenerate };
|
|
1360
1413
|
}
|
|
@@ -1363,6 +1416,43 @@ function cross3(a, b) {
|
|
|
1363
1416
|
return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
|
|
1364
1417
|
}
|
|
1365
1418
|
|
|
1419
|
+
/**
|
|
1420
|
+
* `partFrame` with its axes reordered into the MESH's local order — the one place that says which frame
|
|
1421
|
+
* axis each of a member geometry's local axes becomes. `orientMember` (`web/steel-3d-view.js`) feeds the
|
|
1422
|
+
* returned triple straight to `Matrix4.makeBasis`, so this function IS the renderer's basis; deriving a
|
|
1423
|
+
* second one next to it is what put a top→base member's section 180° out for #770.
|
|
1424
|
+
*
|
|
1425
|
+
* The two geometries lay their axes out differently, and the difference is not cosmetic:
|
|
1426
|
+
*
|
|
1427
|
+
* - EXTRUDED profile (`profileShape` → `ExtrudeGeometry`). `sectionOutlinePts` draws width on local X and
|
|
1428
|
+
* depth on local Y, and the extrusion runs along local Z, so the local triple is literally
|
|
1429
|
+
* (width, depth, axis) = (`frame.y`, `frame.z`, `frame.x`) — right-handed, because `frame.y × frame.z`
|
|
1430
|
+
* is `frame.x` for both of `partFrame`'s branches.
|
|
1431
|
+
* - BOX (`BoxGeometry(w, len, d)`) puts the LENGTH on local Y instead, giving (width, axis, depth). That
|
|
1432
|
+
* ordering is LEFT-handed — `frame.y × frame.x` is `−frame.z` — and feeding a left-handed triple to
|
|
1433
|
+
* `makeBasis` yields a determinant −1 matrix that `setFromRotationMatrix` cannot represent, so it
|
|
1434
|
+
* silently returns a wrong rotation. Negating the WIDTH restores the handedness, and width is the only
|
|
1435
|
+
* one of the three that may be flipped for free: a box is symmetric across it, while flipping depth or
|
|
1436
|
+
* the axis would point real geometry somewhere else.
|
|
1437
|
+
*
|
|
1438
|
+
* The caller applies the authored `rot` roll about `frame.x` on top; that is a rotation about an axis this
|
|
1439
|
+
* basis already fixes, so it composes without disturbing anything here.
|
|
1440
|
+
*
|
|
1441
|
+
* @param {number[]} from
|
|
1442
|
+
* @param {number[]} to
|
|
1443
|
+
* @param {boolean} [boxLike] true for a member rendered as a traced `BoxGeometry` rather than a profile
|
|
1444
|
+
* @param {number[]} [up] the coordinate system's normal, passed through to `partFrame`
|
|
1445
|
+
* @param {number[]} [upX] the frame's X axis, passed through to `partFrame`
|
|
1446
|
+
* @returns {{x:number[], y:number[], z:number[], degenerate:boolean}|null} what mesh-local +X/+Y/+Z become
|
|
1447
|
+
* in world, in `makeBasis` order; null if the member has no length
|
|
1448
|
+
*/
|
|
1449
|
+
export function memberMeshAxes(from, to, boxLike = false, up = [0, 0, 1], upX = [1, 0, 0]) {
|
|
1450
|
+
const f = partFrame(from, to, up, upX);
|
|
1451
|
+
if (!f) return null;
|
|
1452
|
+
if (!boxLike) return { x: f.y, y: f.z, z: f.x, degenerate: f.degenerate };
|
|
1453
|
+
return { x: [-f.y[0], -f.y[1], -f.y[2]], y: f.x, z: f.z, degenerate: f.degenerate };
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1366
1456
|
/**
|
|
1367
1457
|
* The offset from the reference line to the section's centroid, in WORLD mm — position first, then swing
|
|
1368
1458
|
* about the line.
|
|
@@ -1421,10 +1511,12 @@ export function positionOffsetVector(frame, ex, depthFace, widthFace, rotDeg, wi
|
|
|
1421
1511
|
* depth | UNCHANGED | mirrored, offset negated
|
|
1422
1512
|
*
|
|
1423
1513
|
* Both branches are involutions and both leave the composed offset identical — worked through and then
|
|
1424
|
-
* measured, not assumed. The ENVELOPE is what the world-space test asserts, not every point: the
|
|
1425
|
-
*
|
|
1426
|
-
*
|
|
1427
|
-
*
|
|
1514
|
+
* measured, not assumed. The ENVELOPE is what the world-space test asserts, not every point: the frame is
|
|
1515
|
+
* derived from the member's DIRECTION, so reversing the work points mirrors an asymmetric L or C across the
|
|
1516
|
+
* width axis. There is no stored chirality for a transform to carry, so it is asserted as the mirror it is
|
|
1517
|
+
* rather than papered over. Note this is a property of THIS frame, not of any renderer disagreeing with it:
|
|
1518
|
+
* since #770 the 3D solid is built on this same frame (`memberMeshAxes`), and unifying them did not and
|
|
1519
|
+
* could not remove the mirror.
|
|
1428
1520
|
*
|
|
1429
1521
|
* `-0` is normalised back to `0`, so reversing twice restores the document BYTE-for-byte rather than merely
|
|
1430
1522
|
* numerically: `JSON.stringify(-0)` is `"0"`, but an in-memory `-0` would still fail a `deepStrictEqual`.
|
|
@@ -20,7 +20,7 @@ import { RoomEnvironment } from 'three/addons/RoomEnvironment.js';
|
|
|
20
20
|
import { surfaceTextures, applyTriplanar, TILE_MM, DIRECTIONAL } from './steel-materials.js';
|
|
21
21
|
import { canvasToolGuidanceState } from './steel-canvas-guidance.js';
|
|
22
22
|
import { Brush, Evaluator, SUBTRACTION } from 'three-bvh-csg';
|
|
23
|
-
import { snapPoint, planPointToWp, memberGeometry, snapElevation, dim3dGeom, dominantAxis3d, planeBasis, planeFrom3Points, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor, candidateOnPlane, snapGridPoint, clipSegmentToPlanes, pointSegmentDistance2d, perspectiveSegmentParameter, gridDepthWins, segmentHitsRect2d, projectedFootprintHitsRect2d, pickGridLevel, selectedLengthLabelAnchors, sectionKindOf,
|
|
23
|
+
import { snapPoint, planPointToWp, memberGeometry, snapElevation, dim3dGeom, dominantAxis3d, planeBasis, planeFrom3Points, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor, candidateOnPlane, snapGridPoint, clipSegmentToPlanes, pointSegmentDistance2d, perspectiveSegmentParameter, gridDepthWins, segmentHitsRect2d, projectedFootprintHitsRect2d, pickGridLevel, selectedLengthLabelAnchors, sectionKindOf, sectionTopology, memberMeshAxes } from './steel-3d-core.js';
|
|
24
24
|
// `gridGeometry`, `gridCandidates3d` and `mmPerPx` live behind the host's model read boundary because
|
|
25
25
|
// their display-scale argument is meaningless on a world-mm model grid.
|
|
26
26
|
import { visibleGridLevels, gridTransientScopeSignature, reconcileGridTransientState, objectSelectionStatus } from './grid-core.js';
|
|
@@ -460,7 +460,9 @@ function lengthAxisOf(el) {
|
|
|
460
460
|
// finish across the nut's short axis instead of along its sweep.
|
|
461
461
|
if (kind === 'rod' || kind === 'bolt-shank' || kind === 'anchor' || kind === 'nut') return 'y'; // CylinderGeometry
|
|
462
462
|
if (kind === 'plate' || kind === 'washer' || kind === 'bolt-head') return 'z';
|
|
463
|
-
|
|
463
|
+
const display = el?.meta?.displaySection;
|
|
464
|
+
const displayExtrudes = display && !/^(rect|joist|unsupported-custom)$/.test(String(display.shape));
|
|
465
|
+
return !displayExtrudes && shapeOf(el) === 'BOX' ? 'y' : 'z'; // Box vs Extrude
|
|
464
466
|
}
|
|
465
467
|
function shapeOf(el) {
|
|
466
468
|
const explicit = (el.section && el.section.shape || '').toString().toUpperCase().trim();
|
|
@@ -485,73 +487,97 @@ function realThk(xs, key, half) {
|
|
|
485
487
|
// an L4X4 leg came out 18.3mm against a real 9.5, so a connection bearing on the real face rendered buried
|
|
486
488
|
// in a member that was drawn nearly twice too thick. The estimates remain as the fallback for sections we
|
|
487
489
|
// have no data for; they are the reason a member can still be drawn at all.
|
|
488
|
-
function profileShape(kind, w, d, xs) {
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
490
|
+
function profileShape(kind, w, d, xs, displaySection) {
|
|
491
|
+
const fallback = xs ? {
|
|
492
|
+
...(xs.shape === 'i' ? { shape: 'i', d: xs.d, bf: xs.bf, tw: realThk(xs, 'tw', w / 2), tf: realThk(xs, 'tf', d / 2) } : {}),
|
|
493
|
+
...(xs.shape === 'channel' ? { shape: 'channel', d: xs.d, bf: xs.bf, tw: realThk(xs, 'tw', w / 2), tf: realThk(xs, 'tf', d / 2) } : {}),
|
|
494
|
+
...(xs.shape === 'angle' ? { shape: 'angle', d: xs.d, b: xs.b, t: realThk(xs, 't', Math.min(w, d) / 2) } : {}),
|
|
495
|
+
...(xs.shape === 'rhs' ? { shape: 'rhs', d: xs.d, b: xs.b, t: realThk(xs, 't', Math.min(w, d) / 2) } : {}),
|
|
496
|
+
...(xs.shape === 'chs' ? { shape: 'chs', od: xs.od, t: realThk(xs, 't', Math.min(w, d) / 2) } : {}),
|
|
497
|
+
} : null;
|
|
498
|
+
const topology = sectionTopology(displaySection || fallback, w, d, kind);
|
|
499
|
+
const trace = (path, descriptor) => {
|
|
500
|
+
if (descriptor.kind === 'circle') { path.absarc(descriptor.cx, descriptor.cy, descriptor.radius, 0, Math.PI * 2, false); return; }
|
|
501
|
+
descriptor.points.forEach(([x, y], i) => (i ? path.lineTo(x, y) : path.moveTo(x, y))); path.closePath();
|
|
502
|
+
};
|
|
503
|
+
return topology.map(({ outer, holes }) => {
|
|
504
|
+
const shape = new THREE.Shape(); trace(shape, outer);
|
|
505
|
+
for (const hole of holes) { const path = new THREE.Path(); trace(path, hole); shape.holes.push(path); }
|
|
506
|
+
return shape;
|
|
496
507
|
});
|
|
497
|
-
const s = new THREE.Shape();
|
|
498
|
-
const trace = (path, pts) => { pts.forEach(([x, y], i) => (i ? path.lineTo(x, y) : path.moveTo(x, y))); path.closePath(); };
|
|
499
|
-
trace(s, outer);
|
|
500
|
-
if (hole) { const h = new THREE.Path(); trace(h, hole); s.holes.push(h); }
|
|
501
|
-
return s;
|
|
502
508
|
}
|
|
503
509
|
function memberGeom(el, w, d, len) {
|
|
504
510
|
const kind = shapeOf(el);
|
|
505
|
-
|
|
506
|
-
const
|
|
511
|
+
const display = el?.meta?.displaySection;
|
|
512
|
+
const displayExtrudes = display && !/^(rect|joist|unsupported-custom)$/.test(String(display.shape));
|
|
513
|
+
if (kind === 'BOX' && !displayExtrudes) return new THREE.BoxGeometry(w, len, d); // length on local Y
|
|
514
|
+
const shapes = profileShape(kind, w, d, el && el.xsection, display);
|
|
515
|
+
const g = new THREE.ExtrudeGeometry(shapes, { depth: len, bevelEnabled: false, curveSegments: 32 });
|
|
507
516
|
g.translate(0, 0, -len / 2); return g; // extruded +Z, centred
|
|
508
517
|
}
|
|
509
518
|
const _ZA = new THREE.Vector3(0, 0, 1), _YA = new THREE.Vector3(0, 1, 0);
|
|
510
|
-
// NOTE vs AWARE viewer-3d: AWARE converts the Z-up scene into Three's Y-up world before orienting, so
|
|
511
|
-
//
|
|
512
|
-
// world-Z
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
519
|
+
// NOTE vs AWARE viewer-3d: AWARE converts the Z-up scene into Three's Y-up world before orienting, so its
|
|
520
|
+
// depth axis targets world-Y. We render the scene NATIVELY Z-up (camera.up=Z), so depth must target
|
|
521
|
+
// world-Z — else the web lies flat (horizontal) instead of standing vertical. That convention is no longer
|
|
522
|
+
// spelled out here: it is `partFrame`'s `up` parameter, which defaults to world Z (see `memberMeshAxes`).
|
|
523
|
+
/**
|
|
524
|
+
* Orient a member from its two raw world endpoints. `from` and `to` are endpoint triples, never a
|
|
525
|
+
* pre-normalized direction: AWARE #435 makes the raw subtraction operands part of the branch contract.
|
|
526
|
+
* @param {THREE.Object3D & {geometry: THREE.BufferGeometry}} mesh
|
|
527
|
+
* @param {[number, number, number]} from raw world start endpoint
|
|
528
|
+
* @param {[number, number, number]} to raw world end endpoint
|
|
529
|
+
* @param {object} el scene member, optionally carrying the authored `refFrom`/`refTo` frame line
|
|
530
|
+
*/
|
|
531
|
+
function orientMember(mesh, from, to, el) {
|
|
532
|
+
// The basis comes from `memberMeshAxes` (steel-3d-core.js), which is `partFrame` — the SAME frame the
|
|
533
|
+
// bake, the flush offsets and the 2D plan footprint place a section in — reordered into this geometry's
|
|
534
|
+
// local axes. It used to be derived here instead, from `setFromUnitVectors(_ZA, m)` plus a corrective
|
|
535
|
+
// roll, which agreed with the bake for every ordinary member and came out 180° about the reference line
|
|
536
|
+
// for one stored top→base: an asymmetric L or C faced the wrong way in 3D while the plan and the export
|
|
537
|
+
// had it right (#770). One frame, so the tie-break and the near-plumb cut cannot drift apart again.
|
|
538
|
+
//
|
|
539
|
+
// THE AUTHORED REFERENCE LINE selects the frame, and the operands must be the bake's own — not a
|
|
540
|
+
// direction recovered from anywhere else. `partFrame`'s raw cross-multiplied near-plumb predicate is
|
|
541
|
+
// INCLUSIVE, so for a member on the cut a single last-bit operand difference decides the branch and can
|
|
542
|
+
// swing an asymmetric section sharply. Two operand changes had to go (both found by Codex on #801):
|
|
543
|
+
//
|
|
544
|
+
// - normalizing here first, which is forbidden by AWARE #435: classification reads raw `to − from`.
|
|
545
|
+
// - subtracting the PLACED endpoints. `el.from`/`el.to` are `refFrom + o` / `refTo + o` for the same
|
|
546
|
+
// section-position offset, so `to − from` is not bit-identical to `refTo − refFrom`. Swept on that
|
|
547
|
+
// same member, 99,261 of 400,000 legal offsets flipped the branch under the raw predicate.
|
|
548
|
+
//
|
|
549
|
+
// So `contract-to-scene` ships `refFrom`/`refTo` alongside the placed line and they are what comes in
|
|
550
|
+
// here; `from`/`to` remain the fallback for a scene that predates them or an element with no authored
|
|
551
|
+
// line, which is the pre-#801 behaviour rather than a new guess. Connection trims make the same
|
|
552
|
+
// distinction: the physical solid can be shorter while its authored frame line must stay unchanged.
|
|
553
|
+
const p3 = (v) => (Array.isArray(v) && v.length === 3
|
|
554
|
+
&& v.every((n) => typeof n === 'number' && isFinite(n)) ? v : null);
|
|
555
|
+
const ref = el && p3(el.refFrom) && p3(el.refTo) ? [el.refFrom, el.refTo] : [from, to];
|
|
556
|
+
const frameFrom = ref[0], frameTo = ref[1];
|
|
557
|
+
const axes = memberMeshAxes(frameFrom, frameTo, mesh.geometry.type === 'BoxGeometry');
|
|
558
|
+
// A zero-length member has no direction to orient by, and it IS reachable: `placeMember` floors the
|
|
559
|
+
// LENGTH at 1 mm but not the direction, and `Vector3.normalize` leaves (0,0,0) at (0,0,0). Reset rather
|
|
560
|
+
// than return, so this function fully determines the orientation for every input instead of leaving a
|
|
561
|
+
// degenerate member wearing whatever quaternion its mesh arrived with. `buildFromScene` — the only
|
|
562
|
+
// caller — hands over a fresh `THREE.Mesh`, whose quaternion is already identity, so this is not
|
|
563
|
+
// repairing a live defect; it is refusing to make the contract depend on that staying true.
|
|
564
|
+
if (!axes) { mesh.quaternion.identity(); return; }
|
|
565
|
+
const q = new THREE.Quaternion().setFromRotationMatrix(
|
|
566
|
+
new THREE.Matrix4().makeBasis(V(...axes.x), V(...axes.y), V(...axes.z)));
|
|
567
|
+
// el.rot (section roll about the reference line) applies to ANY member — columns AND beams — and is a
|
|
568
|
+
// WORLD rotation about start→end: v2 work points are already right-handed world mm with no flip anywhere
|
|
569
|
+
// in the bake, so contract-to-scene passes `rot` through untouched. Do NOT re-negate (the v1 arm that
|
|
570
|
+
// did, to undo v1's display-space Y flip, went with v1 in #741) — negating mirrors every rolled section.
|
|
571
|
+
// The 2D plan footprint is placed to match (SteelCore.sectionOutlinePx). A non-finite `rot` reads as 0,
|
|
572
|
+
// as it does in `positionOffsetVector`: an Infinity would otherwise reach setFromAxisAngle as NaN and
|
|
573
|
+
// blank the member out of the scene entirely.
|
|
574
|
+
const rot = el && typeof el.rot === 'number' && isFinite(el.rot) ? el.rot : 0;
|
|
575
|
+
if (rot) {
|
|
576
|
+
// The roll axis is normalized here and that is safe: unlike the frame above it feeds no predicate, so
|
|
577
|
+
// a last-bit difference from `partFrame`'s own `x` turns the section by an immaterial angle rather
|
|
578
|
+
// than selecting a different branch. `setFromAxisAngle` requires a unit axis.
|
|
579
|
+
const m = V(frameTo[0] - frameFrom[0], frameTo[1] - frameFrom[1], frameTo[2] - frameFrom[2]).normalize();
|
|
580
|
+
q.premultiply(new THREE.Quaternion().setFromAxisAngle(m, rot * Math.PI / 180));
|
|
555
581
|
}
|
|
556
582
|
mesh.quaternion.copy(q);
|
|
557
583
|
}
|
|
@@ -561,7 +587,7 @@ function placeMember(mesh, a, b, el) {
|
|
|
561
587
|
const dir = new THREE.Vector3().subVectors(B, A); const len = dir.length() || 1; dir.normalize();
|
|
562
588
|
const w = Math.max((el.section && el.section.w) || 50, 1), d = Math.max((el.section && el.section.d) || 50, 1);
|
|
563
589
|
mesh.geometry = memberGeom(el, w, d, len);
|
|
564
|
-
orientMember(mesh,
|
|
590
|
+
orientMember(mesh, a, b, el); // raw physical endpoints; orientMember selects the authored frame line when present
|
|
565
591
|
mesh.position.copy(A).addScaledVector(dir, len / 2);
|
|
566
592
|
}
|
|
567
593
|
|
|
@@ -924,6 +950,7 @@ function buildFromScene(sc) {
|
|
|
924
950
|
const memberCuts = cutsByMember.get(el.id);
|
|
925
951
|
if (memberCuts && memberCuts.length) applyCopes(mesh, memberCuts); // notch a coped member end
|
|
926
952
|
mesh.userData.id = el.id; mesh.userData.group = el.group; mesh.userData.profile = el.meta && el.meta.profile;
|
|
953
|
+
mesh.userData.sectionShape = el.meta?.displaySection?.shape || el.xsection?.shape || shapeOf(el).toLowerCase();
|
|
927
954
|
mesh.userData.family = familyOf(el); // the selection/hover clones and the restore path need it too
|
|
928
955
|
mesh.userData.axis = lengthAxisOf(el); // …and so does the axis, or a clone rebuilds a world-projected shader
|
|
929
956
|
mesh.userData.derived = !!(el.kind && el.kind !== 'box'); // connection parts: rendered, not member-editable
|
|
@@ -7262,6 +7289,13 @@ function debug() {
|
|
|
7262
7289
|
firstId: meshById.keys().next().value ?? null,
|
|
7263
7290
|
ids: [...meshById.keys()].slice(0, 12),
|
|
7264
7291
|
geomTypes: [...meshById.values()].reduce((h, m) => { const t = m.geometry.type; h[t] = (h[t] || 0) + 1; return h; }, {}),
|
|
7292
|
+
sectionGeometry: Object.fromEntries([...meshById].map(([id, m]) => {
|
|
7293
|
+
if (!m.geometry.boundingBox) m.geometry.computeBoundingBox();
|
|
7294
|
+
const size = m.geometry.boundingBox?.getSize(new THREE.Vector3());
|
|
7295
|
+
return [id, { profile: m.userData.profile, shape: m.userData.sectionShape, type: m.geometry.type,
|
|
7296
|
+
vertices: m.geometry.attributes?.position?.count ?? 0, groups: m.geometry.groups?.length ?? 0,
|
|
7297
|
+
localSize: size ? [size.x, size.y, size.z] : null }];
|
|
7298
|
+
})),
|
|
7265
7299
|
lastPick, projection: projection(), mode: displayMode,
|
|
7266
7300
|
// Realistic-mode state. `envOn` is the load-bearing one: metal with no environment renders black,
|
|
7267
7301
|
// so "the mode switched" is not evidence on its own — the environment has to be live.
|
|
@@ -7321,6 +7355,21 @@ function centerOf(id) {
|
|
|
7321
7355
|
return { x: rect.left + (w.x * 0.5 + 0.5) * rect.width, y: rect.top + (-w.y * 0.5 + 0.5) * rect.height };
|
|
7322
7356
|
}
|
|
7323
7357
|
function worldOf(id) { const m = meshById.get(id); if (!m) return null; const w = m.getWorldPosition(new THREE.Vector3()); return [w.x, w.y, w.z]; } // test helper: a rendered part's world position
|
|
7358
|
+
// Test helper: the ACTUAL rendered member basis after its mesh quaternion and parent transforms. Unlike a
|
|
7359
|
+
// fresh `partFrame` call, this observes the object the canvas draws. BoxGeometry's width is local -X; an
|
|
7360
|
+
// extruded asymmetric profile uses local +X width, +Y depth, +Z member axis.
|
|
7361
|
+
function memberBasis(id) {
|
|
7362
|
+
const m = meshById.get(id); if (!m || !m.geometry) return null;
|
|
7363
|
+
const q = m.getWorldQuaternion(new THREE.Quaternion());
|
|
7364
|
+
const box = m.geometry.type === 'BoxGeometry';
|
|
7365
|
+
const xyz = (v) => { v.applyQuaternion(q); return [v.x, v.y, v.z]; };
|
|
7366
|
+
return {
|
|
7367
|
+
geometry: m.geometry.type,
|
|
7368
|
+
width: xyz(new THREE.Vector3(box ? -1 : 1, 0, 0)),
|
|
7369
|
+
depth: xyz(new THREE.Vector3(0, box ? 0 : 1, box ? 1 : 0)),
|
|
7370
|
+
axis: xyz(new THREE.Vector3(0, box ? 1 : 0, box ? 0 : 1)),
|
|
7371
|
+
};
|
|
7372
|
+
}
|
|
7324
7373
|
// test helper: client (px) coords of every POINT snap candidate of `type` currently in view (members + grid, via
|
|
7325
7374
|
// allCandidates) — drives precise E2E snap hovers, including grid nodes/intersections (grid-int).
|
|
7326
7375
|
function snapCandidatesScreen(type) {
|
|
@@ -7474,7 +7523,7 @@ window.Steel3DView = {
|
|
|
7474
7523
|
selDims3dCount: () => (api && api.selDim3d ? (api.selDim3d() || []).length : 0), // test helper: how many 3D dims are selected
|
|
7475
7524
|
dim3dLabelOf: (i) => { const el = dimLabelPool[i]; if (!el || el.style.display === 'none') return null; const r = el.getBoundingClientRect(); return { x: r.left + r.width / 2, y: r.top + r.height / 2, text: el.textContent }; },
|
|
7476
7525
|
wireEdgeColor: (id) => { const ls = wireEdges.get(id); return ls && ls.visible && ls.parent && ls.parent.visible && ls.material ? '#' + ls.material.color.getHexString() : null; }, // test probe: the Wire-mode OUTLINE colour of a member. probe() reads the hidden FILL's emissive, which is set in every mode — so it stays green even when the outline never adopts the cue (exactly the regression this fixes); this is the only read of the line that Wire actually draws. Gated like its sibling probes: ls.visible (leaving Wire only HIDES the outline — wireEdgesFor runs on the wire branch alone — so an ungated read reports a stale Wire colour) and ls.parent.visible (group/legend/isolate/work-area hide the parent MESH, and three skips a hidden parent's children). It still cannot see clip planes, frustum culling or a display:none canvas — a false "on" is possible there, never a false "off"
|
|
7477
|
-
debug, probe, screenOf, centerOf, worldOf, snapCandidatesScreen, referenceObjectsScreen, gridSegmentsScreen, gridBubblesScreen, clipHandlesScreen,
|
|
7526
|
+
debug, probe, screenOf, centerOf, worldOf, memberBasis, snapCandidatesScreen, referenceObjectsScreen, gridSegmentsScreen, gridBubblesScreen, clipHandlesScreen,
|
|
7478
7527
|
clipPlanePreviewShown: () => !!clipPlanePreview, // test helper: is the armed-plane hover ghost currently showing?
|
|
7479
7528
|
clipBoxFloorAt: (x, y) => clipBoxFloorPoint(x, y), // test helper: the snapped footprint point at a cursor ({ xy, snap, world } or null)
|
|
7480
7529
|
pointClipped: (p) => isPointClipped(p), // test helper: is a world point on the cut-away side of any active clip?
|