@floless/app 0.122.0 → 0.123.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.
@@ -891,6 +891,32 @@ let xrefCandWarned = false; // one warning per session if snap c
891
891
  * from the one thing this feature must never let a user believe.
892
892
  */
893
893
  const XREF_COLOR = 0x94a3b8;
894
+
895
+ /**
896
+ * The reference colour modes, and why `file` is the default.
897
+ *
898
+ * `file` paints each object the colour the IFC styles it with. `uniform` is XREF_COLOR everywhere —
899
+ * the signal above, kept as a one-click way back. `custom` paints the whole reference one colour the
900
+ * user picked.
901
+ *
902
+ * An ABSENT `colorMode` means `file`, which is what lets a reference imported before this existed pick
903
+ * its colours up on the next read. Defaulting to `uniform` would have been the conservative-looking
904
+ * choice and the wrong one: every old row would stay grey and read as "this file has no colours".
905
+ */
906
+ const XREF_MODES = new Set(['file', 'uniform', 'custom']);
907
+ const xrefMode = (d) => (XREF_MODES.has(d && d.colorMode) ? d.colorMode : 'file');
908
+ /**
909
+ * The custom colour as a number, or null if it is not a colour.
910
+ *
911
+ * VALIDATED HERE rather than trusted, because the contract is hand- and AI-editable and the schema can
912
+ * only check the length (this repo's validator has no `pattern`). `new THREE.Color('#zzzzzz')` warns to
913
+ * the console and leaves the material BLACK, which against a dark canvas is an invisible reference —
914
+ * a wrong colour a user would report as "it disappeared".
915
+ */
916
+ function xrefCustom(d) {
917
+ const s = d && typeof d.color === 'string' ? d.color.trim() : '';
918
+ return /^#[0-9a-fA-F]{6}$/.test(s) ? parseInt(s.slice(1), 16) : null;
919
+ }
894
920
  /** Vertices closer than this collapse into one snap point — a tessellated corner is many coincident ones. */
895
921
  const XREF_SNAP_QUANT_MM = 0.5;
