@floless/app 0.127.5 → 0.127.6

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.
@@ -403,6 +403,7 @@
403
403
  #selBar button:focus-visible{outline:2px solid var(--brand);outline-offset:1px}
404
404
  #selBar button .car{position:absolute;right:1px;bottom:0;font-size:8px;opacity:.7;pointer-events:none}
405
405
  #selBar button .seldot{position:absolute;top:2px;right:2px;width:6px;height:6px;border-radius:50%;background:var(--brand);box-shadow:0 0 0 1.5px var(--panel)}
406
+ body:not(.v3d) #selBar [data-cls=reference]{display:none} /* borrowed IFC geometry has no 2D pick surface */
406
407
  /* shared type flyout (Members / Connections) — opens upward from the bar */
407
408
  #selFly{position:fixed;z-index:46;min-width:210px;background:var(--panel);border:1px solid var(--line);border-radius:10px;box-shadow:0 10px 30px rgba(0,0,0,.55);padding:6px;display:none}
408
409
  #selFly.open{display:block}
@@ -1551,6 +1552,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
1551
1552
  <button data-cls=connection data-fly=connections aria-label="Connections" data-tip="Connections — click to choose which connection types can be selected · Alt+click: toggle all types"><svg viewBox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><rect x="4" y="4" width="10" height="10" rx="1"/><circle cx="6.5" cy="6.5" r="1.15" fill="currentColor" stroke="none"/><circle cx="11.5" cy="6.5" r="1.15" fill="currentColor" stroke="none"/><circle cx="6.5" cy="11.5" r="1.15" fill="currentColor" stroke="none"/><circle cx="11.5" cy="11.5" r="1.15" fill="currentColor" stroke="none"/></svg><span class=car aria-hidden=true>▾</span></button>
1552
1553
  <button data-cls=grid aria-label="Grid lines" data-tip="Grid lines — allow selecting grid lines (area-select / Ctrl+A)"><svg viewBox="0 0 18 18" fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round aria-hidden=true><path d="M6 2v14M12 2v14M2 6h14M2 12h14"/></svg></button>
1553
1554
  <button data-cls=dim aria-label="Dimensions" data-tip="Dimensions — allow selecting dimensions"><svg viewBox="0 0 18 18" fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round aria-hidden=true><path d="M3 5v8M15 5v8M3 9h12M3 9l3-2M3 9l3 2M15 9l-3-2M15 9l-3 2"/></svg></button>
1555
+ <button data-cls=reference aria-label="Reference models" data-tip="Reference models — allow selecting reference models. Visibility and snapping are controlled separately."><svg viewBox="0 0 18 18" fill=none stroke=currentColor stroke-width=1.35 stroke-linejoin=round aria-hidden=true><path d="M2.5 5.5l5-2.5 5 2.5-5 2.5-5-2.5Z"/><path d="M2.5 5.5v5l5 2.5 5-2.5v-5M7.5 8v5"/><path d="M10.5 8.5l2-1 3 1.5v3l-3 1.5"/></svg></button>
1554
1556
  </div>
1555
1557
  <!-- Quick-access snap toggles (same persistent state as the ⋯ menu → Snapping section; keep the two in sync — same 7 items).
1556
1558
  Glyphs mirror SNAP_KINDS_2D — see the endpoint-glyph constraint there before "correcting" ◻ to □. -->
@@ -2953,7 +2955,7 @@ const autofillTOS=syncDefaults;
2953
2955
  // grid that does not live on a sheet, so without this line every grid edit on a v2 document would be
2954
2956
  // unundoable — silently, since Ctrl+Z would restore the sheets and report success.
2955
2957
  function snapshot(){
2956
- if(MODEL_V2)return JSON.stringify({v2:true,members:C.members,grid:C.grid||null,plans:C.plans.map(p=>({sheet:p.sheet,dims:p.dims||[],memberRefs:p.memberRefs||[],memberObservations:p.memberObservations||[],frame:p.frame||null})),joints:C.joints||[],connections:C.connections||[],details:C.detail_placements||[],views:C.views||[],member_types:C.member_types||[],dim_style:C.dim_style||null,member_styles:C.member_styles||{}});
2958
+ if(MODEL_V2)return JSON.stringify({v2:true,members:C.members,grid:C.grid||null,plans:C.plans.map(p=>({sheet:p.sheet,dims:p.dims||[],memberRefs:p.memberRefs||[],memberObservations:p.memberObservations||[],frame:p.frame||null})),joints:C.joints||[],connections:C.connections||[],details:C.detail_placements||[],views:C.views||[],member_types:C.member_types||[],dim_style:C.dim_style||null,member_styles:C.member_styles||{},...(Array.isArray(C.reference_models)?{reference_models:C.reference_models}:{})});
2957
2959
  return JSON.stringify({planes:C.plans.map(p=>({sheet:p.sheet,members:p.members,dims:p.dims||[],frame:p.frame||null,grid:p.grid||null})),joints:C.joints||[],connections:Array.isArray(C.connections)?C.connections:null,clips:(window.Steel3DView&&window.Steel3DView.clipState)?window.Steel3DView.clipState():null,details:(C.detail_placements||[]),member_types:C.member_types||[],dim_style:C.dim_style||null,member_styles:C.member_styles||{}});
2958
2960
  }
2959
2961
  // Undo/redo is a SINGLE GLOBAL stack (not per-plane): snapshot() above captures EVERY plane's
