@floless/app 0.133.2 → 0.134.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.
@@ -575,6 +575,8 @@
575
575
  body.v3d #moreMenu #dimStyleB{display:none} /* …and the mirror: Dimension style edits the 2D dim overlay, so it has nothing to show in 3D (Grid lines… stays — a grid IS drawn in 3D) */
576
576
  body.v3d #moreMenu #csSetB{display:none} /* the 2D set-local-axes (P.frame) is 2D-only… */
577
577
  body:not(.v3d) #moreMenu #csArm3dB,body:not(.v3d) #moreMenu #csF3dFields{display:none} /* …and the 3D local frame is 3D-only */
578
+ body:not(.v3d) #moreMenu #posGizmoToggleB{display:none} /* the Profile Position gizmo is a 3D handle — hide its toggle in 2D */
579
+ body:not(.v3d) #posFromMemberRow{display:none} /* "From member" adopts a member's own 3D axes as the coordinate system — 3D-only */
578
580
  #moreMenu #csArm3dB.on{border-color:var(--brand);color:var(--brand)}
579
581
  #csF3dFields{display:none;grid-template-columns:auto 1fr;gap:4px 7px;align-items:center;margin:6px 2px 2px} /* base hide as a RULE (not inline) so #csF3dFields.on can override it — an inline display:none can't be beaten by a class (Codex) */
580
582
  #csF3dFields.on{display:grid}
@@ -839,6 +841,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
839
841
  #cmHud{position:fixed;z-index:70;display:none;align-items:center;gap:6px;background:var(--panel);border:1px solid var(--brand);border-radius:8px;padding:6px 8px;box-shadow:0 6px 20px rgba(0,0,0,.55);font:12px system-ui;color:var(--mut)}
840
842
  #cmHud.err{border-color:#fca5a5}
841
843
  #cmHud input{width:110px;height:24px;background:var(--bg);color:var(--text);border:1px solid var(--line);border-radius:5px;padding:0 7px;font:12px system-ui}
844
+ #cmHud input::placeholder{color:var(--mut);opacity:.75} /* the position HUD opens empty with the current value as its placeholder — keep it legibly muted, never the washed-out browser default */
842
845
  #cmHud input:focus{outline:none;border-color:var(--brand)}
843
846
  #cmHud.err input{border-color:#fca5a5}
844
847
  #cmHudPill{display:inline-flex;align-items:center;gap:2px;padding:2px;height:20px;border-radius:4px;background:#0f172a;border:1px solid var(--line)}
@@ -1842,6 +1845,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
1842
1845
  to 16 — then jumped on the first drag. One authority on what a legal size is. -->
1843
1846
  <div class=mrow><span class=mlbl>Grid label size</span><input data-command-id="steel.grid-label-size" id=gridLabelSize type=range min=14 max=48 step=1 aria-label="Grid label size in pixels" data-tip="How big the grid bubbles are drawn, in both 2D and 3D. Like a CAD drawing they hold this size on screen however far you zoom in or out."><span id=gridLabelSizeV class=mval>26 px</span></div>
1844
1847
  <button data-command-id="steel.show-member-length" id=lenToggleB class=dtog role=menuitemcheckbox aria-checked=false data-tip="Show the length of each selected member in 2D and 3D"><span class=mck aria-hidden=true></span>Member length</button>
1848
+ <button data-command-id="steel.position-gizmo" id=posGizmoToggleB class=dtog role=menuitemcheckbox aria-checked=false data-tip="Show a drag handle on the selected member for setting its Profile Position right in the 3D view"><span class=mck aria-hidden=true></span>Position handle</button>
1845
1849
  <button data-command-id="steel.show-property-labels" id=plToggleB class=dtog role=menuitemcheckbox aria-checked=true data-tip="Show or hide property labels in the 2D plan (the property selection is shared with 3D — this hides them here only)"><span class=mck aria-hidden=true></span>Property labels</button>
1846
1850
  <button data-command-id="steel.show-reference-sheet" id=refToggleB class=dtog role=menuitemcheckbox aria-checked=true data-tip="Show or hide the traced reference sheet (the PDF/SVG drawing under the model). Hidden, it also stops contributing snap points."><span class=mck aria-hidden=true></span>Reference sheet</button>
1847
1851
  <button data-command-id="steel.grid" id=gridEditB data-tip="Grid lines — a plan reference with structural bay spacings (n*d repeats a bay). Shows in 2D and 3D; drawing and drags snap to its lines and intersections.">Grid lines…</button>
@@ -3078,6 +3082,7 @@ let _lastDimDown=null; // F8: {id,t} of the last dim pointerdown, for manual d
3078
3082
  let drawDraft=null,drawBasisTok=null; // Add-member tool: the first CLICKED start point + immutable authoring-basis snapshot (or null) — both picks must stay in one frame
3079
3083
  let calloutsVisible=true; // Workstream B: show/hide the clickable callout bubbles (details + section/elevation/detail-ref) on the plan in select mode
3080
3084
  let showSelLen=(()=>{try{return localStorage.getItem('steel:selLen:v2')==='1';}catch(_){return false;}})(); // ⋯ Display → Show member length: paint each selected member's length on the canvas (opt-in, default off)
3085
+ let showPosGizmo=(()=>{try{return localStorage.getItem('steel:posGizmo:v2')==='1';}catch(_){return false;}})(); // ⋯ Display → Position handle: the 3D Profile Position gizmo on the selected member (opt-in, default off)
3081
3086
  let refSheetOn=(()=>{try{return localStorage.getItem('steel:refSheet:v2')!=='0';}catch(_){return true;}})(); // ⋯ Display → Reference sheet (F13): show/hide the traced PDF/SVG overlay under the model (default ON; only an explicit '0' hides it)
3082
3087
  // ⋯ Display → Grid label size: how big a grid bubble is ON SCREEN, in px. Constant on screen in both