896
922
  /**
@@ -963,6 +989,35 @@ function xrefSnapPoints(objects) {
963
989
  return { points: out, capped: false };
964
990
  }
965
991
 
992
+ /**
993
+ * Free every material the reference layer holds — from the SCENE GRAPH, not from a bookkeeping map.
994
+ *
995
+ * Two ways the obvious spellings miss, both of which shipped once and were caught in review:
996
+ *
997
+ * `o.material.dispose()` per mesh — in file mode `o.material` is an ARRAY, which has no
998
+ * `dispose`, so `?.dispose?.()` silently frees nothing at all;
999
+ * `entry.mats` only — a map keyed on reference id loses an entry the moment two
1000
+ * references share an id, and the orphaned group's materials
1001
+ * then have no owner that could ever free them.
1002
+ *
1003
+ * Walking the graph and collecting into a Set is immune to both: it sees arrays, it sees groups whose
1004
+ * map entry was overwritten, and a material shared by ten thousand meshes is disposed exactly once.
1005
+ * `entry.mats` and `entry.flat` are drained too — they deliberately retain materials attached to no
1006
+ * mesh (the file colours kept alive while a reference is overridden, so switching back is free).
1007
+ */
1008
+ function disposeReferenceMaterials() {
1009
+ const seen = new Set();
1010
+ xrefGroup?.traverse((o) => {
1011
+ if (!o.isMesh || !o.material) return;
1012
+ if (Array.isArray(o.material)) o.material.forEach((m) => seen.add(m)); else seen.add(o.material);
1013
+ });
1014
+ for (const entry of xrefById.values()) {
1015
+ for (const m of entry.mats.values()) seen.add(m);
1016
+ if (entry.flat) seen.add(entry.flat);
1017
+ }
1018
+ for (const m of seen) m.dispose?.();
1019
+ }
1020
+
966
1021
  /**
967
1022
  * (Re)build the whole reference layer from what the editor holds.
968
1023
  *
@@ -974,8 +1029,9 @@ function xrefSnapPoints(objects) {
974
1029
  function setReferences(list) {
975
1030
  if (!scene) return;
976
1031
  if (!xrefGroup) { xrefGroup = new THREE.Group(); scene.add(xrefGroup); }
1032
+ disposeReferenceMaterials();
977
1033
  for (const child of [...xrefGroup.children]) {
978
- child.traverse?.((o) => { o.geometry?.dispose?.(); o.material?.dispose?.(); });
1034
+ child.traverse?.((o) => { o.geometry?.dispose?.(); });
979
1035
  xrefGroup.remove(child);
980
1036
  }
981
1037
  xrefById.clear();
@@ -989,16 +1045,28 @@ function setReferences(list) {
989
1045
  // against is worse than no reference.
990
1046
  group.renderOrder = -1;
991
1047
  const objects = Array.isArray(ref.objects) ? ref.objects : [];
1048
+ // MATERIALS ARE SHARED WITHIN ONE REFERENCE AND NEVER ACROSS ONE. A real model draws 77,000
1049
+ // objects from 16 colours, so a material per object would be 77,000 of them; but a cache shared
1050
+ // BETWEEN references would be worse than wasteful, because `applyReferenceDisplay` mutates
1051
+ // `opacity` in place — dragging one reference's slider would fade every other reference that
1052
+ // happened to use the same colour. Per-entry is the only version of this that is correct.
1053
+ const mats = new Map();
992
1054
  for (const o of objects) {
993
1055
  const g = new THREE.BufferGeometry();
994
1056
  g.setAttribute('position', new THREE.Float32BufferAttribute(o.positions || [], 3));
995
1057
  if (Array.isArray(o.indices) && o.indices.length) g.setIndex(o.indices);
996
1058
  g.computeVertexNormals();
997
- const mesh = new THREE.Mesh(g, new THREE.MeshStandardMaterial({
998
- color: XREF_COLOR, metalness: 0, roughness: 0.95,
999
- transparent: true, opacity: 1, depthWrite: false, side: THREE.DoubleSide,
1000
- }));
1059
+ // No material yet — `applyReferenceDisplay` below assigns it from the colour mode, and it is
1060
+ // the only thing that knows which. THREE's own default stands in for the few statements until
1061
+ // then; passing an explicit null would leave the mesh unrenderable if that call ever moved.
1062
+ const mesh = new THREE.Mesh(g);
1063
+ // The colour runs, kept on the mesh so a mode change can re-material without re-uploading a
1064
+ // single vertex — the same economy `setReferencePlacement` exists for. A whole tessellated
1065
+ // building is tens of megabytes of GPU traffic; clicking "Grey" must not pay it.
1066
+ const runs = Array.isArray(o.colors) && o.colors.length ? o.colors : null;
1067
+ if (runs) { g.clearGroups(); runs.forEach((c, i) => g.addGroup(c.start, c.count, i)); }
1001
1068
  mesh.userData.referenceId = ref.id;
1069
+ mesh.userData.colorRuns = runs;
1002
1070
  group.add(mesh);
1003
1071
  }
1004
1072
  group.applyMatrix4(xrefMatrix(ref.placement));
@@ -1011,6 +1079,14 @@ function setReferences(list) {
1011
1079
  xrefById.set(ref.id, {
1012
1080
  group, display: ref.display || {}, name: ref.name || ref.id,
1013
1081
  points, total: points.length, capped: keptCapped, keptCapped,
1082
+ // `painted` is what `applyReferenceDisplay` compares against to decide whether re-materialling
1083
+ // every mesh is necessary at all. Opacity is dragged live and must stay a per-material write.
1084
+ mats, painted: null,
1085
+ // THE one material every override uses, made once and recoloured in place. Kept OUT of `mats`
1086
+ // because that map is keyed by colour and this material's colour changes — caching it there
1087
+ // would put a stale key in front of a live material, and is how the picker drag came to mint
1088
+ // (and strand) a material per pointer move.
1089
+ flat: newXrefMaterial(XREF_COLOR, 1),
1014
1090
  });
1015
1091
  applyReferenceDisplay(ref.id, ref.display || {});
1016
1092
  }
@@ -1036,10 +1112,78 @@ function applyReferenceDisplay(id, display) {
1036
1112
  const visible = entry.display.visible !== false;
1037
1113
  const opacity = Number.isFinite(entry.display.opacity) ? Math.max(0, Math.min(1, entry.display.opacity)) : 0.5;
1038
1114
  entry.group.visible = visible;
1039
- entry.group.traverse((o) => { if (o.material) { o.material.opacity = opacity; o.material.needsUpdate = true; } });
1115
+
1116
+ // ONLY A CHANGE OF SHAPE RE-MATERIALS, and "shape" means file-colours-vs-one-colour, NOT which
1117
+ // colour. Both the opacity slider and the colour picker fire on every pointer move, and reassigning
1118
+ // `mesh.material` across 17,000 meshes per move would turn either drag into a slideshow.
1119
+ //
1120
+ // Keying on the colour was the first cut and review caught it: dragging through a gradient re-walked
1121
+ // every mesh per move AND minted a material per distinct colour, none of which was ever freed. An
1122
+ // override is one material by construction, so changing its colour is one `setHex` on that material
1123
+ // — no traverse, no allocation, however far the pointer travels.
1124
+ const mode = xrefMode(entry.display);
1125
+ const custom = xrefCustom(entry.display);
1126
+ const shape = mode === 'file' ? 'file' : 'flat';
1127
+ if (entry.painted !== shape) { paintReferenceColors(entry, shape); entry.painted = shape; }
1128
+ if (shape === 'flat') entry.flat.color.setHex(mode === 'custom' && custom !== null ? custom : XREF_COLOR);
1129
+
1130
+ // Opacity reaches the MATERIALS, not the meshes — there are at most a handful of the former and
1131
+ // tens of thousands of the latter, and they are the same objects either way.
1132
+ //
1133
+ // FILE ALPHA MULTIPLIES THE SLIDER, so glass authored at 0.149 still reads as glass at any slider
1134
+ // position. Only in `file` mode: overriding the colour means "paint this whole model one colour",
1135
+ // and keeping per-object alpha under an override would leave it patchy for no reason the user
1136
+ // could act on.
1137
+ for (const m of entry.mats.values()) { m.opacity = opacity * m.userData.alpha; m.needsUpdate = true; }
1138
+ entry.flat.opacity = opacity; entry.flat.needsUpdate = true;
1040
1139
  paintReferenceSelection();
1041
1140
  }
1042
1141
 
1142
+ /**
1143
+ * One reference's material for a given colour, made once and reused.
1144
+ *
1145
+ * `alpha` is stashed on the material rather than folded into `opacity` here, because the slider is
1146
+ * applied on top of it on every change and the file's own value has to survive being multiplied.
1147
+ */
1148
+ function xrefMaterial(entry, rgb, alpha) {
1149
+ const key = `${rgb}:${alpha}`;
1150
+ let m = entry.mats.get(key);
1151
+ if (!m) { m = newXrefMaterial(rgb, alpha); entry.mats.set(key, m); }
1152
+ return m;
1153
+ }
1154
+
1155
+ function newXrefMaterial(rgb, alpha) {
1156
+ const m = new THREE.MeshStandardMaterial({
1157
+ color: rgb, metalness: 0, roughness: 0.95,
1158
+ transparent: true, opacity: 1, depthWrite: false, side: THREE.DoubleSide,
1159
+ });
1160
+ m.userData.alpha = alpha;
1161
+ return m;
1162
+ }
1163
+
1164
+ /**
1165
+ * Point every mesh of one reference at the materials its colour mode calls for.
1166
+ *
1167
+ * `file` gives a mesh an ARRAY of materials, one per colour run, which is what makes a multi-coloured
1168
+ * object render as several colours — the geometry groups built in `setReferences` index into it. The
1169
+ * override modes give it a SINGLE material instead, and that is not merely a simplification: THREE
1170
+ * ignores geometry groups entirely when the material is not an array, so one override colour paints
1171
+ * the whole buffer in one draw call rather than N.
1172
+ *
1173
+ * An object with no runs — a file that authors no colour, or a bridge too old to say — falls back to
1174
+ * XREF_COLOR. Never to white, which is what web-ifc reports for unstyled geometry and what this whole
1175
+ * chain exists to keep off the screen.
1176
+ */
1177
+ function paintReferenceColors(entry, shape) {
1178
+ entry.group.traverse((o) => {
1179
+ if (!o.isMesh) return;
1180
+ const runs = shape === 'file' ? o.userData.colorRuns : null;
1181
+ o.material = runs
1182
+ ? runs.map((c) => xrefMaterial(entry, (Math.round(c.rgba[0] * 255) << 16) | (Math.round(c.rgba[1] * 255) << 8) | Math.round(c.rgba[2] * 255), c.rgba[3]))
1183
+ : entry.flat;
1184
+ });
1185
+ }
1186
+
1043
1187
  /**
1044
1188
  * Re-place one reference without touching a single vertex.
1045
1189
  *
@@ -1059,11 +1203,14 @@ function setReferencePlacement(id, placement) {
1059
1203
  function paintReferenceSelection() {
1060
1204
  for (const [id, entry] of xrefById) {
1061
1205
  const on = id === xrefSelected;
1062
- entry.group.traverse((o) => {
1063
- if (!o.material || !o.material.emissive) return;
1064
- o.material.emissive.setHex(on ? 0xe2e8f0 : 0x000000);
1065
- o.material.emissiveIntensity = on ? 0.35 : 0;
1066
- });
1206
+ // THE MATERIALS, not the meshes — a mesh may now hold an ARRAY of them (one per colour run), and
1207
+ // several meshes share each one. Walking the entry's materials reaches every one exactly once and
1208
+ // cannot miss the members of an array the way `o.material.emissive` silently did. `flat` is not in
1209
+ // `mats` and must be lifted too, or selecting an OVERRIDDEN reference would highlight nothing.
1210
+ for (const m of [...entry.mats.values(), entry.flat]) {
1211
+ m.emissive.setHex(on ? 0xe2e8f0 : 0x000000);
1212
+ m.emissiveIntensity = on ? 0.35 : 0;
1213
+ }
1067
1214
  }
1068
1215
  }
1069
1216
 
@@ -1093,6 +1240,42 @@ function selectReference(id) {
1093
1240
  if (api && api.onReferenceSelect) api.onReferenceSelect(xrefSelected);
1094
1241
  }
1095
1242
 
1243
+ /**
1244
+ * What is ACTUALLY painted on one reference right now — the colours, off the materials themselves.
1245
+ *
1246
+ * Exists because "is this reference showing the file's colours?" is otherwise unanswerable from
1247
+ * outside: a screenshot cannot distinguish a correct palette from a plausible one, and the contract
1248
+ * only records what was ASKED for. This reads back what the GPU was given, so a test can assert the
1249
+ * rendered result rather than the intent.
1250
+ *
1251
+ * `colors` are hex strings with the material's own alpha, `opacity` is what the slider multiplied it
1252
+ * to — the two are separate because a wrong answer in either looks identical on screen.
1253
+ */
1254
+ function referenceProbe(id) {
1255
+ const entry = xrefById.get(id);
1256
+ if (!entry) return null;
1257
+ let meshes = 0, arrayMeshes = 0, runs = 0;
1258
+ // COLLECTED OFF THE MESHES, not out of `entry.mats`. The cache deliberately KEEPS a reference's
1259
+ // file-colour materials while it is overridden, so switching back is free — which means reading the
1260
+ // cache would report a grey-overridden model as still carrying six colours. That is precisely the
1261
+ // question this probe exists to answer, so it walks what is actually assigned.
1262
+ const inUse = new Set();
1263
+ entry.group.traverse((o) => {
1264
+ if (!o.isMesh) return;
1265
+ meshes++;
1266
+ if (Array.isArray(o.material)) { arrayMeshes++; runs += o.material.length; o.material.forEach((m) => inUse.add(m)); }
1267
+ else if (o.material) inUse.add(o.material);
1268
+ });
1269
+ return {
1270
+ mode: xrefMode(entry.display), painted: entry.painted,
1271
+ meshes, arrayMeshes, runs, materials: inUse.size, cached: entry.mats.size,
1272
+ colors: [...inUse].map((m) => ({
1273
+ hex: `#${m.color.getHexString()}`, alpha: m.userData.alpha,
1274
+ opacity: Math.round(m.opacity * 1000) / 1000,
1275
+ })).sort((a, b) => (a.hex < b.hex ? -1 : 1)),
1276
+ };
1277
+ }
1278
+
1096
1279
  /** World bounds of one reference — what zoom-to frames, and what the off-screen check measures. */