@@ -3032,6 +3034,7 @@ function apply(json){
3032
3034
  cmDraft=null;cmPrevClear();cmHudClose(); // same for an in-progress Move/Copy pick — the base may reference removed geometry
3033
3035
  if(window.Steel3DView&&window.Steel3DView.cmClear3d)window.Steel3DView.cmClear3d(); // and the 3D-side draft/ghosts
3034
3036
  if(window.Steel3DView&&window.Steel3DView.setClipState&&'clips' in d)window.Steel3DView.setClipState(d.clips); // restore clips + work area alongside the contract
3037
+ if(MODEL_V2&&'reference_models' in d)pushReferences(); // native sync3D cannot repaint the editor-only reference layer
3035
3038
  if('member_types' in d)C.member_types=sanitizeMemberTypes(d.member_types);
3036
3039
  if('member_styles' in d)C.member_styles=(d.member_styles&&typeof d.member_styles==='object'&&!Array.isArray(d.member_styles))?d.member_styles:{}; // F5: model-global per-type line styles ride the undo stack (like dim_style) so a setMemberLineStyle() edit() is undoable
3037
3040
  scheduleSave();render();sync3D();}
@@ -4480,7 +4483,7 @@ function reflect2dGridSelection(){const geo=gridGeo()||{};
4480
4483
  if(!selDimIds.size){svg.querySelectorAll('.dimsel').forEach(el=>el.classList.remove('dimsel'));svg.querySelectorAll('circle.dimhandle').forEach(el=>el.remove());} // an additive grid click keeps an already-selected dimension visibly selected; a plain grid click cleared selDimIds above
4481
4484
  if(!selIds.size)svg.querySelectorAll('circle.handle,circle.numbg,text.numtx,g.mlenlabels').forEach(el=>el.remove());
4482
4485
  panel();try{updateConnCrumb();}catch(_){}syncPropLabelsAfterRender();}
4483
- function selectGridLine(id,additive,surgical=false){if(!id||!selGridOK())return;if(!additive){selDimIds.clear();sel3dDimIds.clear();selIds.clear();selGridIds=new Set([id]);if(window.Steel3DView&&window.Steel3DView.setSelectedClips)window.Steel3DView.setSelectedClips([]);}else{selGridIds.has(id)?selGridIds.delete(id):selGridIds.add(id);}surgical?reflect2dGridSelection():render();} // additive grid picks preserve an intentional mixed dimension/grid selection in either click order
4486
+ function selectGridLine(id,additive,surgical=false){if(!id||!selGridOK())return;clearWholeReferenceSelection();if(!additive){selDimIds.clear();sel3dDimIds.clear();selIds.clear();selGridIds=new Set([id]);if(window.Steel3DView&&window.Steel3DView.setSelectedClips)window.Steel3DView.setSelectedClips([]);}else{selGridIds.has(id)?selGridIds.delete(id):selGridIds.add(id);}surgical?reflect2dGridSelection():render();} // additive grid picks preserve an intentional mixed dimension/grid selection in either click order
4484
4487
  // selected grid lines → display rows {label,type} for the inspector (resolves labels/types from gridGeo)