3083
3088
  // views (2D divides by zoom, 3D re-derives a world size per frame), so one grid reads the same in each —
@@ -3397,6 +3402,45 @@ function commitPositionEdit(members,userPatch,source){const captured=positionAut
3397
3402
  if(blockers.length)return positionRefuse('No changes made — '+blockers.join('; ')+'. Resolve every blocker, or set Depth and Width to Middle in each stored frame first.',source);
3398
3403
  const current=positionAuthoringBasis();if(current.generation!==captured.generation)return positionRefuse('Frame changed — review the refreshed Profile Position and try again.',source);
3399
3404
  edit(()=>{for(const row of prepared)ModelCmd.patchMember(row.m,row.patch);});return true;}
3405
+ /*
3406
+ * Read-only snapshot the 3D Profile Position gizmo (slice 3a) renders from. The editor owns the
3407
+ * semantics; the 3D view only draws the arrows and reports back an ABSOLUTE new value, which
3408
+ * `commitMemberPosition` sends through the shipped `commitPositionEdit` (which rebases to the current
3409
+ * authoring frame exactly as a panel edit does). The values here MIRROR the inspector panel — the SAME
3410
+ * numbers the panel shows — so the gizmo and the panel can never show two different numbers for the same
3411
+ * member:
3412
+ * - the numeric offsets are the stored values (they are basis-independent — a rebase preserves them);
3413
+ * - `rot` is `positionAuthoringRoll(m)` — the stored roll RE-EXPRESSED into the current authoring frame
3414
+ * (3b.2), matching the panel's rotation field/chips (`rotDisp`/`rotN` also read `positionAuthoringRoll`).
3415
+ * The axes are the CURRENT authoring frame's part frame, so a depth/width drag moves the steel along the
3416
+ * same axis a panel offset edit would, and the re-expressed roll makes the roll drag agree too — which is
3417
+ * why the 3a basis-match guard is retired here (the gizmo works under any frame with preview == commit).
3418
+ */
3419
+ function memberPositionGizmoState(id){
3420
+ const m=byId(id);if(!m)return{available:false,reason:'no member'};
3421
+ const captured=positionAuthoringBasis();if(!captured.ok)return{available:false,reason:captured.message};
3422
+ const input=positionRebaseInput(m);if(!input)return{available:false,reason:m.id+' has incomplete work points'};
3423
+ // 3b.2: the gizmo works under ANY frame. The displayed roll is re-expressed into the current authoring
3424
+ // frame (positionAuthoringRoll — the same angle the Inspect panel shows), and the numeric offsets are
3425
+ // basis-independent, so a drag's live preview — swung with THIS roll on the current-frame axes, from the
3426
+ // last bake — is exactly what commitPositionEdit re-derives (no jump on release; the 3a basis-match guard
3427
+ // is retired). It is available only where a commit would succeed: preflight the rebase and refuse on any
3428
+ // failure (a named face on an unresolved section, a residual, a degenerate frame), so the gizmo never
3429
+ // shows a member the Inspect panel would refuse to commit — never a stored-roll fallback that lies.
3430
+ if(!positionBasisMatches(input.canonical,captured)){
3431
+ const pf=SteelCore.reexpressMemberPlacement(input.canonical,input.from,input.to,captured,input.extents);
3432
+ if(!pf.ok)return{available:false,reason:m.id+' can’t be re-expressed in the current frame — use the Inspect panel'};
3433
+ }
3434
+ const f=SteelCore.positionGizmoFrame(input.from,input.to,captured);
3435
+ if(!f)return{available:false,reason:m.id+' has no Profile Position frame in the current view'};
3436
+ return{available:true,id,anchor:[...input.from],xAxis:[...f.x],yAxis:[...f.y],zAxis:[...f.z],
3437
+ positionOffset:+m.positionOffset||0,positionHOffset:+m.positionHOffset||0,rot:positionAuthoringRoll(m),degenerate:!!f.degenerate};}
3438
+ /*
3439
+ * The gizmo's one write path: the 3D view hands back an absolute new offset (mm) or roll (deg) for a
3440
+ * single member; this routes it through `commitPositionEdit`, which rebases to the current frame,
3441
+ * applies the edit, and produces exactly one undo entry. Returns a boolean (false = refused).
3442
+ */
3443
+ function commitMemberPosition(id,patch,source){const m=byId(id);if(!m)return positionRefuse('That member is no longer in the model.',source);return commitPositionEdit([m],patch,source||null);}
3400
3444
  /*
3401
3445
  * ONE row of the Profile Position section: heading + offset box on the first line, named faces on the
3402
3446
  * second. The mockup drew all three on one line; at 280 px — ~246 px of content once the rail's padding and
@@ -4592,13 +4636,52 @@ function planRegistration(){
4592
4636
  }
4593
4637
  _planXfCache={key,xf};return xf;
4594
4638
  }
4595
- function positionEffectiveWorldRot(m){
4596
- if(!m||!m.positionBasis)return +m.rot||0;
4597
- const basis=SteelCore.basisFromAxes(m.positionBasis.x,m.positionBasis.y),g=SteelCore.memberGeometryV2(v2CanonicalMember(m.id));
4598
- if(!basis||!g)return null;
4599
- const a=SteelCore.partFrame(g.line[0],g.line[1],basis.z,basis.x),global=SteelCore.partFrame(g.line[0],g.line[1]);if(!a||!global)return null;
4600
- const th=(+m.rot||0)*Math.PI/180,c=Math.cos(th),s=Math.sin(th),w=[c*a.y[0]+s*a.z[0],c*a.y[1]+s*a.z[1],c*a.y[2]+s*a.z[2]];
4601
- return Math.atan2(w[0]*global.z[0]+w[1]*global.z[1]+w[2]*global.z[2],w[0]*global.y[0]+w[1]*global.y[1]+w[2]*global.y[2])*180/Math.PI;
4639
+ // The member's stored roll RE-EXPRESSED into `target` (a positionAuthoringBasis snapshot; null/global →
4640
+ // world). ONE copy of the roll math — the 2D plan footprint targets global (positionEffectiveWorldRot),
4641
+ // the Profile Position panel + 3D gizmo target the current authoring frame (positionAuthoringRoll). The
4642
+ // roll needs NO section extents (unlike the offset re-expression), so it is always computable for a
4643
+ // non-degenerate member. Returns null only for a degenerate/unresolvable frame; a caller picks its fallback.
4644
+ function positionEffectiveRotInto(m,target){
4645
+ if(!m)return null;
4646
+ // Match the commit path (SteelCore.reexpressMemberPlacement) EXACTLY so the displayed roll can never
4647
+ // diverge from what a commit re-expresses: the stored basis is read as-is (stored bases are already
4648
+ // canonical), and the TARGET is CANONICALISED the same way (Gram-Schmidt) — a skew authoring basis then
4649
+ // still agrees instead of silently falling back to the stored roll. Wrapped so a single degenerate member
4650
+ // degrades to null (→ stored roll) rather than throwing partFrame and taking down the whole panel render.
4651
+ try{
4652
+ const oldBasis=m.positionBasis?SteelCore.basisFromAxes(m.positionBasis.x,m.positionBasis.y):{x:[1,0,0],y:[0,1,0],z:[0,0,1]};
4653
+ const ct=(!target||target.kind==='global')?{x:[1,0,0],y:[0,1,0]}:SteelCore.canonicalPositionBasis(target.x,target.y);
4654
+ const tgt=ct&&SteelCore.basisFromAxes(ct.x,ct.y);
4655
+ const g=SteelCore.memberGeometryV2(v2CanonicalMember(m.id));
4656
+ if(!oldBasis||!tgt||!g)return null;
4657
+ const a0=SteelCore.partFrame(g.line[0],g.line[1],oldBasis.z,oldBasis.x),a1=SteelCore.partFrame(g.line[0],g.line[1],tgt.z,tgt.x);
4658
+ if(!a0||!a1)return null;
4659
+ const th=(+m.rot||0)*Math.PI/180,c=Math.cos(th),s=Math.sin(th),w=[c*a0.y[0]+s*a0.z[0],c*a0.y[1]+s*a0.z[1],c*a0.y[2]+s*a0.z[2]];
4660
+ return Math.atan2(w[0]*a1.z[0]+w[1]*a1.z[1]+w[2]*a1.z[2],w[0]*a1.y[0]+w[1]*a1.y[1]+w[2]*a1.y[2])*180/Math.PI;
4661
+ }catch(err){console.warn('[positionEffectiveRotInto]',m&&m.id,'roll re-expression failed',err);return null;}
4662
+ }
4663
+ function positionEffectiveWorldRot(m){if(!m||!m.positionBasis)return +m.rot||0;return positionEffectiveRotInto(m,null);}
4664
+ // The roll AS IT READS in the current authoring frame (deg, signed like the stored value) — the one source
4665
+ // the panel and the 3D gizmo both show, so a member authored in another frame reads the angle you would type
4666
+ // to leave it where it is, matching what commitPositionEdit round-trips. Falls back to the stored roll when
4667
+ // the authoring basis is invalid, the work points are incomplete, the bases already match, or the frame is
4668
+ // degenerate — every case where there is no distinct current-frame roll to show.
4669
+ function positionAuthoringRoll(m){
4670
+ if(!m)return 0;const stored=+m.rot||0;
4671
+ const captured=positionAuthoringBasis();if(!captured.ok)return stored;
4672
+ // Cheap membership check — deliberately NOT positionRebaseInput, which builds the section outline/extents
4673
+ // this never uses (it would run N outline builds per multi-select render). Only the canonical member (for
4674
+ // positionBasisMatches) and resolvable work points are needed; positionEffectiveRotInto re-derives the rest.
4675
+ const c=v2CanonicalMember(m.id);
4676
+ if(!c||SteelCore.knownZ(c.from&&c.from.z)==null||SteelCore.knownZ(c.to&&c.to.z)==null)return stored;
4677
+ if(positionBasisMatches(c,captured))return stored;
4678
+ const r=positionEffectiveRotInto(m,captured);
4679
+ // A distinct current-frame roll exists but is degenerate/unresolvable — show the stored roll rather than a
4680
+ // thrown panel, and SAY SO (a silent wrong angle is the one thing a placement display may never be). The
4681
+ // 3D gizmo never reaches here: its reexpress preflight shares partFrame's degeneracy, so it is unavailable
4682
+ // in exactly these cases (no preview jump). This is a display-only fallback on an already-degenerate member.
4683
+ if(r==null){console.warn('[positionAuthoringRoll]',m.id,'no current-frame roll (degenerate/unresolvable) — showing the stored roll');return stored;}
4684
+ return r;
4602
4685
  }
4603
4686
  function columnSectionPoly(m){
4604
4687
  const wp=m&&m.wp;if(!wp||!wp.length)return null;
@@ -6600,7 +6683,7 @@ function panel(){
6600
6683
  // reads is what stops the two from ever disagreeing. (code review)
6601
6684
  const rollDeg=r=>{const th=((typeof r==='number'&&isFinite(r))?r:0)*Math.PI/180;
6602
6685
  const d=Math.atan2(Math.sin(th),Math.cos(th))*180/Math.PI;return +(((d%360)+360)%360).toFixed(6);};
6603
- const rotAgg=agg(arr,m=>rollDeg(+m.rot)); // shared rotation, or VARIES
6686
+ const rotAgg=agg(arr,m=>rollDeg(positionAuthoringRoll(m))); // 3b.2: shared roll RE-EXPRESSED into the current frame (rollDeg reads the geometry quantity + normalises), or VARIES
6604
6687
  const qdElig=(sel2d()||[]).filter(isDimAnchorableMember),qdN=qdElig.length+selGridIds.size,qdHasBeam=qdElig.some(m=>(m.role||'beam')!=='column'); // F7: active-plan beams + columns + co-selected grid lines; the Start/Mid/End toggle only matters when a beam is in the set
6605
6688
  p.innerHTML=`<h3>${arr.length} members selected</h3>
6606
6689
  ${typeFilterHTML()}
@@ -6670,7 +6753,7 @@ function panel(){
6670
6753
  // Rotation — apply one angle to every selected member's section (blank input = no-op). Normalised (-360,360).
6671
6754
  {const setRot=v=>{const raw=String(v).trim();let r=Number(raw.replace(',','.'));
6672
6755
  if(!isFinite(r)){toast('Couldn’t read “'+raw+'” as an angle — enter degrees, e.g. 45 or -90.');render();return;}
6673
- r=r%360;commitPositionEdit(selArr(),{rot:r},document.activeElement);};
6756
+ r=SteelCore.rollCommitNorm(r);commitPositionEdit(selArr(),{rot:r},document.activeElement);}; // shared fold (== r%360, signed) — one convention for panel + gizmo
6674
6757
  const _ri=document.getElementById('detRotZ');if(_ri)_ri.onchange=e=>{if(e.target.value.trim()==='')return;setRot(e.target.value);};
6675
6758
  const chip=(id,val)=>{const b=document.getElementById(id);if(b)b.onclick=()=>setRot(val);};
6676
6759
  chip('rot0',0);chip('rot90',90);chip('rot180',180);chip('rot270',270);}
@@ -6815,8 +6898,9 @@ function panel(){
6815
6898
  const spSect=spjs.length?`<div class=hint style="margin:8px 0 0">${spIntro}</div>${spjs.map(spBlock).join('')}`:'';
6816
6899
  const _cps=(!col&&copesByMember[m.id])?copesByMember[m.id]:[]; // auto cope(s) on this beam (from the rendered scene)
6817
6900
  const copeSect=_cps.length?`<div class=divrow><hr><span class=sect style="margin:0">Cope (auto)</span><hr></div><div class=hint style="margin:0 0 2px">${_cps.map(esc).join(' · ')} — auto, clash-driven so the beam clears the support.</div>`:'';
6818
- const rotN=((((+m.rot||0)%360)+360)%360); // [0,360) → drives the quick-chip highlight
6819
- const rotDisp=Number((((+m.rot||0)%360)).toFixed(2));// signed (-360,360), cleaned, shown in the input
6901
+ const _effRot=positionAuthoringRoll(m); // 3b.2: roll as it reads in the CURRENT authoring frame, not the raw stored value
6902
+ const rotN=Number(((((_effRot)%360)+360)%360).toFixed(2));// [0,360), 2dp → a re-expressed 90.0000001 still lights the 90° chip
6903
+ const rotDisp=Number((((_effRot)%360)).toFixed(2)); // signed (-360,360), cleaned, shown in the input
6820
6904
  const br=isBrace(m), brc=(m.brace||{}); // B4 brace controls (Brace type / Position / Offset / swap lower↔higher)
6821
6905
  const braceSect=!br?'':`<div class=divrow><hr><span class=sect style="margin:0">Brace</span><hr></div>
6822
6906
  <div class=elab>Brace type</div>
@@ -6903,6 +6987,7 @@ function panel(){
6903
6987
  ${bpSect}${spSect}${copeSect}
6904
6988
  <div class=divrow><hr><span class=sect style="margin:0" data-tip="${POSTIP.head}">Profile Position <span style="opacity:.45;font-weight:400">ⓘ</span></span><hr></div>
6905
6989
  ${positionFrameHTML()}
6990
+ <div class=row id=posFromMemberRow style="margin:0 0 6px"><button data-command-id="steel.position-from-member" id=posFromMemberB class=ghostw data-tip="Set the coordinate system to this member's own axes — its Rotation then reads 0">⌖ From member</button></div>
6906
6991
  ${posRow('Depth','posOff','Offset',m.positionOffset,POSTIP.offD,
6907
6992
  `<button data-command-id="steel.position-face#with its top face on the line" id=posTop class="${pos==='top'?'on':''}" aria-pressed="${pos==='top'?'true':'false'}" data-tip="${POSTIP.top}">Top</button><button data-command-id="steel.position-face#centred in depth" id=posMid class="${pos==='middle'?'on':''}" aria-pressed="${pos==='middle'?'true':'false'}" data-tip="${POSTIP.mid}">Middle</button><button data-command-id="steel.position-face#with its underside on the line" id=posBot class="${pos==='bottom'?'on':''}" aria-pressed="${pos==='bottom'?'true':'false'}" data-tip="${POSTIP.bot}">Bottom</button>`)
6908
6993
  +posRow('Width','posHOff','Offset',m.positionHOffset,POSTIP.offW,
@@ -6966,10 +7051,37 @@ function panel(){
6966
7051
  // the one thing a placement field may never do.
6967
7052
  {const setRot=v=>{const raw=String(v).trim();let r=Number(raw.replace(',','.'));
6968
7053
  if(!isFinite(r)){toast('Couldn’t read “'+raw+'” as an angle — enter degrees, e.g. 45 or -90.');render();return;}
6969
- r=r%360;commitPositionEdit([m],{rot:r},document.activeElement);};
7054
+ r=SteelCore.rollCommitNorm(r);commitPositionEdit([m],{rot:r},document.activeElement);}; // shared fold (== r%360, signed) — one convention for panel + gizmo
6970
7055
  const _ri=document.getElementById('detRotZ');if(_ri)_ri.onchange=e=>setRot(e.target.value);
6971
7056
  const chip=(id,val)=>{const b=document.getElementById(id);if(b)b.onclick=()=>setRot(val);};
6972
7057
  chip('rot0',0);chip('rot90',90);chip('rot180',180);chip('rot270',270);}
7058
+ // From member (§3.2): adopt this member's OWN axes — INCLUDING its roll — as the 3D coordinate system, so it
7059
+ // then reads Rotation 0. The steel does not move (only the frame the numbers are read against changes), and
7060
+ // it is idempotent. The adopted basis is built from the member's ROLLED transverse axes (rolledWidth =
7061
+ // a0.y·cosθ + a0.z·sinθ, and its cross with the member axis is the rolled depth = the CS normal); partFrame
7062
+ // then re-derives the member's frame as exactly this rolled frame, so positionAuthoringRoll reads 0.
7063
+ {const _fm=document.getElementById('posFromMemberB');
7064
+ if(_fm)_fm.onclick=()=>{
7065
+ if(!(view3d&&window.Steel3DView&&window.Steel3DView.setFrameBasis)){toast('Switch to the 3D view to adopt a member’s axes.');return;}
7066
+ const input=positionRebaseInput(m);
7067
+ if(!input){toast('This member’s work points aren’t resolved yet — can’t read its axes.');return;}
7068
+ let frame;
7069
+ try{
7070
+ const sb=m.positionBasis?SteelCore.basisFromAxes(m.positionBasis.x,m.positionBasis.y):{x:[1,0,0],y:[0,1,0],z:[0,0,1]};
7071
+ const a0=sb&&SteelCore.partFrame(input.from,input.to,sb.z,sb.x);
7072
+ if(!a0){toast('This member has no usable section frame to adopt.');return;}
7073
+ const th=(+m.rot||0)*Math.PI/180,c=Math.cos(th),s=Math.sin(th);
7074
+ const rolledWidth=[a0.y[0]*c+a0.z[0]*s,a0.y[1]*c+a0.z[1]*s,a0.y[2]*c+a0.z[2]*s];
7075
+ const b=SteelCore.basisFromAxes(a0.x,rolledWidth); // b.z = the rolled depth = the coordinate system normal
7076
+ if(!b){toast('This member’s axes don’t form a usable frame.');return;}
7077
+ frame={origin:[...input.from],xAxis:[...b.x],yAxis:[...b.y],normal:[...b.z]};
7078
+ }catch(err){console.error('[steel.position-from-member] failed to derive '+(m&&m.id)+' axes',err);toast('Couldn’t read this member’s axes.');return;}
7079
+ // The write + confirmation live OUTSIDE the try: a throw inside setFrameBasis's render chain is a
7080
+ // different failure (it would half-apply the frame) and must not be reported as "couldn't read axes".
7081
+ // The toast is NON-sticky (false) so the confirmation fades — `true` would pin it on screen forever.
7082
+ window.Steel3DView.setFrameBasis(frame);
7083
+ toast('Coordinate system set to '+m.id+'’s axes — its Rotation now reads 0.',false,3200);
7084
+ };}
6973
7085
  const wireTos=(id,o)=>{const ck=document.getElementById(id+'_ck');if(ck)ck.onchange=e=>edit(()=>{ModelCmd.setTosDefault(o,e.target.checked,defaultTOS);});
6974
7086
  const inp=document.getElementById(id);if(inp)inp.onchange=e=>edit(()=>{ModelCmd.setTosValue(o,parseLen(e.target.value));});};
6975
7087
  const wireDet=(id,o)=>{const i=document.getElementById(id);if(i)i.onchange=e=>edit(()=>{ModelCmd.patchEnd(o,{detail:e.target.value.trim()});});
@@ -8104,8 +8216,23 @@ function cmCommit(v){cmApplyOffsets(cmOffsetsFor(v));}
8104
8216
  // --- numeric HUD (spec §3.3): type after the base pick → exact distance or dx,dy[,dz] (dz inches).
8105
8217
  // Live parse echo while typing; unparseable Enter flags the chip red (inline, not just a toast). ---
8106
8218
  let cmHudEl=null,cmHudAbs=false,cmHudLock=false,cmHudConsumer='movecopy',cmHudPrimed=false; // UCS stage 3 typed-entry HUD state (per open)
8219
+ let posHudTarget=null; // 3b.3: {id,axis,cur} when the shared #cmHud is opened as the Profile Position typed-entry consumer (double-click a handle)
8220
+ // Double-click a position gizmo handle → dock the shared #cmHud at it to type an exact value (bypasses snap).
8221
+ // Opens EMPTY (the current value is the placeholder, spec §3.1); the view freezes the camera so orbit can't
8222
+ // drift the anchor the HUD is pinned to. Only opens where the panel would commit (memberPositionGizmoState.available).
8223
+ function openPositionHud(id,axis,scr){
8224
+ const st=memberPositionGizmoState(id);
8225
+ if(!st||!st.available){ // a double-click on a VISIBLE handle that opens nothing is confusing — the view picked it from a cached snapshot, but a fresh read can disagree (a mid-flight external write, a roll that became unresolvable). Surface it instead of a silent return (mirrors currentPositionGizmoState's console.debug + the drag bail).
8226
+ console.debug('steel: position HUD not opened —',st&&st.reason);
8227
+ toast('Can’t edit this handle right now'+(st&&st.reason?' — '+st.reason:'')+'. Try the Inspect panel.');return;}
8228
+ const cur=axis==='depth'?st.positionOffset:axis==='width'?st.positionHOffset:st.rot;
8229
+ posHudTarget={id,axis,cur};
8230
+ if(view3d&&window.Steel3DView&&window.Steel3DView.setPositionTyping)window.Steel3DView.setPositionTyping(true);
8231
+ cmHudShow('',{consumer:'position',scr});
8232
+ }
8107
8233
  function cmHudIsOpen(){return !!(cmHudEl&&cmHudEl.style.display!=='none');}
8108
8234
  function cmHudClose(){if(cmHudEl){cmHudEl.style.display='none';cmHudEl.classList.remove('err');const i=cmHudEl.querySelector('input');if(i)i.value='';}
8235
+ if(posHudTarget){posHudTarget=null;if(view3d&&window.Steel3DView&&window.Steel3DView.setPositionTyping)window.Steel3DView.setPositionTyping(false);} // 3b.3: unfreeze the camera + drop the position target (a close is not a commit). KEEP THESE TWO ATOMIC — the camera unfreeze is gated on posHudTarget being non-null here; nulling posHudTarget anywhere else would strand the camera frozen.
8109
8236
  if(view3d&&window.Steel3DView&&window.Steel3DView.pointEntryEnd)window.Steel3DView.pointEntryEnd(); // drop the view's captured token (a close is not a commit)
8110
8237
  try{stage.focus({preventScroll:true});}catch(_){}}
8111
8238
  function cmHudSetAbs(abs){if(cmHudLock)abs=true;cmHudAbs=!!abs;cmHudSyncPill();cmHudPlaceholder();if(cmHudEl)cmHudEcho();} // REL/ABS pill toggle — re-runs the same live parse/echo
@@ -8114,6 +8241,7 @@ function cmHudSyncPill(){if(!cmHudEl)return;const pill=cmHudEl.querySelector('#c
8114
8241
  pill.querySelectorAll('.cmHudSeg').forEach(s=>{const on=((s.dataset.mode==='abs')===cmHudAbs);s.setAttribute('aria-checked',on?'true':'false');s.tabIndex=on?0:-1;s.classList.toggle('on',on);}); // roving tabindex: only the selected radio is Tab-reachable
8115
8242
  const abs=pill.querySelector('.cmHudSeg[data-mode="abs"]');if(abs)abs.setAttribute('data-tip',cmHudLock?'First point has no anchor to offset from — absolute only':'Absolute — X′,Y′,Z′ in the local frame (X,Y,Z if none)');}
8116
8243
  function cmHudPlaceholder(){if(!cmHudEl)return;const inp=cmHudEl.querySelector('input');if(!inp)return;
8244
+ if(cmHudConsumer==='position'){inp.placeholder=posHudTarget?(posHudTarget.axis==='rot'?(String(+(+posHudTarget.cur||0).toFixed(2))+'°'):(posOffDisp(posHudTarget.cur)||'0"')):'';return;} // 3b.3: the current value is the hint (HUD opens empty)
8117
8245
  inp.placeholder=cmHudAbs?(cmHudPrimed?"X′,Y′ · or X′,Y′,Z′":"X,Y · or X,Y,Z"):(cmHudConsumer==='add'?"dx,dy · or dx,dy,dz":"12'-6 · or dx,dy");}
8118
8246
  function cmHudEcho(){const inp=cmHudEl.querySelector('input'),lbl=cmHudEl.querySelector('#cmHudLbl');
8119
8247
  const pv=parseVec(inp.value),n=(cmTool==='copy'&&!cmArrayMode&&cmCount>1)?(' ×'+cmCount):'';let txt='';
@@ -8122,8 +8250,10 @@ function cmHudEcho(){const inp=cmHudEl.querySelector('input'),lbl=cmHudEl.queryS
8122
8250
  txt='= '+pv.comp.map((c,i)=>pv.provided[i]?((ax[i]?ax[i]+' ':'')+fmtFtIn(c)):null).filter(Boolean).join(', ');}}
8123
8251
  lbl.textContent=(txt?txt+n:n.trim());
8124
8252
  cmHudEl.classList.remove('err');}
8125
- function cmHudShow(seed){
8126
- if(view3d&&window.Steel3DView&&window.Steel3DView.pointEntryBegin){ // 3D: capture the view's frame/anchor/aim token for this operation
8253
+ function cmHudShow(seed,opts){
8254
+ if(opts&&opts.consumer==='position'){ // 3b.3: Profile Position typed entry — its own commit path (commitMemberPosition), no pointEntry token, no coordinate-mode pill
8255
+ cmHudConsumer='position';cmHudLock=false;cmHudAbs=false;cmHudPrimed=false;
8256
+ }else if(view3d&&window.Steel3DView&&window.Steel3DView.pointEntryBegin){ // 3D: capture the view's frame/anchor/aim token for this operation
8127
8257
  const consumer=cmTool?'movecopy':(mode==='add'?'add':null);if(!consumer)return;
8128
8258
  const b=window.Steel3DView.pointEntryBegin(consumer);if(!b||!b.ok)return;
8129
8259
  cmHudConsumer=consumer;cmHudLock=!!b.locked;cmHudAbs=!!(b.mode==='abs'||b.locked);cmHudPrimed=!!b.primed;
@@ -8144,16 +8274,31 @@ function cmHudShow(seed){
8144
8274
  inp.addEventListener('input',cmHudEcho);
8145
8275
  inp.addEventListener('keydown',ev=>{ev.stopPropagation();
8146
8276
  if(ev.key==='Enter'){ev.preventDefault();cmHudCommit(inp.value);}
8147
- else if(ev.key==='Escape'){ev.preventDefault();cmHudClose();}});}
8277
+ else if(ev.key==='Escape'){ev.preventDefault();cmHudClose();}});
8278
+ inp.addEventListener('blur',()=>{if(cmHudConsumer==='position'&&cmHudIsOpen()){const had=inp.value.trim()!=='';cmHudClose();if(had)toast('Discarded — nothing was committed. Double-click the handle to type again.');}});} // 3b.3: losing focus (click away) cancels the transient docked position HUD; a toast prevents silent data loss when text was typed (ui-ux). Enter commits, Esc cancels quietly, blur cancels with the toast.
8148
8279
  cmHudEl.classList.toggle('v3d',!!view3d);
8280
+ {const pill=cmHudEl.querySelector('#cmHudPill');if(pill)pill.style.display=(cmHudConsumer==='position')?'none':'';} // 3b.3: position is a single scalar — no REL/ABS pill; restored ('') for the movecopy/add consumers on every open (shared-singleton teardown)
8149
8281
  cmHudSyncPill();cmHudPlaceholder();
8282
+ const scrPos=(opts&&opts.consumer==='position')?opts.scr:null;
8150
8283
  const scr3=view3d&&window.Steel3DView&&window.Steel3DView.cmLastClient?window.Steel3DView.cmLastClient():null;
8151
- const scr=scr3||(cmLastEvt?[cmLastEvt.clientX,cmLastEvt.clientY]:[innerWidth/2,innerHeight/2]);
8152
- cmHudEl.style.left=Math.min(scr[0]+16,innerWidth-240)+'px';cmHudEl.style.top=Math.min(scr[1]+16,innerHeight-46)+'px';
8284
+ const scr=scrPos||scr3||(cmLastEvt?[cmLastEvt.clientX,cmLastEvt.clientY]:[innerWidth/2,innerHeight/2]);
8285
+ cmHudEl.style.left=Math.max(6,Math.min(scr[0]+16,innerWidth-240))+'px';cmHudEl.style.top=Math.max(6,Math.min(scr[1]+16,innerHeight-46))+'px'; // dock at the handle, clamped both edges (a member at the viewport edge stays typeable)
8153
8286
  cmHudEl.style.display='flex';cmHudEl.classList.remove('err');
8154
8287
  const inp=cmHudEl.querySelector('input');inp.value=seed||'';cmHudEcho();inp.focus();
8155
8288
  try{inp.setSelectionRange(inp.value.length,inp.value.length);}catch(_){}}
8156
- function cmHudCommit(str){const pv=parseVec(str);
8289
+ function cmHudCommit(str){
8290
+ if(cmHudConsumer==='position'){ // 3b.3: single scalar → commitMemberPosition (same path as a drag: absolute value, one undo entry). Typed values BYPASS the ¼"/5° snap.
8291
+ const t=String(str==null?'':str).trim();
8292
+ if(t===''||!posHudTarget){cmHudClose();return;} // empty = no-op close
8293
+ let val;
8294
+ if(posHudTarget.axis==='rot'){val=Number(t.replace(',','.'));if(!isFinite(val)){cmHudEl.classList.add('err');toast('Enter an angle in degrees, e.g. 45 or -90.');return;}val=SteelCore.rollCommitNorm(val);}
8295
+ else{const inch=parseLen(t);if(inch==null||!isFinite(inch)){cmHudEl.classList.add('err');toast('Couldn’t read “'+t+'” as a length — try 3 1/2" or 1\'-3 1/2".');return;}val=inch*25.4;}
8296
+ const key=posHudTarget.axis==='depth'?'positionOffset':posHudTarget.axis==='width'?'positionHOffset':'rot';
8297
+ const ok=commitMemberPosition(posHudTarget.id,{[key]:val},cmHudEl); // refused (frame drift) toasts its own reason; keep the HUD open + .err so the user can retry. Passing cmHudEl as `source` is safe ONLY because #cmHud is not focusable — positionRefuse calls source.focus(), a no-op on a plain <div>; giving #cmHud a tabindex/contenteditable would blur the input, fire the blur handler, and wrongly discard+toast.
8298
+ if(!ok){cmHudEl.classList.add('err');return;}
8299
+ cmHudClose();return;
8300
+ }
8301
+ const pv=parseVec(str);
8157
8302
  if(!pv){cmHudEl.classList.add('err');toast('Enter a length (12\'-6) or components (dx,dy)');return;}
8158
8303
  if(view3d&&window.Steel3DView){ // 3D: the view resolves via the pure resolver + its token, commits via onTransform3d/onAddMember3d
8159
8304
  const fn=cmHudConsumer==='add'?window.Steel3DView.drHudApply:window.Steel3DView.cmHudApply;
@@ -8581,11 +8726,13 @@ document.getElementById('csArm3dB').onclick=()=>{const d3=window.Steel3DView;if(
8581
8726
  * updater here and nowhere else; `npm run verify:display-sync` fails the build if a `.dtog` id in the
8582
8727
  * markup has no updater in this function.
8583
8728
  */