1097
1280
  function referenceBounds(id) {
1098
1281
  const entry = xrefById.get(id);
@@ -1703,19 +1886,29 @@ function setEnvironment(on) {
1703
1886
  // dropping the coplanar diagonals, keeping the true member outline. Built lazily on first Wire entry and
1704
1887
  // cached per mesh; the outline is a CHILD of the mesh (inherits its transform, hidden with it) and is never
1705
1888
  // picked (member raycasts are non-recursive over meshById). The outline is drawn in the MEMBER's colour
1706
- // (matches the Solid legend, incl. the selection highlight) — line materials are shared per colour so ~24
1707
- // profiles cost ~24 materials, not one per member.
1889
+ // (matches the Solid legend) unless it is selected or hovered — see wireEdgeColorOf — and line materials are
1890
+ // shared per colour so ~24 profiles cost ~24 materials, not one per member.
1708
1891
  const WIRE_EDGE_FALLBACK = 0x94a3b8; // slate — only if a mesh somehow has no colour
1709
1892
  const wireEdgeMats = new Map(); // colour hex -> shared LineBasicMaterial
1710
1893
  const wireEdges = new Map(); // meshId -> LineSegments (edge overlay child)
1711
- function wireEdgeColorOf(mesh) { const c = mesh.material && mesh.material.color; return c ? c.getHex() : WIRE_EDGE_FALLBACK; }
1894
+ // In Wire mode the solid fill is hidden (applyDisplayMode), so a member's hover/selection cue — which lives on
1895
+ // the fill's EMISSIVE — is invisible unless the OUTLINE adopts it. Mirror it here, selection beating hover
1896
+ // exactly as setHoverGlow does. This tracks live because the only two writers of these sets end in
1897
+ // applyDisplayMode — setSelection and setHover both assign BEFORE their call, and clearRoot's reset is picked
1898
+ // up by the rebuild's own sweep — which re-colours through wireEdgesFor. hoverGlowIds (not hoverId) is the set
1899
+ // actually lit, so hovering one part of a connection outlines the whole connection — the grouping the glow uses.
1900
+ function wireEdgeColorOf(id, mesh) {
1901
+ if (selIds.has(id)) return SELECT_EMISSIVE; // selected → brand-blue outline
1902
+ if (hoverGlowIds.includes(id)) return HOVER_EMISSIVE; // hovered → sky outline (matches Solid/X-ray)
1903
+ const c = mesh.material && mesh.material.color; return c ? c.getHex() : WIRE_EDGE_FALLBACK;
1904
+ }
1712
1905
  function wireEdgeMatFor(hex) { let m = wireEdgeMats.get(hex); if (!m) { m = new THREE.LineBasicMaterial({ color: hex }); wireEdgeMats.set(hex, m); } return m; }
1713
1906
  function wireEdgesFor(id, mesh) {
1714
1907
  let ls = wireEdges.get(id);
1715
1908
  if (ls && ls.parent !== mesh) { if (ls.parent) ls.parent.remove(ls); ls.geometry.dispose(); ls = null; } // mesh rebuilt under the same id → drop the stale outline
1716
- const mat = wireEdgeMatFor(wireEdgeColorOf(mesh));
1909
+ const mat = wireEdgeMatFor(wireEdgeColorOf(id, mesh));
1717
1910
  if (!ls) { ls = new THREE.LineSegments(new THREE.EdgesGeometry(mesh.geometry, 20), mat); mesh.add(ls); wireEdges.set(id, ls); } // 20° threshold: keep corners, drop the flat-face triangulation diagonals
1718
- else ls.material = mat; // re-colour if the member's colour changed (selection highlight / recolour) — applyDisplayMode re-runs on selection
1911
+ else ls.material = mat; // re-colour if the outline's colour changed (selection / hover cue, or a member recolour) — applyDisplayMode re-runs on both
1719
1912
  return ls;
1720
1913
  }
1721
1914
  function clearWireEdges() {
@@ -2504,8 +2697,8 @@ function setSelection(ids) {
2504
2697
  mesh.material.emissive = new THREE.Color(on ? SELECT_EMISSIVE : 0x000000);
2505
2698
  mesh.material.emissiveIntensity = on ? 0.6 : 0;
2506
2699
  }
2700
+ selIds = new Set(set); // BEFORE applyDisplayMode: in Wire mode wireEdgeColorOf reads selIds to colour the outline, so it must already be current (mirrors the setHover ordering) — else a just-(de)selected outline keeps its old colour until the NEXT applyDisplayMode. The reglow re-sync below only fires when a still-hovered part was deselected, so it does not save the ordinary click-to-select case
2507
2701
  applyDisplayMode(); // selection swapped the materials → re-apply wire/xray
2508
- selIds = new Set(set);
2509
2702
  reconcileConnState(set); // any selection path (2D click, box-select, keyboard) must not leave a stale connection envelope/drill
2510
2703
  rebuildEndpoints(); // endpoint dots follow the selection
2511
2704
  let reglow = false; for (const g of hoverGlowIds) if (!set.has(g)) { setHoverGlow(g, true, false); reglow = true; } // still-hovered, now-unselected parts keep their glow (the material swap above cleared it)
@@ -4798,7 +4991,7 @@ function dispose() {
4798
4991
  dims3dGroup = dimPreviewLine = overlayDimsGroup = null;
4799
4992
  // The reference layer owns real GPU buffers — a whole tessellated building's worth. Leaving them
4800
4993
  // attached to a torn-down scene is the kind of leak that only shows up after the fifth 2D↔3D switch.
4801
- if (xrefGroup) { xrefGroup.traverse((o) => { o.geometry?.dispose?.(); o.material?.dispose?.(); }); if (scene) scene.remove(xrefGroup); }
4994
+ if (xrefGroup) { disposeReferenceMaterials(); xrefGroup.traverse((o) => { o.geometry?.dispose?.(); }); if (scene) scene.remove(xrefGroup); }
4802
4995
  xrefGroup = null; xrefById.clear(); xrefSelected = null;
4803
4996
  clearStructGrid();
4804
4997
  clearWireEdges();
@@ -4905,7 +5098,7 @@ window.Steel3DView = {
4905
5098
  // Reference models (#278) — an editor-only layer. `setReferences` takes the geometry the editor
4906
5099
  // fetched from the reference route; nothing here ever passes through contractToScene, which is what
4907
5100
  // keeps borrowed geometry out of every export by construction rather than by filtering.
4908
- setReferences, setReferenceDisplay: applyReferenceDisplay, setReferencePlacement, selectReference,
5101
+ setReferences, setReferenceDisplay: applyReferenceDisplay, setReferencePlacement, selectReference, referenceProbe,
4909
5102
  selectedReference: () => xrefSelected, frameReference, referenceBounds, referenceInfo,
4910
5103
  pickReferenceAt,
4911
5104
  setLabelsOn, labelsOn: () => labelsOnFlag, // member mark/id label overlay toggle
@@ -4948,6 +5141,7 @@ window.Steel3DView = {
4948
5141
  addDestAt: (x, y) => { if (!drDraft) return null; const r = drDestPoint({ clientX: x, clientY: y, shiftKey: false, altKey: false }); return r ? { p: r.p, snap: r.snap } : null; }, // test probe: the resolved 2nd draw point at a cursor (respects the axis lock) — read-only, no commit
4949
5142
  selDims3dCount: () => (api && api.selDim3d ? (api.selDim3d() || []).length : 0), // test helper: how many 3D dims are selected
4950
5143
  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 }; },
5144
+ 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"
4951
5145
  debug, probe, screenOf, centerOf, worldOf, snapCandidatesScreen, gridSegmentsScreen, gridBubblesScreen, clipHandlesScreen,
4952
5146
  clipPlanePreviewShown: () => !!clipPlanePreview, // test helper: is the armed-plane hover ghost currently showing?
4953
5147
  clipBoxFloorAt: (x, y) => clipBoxFloorPoint(x, y), // test helper: the snapped footprint point at a cursor ({ xy, snap, world } or null)
@@ -72,6 +72,28 @@
72
72
  body.panel-collapsed #panelToggle{right:4px}
73
73
  aside h3{margin:0 0 8px;font-size:12px;color:var(--mut);text-transform:uppercase;letter-spacing:.05em}
74
74
  select,input{background:#0f172a;color:var(--text);border:1px solid #475569;border-radius:6px;padding:6px;width:100%;font:13px system-ui}
75
+ /* The two control classes the generic rule above actively BREAKS, themed globally so anything added
76
+ later inherits the fix instead of needing its own escape hatch (CLAUDE.md "Style EVERY control").
77
+ Radios: with no accent-color a native radio paints in the LIGHT scheme on this dark page, and
78
+ `width:100%;padding:6px` above stretches it into a smear. Every checkbox in this file carries a
79
+ hand-written escape hatch for exactly that (.gck input, .m3dmenu label input, …); the two radios in
80
+ openCaptureModal/openDetailPick carried none. Numbers: the native spinner is drawn light too —
81
+ #confTarget suppressed it per-id and the three #csF3dFields origin inputs did not, which is the
82
+ per-container patching the scrollbar guard's history says never holds. Global, once, for both. */
83
+ /* appearance:none, NOT accent-color. accent-color only tints the CHECKED fill; the UNCHECKED radio
84
+ stays the UA widget — a solid white disc with a grey ring on this #070a0f page — and nothing here
85
+ declares `color-scheme`, so nothing pushes that widget dark. Measured in Chromium at 6x before
86
+ picking this route. So the radio is rebuilt the way app.css:1271 already builds .modal-check's
87
+ checkbox: own box, own ::before dot, :checked border, focus ring. */
88
+ input[type=radio]{appearance:none;-webkit-appearance:none;width:13px;height:13px;flex:none;padding:0;
89
+ border:1px solid #475569;border-radius:50%;background:#0f172a;cursor:pointer;display:inline-grid;place-content:center;
90
+ transition:border-color .12s} /* the ring animates WITH the dot, as app.css:1276 .modal-check already does — without this the border-colour snaps while the dot eases, which reads as two separate events (design review) */
91
+ input[type=radio]::before{content:'';width:7px;height:7px;border-radius:50%;background:var(--brand);transform:scale(0);transition:transform .12s ease}
92
+ input[type=radio]:checked{border-color:var(--brand)}
93
+ input[type=radio]:checked::before{transform:scale(1)}
94
+ input[type=radio]:focus-visible{outline:2px solid var(--brand);outline-offset:2px}
95
+ input[type=number]{-moz-appearance:textfield;appearance:textfield}
96
+ input[type=number]::-webkit-outer-spin-button,input[type=number]::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}
75
97
  .row{margin:8px 0} .danger{background:#7f1d1d;border-color:#991b1b} .danger:hover{background:#991b1b}
76
98
  .pill{display:inline-block;padding:1px 6px;border-radius:4px;font-size:11px}
77
99
  .pill-clickable{cursor:pointer;text-decoration:underline dotted rgba(254,202,202,.55);text-underline-offset:2px}
@@ -356,8 +378,10 @@
356
378
  .mhead{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;border-bottom:1px solid var(--line)}
357
379
  .mhead b{font-size:14px} .mhead button{padding:2px 9px}
358
380
  .conf-tgt{display:flex;align-items:center;gap:6px;margin-left:auto;margin-right:12px;font-size:12px;color:var(--mut)}
359
- #confTarget{width:54px;text-align:right;padding:4px 6px;font:13px system-ui;-moz-appearance:textfield;appearance:textfield}
360
- #confTarget::-webkit-outer-spin-button,#confTarget::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}
381
+ /* Layout only — the spinner suppression this used to carry per-id now lives on the global
382
+ input[type=number] rule near the top, which is what the three origin fields were missing. Leaving
383
+ the per-id copy here would just be the template for the next field to be patched one at a time. */
384
+ #confTarget{width:54px;text-align:right;padding:4px 6px;font:13px system-ui}
361
385
  .mgrid{padding:14px;overflow:auto;display:grid;grid-template-columns:repeat(auto-fill,minmax(168px,1fr));gap:12px}
362
386
  .dcard{border:1px solid var(--line);border-radius:8px;overflow:hidden;background:var(--bg)}
363
387
  .dcard .dprev{height:120px;display:flex;align-items:center;justify-content:center;background:#0b1220;color:var(--mut);font-size:11px;text-align:center;padding:8px;line-height:1.4}
@@ -785,6 +809,20 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
785
809
  #m3dRefsBody .refdet .lockrow .mck::after{content:'';position:absolute;top:1px;left:1px;width:10px;height:10px;border-radius:50%;background:#64748b;transition:transform .15s,background-color .15s}
786
810
  #m3dRefsBody .refdet .lockrow.on .mck{background:rgba(59,130,246,.28);border-color:var(--brand)}
787
811
  #m3dRefsBody .refdet .lockrow.on .mck::after{transform:translateX(12px);background:var(--brand)}
812
+ /* ── Reference colour: File / Grey / your own.
813
+ THE SWATCH IS THE THIRD SEGMENT, not a control beside one. Picking a colour and choosing "custom"
814
+ are one decision, so they are one gesture — the native colour input IS the third pill, and its own
815
+ swatch chrome carries the chosen colour. `.swc` is 14x14 and `flex:none` for the profile legend, so
816
+ it is restretched here to fill its cell; everything else about it is inherited, which is what makes
817
+ this read as a sibling of the member-profile swatch rather than a new species of control.
818
+ Selection is `var(--brand)` exactly as `.seg2 button.on` already does — but as an inset RING on the
819
+ swatch, never a fill: filling it would hide the very colour it exists to show. */
820
+ #m3dRefsBody .refdet .seg2{margin-top:0;height:24px}
821
+ #m3dRefsBody .refdet .seg2 button{font-size:11px;padding:0}
822
+ #m3dRefsBody .refdet .seg2 .swc{flex:1;width:auto;height:100%;border:0;border-radius:0;min-width:0}
823
+ #m3dRefsBody .refdet .seg2 .swc.on{box-shadow:inset 0 0 0 2px var(--brand)}
824
+ #m3dRefsBody .refdet .colrow{display:flex;align-items:center;gap:6px}
825
+ #m3dRefsBody .refdet .colrow .seg2{flex:1;min-width:0}
788
826
  /* ── Reference-model import modal (#refImportModal) — the #connImportModal recipe, under its own ids.
789
827
  A sibling rather than a third stage inside it: that modal's last stage is "pick one of several
790
828
  candidates found inside the file", and this one's is "confirm the one thing you are about to add",
@@ -8786,11 +8824,17 @@ function pushReferences(){
8786
8824
  * what rebuilds it. That is also why nothing here blocks — the native steel is already on screen and
8787
8825
  * the reference streams in behind it.
8788
8826
  */
8789
- async function loadReferenceGeometry(id){
8827
+ // `rebuild` forces the SERVER to re-read the IFC instead of serving its cache. Clearing the client
8828
+ // maps alone is not a reload: the cache is keyed on the IFC bytes, which a bridge upgrade does not
8829
+ // change, so a reference read before colours existed would stay grey for ever however often you asked.
8830
+ async function loadReferenceGeometry(id,opts){
8790
8831
  if(refGeom.has(id)||refLoading.has(id))return;
8791
8832
  refLoading.add(id);if(legendTab==='refs')renderRefsTab();
8792
8833
  try{
8793
- const res=await fetch(refApi('/'+encodeURIComponent(id)+'/geometry'));
8834
+ // INSIDE the suffix, not appended after. `refApi` already adds `?project=` and picks its own
8835
+ // separator from whether the suffix carries a `?` — appending afterwards produced a second `?`
8836
+ // and a 400, which is exactly what the browser pass caught.
8837
+ const res=await fetch(refApi('/'+encodeURIComponent(id)+'/geometry'+((opts&&opts.rebuild)?'?rebuild=1':'')));
8794
8838
  const d=await res.json().catch(()=>({}));
8795
8839
  // A LATE RESPONSE FOR A REMOVED REFERENCE IS DROPPED. These bodies can be hundreds of megabytes, and
8796
8840
  // repopulating `refGeom` under an id the contract no longer holds leaks all of it while making the
@@ -8800,7 +8844,7 @@ async function loadReferenceGeometry(id){
8800
8844
  // a row ends up claiming both "file missing" and "nothing to draw", or keeps a stale reason after a
8801
8845
  // successful retry.
8802
8846
  const only=(set)=>{for(const s of [refUnresolved,refFailed,refEmpty])if(s!==set)s.delete(id);};
8803
- if(res.ok&&d.ok){refGeom.set(id,{objects:d.objects||[],dropped:d.dropped||0,spanMm:d.spanMm||0});only(null);}
8847
+ if(res.ok&&d.ok){refGeom.set(id,{objects:d.objects||[],dropped:d.dropped||0,spanMm:d.spanMm||0,colorsAvailable:d.colorsAvailable===undefined?null:d.colorsAvailable});only(null);}
8804
8848
  else if(d.code==='reference-unresolved'){only(refUnresolved);refUnresolved.add(id);}
8805
8849
  else if(d.code==='reference-empty'){only(refEmpty);refEmpty.add(id);}
8806
8850
  // An `else` is mandatory here: a 500 whose body is not JSON parses to `{}`, so without one a failed
@@ -8996,11 +9040,98 @@ function buildRefRow(r){
8996
9040
  return row;
8997
9041
  }
8998
9042
 
9043
+ /** The default a custom swatch opens on: the app's own reference grey, so the picker starts somewhere
9044
+ * deliberate rather than on black. Mirrors XREF_COLOR in web/steel-3d-view.js. */
9045
+ const REF_GREY='#94a3b8';
9046
+ /** `file` unless the contract says otherwise — see the schema: absence must mean colours, so a
9047
+ * reference imported before this existed picks them up instead of staying grey forever. */
9048
+ const refColourMode=(d)=>(d&&(d.colorMode==='uniform'||d.colorMode==='custom')?d.colorMode:'file');
9049
+
9050
+ /**
9051
+ * Colour: File / Grey / a colour you pick.
9052
+ *
9053
+ * ONE CONTROL, NOT TWO. The swatch IS the third segment rather than a picker standing beside a
9054
+ * "Custom" button — choosing custom and choosing which colour are the same decision, and splitting
9055
+ * them into two controls would leave "Custom" meaning nothing until the other one was used.
9056
+ *
9057
+ * "File" IS HIDDEN, NOT DISABLED, for an IFC that carries no colour. A disabled option says "do
9058
+ * something and this will light up", and nothing the user can do in this panel will ever give that
9059
+ * file a palette — the same mistake as shipping disabled bulk actions in an empty state. What the
9060
+ * stored `colorMode` says is left ALONE while it is hidden: reload the geometry against a file that
9061
+ * has since gained colours, or refresh a bridge too old to report them, and File comes straight back
9062
+ * with the preference intact and nothing to migrate.
9063
+ */
9064
+ function buildRefColourRow(r,d){
9065
+ const row=document.createElement('div');row.className='colrow';
9066
+ row.appendChild(Object.assign(document.createElement('span'),{className:'dlab',textContent:'Colour'}));
9067
+
9068
+ const geom=refGeom.get(r.id);
9069
+ // TRUE ONLY WHEN THE ANSWER IS IN. Before geometry arrives there is nothing to say, and flickering
9070
+ // the segment out and back while a big model streams would be worse than showing it optimistically.
9071
+ // `colorsAvailable===false` is the file speaking; null is a bridge that could not be asked.
9072
+ const noColours=!!geom&&geom.colorsAvailable===false;
9073
+ const mode=refColourMode(d);
9074
+ // WHAT THE CONTROL SHOWS, which is not always what the contract stores. With File hidden, a stored
9075
+ // `file` would leave no segment lit at all — a radio group with nothing selected, when the reference
9076
+ // is plainly being drawn in something. It IS being drawn in the grey, so Grey is what lights up.
9077
+ // The stored value is left alone deliberately: reload against a file that has since gained colours,
9078
+ // or refresh a bridge too old to report them, and File returns already selected with nothing to migrate.
9079
+ const shown=(noColours&&mode==='file')?'uniform':mode;
9080
+
9081
+ const seg=document.createElement('div');seg.className='seg2';
9082
+ // role=group, NOT radiogroup. A radiogroup promises three elements with role=radio, and the third
9083
+ // is an <input type=color>, which ARIA-in-HTML allows no role on at all — overriding it announced
9084
+ // "radio button, not checked" and threw away the colour-picker semantics a screen reader needs.
9085
+ // Two toggle buttons plus a labelled colour input describes what this actually is.
9086
+ seg.setAttribute('role','group');seg.setAttribute('aria-label','Reference colour');
9087
+ const pick=(m,extra)=>{refEdit(r.id,{display:{colorMode:m,...(extra||{})}});};
9088
+ const mk=(m,label,tip)=>{
9089
+ const b=document.createElement('button');b.type='button';b.textContent=label;
9090
+ b.className=(shown===m?'on':'');b.dataset.mode=m;
9091
+ b.setAttribute('aria-pressed',String(shown===m));
9092
+ b.dataset.tip=tip;b.addEventListener('click',()=>pick(m));
9093
+ return b;};
9094
+ if(!noColours)seg.appendChild(mk('file','File','This model’s own colours, as the file authors them.'));
9095
+ seg.appendChild(mk('uniform','Grey','Flat grey — the reminder that this isn’t your steel, whatever colours the file uses.'));
9096
+
9097
+ const sw=document.createElement('input');sw.type='color';sw.className='swc'+(shown==='custom'?' on':'');
9098
+ sw.value=(d&&typeof d.color==='string'&&/^#[0-9a-fA-F]{6}$/.test(d.color))?d.color.toLowerCase():REF_GREY;
9099
+ sw.dataset.mode='custom';
9100
+ // A data-tip is invisible to a screen reader, so the swatch carries a real accessible name — and
9101
+ // it states whether this colour is the one in use, since there is no aria-pressed on an input.
9102
+ sw.setAttribute('aria-label','Custom colour for this reference'+(shown==='custom'?' (in use)':''));
9103
+ sw.dataset.tip='One colour for the whole reference — click to pick it.';
9104
+ // `input` repaints live as the user drags around the OS picker; `change` is what persists. Both set
9105
+ // the mode, so picking a colour IS choosing custom and there is never a colour chosen but not shown.
9106
+ sw.addEventListener('input',()=>{const v=window.Steel3DView;
9107
+ if(v&&v.setReferenceDisplay)v.setReferenceDisplay(r.id,{...refDisp(r),colorMode:'custom',color:sw.value});});
9108
+ sw.addEventListener('change',()=>pick('custom',{color:sw.value}));
9109
+ seg.appendChild(sw);
9110
+ row.appendChild(seg);
9111
+
9112
+ const wrap=document.createElement('div');wrap.style.cssText='display:flex;flex-direction:column;gap:4px';
9113
+ wrap.appendChild(row);
9114
+ // ALWAYS VISIBLE, never only a tooltip — a keyboard or screen-reader user never sees a data-tip, and
9115
+ // both of these sentences are the kind a user has to have to read the control correctly.
9116
+ if(noColours){
9117
+ const n=Object.assign(document.createElement('div'),{className:'dnote'});
9118
+ n.textContent='This file carries no colour information, so there is no File-colours option for it.';
9119
+ wrap.appendChild(n);
9120
+ } else if(shown==='file'){
9121
+ const n=Object.assign(document.createElement('div'),{className:'dnote'});
9122
+ n.textContent='Grey is this app’s signal that a reference is not your own content.';
9123
+ wrap.appendChild(n);
9124
+ }
9125
+ return wrap;
9126
+ }
9127
+
8999
9128
  /** The expanded block for the selected reference — the five controls a row has no room for. */
9000
9129
  function buildRefDetail(r){
9001
9130
  const d=refDisp(r),wrap=document.createElement('div');wrap.className='refdet';
9002
9131
  const opPct=Math.round((Number.isFinite(d.opacity)?d.opacity:0.5)*100);
9003
9132
 
9133
+ wrap.appendChild(buildRefColourRow(r,d));
9134
+
9004
9135
  const opRow=document.createElement('div');opRow.className='drow';
9005
9136
  opRow.appendChild(Object.assign(document.createElement('span'),{className:'dlab',textContent:'Opacity'}));
9006
9137
  const op=document.createElement('input');op.type='range';op.min='10';op.max='100';op.value=String(opPct);
@@ -9141,7 +9272,7 @@ function openRefRowMenu(r,anchorEl){closeRefRowMenu();
9141
9272
  if(nativeModelBounds())m.append(mk(REF_MOVE_LABEL,()=>refMoveToOrigin(r.id)));
9142
9273
  m.append(mk('Reload its geometry',()=>{
9143
9274
  if(refDisp(r).locked){toast('“'+r.name+'” is locked — unlock it to reload it');return;} // the lock freezes reload, as the schema says
9144
- refGeom.delete(r.id);refFailed.delete(r.id);refEmpty.delete(r.id);refUnresolved.delete(r.id);loadReferenceGeometry(r.id);}));
9275
+ refGeom.delete(r.id);refFailed.delete(r.id);refEmpty.delete(r.id);refUnresolved.delete(r.id);loadReferenceGeometry(r.id,{rebuild:true});}));
9145
9276
  m.appendChild(document.createElement('hr'));
9146
9277
  m.appendChild(mk('Remove',()=>refRemove(r),true));
9147
9278
  document.body.appendChild(m);
@@ -9295,7 +9426,7 @@ function adoptReferenceWrite(etag){if(!etag)return;const prev=serverEtag;serverE
9295
9426
  adoptReferenceWrite(d.etag);
9296
9427
  if(!Array.isArray(C.reference_models))C.reference_models=[];
9297
9428
  C.reference_models.push(d.reference);
9298
- refGeom.set(d.reference.id,{objects:d.objects||[],dropped:d.dropped||0,spanMm:d.spanMm||0});
9429
+ refGeom.set(d.reference.id,{objects:d.objects||[],dropped:d.dropped||0,spanMm:d.spanMm||0,colorsAvailable:d.colorsAvailable===undefined?null:d.colorsAvailable});
9299
9430
  refSelectedId=d.reference.id;
9300
9431
  inserted=d.reference;
9301
9432
  }catch(e){riClearSoft();riStage('drop');riErr('Could not add that reference.');console.error('[reference] insert failed',e);return;}
@@ -25,13 +25,15 @@
25
25
  * UNITS AND SIGNS — the one thing to get right.
26
26
  * Contract geometry is per-sheet display pixels scaled by `plan.pt_per_ft`, with Y growing DOWNWARD, and
27
27
  * elevations in INCHES. World mm is X east, Y "up the plan", Z up. So the plan Y axis is NEGATED, exactly
28
- * as `server/contract-to-scene.ts:dispToMm` does it. That negation is a reflection: it reverses handedness,
28
+ * as `steel-3d-core.js:dispToMm` does it. That negation is a reflection: it reverses handedness,
29
29
  * which is why `sheetFrame` documents what happens to a local frame's sense.
30
30
  *
31
- * This mirrors `contract-to-scene.ts`'s conversion rather than importing it (that file is server TypeScript;
32
- * this one is a browser module). Two independent world-mm conversions would be a real hazard — a model that
33
- * renders in one place and exports in another — so the mirror is held in lock-step by a parity test matrix
34
- * (`server/steel-model-adapter.test.ts`, "parity with contract-to-scene"). Change one, change both.
31
+ * IT IS NO LONGER A MIRROR. This module, the 3D view and `server/contract-to-scene.ts` all CALL the one
32
+ * `dispToMm` in `steel-3d-core.js` — a browser module the server already imports, so "that file is server
33
+ * TypeScript" never justified a second copy. Two independent world-mm conversions were a real hazard (a
34
+ * model that renders in one place and exports in another) and the parity test matrix
35
+ * (`server/steel-model-adapter.test.ts`, "parity with contract-to-scene") that held them in lock-step by
36
+ * hand is kept: it now guards the shared conversion instead of a copy of it.
35
37
  *
36
38
  * The two agree on every conversion of well-formed data: px scale, the Y negation, inches to mm (including
37
39
  * numeric strings), and the plumb-column rule. They diverge, deliberately and by assertion, on MALFORMED or
@@ -44,16 +46,12 @@
44
46
  * recorded here rather than asserted, since pinning a NaN as expected output would entrench a bug).
45
47
  */
46
48
 
47
- import { MODEL_V2_TOL, memberGeometryV2 } from './steel-3d-core.js';
49
+ import { MODEL_V2_TOL, memberGeometryV2, dispToMm } from './steel-3d-core.js';
48
50
 
49
- const FT_MM = 304.8;
50
51
  const IN_MM = 25.4; // ← becomes 1 when the contract stores elevations in mm (metric canonicalization)
51
52
 
52
- /** Scale for one plan's display pixels → mm. Matches contract-to-scene: a missing/zero pt_per_ft means 1. */
53
- const scaleOf = (plan) => FT_MM / (plan && plan.pt_per_ft > 0 ? plan.pt_per_ft : 1);
54
-
55
- /** Display point → world mm. Y is NEGATED (display Y grows down; world Y grows up the plan). */
56
- const dispToMm = (pt, k) => [pt[0] * k, -pt[1] * k];
53
+ /** One plan's `pt_per_ft`, or undefined — `dispToMm` reads a missing/zero/negative scale as 1 pt/ft. */
54
+ const ptPerFtOf = (plan) => plan && plan.pt_per_ft;
57
55
 
58
56
  const finitePt = (p) => Array.isArray(p) && p.length >= 2 && Number.isFinite(p[0]) && Number.isFinite(p[1]);
59
57
 
@@ -80,7 +78,8 @@ const num = (v) => {
80
78
  * Validity is the server's to judge, and a read boundary that quietly fell back to the v1 arm for a
81
79
  * malformed v2 document would answer with confident nonsense — a v2 member has no `wp`, so every method
82
80
  * would report an absence rather than a problem. Mirrored rather than imported because that module is
83
- * server TypeScript and this is a browser module; the same is true of the `dispToMm` mirror above.
81
+ * server TypeScript and this is a browser module — a reason that holds for the DISCRIMINATOR only; the
82
+ * `dispToMm` mirror it used to cite alongside is gone, imported from `steel-3d-core.js` now.
84
83
  */
85
84
  export function createModelAdapter(contract, opts = {}) {
86
85
  return (contract && typeof contract === 'object' && contract.type === 'steel.model/v2')
@@ -171,11 +170,11 @@ function createModelAdapterV1(contract, { activeSheet } = {}) {
171
170
  const m = memberById(id);
172
171
  if (!m || !Array.isArray(m.wp) || m.wp.length < 2 || !finitePt(m.wp[0]) || !finitePt(m.wp[1])) return null;
173
172
  const plan = planFor(m);
174
- const k = scaleOf(plan);
173
+ const ptPerFt = ptPerFtOf(plan);
175
174
  const z0 = endElevMm(m, plan, 0), z1 = endElevMm(m, plan, 1);
176
175
  if (z0 == null || z1 == null) return null;
177
- const a = dispToMm(m.wp[0], k);
178
- const b = m.role === 'column' ? a : dispToMm(m.wp[1], k); // plumb: the top shares the base X/Y
176
+ const a = dispToMm(m.wp[0], ptPerFt);
177
+ const b = m.role === 'column' ? a : dispToMm(m.wp[1], ptPerFt); // plumb: the top shares the base X/Y
179
178
  return { from: [a[0], a[1], z0], to: [b[0], b[1], z1], frame: 'world-mm' };
180
179
  },
181
180
 
@@ -204,8 +203,7 @@ function createModelAdapterV1(contract, { activeSheet } = {}) {
204
203
  if (!f || !finitePt(f.o) || !finitePt(f.u)) return null;
205
204
  const len = Math.hypot(f.u[0], f.u[1]);
206
205
  if (!(len > 0)) return null; // a zero-length axis carries no direction — matches the editor's sanitizeFrame
207
- const k = scaleOf(p);
208
- return { origin: dispToMm(f.o, k), xAxis: [f.u[0] / len, -f.u[1] / len] };
206
+ return { origin: dispToMm(f.o, ptPerFtOf(p)), xAxis: [f.u[0] / len, -f.u[1] / len] };
209
207
  },
210
208
 
211
209
  /**