4485
4488
  function gridSelSummary(){const geo=gridGeo()||{};const out=[];
4486
4489
  for(const id of selGridIds){
@@ -4944,6 +4947,10 @@ function doDup(){const arr=sel2d();if(!arr.length)return;const o=12,pv=snapshot(
4944
4947
  selIds=ns;selDimIds.clear();mode='sel';setMode();pushUndo(pv);render();}
4945
4948
  function esc(s){return String(s).replace(/[<>&"]/g,c=>({'<':'&lt;','>':'&gt;','&':'&amp;','"':'&quot;'}[c]));}
4946
4949
  function render(){
4950
+ // Selection has many entry points (2D clicks/marquees, 3D picks, inspectors, Locate actions). Enforce
4951
+ // the one-target invariant at their shared paint boundary as well as at the direct 3D sinks: if any
4952
+ // native/dimension/grid target is about to be shown selected, a stale whole-reference selection ends.
4953
+ if(refSelectedId&&(selIds.size||selDimIds.size||selGridIds.size||sel3dDimIds.size))clearWholeReferenceSelection();
4947
4954
  // A v2 document has no 2D plan to draw (§1): its members are world-mm and model-level, and the sheet
4948
4955
  // registration that would place them back into this sheet's display space is computed at migration and
4949
4956
  // never persisted — the adapter's own sheetFrame() refuses to fabricate one. So the canvas stays empty
@@ -5357,12 +5364,12 @@ function panel(){
5357
5364
  if(csaxisMode){p.innerHTML=`<span class=badge>Set local axes</span>
5358
5365
  <div class=hint style="margin-top:8px">${csDraft?'Click the <b>second</b> point — the local-X direction. Y follows at 90°.':'Click the <b>origin</b> point to start.'}</div>
5359
5366
  <div class=hint style="margin-top:8px">Two clicks define the frame; snaps to member ends &amp; grid (<b>Alt</b> off). <b>Esc</b> cancels.</div>`;return;}
5360
- if(cmTool){const nsel=selIds.size;
5367
+ if(cmTool){const refTarget=view3d&&!selIds.size&&refSelectedId&&refSelectedObjIdx===null?refById(refSelectedId):null,nsel=refTarget?1:selIds.size;
5361
5368
  p.innerHTML=`<span class=badge>${cmTool==='move'?'Move':(cmArrayMode?'Copy array':'Copy')}</span>
5362
5369
  <div class=hint id=cmHint style="margin-top:8px">${esc(cmHintText())}</div>
5363
5370
  ${cmTool==='copy'&&!cmArrayMode?`<div class=sect style="margin-top:12px">Copies</div><input id=cmN inputmode=numeric value="${cmCount}" autocomplete=off><div class=hint style="margin-top:4px">×N places a row — each copy one step further along the pick (linear).</div>`:''}
5364
5371
  ${cmArrayMode?`<div class=sect style="margin-top:12px">Array counts</div><div class=elab>Direction A</div><input id=cmNA inputmode=numeric value="${cmCountA}" autocomplete=off><div class=elab>Direction B</div><input id=cmNB inputmode=numeric value="${cmCountB}" autocomplete=off><div class=hint id=cmCapHint style="margin-top:4px">Counts include the original — 4 × 6 fills a 4-by-6 grid (max 100).</div>`:''}
5365
- <div class=hint style="margin-top:8px">${nsel} member${nsel===1?'':'s'} selected. ${view3d?'<b>Shift</b>=straight · <b>X/Y/Z</b> lock (press again to release · <b>F</b> clears; lock two to snap to whichever you drag toward) · <b>Alt</b>=lock out-of-plane':'<b>Shift</b>=straight · <b>X/Y/F</b> axis · <b>Alt</b>=no snap'} · type after the first pick for an exact value · <b>Esc</b> cancels. Connections don't copy.</div>`;
5372
+ <div class=hint style="margin-top:8px">${refTarget?'1 reference model selected.':nsel+' member'+(nsel===1?'':'s')+' selected.'} ${view3d?'<b>Shift</b>=straight · <b>X/Y/Z</b> lock (press again to release · <b>F</b> clears; lock two to snap to whichever you drag toward) · <b>Alt</b>=lock out-of-plane':'<b>Shift</b>=straight · <b>X/Y/F</b> axis · <b>Alt</b>=no snap'} · type after the first pick for an exact value · <b>Esc</b> cancels.${refTarget?'':' Connections don’t copy.'}</div>`;
5366
5373
  const wireN=(id,set)=>{const i=document.getElementById(id);if(i)i.onchange=e=>{const n=Math.max(1,Math.min(99,Math.round(Number(e.target.value)||1)));set(n);e.target.value=n;
5367
5374
  const ch=document.getElementById('cmCapHint');if(ch)ch.style.color=(cmArrayMode&&cmCountA*cmCountB>100)?'#fca5a5':'';cmRefreshPrev();};};
5368
5375
  wireN('cmN',n=>cmCount=n);wireN('cmNA',n=>cmCountA=n);wireN('cmNB',n=>cmCountB=n);
@@ -6127,12 +6134,12 @@ function saveOriginGrid(){try{localStorage.setItem(OGRID_ON_KEY,originGridOn?'1'
6127
6134
  // connection kinds — may enter a selection. One persisted source of truth, consulted at every pick
6128
6135
  // sink (2D click/marquee/Ctrl+A, 3D pick/box). Default: everything ON, so nothing is filtered out
6129
6136
  // (that default is also what fixes the silent Ctrl+A/marquee drops of dims + grids). GLOBAL like snaps.
6130
- // State: grid/dim are plain on/off; Members & Connections have per-TYPE switches (mtype/ckind, absent===on)
6137
+ // State: grid/dim/reference are plain on/off; Members & Connections have per-TYPE switches (mtype/ckind, absent===on)
6131
6138
  // and their class button is DERIVED (all/some/none on) — so "Members off" just means every member type off.
6132
6139
  const SELF_KEY='steel:selFilter:v1';
6133
6140
  // Grids default OFF (opt-in) — grid-line selection is a deliberate act, so a plain marquee/Ctrl+A doesn't
6134
- // sweep the structural grid unless you switch it on. Members/Connections/Dimensions default ON.
6135
- let selFilter=(()=>{try{const s=JSON.parse(localStorage.getItem(SELF_KEY)||'{}');return {grid:s.grid===true,dim:s.dim!==false,mtype:(s.mtype&&typeof s.mtype==='object')?s.mtype:{},ckind:(s.ckind&&typeof s.ckind==='object')?s.ckind:{}};}catch(_){return {grid:false,dim:true,mtype:{},ckind:{}};}})();
6141
+ // sweep the structural grid unless you switch it on. Members/Connections/Dimensions/References default ON.
6142
+ let selFilter=(()=>{try{const s=JSON.parse(localStorage.getItem(SELF_KEY)||'{}');return {grid:s.grid===true,dim:s.dim!==false,reference:s.reference!==false,mtype:(s.mtype&&typeof s.mtype==='object')?s.mtype:{},ckind:(s.ckind&&typeof s.ckind==='object')?s.ckind:{}};}catch(_){return {grid:false,dim:true,reference:true,mtype:{},ckind:{}};}})();
6136
6143
  function saveSelFilter(){try{localStorage.setItem(SELF_KEY,JSON.stringify(selFilter));}catch(_){}}
6137
6144
  const normConnKind=k=>String(k||'').trim().toLowerCase(); // 'base-plate' | 'shear-plate' | 'custom'
6138
6145
  const selTypeOK=k=>selFilter.mtype[k]!==false; // per-member-type; absent === allowed
@@ -6142,6 +6149,7 @@ function connKindOfPart(id){const p=partsById&&partsById[id];if(!p||!p.conn)retu
6142
6149
  function selConnPartOK(id){return selKindOK(connKindOfPart(id));}
6143
6150
  const selGridOK=()=>selFilter.grid!==false;
6144
6151
  const selDimOK=()=>selFilter.dim!==false;
6152
+ const selReferenceOK=()=>selFilter.reference!==false;
6145
6153
  // classify any id already in / entering selIds — connection part, placed detail, or plain member — → allowed?
6146
6154
  function selIdOK(id){if(id==null)return true;if(partsById&&partsById[id]&&partsById[id].conn)return selConnPartOK(id);if(/^det:/.test(id))return true;const m=byId(id);return m?selMemberOK(m):true;}
6147
6155
  // a type fires when a transient override forces exactly it (override ignores running-snaps, AutoCAD-style), else when its running-snap is on
@@ -7034,8 +7042,14 @@ function disarmCm(){cmTool=null;cmArrayMode=false;cmDraft=null;cmHudClose();cmPr
7034
7042
  if(window.Steel3DView&&window.Steel3DView.cmClear3d)window.Steel3DView.cmClear3d();} // drop the 3D-side pick/preview too
7035
7043
  function armCm(tool,array){ // re-arming the same config toggles the tool off — works in 2D and (on the working plane) in 3D
7036
7044
  if(cmTool===tool&&cmArrayMode===!!array){disarmCm();render();return;}
7045
+ const refTarget=view3d&&!selIds.size&&refSelectedId&&refSelectedObjIdx===null?refById(refSelectedId):null;
7046
+ if(view3d&&refSelectedObjIdx!==null){toast('Select the whole reference model to move it');return;}
7047
+ if(refTarget&&tool!=='move'){toast('Reference models can only be moved');return;}
7048
+ if(refTarget&&refDisp(refTarget).locked){toast('“'+refTarget.name+'” is locked — unlock it to move it');return;}
7049
+ const refObjects=refTarget&&(refGeom.get(refTarget.id)||{}).objects;
7050
+ if(refTarget&&(!Array.isArray(refObjects)||!refObjects.length)){toast(refLoading.has(refTarget.id)?'Still reading its geometry — try again in a moment':'There is no reference geometry to move yet');return;}
7037
7051
  if(view3d&&window.Steel3DView){const dm=document.getElementById('m3dDim');if(dm&&dm.classList.contains('on'))window.Steel3DView.toggleDimTool();if(window.Steel3DView.disarmFrame3d)window.Steel3DView.disarmFrame3d();if(window.Steel3DView.armRefMeasure3d){window.Steel3DView.armRefMeasure3d(null);refMeasureClear();}} // the 3D dim tool + the local frame share the left-click — disarm both
7038
- if(!selIds.size){toast('Select members first, then '+(tool==='move'?'Move':'Copy'));return;}
7052
+ if(!selIds.size&&!refTarget){toast(view3d&&tool==='move'?'Select members or a reference model first, then Move':'Select members first, then '+(tool==='move'?'Move':'Copy'));return;}
7039
7053
  if(mode==='add'){mode='sel';setMode();if(window.Steel3DView&&window.Steel3DView.drClear3d)window.Steel3DView.drClear3d();}
7040
7054
  if(dimMode){dimMode=false;setDimMode();}
7041
7055
  if(csaxisMode){csaxisMode=false;setCsMode();}
@@ -7348,6 +7362,7 @@ svg.addEventListener('pointerdown',e=>{if(e.button!==0)return;const t=e.target;
7348
7362
  if(isDimAnchorableMember(m))gm={mid:m.id,pt:ref0.pt,rigid:ref0.pt==='mid'||(m.role||'beam')==='column',ow:[m.wp[0].slice(),m.wp[1].slice()],oa:(end===0?d0.a:d0.b).slice()};}
7349
7363
  buildSnap(gm?new Set([id,gm.mid]):id);drag={type:'dimend',id,end,grip:gm,pre:snapshot()};svg.setPointerCapture(e.pointerId);e.preventDefault();return;}
7350
7364
  if(t.dataset.dim&&mode==='sel'&&selDimOK()){const did=t.dataset.dim,add=e.ctrlKey||e.metaKey;
7365
+ clearWholeReferenceSelection();
7351
7366
  if(!add&&_lastDimDown&&_lastDimDown.id===did&&(e.timeStamp-_lastDimDown.t)<400){_lastDimDown=null;selDimIds=new Set([did]);openDimEdit(did);e.preventDefault();return;} // F8: double-click a dim → value editor. Detected HERE (in pointerdown), NOT via the native dblclick event, so the select-render between the two clicks can't swallow it (Codex R4 #2).
7352
7367
  _lastDimDown={id:did,t:e.timeStamp};
7353
7368
  selIds.clear();if(!add)selGridIds.clear(); // a plain dim click is exclusive (clears member + grid selection); Ctrl keeps an intentional mixed grid/dim selection. Dimensions select-switch off → click falls through (inert)
@@ -7920,16 +7935,17 @@ addEventListener('keydown',e=>{
7920
7935
  if(k==='z'&&!e.shiftKey){e.preventDefault();doUndo();}
7921
7936
  else if(k==='y'||(k==='z'&&e.shiftKey)){e.preventDefault();doRedo();}
7922
7937
  else if(k==='d'&&selIds.size){e.preventDefault();doDup();}
7923
- else if(k==='a'&&!inForm){e.preventDefault(); // Ctrl+A — select all MEMBERS (honouring the Members switch) plus, in 2D, the visible dims + grid lines. Was: active-plan members only, and it CLEARED dims + never grabbed grids.
7924
- // Scope to what's VISIBLE: 3D asks the renderer for visible member meshes after legend/isolate/work-area filtering; 2D uses the active plan (matching its marquee). Connections + 3D dims are picked by click/box, not swept by Ctrl+A.
7925
- const memberIds=view3d?(window.Steel3DView&&window.Steel3DView.visibleMemberIds?window.Steel3DView.visibleMemberIds():[]):P.members.map(m=>m.id);
7926
- selIds=new Set(memberIds.filter(id=>{const m=byId(id);return m&&selMemberOK(m);}));
7938
+ else if(k==='a'&&!inForm){e.preventDefault(); // Ctrl+A — select every visible/selectable object: 3D members + connection parts, plus logical grids when their switch is on; 2D keeps its members + dims + grids scope.
7939
+ // Scope to what's VISIBLE: 3D asks the renderer after legend/isolate/work-area/selection-hide filtering, then the editor applies its per-type Select switches. 2D uses the active plan, matching its marquee.
7940
+ const objectIds=view3d?(window.Steel3DView&&window.Steel3DView.visibleObjectIds?window.Steel3DView.visibleObjectIds():[]):P.members.map(m=>m.id);
7941
+ selIds=new Set(objectIds.filter(selIdOK));
7927
7942
  selDimIds.clear();sel3dDimIds.clear();selGridIds.clear();
7928
- if(selGridOK())selGridIds=new Set(gridSelectables().map(g=>g.id));
7943
+ if(selGridOK())selGridIds=new Set(view3d?(window.Steel3DView&&window.Steel3DView.visibleGridIds?window.Steel3DView.visibleGridIds():[]):gridSelectables().map(g=>g.id));
7929
7944
  if(!view3d){ // the 2D-drawable dimensions join the sweep
7930
7945
  if(selDimOK()&&dimsVisible)selDimIds=new Set((P.dims||[]).map(d=>d.id)); // dimensions now included — fixes the reported "Ctrl+A doesn't select dimensions" (skip when dims are hidden, like the marquee)
7931
7946
  }
7932
- render();}
7947
+ if(selIds.size||selDimIds.size||selGridIds.size)clearWholeReferenceSelection();
7948
+ render();}
7933
7949
  else if(k==='s'){e.preventDefault();persist();(window.flushContract?window.flushContract():Promise.resolve()).then(()=>toast('Saved ✓')).catch(()=>toast('Save failed'));}}); // edits autosave; Ctrl+S just flushes now (no browser "save page" dialog)
7934
7950
  // zoom bar
7935
7951
  document.getElementById('zIn').onclick=()=>zoomCentered(zoom*1.25);
@@ -8423,6 +8439,15 @@ function modelReadsV2(){
8423
8439
  return {g,geo:gc.gridGeometry(g,V2_PT_PER_FT,V2_GRID_OPTS),k:1,flipY:false};}, // k=1 and no flip: the stored coordinates ARE the scene's
8424
8440
  };
8425
8441
  }
8442
+ // One canvas has one action target. Direct native/grid/clip sinks call this before taking selection for
8443
+ // immediate state coherence, and render() is the invariant boundary that covers 2D + programmatic sinks.
8444
+ function clearWholeReferenceSelection(){
8445
+ if(!refSelectedId)return false;
8446
+ refSelectedId=null;refSelectedObjIdx=null;
8447
+ const v=window.Steel3DView;if(v&&v.selectReference)v.selectReference(null);
8448
+ if(legendTab==='refs')renderRefsTab();
8449
+ return true;
8450
+ }
8426
8451
  const view3dApi={
8427
8452
  // The model read half — see modelReadsV1 / modelReadsV2 above. Built ONCE per view init; the arm is
8428
8453
  // decided by MODEL_RO, which boot() pinned from the validated type and nothing changes afterwards.
@@ -8459,14 +8484,14 @@ const view3dApi={
8459
8484
  for(const p of (C.detail_placements||[])){if(!p||!p.id)continue;const raw=C.custom_details[p.detailName];if(raw==null)continue;const url=String(raw).startsWith('data:')?raw:'data:image/jpeg;base64,'+raw;const el={kind:'image',id:'det:'+p.id,group:'detail',url,pos:p.pos||[0,0,0],u:p.u,n:p.n,rotZ:p.rotZ||0,size:p.size||1000,opacity:p.opacity==null?1:p.opacity};sc.elements.push(el);pb[el.id]=el;}
8460
8485
  copesByMember=cm;partsById=pb;return sc;}, // cache resolved parts by id (real dims for the part Inspector) AND cope labels per member; placed details ride in as image elements
8461
8486
 
8462
- onSelect:(id,additive)=>{if(id&&!selIdOK(id))return;selDimIds.clear();sel3dDimIds.clear();if(!id){selIds=new Set();if(!additive)selGridIds.clear();}else{if(additive){selIds.has(id)?selIds.delete(id):selIds.add(id);}else{selIds=new Set([id]);selGridIds.clear();}}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // 3D pick → shared model-wide selection (byId/selArr span all sheets, so no plan switch needed; clears dimension + non-additive grid selection so Delete is unambiguous). A filtered object (Select switch off) is inert.
8487
+ onSelect:(id,additive)=>{if(id&&!selIdOK(id))return;if(id)clearWholeReferenceSelection();selDimIds.clear();sel3dDimIds.clear();if(!id){selIds=new Set();if(!additive)selGridIds.clear();}else{if(additive){selIds.has(id)?selIds.delete(id):selIds.add(id);}else{selIds=new Set([id]);selGridIds.clear();}}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // 3D pick → shared model-wide selection (byId/selArr span all sheets, so no plan switch needed; clears dimension + non-additive grid selection so Delete is unambiguous). A filtered object (Select switch off) is inert.
8463
8488
  onSelectMany:(ids,additive)=>{const ids2=(ids||[]).filter(selIdOK); // 3D box / whole-connection → gate each framed id through the Select switches (members by type, connection parts by kind)
8464
8489
  if(!additive&&(ids||[]).length&&!ids2.length)return; // a direct pick / box that caught ONLY filtered objects → inert (leave the current selection), matching a filtered single-pick; a genuinely empty box (ids empty) still falls through and clears
8465
- selDimIds.clear();sel3dDimIds.clear();
8490
+ if(ids2.length)clearWholeReferenceSelection();selDimIds.clear();sel3dDimIds.clear();
8466
8491
  if(additive){for(const id of ids2)selIds.has(id)?selIds.delete(id):selIds.add(id);} // Ctrl/Shift + 3D area-select → toggle each framed object into the current selection (add/remove), like Tekla — spans sheets
8467
8492
  else{selIds=new Set(ids2);selGridIds.clear();}
8468
8493
  if(mode==='add'){mode='sel';setMode();}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // 3D box-select → shared selection
8469
- onSelectBatch:({memberIds=[],gridIds=[]},additive)=>{const mids=memberIds.filter(selIdOK),gridAllowed=selGridOK(),gids=gridAllowed?gridIds:[];if(!additive&&(memberIds.length||gridIds.length)&&!mids.length&&!gids.length)return;selDimIds.clear();sel3dDimIds.clear();if(additive){for(const id of mids)selIds.has(id)?selIds.delete(id):selIds.add(id);for(const id of gids)selGridIds.has(id)?selGridIds.delete(id):selGridIds.add(id);}else{selIds=new Set(mids);selGridIds=new Set(gids);if(window.Steel3DView&&window.Steel3DView.setSelectedClips)window.Steel3DView.setSelectedClips([]);}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // Atomic 3D area/direct pick for members + logical grids: filter each class, toggle additively, otherwise replace both selections together.
8494
+ onSelectBatch:({memberIds=[],gridIds=[]},additive)=>{const mids=memberIds.filter(selIdOK),gridAllowed=selGridOK(),gids=gridAllowed?gridIds:[];if(!additive&&(memberIds.length||gridIds.length)&&!mids.length&&!gids.length)return;if(mids.length||gids.length)clearWholeReferenceSelection();selDimIds.clear();sel3dDimIds.clear();if(additive){for(const id of mids)selIds.has(id)?selIds.delete(id):selIds.add(id);for(const id of gids)selGridIds.has(id)?selGridIds.delete(id):selGridIds.add(id);}else{selIds=new Set(mids);selGridIds=new Set(gids);if(window.Steel3DView&&window.Steel3DView.setSelectedClips)window.Steel3DView.setSelectedClips([]);}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // Atomic 3D area/direct pick for members + logical grids: filter each class, toggle additively, otherwise replace both selections together.
8470
8495
  // THE MEMBER LIST. v1 keeps one per sheet; v2 keeps ONE at the document root, which IS the whole model —
8471
8496
  // so for v2 both of these answer the same list, truthfully, rather than the silent [] that reading
8472
8497
  // `C.plans[].members` would give (§8.3). The view takes ids and hands the records back to
@@ -8490,6 +8515,9 @@ const view3dApi={
8490
8515
  originGrid:()=>({on:originGridOn,incMm:originGridInc*25.4}), // UCS Stage 6 origin-relative snap — read live per hover; incMm from the inches step. Off ⇒ view skips it; requires a local frame to have any effect
8491
8516
  canSelectId:(id)=>selIdOK(id), // Select-filter predicate for the 3D view (e.g. don't draw a whole-connection envelope for a fully-filtered connection)
8492
8517
  canSelectGrid:()=>selGridOK(), // Grid line/bubble picks and area selection obey the same Select switch as 2D.
8518
+ canSelectReference:()=>selReferenceOK(), // Reference picks/drills obey their 3D-only Select switch; visibility and snapping stay independent.
8519
+ gridScopeKey:()=>MODEL_V2?'model':String(((C&&Number.isInteger(C.active))?C.active:'')+':'+((P&&P.sheet)||'')), // v2's grid is model-global; v1 needs the plan index too because its valid schema permits duplicate sheet labels
8520
+ onGridSelectionReset:()=>queueMicrotask(()=>{if(!selGridIds.size)return;selGridIds.clear();render();}), // a grid rebuild may invalidate positional ids; mirror the renderer reset after its current stack completes
8493
8521
  ptPerFt:()=>MODEL_V2?v2Refuse('ptPerFt — a drawing scale belongs to a SHEET; v2 members and grid are world mm'):(P&&P.pt_per_ft>0?P.pt_per_ft:1),
8494
8522
  defaultTosMm:()=>MODEL_V2?v2Refuse('defaultTosMm — v2 materialised every elevation, so a substituted default would silently relocate members'):(defaultTOS!=null?defaultTOS*25.4:0), // editor stores default T.O.S in inches
8495
8523
  geoMode:()=>geoMode, // 'el' | 'split' | null — armed Trim/Extend/Split state
@@ -8549,7 +8577,7 @@ const view3dApi={
8549
8577
  onDeleteDim3d:(id)=>{if(!canWriteModel())return;C.dims3d=(C.dims3d||[]).filter(x=>x.id!==id);sel3dDimIds.delete(id);scheduleSave();refreshDims3d();},
8550
8578
  onSelectDim3d:(id,mods)=>{ // Ctrl/Shift multi-select (same as parts); selecting a dim is exclusive with member/2D-dim/clip selection
8551
8579
  if(id&&!selDimOK())return; // Dimensions select-switch off → a 3D dim is inert too
8552
- if(!id){sel3dDimIds.clear();render();return;}
8580
+ if(!id){sel3dDimIds.clear();render();return;}clearWholeReferenceSelection();
8553
8581
  selIds=new Set();selDimIds.clear();selGridIds.clear();if(window.Steel3DView&&window.Steel3DView.setSelectedClips)window.Steel3DView.setSelectedClips([]);
8554
8582
  const ids=(C.dims3d||[]).map(d=>d.id),cur=new Set(sel3dDimIds);let next;
8555
8583
  if(mods&&mods.shift&&dim3dAnchor!=null&&ids.includes(dim3dAnchor)&&ids.includes(id)){const i0=ids.indexOf(dim3dAnchor),i1=ids.indexOf(id);next=ids.slice(Math.min(i0,i1),Math.max(i0,i1)+1);}
@@ -8567,11 +8595,17 @@ const view3dApi={
8567
8595
  // app under the cursor without a round-trip per pointer move. Advisory: the release re-resolves.
8568
8596
  hostWindows:async()=>{try{const r=await fetch('/api/host-windows');return await r.json();}catch(e){return null;}},
8569
8597
  // 3D Move/Copy: the 3D view reads the armed tool + counts, and hands commit offsets back in scene mm.
8570
- cmState:()=>cmTool?{tool:cmTool,array:cmArrayMode,count:cmCount,countA:cmCountA,countB:cmCountB}:null,
8598
+ cmState:()=>cmTool?{tool:cmTool,array:cmArrayMode,count:cmCount,countA:cmCountA,countB:cmCountB,referenceId:(view3d&&refSelectedObjIdx===null?refSelectedId:null)}:null,
8571
8599
  // mm → plan px (Y FLIPPED) + inches for dz, now owned by the model boundary. toDisplayOffsets MUTATES
8572
8600
  // NOTHING on purpose: cmApplyOffsets below is what moves the members, and it also owns the empty-selection
8573
8601
  // toast, the 100-copy cap and the distance toast — which measures from these same ROUNDED offsets.
8574
- onTransform3d:(offsMm)=>{cmApplyOffsets(MC().toDisplayOffsets(offsMm));},
8602
+ onTransform3d:(offsMm)=>{const refTarget=refSelectedId&&refSelectedObjIdx===null?refById(refSelectedId):null;
8603
+ if(refTarget&&cmTool==='move'&&!selIds.size){const off=offsMm&&offsMm[0];if(!off||off.length<3)return;
8604
+ if(refDisp(refTarget).locked){toast('“'+refTarget.name+'” is locked — unlock it to move it');disarmCm();render();return;}
8605
+ const old=(refTarget.placement&&refTarget.placement.origin)||[0,0,0],next=[0,1,2].map(i=>(Number(old[i])||0)+(Number(off[i])||0));
8606
+ refEdit(refTarget.id,{placement:{origin:next}});
8607
+ toast('Moved 1 reference model · '+fmtFtIn(Math.hypot(off[0],off[1],off[2])/25.4));panel();return;}
8608
+ cmApplyOffsets(MC().toDisplayOffsets(offsMm));},
8575
8609
  disarmTransform:()=>{if(cmTool){disarmCm();render();}}, // the 3D dim tool arming kicks Move/Copy off the left-click
8576
8610
  // 3D draw-on-plane (spec §7): the editor's add-member mode + profile drive it; two plane picks (scene mm) come back here.
8577
8611
  addModeActive:()=>mode==='add',
@@ -8596,7 +8630,7 @@ const view3dApi={
8596
8630
  selIds=new Set([id]);});
8597
8631
  const asCol=hIn<6&&dzIn>6;
8598
8632
  toast('Added '+(asCol?'a column':'a beam')+' on the working plane'+(((addType==='column')!==asCol)?' — the pick geometry set the type, not '+memberTypeLabel(addType):''));}, // say it out loud when 3D geometry overrode the Add panel's type
8599
- onClipsChange:()=>{build3DLegend();}, // a clip added / removed / toggled → rebuild the legend's Clip section
8633
+ onClipsChange:()=>{const v=window.Steel3DView;if(v&&v.selectedClips&&v.selectedClips().length)clearWholeReferenceSelection();build3DLegend();}, // a clip added / removed / toggled → its renderer-side selection also takes the one action target, then rebuild the legend's Clip section
8600
8634
  beginClipEdit:()=>pushUndo(snapshot()), // a clip / work-area manipulation → push a pre-edit snapshot so Ctrl+Z/Y restores it
8601
8635
  onClipModeChange:(m)=>{const b=document.getElementById('m3dClip');if(b){b.classList.toggle('on',!!m);b.textContent=m?'Clip ✕':'Clip ▾';}}, // armed → button fills brand-blue + becomes a cancel target (✕ = cancel)
8602
8636
  onInsertModeChange:(on)=>{const b=document.getElementById('m3dInsert');if(b){b.classList.toggle('on',!!on);b.textContent=on?'✕ Cancel insert':'Insert…';} if(!on)favDisarmed();}, // armed → cancel target; disarm also clears any armed favourite (the pinned bar + the .armed row)
@@ -8610,22 +8644,16 @@ const view3dApi={
8610
8644
  // describing the first object while the 3D view highlights the second.
8611
8645
  onReferenceSelect:(id,obj)=>{
8612
8646
  const nextId=id||null,nextIdx=obj&&Number.isInteger(obj.index)?obj.index:null;
8613
- if(refSelectedId===nextId&&refSelectedObjIdx===nextIdx)return;
8647
+ const nativeSelected=selIds.size||selDimIds.size||selGridIds.size||sel3dDimIds.size;
8648
+ if(refSelectedId===nextId&&refSelectedObjIdx===nextIdx&&!(nextId&&nativeSelected))return;
8614
8649
  refSelectedId=nextId;refSelectedObjIdx=nextIdx;
8615
- // DRILLING IN TAKES THE SELECTION, NOT JUST THE PANEL — the exact mirror of `clickSelect` dropping the
8616
- // reference the moment a click lands on one of our own members. The two are one selection between
8617
- // them, and the first cut let them coexist: with a beam selected, drilling into a reference object put
8618
- // its facts in the panel while Delete and the arrow keys still acted on the beam. Panel and keystroke
8619
- // target pointing at different things is the worst state this feature has.
8620
- //
8621
- // Only a DRILL steals. Selecting a whole reference (a row click) does not take the panel, so it has no
8622
- // business taking the selection either.
8623
- //
8624
- // This is also what keeps `panel()`'s release guard from fighting an intentional drill: the guard fires
8625
- // when something of ours is selected, and by the time it runs, nothing is. The browser pass caught
8626
- // that — with a marquee selection live, drilling was silently impossible.
8627
- const stole=nextIdx!==null&&(selIds.size||selDimIds.size||selGridIds.size||sel3dDimIds.size);
8650
+ // A REFERENCE TAKES THE SELECTION, whole or drilled. Move with two points accepts a whole reference,
8651
+ // so letting a beam remain selected would make one toolbar command have two incompatible targets.
8652
+ // Drilling already needed the same exclusivity for a more dangerous reason: the panel could describe
8653
+ // an IFC object while Delete and the arrow keys still acted on our beam. One canvas now has one target.
8654
+ const stole=nextId!==null&&!!nativeSelected;
8628
8655
  if(stole){selIds.clear();selDimIds.clear();selGridIds.clear();sel3dDimIds.clear();}
8656
+ if(nextId&&window.Steel3DView&&window.Steel3DView.setSelectedClips)window.Steel3DView.setSelectedClips([]);
8629
8657
  // The object tree, if the user has it open, comes to the object — see `revealRefTreeObject`. It
8630
8658
  // repaints the tab itself, so the ordinary repaint below is skipped when it did.
8631
8659
  if(!(nextId&&nextIdx!==null&&revealRefTreeObject(nextId,nextIdx))&&legendTab==='refs')renderRefsTab();
@@ -8818,6 +8846,7 @@ let clipAnchor=null;
8818
8846
  // Shift = the range from the anchor (in list order). Selecting a clip clears member/dim/grid selection (exclusive).
8819
8847
  function clipSelect(id,e){
8820
8848
  if(!window.Steel3DView)return;
8849
+ clearWholeReferenceSelection();
8821
8850
  if(selIds.size||sel3dDimIds.size||selGridIds.size||(typeof selDimIds!=='undefined'&&selDimIds.size)){selIds=new Set();sel3dDimIds.clear();selGridIds.clear();if(typeof selDimIds!=='undefined')selDimIds.clear();render();}
8822
8851
  const ids=window.Steel3DView.getClips().map(c=>c.id),cur=new Set(window.Steel3DView.selectedClips());
8823
8852
  let next;
@@ -11857,7 +11886,7 @@ function build3DLegend(){const host=document.getElementById('m3dLegendBody');if(
11857
11886
  // Contextual visibility menu: selection exposes Isolate/Hide; any active object filter keeps Show all reachable
11858
11887
  // after Hide selected clears that now-invisible selection. Updated on selection change + every visibility callback.
11859
11888
  function updateIsolateBtn(){const wrap=document.getElementById('m3dIsoWrap'),b=document.getElementById('m3dIso'),menu=document.getElementById('m3dIsoMenu');if(!wrap||!b||!menu||!window.Steel3DView)return;
11860
- const V=window.Steel3DView,filtered=V.hasVisibilityFilter?V.hasVisibilityFilter():!!(V.isIsolated&&V.isIsolated()),hasSel=selIds.size>0;
11889
+ const V=window.Steel3DView,filtered=V.hasVisibilityFilter?V.hasVisibilityFilter():!!(V.isIsolated&&V.isIsolated()),hasSel=selIds.size>0||selGridIds.size>0;
11861
11890
  const visible=filtered||hasSel;if(!visible&&wrap.contains(document.activeElement)){const stable=document.getElementById('m3dViewsBtn');if(stable)stable.focus();}wrap.style.display=visible?'':'none';b.classList.toggle('on',filtered);b.textContent=filtered?'Show all ▾':'Isolate ▾';
11862
11891
  b.setAttribute('data-tip',filtered?'Restore hidden objects or change the current selection’s visibility':'Visibility actions for the selected objects');
11863
11892
  const show=menu.querySelector('[data-vis=show-all]'),div=menu.querySelector('[data-vis-divider]'),iso=menu.querySelector('[data-vis=isolate]'),hide=menu.querySelector('[data-vis=hide]');
@@ -11886,6 +11915,7 @@ function refresh3DLegend(){if(!window.Steel3DView)return;const st=window.Steel3D
11886
11915
  function legendRowClick(e,row){if(row&&row._dragging)return;const mods={ctrl:e.ctrlKey||e.metaKey,shift:e.shiftKey};clearTimeout(leg3dClickT);if(mods.ctrl||mods.shift)legendSelect(row,mods);else leg3dClickT=setTimeout(()=>legendSelect(row,mods),220);}
11887
11916
  function legendSelect(row,mods){
11888
11917
  if(!row)return;const ids=legRowIds(row);if(!ids.length)return;
11918
+ clearWholeReferenceSelection();
11889
11919
  if(mods&&mods.shift&&legendSelAnchor&&document.body.contains(legendSelAnchor)){ // Shift → union every VISIBLE object row from the anchor to here (a search-hidden row can't be range-selected)
11890
11920
  const rows=[...document.querySelectorAll('#m3dLegend .lrow[data-key]:not(.qhide),#m3dLegend .lrow[data-connkey]:not(.qhide)')];
11891
11921
  const i0=rows.indexOf(legendSelAnchor),i1=rows.indexOf(row);
@@ -12133,7 +12163,7 @@ function wire3DBar(){if(bar3dWired||!window.Steel3DView)return;bar3dWired=true;
12133
12163
  isoMenu.classList.add('open');isoBtn.setAttribute('aria-expanded','true');document.addEventListener('mousedown',isoMenuOutside,true);menuItems(isoMenu)[0]?.focus();}};
12134
12164
  isoMenu.querySelector('[data-vis=show-all]').onclick=()=>{d3.showAllGroups();isoMenuClose(true);toast('Showing all objects');};
12135
12165
  isoMenu.querySelector('[data-vis=isolate]').onclick=()=>{d3.isolateSelected();isoMenuClose(true);};
12136
- isoMenu.querySelector('[data-vis=hide]').onclick=()=>{const n=d3.hideSelected?d3.hideSelected():0;if(n){selIds.clear();render();toast(n+' object'+(n===1?'':'s')+' hidden');}isoMenuClose(true);};
12166
+ isoMenu.querySelector('[data-vis=hide]').onclick=()=>{const n=d3.hideSelected?d3.hideSelected():0;if(n){selIds.clear();selGridIds.clear();render();toast(n+' object'+(n===1?'':'s')+' hidden');}isoMenuClose(true);};
12137
12167
  isoBtn.addEventListener('keydown',e=>{if(e.key==='Escape'&&isoMenu.classList.contains('open')){e.preventDefault();e.stopPropagation();isoMenuClose(true);}else if((e.key==='ArrowDown'||e.key==='Enter'||e.key===' ')&&!isoMenu.classList.contains('open')){e.preventDefault();e.stopPropagation();isoBtn.click();}});
12138
12168
  isoMenu.addEventListener('keydown',e=>menuKeys(e,isoMenu,isoBtn,isoMenuClose));
12139
12169
  // Views toolbar button: open the panel on the Views tab (or, if it's already open on Views, toggle it closed — a natural toolbar toggle).
@@ -296,6 +296,7 @@ export function createV2CommandSession(model, options = {}) {
296
296
  if (Object.hasOwn(saved, 'member_types')) draft.member_types = clone(saved.member_types || []);
297
297
  if (Object.hasOwn(saved, 'dim_style')) draft.dim_style = clone(saved.dim_style || {});
298
298
  if (Object.hasOwn(saved, 'member_styles')) draft.member_styles = clone(saved.member_styles || {});
299
+ if (Object.hasOwn(saved, 'reference_models')) draft.reference_models = clone(saved.reference_models || []);
299
300
  return { structural: true };
300
301
  });
301
302
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.127.5",
3
+ "version": "0.127.6",
4
4
  "type": "module",
5
5
  "description": "Thin localhost host for floless.app — serves web/ and shells the aware CLI. No engine, no LLM.",
6
6
  "bin": {