8584
- function syncDisplayRows(){updGridToggle();updLenToggle();updDimToggle();updCalloutToggle();updPlToggle();updRefToggle();}
8729
+ function syncDisplayRows(){updGridToggle();updLenToggle();updPosGizmoToggle();updDimToggle();updCalloutToggle();updPlToggle();updRefToggle();}
8585
8730
  function updDimToggle(){const b=document.getElementById('dimToggleB');if(!b)return;b.disabled=false;b.classList.toggle('on',dimsVisible);b.setAttribute('aria-checked',String(dimsVisible));}
8586
8731
  document.getElementById('dimToggleB').onclick=e=>{e.stopPropagation();dimsVisible=!dimsVisible;updDimToggle();render();};
8587
8732
  function updLenToggle(){const b=document.getElementById('lenToggleB');if(!b)return;const on=showSelLen;b.disabled=false;b.classList.toggle('on',on);b.setAttribute('aria-checked',String(on));}
8588
8733
  document.getElementById('lenToggleB').onclick=e=>{e.stopPropagation();showSelLen=!showSelLen;try{localStorage.setItem('steel:selLen:v2',showSelLen?'1':'0');}catch(_){}updLenToggle();render();}; // render() repaints the 2D chips + pushes/clears labels in 3D
8734
+ function updPosGizmoToggle(){const b=document.getElementById('posGizmoToggleB');if(!b)return;b.disabled=false;b.classList.toggle('on',showPosGizmo);b.setAttribute('aria-checked',String(showPosGizmo));}
8735
+ document.getElementById('posGizmoToggleB').onclick=e=>{e.stopPropagation();showPosGizmo=!showPosGizmo;try{localStorage.setItem('steel:posGizmo:v2',showPosGizmo?'1':'0');}catch(_){}updPosGizmoToggle();if(view3dReady&&window.Steel3DView&&window.Steel3DView.setPositionGizmoVisible)window.Steel3DView.setPositionGizmoVisible(showPosGizmo);}; // the gizmo is a 3D overlay — push straight to the view (.stopPropagation keeps the menu open, like every .dtog)
8589
8736
  // ⋯ Display → Grid label size. One setting, both views: 2D re-places its bubbles from the anchors baked
8590
8737
  // by gridSvg (no re-render — a rebuild between a dblclick's two clicks would kill the rename gesture),
8591
8738
  // and 3D is told live, where sizeGridLabels() re-derives the world size on the next frame.
@@ -9371,6 +9518,11 @@ const view3dApi={
9371
9518
  defaultTosMm:()=>v2Refuse('defaultTosMm — native members carry explicit elevations, so a substituted default would silently relocate them'),
9372
9519
  geoMode:()=>geoMode, // 'el' | 'split' | null — armed Trim/Extend/Split state
9373
9520
  onMoveMember:(id,newWp)=>{edit(()=>{const m=byId(id);if(m)MC().replaceEndpoints(m,newWp);});}, // 3D drag → write wp (undoable, autosaves, syncs 2D/chip/BOM). NOTE: the Select filter gates SELECTION (pick/marquee/Ctrl+A), NOT direct 3D drag-manipulation — gating here would strand the renderer's live preview (the mesh is already moved), so a filtered member is still directly draggable in 3D by design.
9521
+ positionGizmoState:(id)=>memberPositionGizmoState(id), // 3D Profile Position gizmo (slice 3a): read-only frame axes + current-frame offset/roll for one member
9522
+ commitMemberPosition:(id,patch,source)=>commitMemberPosition(id,patch,source), // gizmo drag/type → absolute {positionOffset|positionHOffset|rot} through the shipped commitPositionEdit (one undo entry)
9523
+ openPositionHud:(id,axis,scr)=>openPositionHud(id,axis,scr), // 3b.3: double-click a handle → dock the shared #cmHud typed-entry HUD at it, commit bypasses snap
9524
+ showHandleTip:(txt,x,y)=>{if(window.__tip)window.__tip.showText(txt,x,y);}, // 3b.3: canvas gizmo handles carry no DOM data-tip — route through the shared themed #tooltip programmatically
9525
+ hideHandleTip:()=>{if(window.__tip)window.__tip.hide();},
9374
9526
  dragMoveEnabled:()=>dragMoveOn, // the 3D view gates its plain member-drag on this
9375
9527
  dragMoveHint:()=>{if(dragHintShown)return;dragHintShown=true;try{localStorage.setItem('steel:dragmovehint:v2','1');}catch(_){}toast('Drag to move/copy is off — turn it on in the Move / Copy menu, or use the Move (M) / Copy (C) tools');},
9376
9528
  onCopyDrag3d:(ids,dxMm,dyMm)=>{ // Ctrl+drag copy: WORLD MM straight across the boundary now — it owns the per-plane mm→px conversion (direct manipulation, not gated by the Select filter — see onMoveMember)
@@ -15406,6 +15558,7 @@ async function setView(on,{remember=true}={}){
15406
15558
  // nothing to undo here; just stop.
15407
15559
  if(seq!==viewSeq)return;
15408
15560
  window.Steel3DView.setSelection(selIds);
15561
+ if(window.Steel3DView.setPositionGizmoVisible)window.Steel3DView.setPositionGizmoVisible(showPosGizmo); // reflect the persisted ⋯ Display → Position handle state when 3D becomes visible
15409
15562
  if(window.Steel3DView.setGridSelection)window.Steel3DView.setGridSelection(selGridIds); // carry the shared 2D grid selection across the rebuild; rebuild replaces the line objects/materials
15410
15563
  if(window.Steel3DView.setGridLabelPx)window.Steel3DView.setGridLabelPx(gridLabelPx); // the renderer reads the shared key at LOAD and the slider pushes live, but a size set BEFORE the module arrived reaches it through neither — so relay it here too, like every other preference in this block. Makes a 2D/3D divergence self-healing on the next switch rather than permanent.
15411
15564
  wire3DBar();wireLegendTabs();loadSteelFavourites();build3DLegend();
@@ -17781,5 +17934,12 @@ boot().catch(err => { document.body.replaceChildren(Object.assign(document.creat
17781
17934
  document.addEventListener('pointerover', e=>{ const el=e.target.closest('[data-tip]'); if(!el) return; clearTimeout(t); t=setTimeout(()=>show(el),400); });
17782
17935
  document.addEventListener('pointerout', e=>{ if(e.target.closest('[data-tip]')) hide(); });
17783
17936
  document.addEventListener('pointerdown', hide, true); // a click hides the tip immediately
17937
+ // Programmatic access for canvas handles (the 3D gizmo has no DOM to carry data-tip). Same shared themed
17938
+ // #tooltip element, positioned at a client point, clamped to the viewport — so a WebGL handle's tooltip is
17939
+ // themed exactly like every toolbar tip and never a native light title=. showText hides on the next hover-out
17940
+ // or pointerdown via the existing listeners; the 3D view also calls hideHandleTip when the cursor leaves a handle.
17941
+ window.__tip = { showText(txt, x, y){ clearTimeout(t); if(!txt){ hide(); return; } tip.textContent=txt; tip.classList.add('show');
17942
+ const tw=tip.offsetWidth, th=tip.offsetHeight; tip.style.left=Math.max(6,Math.min(x - tw/2, innerWidth - tw - 6))+'px';
17943
+ tip.style.top=(y + 18 + th > innerHeight - 6 ? y - th - 12 : y + 18)+'px'; }, hide };
17784
17944
  })();
17785
17945
  </script></body></html>