@floless/app 0.149.1 → 0.150.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +101814 -88311
- package/dist/schemas/drawing-check.profile.v1.schema.json +45 -2
- package/dist/schemas/steel.model.v2.schema.json +9 -0
- package/dist/skills/floless-app-approval/SKILL.md +79 -4
- package/dist/skills/floless-app-onboarding/SKILL.md +4 -4
- package/dist/skills/floless-app-onboarding/references/aware-runtime.md +1 -1
- package/dist/skills/floless-app-onboarding/references/floless-app-tour.md +15 -13
- package/dist/skills/floless-app-routines/SKILL.md +4 -1
- package/dist/skills/floless-app-routines/references/routines-api.md +14 -2
- package/dist/skills/floless-app-steel-model/SKILL.md +4 -2
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +14 -9
- package/dist/skills/floless-app-workflows/SKILL.md +2 -2
- package/dist/templates/tekla-parser.flo +13 -3
- package/dist/web/agents.js +887 -0
- package/dist/web/app.css +458 -23
- package/dist/web/app.js +20 -5
- package/dist/web/aware.js +1339 -134
- package/dist/web/chat.css +50 -1
- package/dist/web/chat.js +1582 -52
- package/dist/web/commands-drawing-check.js +15 -0
- package/dist/web/commands-revit.js +5 -0
- package/dist/web/commands-shell.js +761 -47
- package/dist/web/commands-tekla-parser.js +8 -1
- package/dist/web/connections.js +57 -14
- package/dist/web/drawing-check-editor.html +10 -2
- package/dist/web/drawing-check-editor.js +569 -40
- package/dist/web/drawing-check-overlay.js +45 -2
- package/dist/web/index.html +98 -27
- package/dist/web/instructor.js +85 -8
- package/dist/web/leave-guard.js +1 -0
- package/dist/web/left-pane.js +20 -1
- package/dist/web/local-discovery.js +12 -2
- package/dist/web/model-editor.css +32 -32
- package/dist/web/model-panel-bridge.js +11 -3
- package/dist/web/model-viewport-lighting.js +4 -2
- package/dist/web/model-viewport-revit-adapter.js +3 -0
- package/dist/web/model-viewport-toolbar.js +6 -3
- package/dist/web/model-viewport.js +11 -1
- package/dist/web/revit-editor.css +14 -14
- package/dist/web/revit-editor.js +64 -12
- package/dist/web/steel-3d-core.js +133 -0
- package/dist/web/steel-3d-view.js +10 -0
- package/dist/web/steel-editor.html +171 -39
- package/dist/web/steel-model-v2-client-validation.js +11 -0
- package/dist/web/steel-model-v2-commands.js +80 -5
- package/dist/web/tool-updates.js +367 -0
- package/dist/web/workspaces.js +679 -59
- package/package.json +1 -1
package/dist/web/revit-editor.js
CHANGED
|
@@ -40,8 +40,10 @@ const modelExplorerTabs = isTeklaParser
|
|
|
40
40
|
? Object.freeze([{ key: 'type', bodyId: 'revitExplorerTypes' }])
|
|
41
41
|
: revitExplorerTabs;
|
|
42
42
|
const hostThemeKey = 'floless-demo-theme-v1';
|
|
43
|
+
let viewport = null;
|
|
43
44
|
function syncHostTheme() {
|
|
44
45
|
document.documentElement.dataset.theme = localStorage.getItem(hostThemeKey) === 'light' ? 'light' : 'dark';
|
|
46
|
+
viewport?.setTheme?.(document.documentElement.dataset.theme);
|
|
45
47
|
}
|
|
46
48
|
syncHostTheme();
|
|
47
49
|
window.addEventListener('storage', (event) => { if (event.key === hostThemeKey) syncHostTheme(); });
|
|
@@ -51,7 +53,7 @@ const commandPrefix = isTeklaParser ? 'tekla-parser' : 'revit';
|
|
|
51
53
|
const subjectSource = isTeklaParser ? 'tekla-parser' : 'revit';
|
|
52
54
|
const editorProjectRoute = isTeklaParser ? '/api/editor/tekla-projects' : '/api/editor/revit-projects';
|
|
53
55
|
const contractRoute = isTeklaParser ? '/api/contract/tekla-parser' : '/api/contract/revit-model';
|
|
54
|
-
let entities = [], properties = [], relationships = [], entityById = new Map(), propertyByEntity = new Map(), selectedId = null, selectedIds = [], selectionOrigin = 'tree', classificationFollowedId = null, facade = null,
|
|
56
|
+
let entities = [], properties = [], relationships = [], entityById = new Map(), propertyByEntity = new Map(), selectedId = null, selectedIds = [], selectionOrigin = 'tree', classificationFollowedId = null, facade = null, inspector = null;
|
|
55
57
|
let selectionTools = null;
|
|
56
58
|
let selectionFilterChrome = null;
|
|
57
59
|
let spatialTools = null;
|
|
@@ -78,6 +80,7 @@ let sharedTools = null;
|
|
|
78
80
|
let displayUnitControl = null, displayUnitEvents = null, lastCursorCoordinates = null;
|
|
79
81
|
let propertyDisplayRefresh = new Set();
|
|
80
82
|
let toolbarChrome = null;
|
|
83
|
+
let lightingPanel = null;
|
|
81
84
|
let teklaAssemblyMembers = new Map();
|
|
82
85
|
let geometrySelectionIds = [];
|
|
83
86
|
let terminalDisposed = false;
|
|
@@ -153,7 +156,7 @@ const chatQuestionsSection = Object.freeze({ id: 'chat-questions', editable: fal
|
|
|
153
156
|
if (!chatLinksAvailable()) return;
|
|
154
157
|
const box = renderChatQuestions({ doc: document, chatLinks, selected: selectedSubjectItems(), resolves: chatSubjectResolves,
|
|
155
158
|
currentLabel: (link) => subjectLabelOf(link.id), commandPrefix, ui: chatQuestionsUi, toast,
|
|
156
|
-
onShow: (link) => !!modelPanelBridge?.openChat(link.chatId, link.messageEventId, projectId),
|
|
159
|
+
onShow: (link) => !!modelPanelBridge?.openChat(link.chatId, link.messageEventId, projectId, link.owner),
|
|
157
160
|
onRetry: () => refreshChatLinks(true) });
|
|
158
161
|
if (box) host.append(box);
|
|
159
162
|
} });
|
|
@@ -756,7 +759,7 @@ function mountRevitSelectionFilters(tools) {
|
|
|
756
759
|
const button = host.querySelector(`[data-cls="${facet}"]`); const spec = SELECTION_FACETS.find((item) => item.id === facet);
|
|
757
760
|
if (!button || !spec) return;
|
|
758
761
|
if (menu?.dataset.facet === facet) { close(); return; }
|
|
759
|
-
close();
|
|
762
|
+
close(); closeSpatialDialog(); spatialPanel?.close({ restoreFocus: false }); toolbarChrome?.closeMenus(); lightingPanel?.close({ restoreFocus: false });
|
|
760
763
|
const values = selectionFacetValues(facet); const filters = tools.filters(); const selected = new Set(own(filters, facet) ? filters[facet] : values);
|
|
761
764
|
const panel = document.createElement('section'); panel.className = 'model-selection-filter-flyout'; panel.dataset.facet = facet; panel.setAttribute('aria-label', `${spec.label} selection filter`);
|
|
762
765
|
const heading = document.createElement('div'); heading.className = 'model-filter-heading';
|
|
@@ -791,6 +794,7 @@ function mountRevitSelectionFilters(tools) {
|
|
|
791
794
|
return Object.freeze({
|
|
792
795
|
port: Object.freeze({ getState: state, subscribe(listener) { subscribers.add(listener); listener(state()); return () => subscribers.delete(listener); }, toggle: open }),
|
|
793
796
|
refresh() { publish(); close(); },
|
|
797
|
+
close,
|
|
794
798
|
destroy() { if (destroyed) return; destroyed = true; close(); filterUnsubscribe(); subscribers.clear(); document.removeEventListener('click', outside); },
|
|
795
799
|
});
|
|
796
800
|
}
|
|
@@ -810,7 +814,13 @@ function reflectSelectionMarquee(rect) {
|
|
|
810
814
|
box.style.left = `${rect.left - surface.left}px`; box.style.top = `${rect.top - surface.top}px`; box.style.width = `${rect.right - rect.left}px`; box.style.height = `${rect.bottom - rect.top}px`;
|
|
811
815
|
}
|
|
812
816
|
|
|
813
|
-
function closeSpatialDialog(
|
|
817
|
+
function closeSpatialDialog({ restoreFocus = false } = {}) {
|
|
818
|
+
const anchor = spatialDialog?.__anchor;
|
|
819
|
+
spatialDialog?.remove(); spatialDialog = null;
|
|
820
|
+
$('revitSavedViews')?.setAttribute('aria-expanded', 'false');
|
|
821
|
+
if (restoreFocus) anchor?.focus();
|
|
822
|
+
window.__instructor?.notifyChanged();
|
|
823
|
+
}
|
|
814
824
|
|
|
815
825
|
function spatialFrameFromStored(frame) {
|
|
816
826
|
return { id: frame.frameId, kind: frame.frameId === 'object' ? 'object' : frame.frameId === 'work-plane' ? 'work-plane' : 'local',
|
|
@@ -963,30 +973,36 @@ function commitSpatialForRevision(candidate) {
|
|
|
963
973
|
inspect(null);
|
|
964
974
|
});
|
|
965
975
|
spatialTools.subscribe((value) => { $('modelFrameStatus').textContent = spatialTools.activeFrame().label; window.__revitInstructorState = { ...(window.__revitInstructorState || {}), activeFrame: value.activeFrameId }; reflectToolbarState(); });
|
|
966
|
-
spatialPanel = mountModelSpatialPanel({ tools: spatialTools, trigger: $('modelFrameStatus'), onBeforeOpen: closeSpatialDialog,
|
|
976
|
+
spatialPanel = mountModelSpatialPanel({ tools: spatialTools, trigger: $('modelFrameStatus'), onBeforeOpen: () => { closeSpatialDialog(); toolbarChrome?.closeMenus(); selectionFilterChrome?.close(); lightingPanel?.close({ restoreFocus: false }); },
|
|
967
977
|
lengthDisplay: { format: (mm) => formatLength(mm, displayUnitControl.units()), parse: (text) => parseLengthMm(text, displayUnitControl.units()), unitLabel: () => displayUnitControl.units() },
|
|
968
978
|
onError: (error) => toast(error.message || 'That spatial action is unavailable.') });
|
|
969
979
|
if (candidate.recovered) { editorStateDirtyPayload = editorStatePayload(); editorStateDirtyGeneration = 1; retainEditorStateRecovery(); editorStateSaveTimer = setTimeout(() => drainEditorStateSaves().catch((error) => toast(error.message || 'Could not restore model view state.')), 0); }
|
|
970
980
|
}
|
|
971
981
|
|
|
972
982
|
function positionDialog(panel, anchor) {
|
|
983
|
+
panel.__anchor = anchor;
|
|
973
984
|
document.body.append(panel); spatialDialog = panel; const rect = anchor.getBoundingClientRect();
|
|
974
985
|
panel.style.left = `${Math.max(8, Math.min(rect.left, innerWidth - panel.offsetWidth - 8))}px`; panel.style.top = `${Math.min(innerHeight - panel.offsetHeight - 8, rect.bottom + 7)}px`;
|
|
975
986
|
}
|
|
976
987
|
|
|
977
988
|
function openSavedViews() {
|
|
978
989
|
const anchor = $('revitSavedViews'); if (!anchor || !spatialTools) return;
|
|
979
|
-
|
|
990
|
+
if (spatialDialog?.__anchor === anchor) { closeSpatialDialog({ restoreFocus: true }); return; }
|
|
991
|
+
toolbarChrome?.closeMenus(); selectionFilterChrome?.close(); lightingPanel?.close({ restoreFocus: false });
|
|
992
|
+
spatialPanel?.close({ restoreFocus: false }); closeSpatialDialog(); const panel = document.createElement('section'); panel.className = 'model-spatial-dialog'; panel.setAttribute('role', 'dialog'); panel.setAttribute('aria-modal', 'false'); panel.setAttribute('aria-label', 'Saved camera views');
|
|
980
993
|
const header = document.createElement('div'); header.className = 'model-spatial-dialog-header'; const headingLabel = document.createElement('strong'); headingLabel.textContent = 'Saved views';
|
|
981
|
-
const close = document.createElement('button'); close.type = 'button'; close.textContent = '×'; close.dataset.tip = 'Close saved views'; close.setAttribute('aria-label', 'Close saved views'); close.addEventListener('click', closeSpatialDialog); header.append(headingLabel, close);
|
|
994
|
+
const close = document.createElement('button'); close.type = 'button'; close.textContent = '×'; close.dataset.tip = 'Close saved views'; close.dataset.commandId = `${commandPrefix}.saved-view-close`; close.setAttribute('aria-label', 'Close saved views'); close.addEventListener('click', () => closeSpatialDialog({ restoreFocus: true })); header.append(headingLabel, close);
|
|
982
995
|
const input = document.createElement('input'); input.type = 'text'; input.maxLength = 120; input.placeholder = 'View name'; input.setAttribute('aria-label', 'Saved view name');
|
|
996
|
+
input.dataset.commandId = `${commandPrefix}.saved-view-name`;
|
|
983
997
|
const save = document.createElement('button'); save.type = 'button'; save.textContent = 'Save current view';
|
|
998
|
+
save.dataset.commandId = `${commandPrefix}.saved-view-save`;
|
|
984
999
|
const list = document.createElement('div'); list.className = 'model-saved-view-list';
|
|
985
1000
|
const paint = () => {
|
|
986
1001
|
list.replaceChildren(); const views = spatialTools.state().savedViews;
|
|
987
1002
|
for (const view of views) {
|
|
988
1003
|
const row = document.createElement('div'); row.className = 'model-saved-view-row';
|
|
989
1004
|
const restore = document.createElement('button'); restore.type = 'button'; restore.textContent = view.name; restore.dataset.tip = `Restore ${view.name}`;
|
|
1005
|
+
restore.dataset.commandId = `${commandPrefix}.saved-view-restore#${encodeURIComponent(view.id)}`; restore.dataset.commandInstanceLabel = view.name;
|
|
990
1006
|
restore.addEventListener('click', () => {
|
|
991
1007
|
const saved = view.state || {}; if (saved.camera) viewport.applyCamera(saved.camera); if (saved.displayMode) facade.dispatch('model.display-mode.set', saved.displayMode);
|
|
992
1008
|
if (typeof saved.ghostUnselected === 'boolean' && facade.ghostUnselected() !== saved.ghostUnselected) facade.dispatch('model.ghost-unselected');
|
|
@@ -994,16 +1010,19 @@ function openSavedViews() {
|
|
|
994
1010
|
spatialTools.clearWorkPlane();
|
|
995
1011
|
if (saved.workPlane?.source === 'principal') { spatialTools.setPrincipalWorkPlane({ plane: saved.workPlane.principal, offsetMm: saved.workPlane.offsetMm }); if (saved.workPlane.visible === false) spatialTools.setWorkPlaneVisible(false); }
|
|
996
1012
|
if (view.frameId && spatialTools.state().frames.some((frame) => frame.id === view.frameId)) spatialTools.activateFrame(view.frameId);
|
|
997
|
-
closeSpatialDialog();
|
|
1013
|
+
closeSpatialDialog({ restoreFocus: true });
|
|
998
1014
|
});
|
|
999
|
-
const remove = document.createElement('button'); remove.type = 'button'; remove.textContent = 'Delete'; remove.dataset.tip = `Delete ${view.name}`; remove.addEventListener('click', () => { spatialTools.deleteView(view.id); paint(); });
|
|
1015
|
+
const remove = document.createElement('button'); remove.type = 'button'; remove.textContent = 'Delete'; remove.dataset.tip = `Delete ${view.name}`; remove.setAttribute('aria-label', `Delete saved view ${view.name}`); remove.addEventListener('click', () => { spatialTools.deleteView(view.id); paint(); input.focus(); });
|
|
1016
|
+
remove.dataset.commandId = `${commandPrefix}.saved-view-delete#${encodeURIComponent(view.id)}`; remove.dataset.commandInstanceLabel = view.name;
|
|
1000
1017
|
row.append(restore, remove); list.append(row);
|
|
1001
1018
|
}
|
|
1002
1019
|
if (!views.length) { const empty = document.createElement('div'); empty.className = 'model-dialog-note'; empty.textContent = 'No saved views for this model revision yet.'; list.append(empty); }
|
|
1003
1020
|
};
|
|
1004
1021
|
save.addEventListener('click', () => { const name = input.value.trim(); if (!name) { input.focus(); return; } const spatial = spatialTools.state(); spatialTools.saveView({ id: `view-${Date.now().toString(36)}`, name, frameId: spatialTools.activeFrame().id,
|
|
1005
1022
|
state: { camera: viewport.cameraState(), displayMode: viewport.displayMode(), ghostUnselected: facade.ghostUnselected(), clips: spatial.clips, workArea: spatial.workArea, workPlane: spatial.workPlane } }); input.value = ''; paint(); });
|
|
1006
|
-
panel.
|
|
1023
|
+
panel.dataset.revealBy = '#revitSavedViews';
|
|
1024
|
+
panel.addEventListener('keydown', (event) => { if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); closeSpatialDialog({ restoreFocus: true }); } });
|
|
1025
|
+
panel.append(header, input, save, list); positionDialog(panel, anchor); anchor.setAttribute('aria-expanded', 'true'); paint(); input.focus(); window.__instructor?.notifyChanged();
|
|
1007
1026
|
}
|
|
1008
1027
|
|
|
1009
1028
|
function openPlaneOffset(plane, anchor) {
|
|
@@ -1080,11 +1099,17 @@ function wireToolbar() {
|
|
|
1080
1099
|
const plan = isTeklaParser
|
|
1081
1100
|
? readOnlyModelRenderPlan({ commandPrefix, sourceLabel: 'Tekla' })
|
|
1082
1101
|
: revitRenderPlan();
|
|
1083
|
-
const bar = $('m3dBar'); bar.innerHTML = renderToolbarMarkup(plan);
|
|
1102
|
+
const bar = $('m3dBar'); bar.innerHTML = renderToolbarMarkup(plan);
|
|
1103
|
+
const chrome = mountToolbarChrome({ toolbar: bar, port: facade, onBeforeOpen: () => { closeSpatialDialog(); selectionFilterChrome?.close(); spatialPanel?.close({ restoreFocus: false }); lightingPanel?.close({ restoreFocus: false }); } });
|
|
1104
|
+
const savedViews = $('revitSavedViews'); savedViews?.setAttribute('aria-haspopup', 'dialog'); savedViews?.setAttribute('aria-expanded', 'false');
|
|
1105
|
+
const outsideDialog = (event) => { if (spatialDialog && !spatialDialog.contains(event.target) && !spatialDialog.__anchor?.contains(event.target)) closeSpatialDialog(); };
|
|
1106
|
+
document.addEventListener('mousedown', outsideDialog, true);
|
|
1084
1107
|
const lightingChrome = mountModelLightingPanel({
|
|
1085
1108
|
trigger: $('revitLighting'), anchor: $('revitDisplay'), target: facade,
|
|
1086
1109
|
profile: isTeklaParser ? 'tekla-parser' : 'revit',
|
|
1110
|
+
onBeforeOpen: () => { closeSpatialDialog(); selectionFilterChrome?.close(); spatialPanel?.close({ restoreFocus: false }); chrome.closeMenus(); },
|
|
1087
1111
|
});
|
|
1112
|
+
lightingPanel = lightingChrome;
|
|
1088
1113
|
const clipButton = $('revitClip');
|
|
1089
1114
|
const cancelArmedClip = (event) => {
|
|
1090
1115
|
if (!facade.clipMode?.()) return;
|
|
@@ -1111,7 +1136,7 @@ function wireToolbar() {
|
|
|
1111
1136
|
updateSelectionActions();
|
|
1112
1137
|
reflectToolbarState();
|
|
1113
1138
|
const release = facade.subscribe(() => { try { syncGridVisibilityAction(); reflectToolbarState(); } catch (_) {} });
|
|
1114
|
-
return { destroy() { clipButton?.removeEventListener('click', cancelArmedClip, true); release?.(); lightingChrome.destroy(); chrome.destroy(); } };
|
|
1139
|
+
return { closeMenus: () => chrome.closeMenus(), destroy() { document.removeEventListener('mousedown', outsideDialog, true); clipButton?.removeEventListener('click', cancelArmedClip, true); release?.(); lightingChrome.destroy(); chrome.destroy(); } };
|
|
1115
1140
|
}
|
|
1116
1141
|
|
|
1117
1142
|
/**
|
|
@@ -1376,6 +1401,7 @@ function authorityButtons(state) {
|
|
|
1376
1401
|
candidate = await prepareSpatialForRevision(state, state[key]);
|
|
1377
1402
|
if (!await loadRevision(state, key, candidate)) return;
|
|
1378
1403
|
host.querySelectorAll('button').forEach((item) => item.setAttribute('aria-pressed', String(item === button)));
|
|
1404
|
+
const findingsChip = document.getElementById('authorityFindings'); if (findingsChip) findingsChip.hidden = key !== 'approved';
|
|
1379
1405
|
window.__revitInstructorState = { ...(window.__revitInstructorState || {}), authority: key }; window.__instructor?.notifyChanged();
|
|
1380
1406
|
} catch (error) {
|
|
1381
1407
|
const current = host.querySelector('[aria-pressed="true"]')?.textContent || 'The current model';
|
|
@@ -1386,6 +1412,32 @@ function authorityButtons(state) {
|
|
|
1386
1412
|
candidate?.dispose(); host.removeAttribute('aria-busy'); host.querySelectorAll('button').forEach((item) => { item.disabled = false; });
|
|
1387
1413
|
}
|
|
1388
1414
|
}); host.append(button); }
|
|
1415
|
+
// #1840: an approved snapshot that accepted open import findings says so beside the toggle while it is
|
|
1416
|
+
// shown (the server's own sentence), and the chip opens the findings in the Audit tab.
|
|
1417
|
+
document.getElementById('authorityFindings')?.remove();
|
|
1418
|
+
const accepted = isTeklaParser && state.approved && state.approvedImportFindings && typeof state.approvedImportFindings.note === 'string'
|
|
1419
|
+
? state.approvedImportFindings : null;
|
|
1420
|
+
if (accepted) {
|
|
1421
|
+
const approvedButton = [...host.querySelectorAll('button')].find((item) => item.dataset.commandInstanceLabel === 'approved');
|
|
1422
|
+
if (approvedButton) approvedButton.dataset.tip = `The approved copy of the model. ${accepted.note}`;
|
|
1423
|
+
const open = Number(accepted.open) || 0;
|
|
1424
|
+
const chip = document.createElement('button'); chip.type = 'button'; chip.id = 'authorityFindings'; chip.className = 'authority-findings';
|
|
1425
|
+
chip.textContent = `${open.toLocaleString('en-US')} ${open === 1 ? 'finding' : 'findings'} accepted`;
|
|
1426
|
+
chip.dataset.commandId = 'tekla-parser.audit-open'; chip.dataset.tip = `${accepted.note} Show them in the Audit tab.`;
|
|
1427
|
+
chip.hidden = initial !== 'approved';
|
|
1428
|
+
chip.addEventListener('click', () => { modelPanelBridge?.reveal('audit'); });
|
|
1429
|
+
host.after(chip);
|
|
1430
|
+
} else if (isTeklaParser && state.approved && state.approvalDetailsUnavailable === true) {
|
|
1431
|
+
// The server could not read how this snapshot was approved: say so beside the toggle while it is
|
|
1432
|
+
// shown, instead of presenting it as a plain approval.
|
|
1433
|
+
const unavailable = 'FloLess could not confirm how this snapshot was approved, so it is not shown as a normal approval. If you need help, use Report an issue.';
|
|
1434
|
+
const approvedButton = [...host.querySelectorAll('button')].find((item) => item.dataset.commandInstanceLabel === 'approved');
|
|
1435
|
+
if (approvedButton) approvedButton.dataset.tip = 'The approved copy of the model. FloLess could not confirm how it was approved, so it is not shown as a normal approval. If you need help, use Report an issue.';
|
|
1436
|
+
const note = document.createElement('span'); note.id = 'authorityFindings'; note.className = 'authority-note';
|
|
1437
|
+
note.textContent = 'Approval details unavailable'; note.dataset.tip = unavailable;
|
|
1438
|
+
note.hidden = initial !== 'approved';
|
|
1439
|
+
host.after(note);
|
|
1440
|
+
}
|
|
1389
1441
|
return initial;
|
|
1390
1442
|
}
|
|
1391
1443
|
|
|
@@ -1915,6 +1915,139 @@ export function directionPreservingGesture(gesture) {
|
|
|
1915
1915
|
return gesture === 'slide' || gesture === 'translate';
|
|
1916
1916
|
}
|
|
1917
1917
|
|
|
1918
|
+
/**
|
|
1919
|
+
* The ONE frame-branch policy a work-point commit (`commitMemberEndpoints`) is held to: may the candidate
|
|
1920
|
+
* points land, given which `partFrame` branch the member is on before and after? `before`/`after` are
|
|
1921
|
+
* `positionGizmoFrame` results for the stored and the candidate points; a zero-length candidate has no
|
|
1922
|
+
* frame and is refused before this is asked.
|
|
1923
|
+
*
|
|
1924
|
+
* What it guards against is the section frame JUMPING. Inside the degeneracy cone (a member within
|
|
1925
|
+
* ≈0.057° of the authoring basis' up — sin θ ≤ 1e-3, `FRAME_DEGENERATE_SQ`; "plumb" under the global or
|
|
1926
|
+
* any level frame) the frame is seeded from the basis X axis; outside it, from the up vector. Crossing
|
|
1927
|
+
* between the two rotates the profile about the member axis — by up to a half turn, depending on which way
|
|
1928
|
+
* the member leans — even though the line barely moved. So:
|
|
1929
|
+
* - a rigid move (`directionPreservingGesture`) must KEEP its branch, in both directions: it changes
|
|
1930
|
+
* neither direction nor length, so a crossing can only come from each endpoint quantising on its own at
|
|
1931
|
+
* the edge of the cone — and it would rebuild a different frame than the rigid preview showed;
|
|
1932
|
+
* - the end-node drag ('endpoint') may not ENTER the cone from the ordinary branch — making a leaning
|
|
1933
|
+
* member plumb is that jump — but it may STAY in it while the member keeps its sense (#1933). Its Alt
|
|
1934
|
+
* mode moves an end straight up or down, so a plumb member stays plumb on the seeded frame it already
|
|
1935
|
+
* had. Dragging the end PAST the other one so that the member lands still inside the cone is refused
|
|
1936
|
+
* ('reverses'): it turns end for end, the seeded depth axis flips with it, and the section turns a half
|
|
1937
|
+
* turn about its width axis, so an asymmetric section or an offset ends up on the other side. LEAVING
|
|
1938
|
+
* the cone (a plan drag that starts a plumb column leaning — or a reversal that also tips the member
|
|
1939
|
+
* out of the cone) is not refused either, and no longer turns the section: the commit carries its world
|
|
1940
|
+
* orientation across the boundary with `endpointPlacementCompensation` (#1946). Entering the cone and
|
|
1941
|
+
* reversing inside it stay refused for now (a product decision: ask / proceed on an assumption);
|
|
1942
|
+
* - every other gesture (the two swings, and any gesture this does not recognise) re-aims the member and
|
|
1943
|
+
* must land on the ordinary branch — for them 'enters-plumb' means "lands in the cone".
|
|
1944
|
+
*
|
|
1945
|
+
* @param {string} gesture the commit's `spec.gesture`
|
|
1946
|
+
* @param {{x:number[], degenerate?:boolean}|null} before the frame of the member as stored now (the
|
|
1947
|
+
* drag-start frame while the gesture's snapshot is current)
|
|
1948
|
+
* @param {{x:number[], degenerate?:boolean}} after the candidate frame
|
|
1949
|
+
* @returns {null|'branch-flip'|'enters-plumb'|'reverses'} null when the commit may land, else why it may not
|
|
1950
|
+
*/
|
|
1951
|
+
export function endpointFrameRefusal(gesture, before, after) {
|
|
1952
|
+
const was = !!(before && before.degenerate), now = !!(after && after.degenerate);
|
|
1953
|
+
if (directionPreservingGesture(gesture)) return was === now ? null : 'branch-flip';
|
|
1954
|
+
if (!now) return null;
|
|
1955
|
+
if (gesture !== 'endpoint' || !was) return 'enters-plumb';
|
|
1956
|
+
// Both frames are inside the cone, so each member axis lies within a hair of ±up: the dot product is
|
|
1957
|
+
// close to +1 when the sense is kept and close to -1 when the drag turned the member end for end.
|
|
1958
|
+
const bx = before.x, ax = after.x;
|
|
1959
|
+
return bx[0] * ax[0] + bx[1] * ax[1] + bx[2] * ax[2] > 0 ? null : 'reverses';
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1962
|
+
/**
|
|
1963
|
+
* The placement fields an end-node drag must rewrite so the section keeps its WORLD orientation when the
|
|
1964
|
+
* drag moves `partFrame` between its seeded and ordinary branches, or reverses the member (#1946).
|
|
1965
|
+
*
|
|
1966
|
+
* WHY. `rot` is stored relative to the part frame, and the frame is built from the member's direction by a
|
|
1967
|
+
* different rule on each branch (seeded: width = the basis X, projected; ordinary: depth = the basis up,
|
|
1968
|
+
* projected). Tipping a plumb column off plumb therefore turns its section by 90° / 180° / 0° about its own
|
|
1969
|
+
* axis depending only on which way it leans, and dragging an end past the other end flips the width axis.
|
|
1970
|
+
* `Swap ends` already compensates (`reversePlacement`); the end-node drag did not.
|
|
1971
|
+
*
|
|
1972
|
+
* WHAT. The section's rolled WIDTH axis is carried from the old frame to the new one: for a reversal the
|
|
1973
|
+
* old placement is first reversed exactly as `Swap ends` does (so the steel keeps its place and its
|
|
1974
|
+
* facing), and the width axis is then projected onto the plane the new member axis is normal to — the
|
|
1975
|
+
* smallest turn that keeps it perpendicular. `rot'` is the roll that puts the new frame's rolled width
|
|
1976
|
+
* on that vector, so the depth axis follows by right-handedness. A tilt can never leave the axes literally
|
|
1977
|
+
* unchanged (the member axis itself moved); when the lean is across the width axis they ARE unchanged, and
|
|
1978
|
+
* otherwise they turn by no more than the tilt.
|
|
1979
|
+
*
|
|
1980
|
+
* Returns null when nothing needs carrying (same branch, same sense: a plain drag keeps the stored
|
|
1981
|
+
* placement bit for bit) or when the frame cannot be built. Otherwise the fields to overwrite — only the
|
|
1982
|
+
* ones that change — as a plain object.
|
|
1983
|
+
*
|
|
1984
|
+
* @param {object} member the stored member (`rot`, `position*`, `positionH*`)
|
|
1985
|
+
* @param {number[]} from0 @param {number[]} to0 the stored work points
|
|
1986
|
+
* @param {number[]} from1 @param {number[]} to1 the candidate work points
|
|
1987
|
+
* @param {{kind?:string,x?:number[],y?:number[]}} basis the member's STORED basis (global when absent)
|
|
1988
|
+
* @returns {{rot?:number, position?:string, positionOffset?:number, positionH?:string, positionHOffset?:number}|null}
|
|
1989
|
+
*/
|
|
1990
|
+
export function endpointPlacementCompensation(member, from0, to0, from1, to1, basis) {
|
|
1991
|
+
const d = endpointPlacementCompensationDetail(member, from0, to0, from1, to1, basis);
|
|
1992
|
+
return d ? d.placement : null;
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
/**
|
|
1996
|
+
* `endpointPlacementCompensation` plus WHY it is shaped as it is: `{placement, squared}`, where `squared` is
|
|
1997
|
+
* true when the old width axis ended up parallel to the new member axis (a plumb column's top dragged
|
|
1998
|
+
* sideways along its own width) so it could not be kept (#1946). There the DEPTH axis is the one carried,
|
|
1999
|
+
* and the width is derived from it, so the section turns about the member axis but stays square to it.
|
|
2000
|
+
* Returns null exactly when `endpointPlacementCompensation` does. The command layer (`moveWorkPoints`) and
|
|
2001
|
+
* the editor both call this ONE implementation, so what the editor predicts is what the command verifies.
|
|
2002
|
+
*/
|
|
2003
|
+
export function endpointPlacementCompensationDetail(member, from0, to0, from1, to1, basis) {
|
|
2004
|
+
const f0 = positionGizmoFrame(from0, to0, basis), f1 = positionGizmoFrame(from1, to1, basis);
|
|
2005
|
+
if (!f0 || !f1) return null;
|
|
2006
|
+
const reversed = dot3(f0.x, f1.x) < 0;
|
|
2007
|
+
if (f0.degenerate === f1.degenerate && !reversed) return null;
|
|
2008
|
+
const base = {
|
|
2009
|
+
rot: member.rot, position: member.position, positionOffset: member.positionOffset,
|
|
2010
|
+
positionH: member.positionH, positionHOffset: member.positionHOffset,
|
|
2011
|
+
};
|
|
2012
|
+
const placed = reversed ? reversePlacement(base, f0.degenerate) : base;
|
|
2013
|
+
// The axes the section would have had if only the sense had changed (reversal: Swap ends' own rule).
|
|
2014
|
+
const vf = reversed
|
|
2015
|
+
? (f0.degenerate ? { y: f0.y, z: f0.z.map((n) => -n) } : { y: f0.y.map((n) => -n), z: f0.z })
|
|
2016
|
+
: f0;
|
|
2017
|
+
const axes = rolledProfileAxes(vf, placed.rot);
|
|
2018
|
+
const w = axes.y;
|
|
2019
|
+
const k = dot3(w, f1.x);
|
|
2020
|
+
const proj = [w[0] - k * f1.x[0], w[1] - k * f1.x[1], w[2] - k * f1.x[2]];
|
|
2021
|
+
let l = len3(proj);
|
|
2022
|
+
let wn, squared = false;
|
|
2023
|
+
if (l > 1e-9) {
|
|
2024
|
+
wn = [proj[0] / l, proj[1] / l, proj[2] / l];
|
|
2025
|
+
} else {
|
|
2026
|
+
// The old width lies ALONG the new member axis, so no turn of the section can keep it. Keep the DEPTH
|
|
2027
|
+
// axis instead (projected square to the new axis) and derive the width from it: width = depth x axis.
|
|
2028
|
+
const d = axes.z, kd = dot3(d, f1.x);
|
|
2029
|
+
const dp = [d[0] - kd * f1.x[0], d[1] - kd * f1.x[1], d[2] - kd * f1.x[2]];
|
|
2030
|
+
const dl = len3(dp);
|
|
2031
|
+
if (!(dl > 1e-9)) return null;
|
|
2032
|
+
const dn = [dp[0] / dl, dp[1] / dl, dp[2] / dl];
|
|
2033
|
+
wn = cross3(dn, f1.x);
|
|
2034
|
+
squared = true;
|
|
2035
|
+
}
|
|
2036
|
+
let rot = Math.atan2(dot3(wn, f1.z), dot3(wn, f1.y)) * 180 / Math.PI;
|
|
2037
|
+
if (rot <= -180) rot += 360;
|
|
2038
|
+
rot = Math.round(rot * 1e9) / 1e9;
|
|
2039
|
+
const out = {};
|
|
2040
|
+
const sameRot = Math.abs((typeof member.rot === 'number' ? member.rot : 0) - rot) < 1e-9
|
|
2041
|
+
|| Math.abs(Math.abs((typeof member.rot === 'number' ? member.rot : 0) - rot) - 360) < 1e-9;
|
|
2042
|
+
if (!sameRot || reversed) out.rot = (rot === 0 ? 0 : rot);
|
|
2043
|
+
if (reversed) {
|
|
2044
|
+
for (const k2 of ['position', 'positionOffset', 'positionH', 'positionHOffset']) {
|
|
2045
|
+
if (placed[k2] !== base[k2]) out[k2] = placed[k2];
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
return Object.keys(out).length || squared ? { placement: Object.keys(out).length ? out : null, squared } : null;
|
|
2049
|
+
}
|
|
2050
|
+
|
|
1918
2051
|
/**
|
|
1919
2052
|
* The three handles that move the reference line WITHOUT re-aiming it: the member-axis slide and, since
|
|
1920
2053
|
* the redesign, the depth and width arrows. `directionPreservingGesture` names the same property for the
|
|
@@ -8303,6 +8303,16 @@ function onMove(e) {
|
|
|
8303
8303
|
if (!pending || pending.geo) return;
|
|
8304
8304
|
if (pending.gridId||pending.filteredGrid||pending.filteredReference||pending.posAnchor) { const d=Math.hypot(e.clientX-downXY[0],e.clientY-downXY[1]);if(d<=DRAG_TOL_PX)return;pending=null;controls.enabled=true;boxSel={x:downXY[0],y:downXY[1]};onBoxMove(e);return; } // a filtered-reference/grid click stays inert, but once it moves the same press becomes a normal marquee so an overlay cannot blanket-disable box selection
|
|
8305
8305
|
if (pending.epDrag) { onMoveEndpoint(e); return; }
|
|
8306
|
+
if (pending.id && !pending.grab && !pending.origMm && MODEL().memberEditing === false) {
|
|
8307
|
+
// A native model's whole-member drag lives in 2D; here the press only selects. Say so once per gesture instead of doing nothing -
|
|
8308
|
+
// but ONLY while Drag to move/copy is on: a press on a member leaves orbit enabled, so with the toggle off this
|
|
8309
|
+
// drag is just the person orbiting, and no body drag was expected.
|
|
8310
|
+
if (!pending._nativeHinted && api && api.dragMoveEnabled && api.dragMoveEnabled() && Math.hypot(e.clientX - downXY[0], e.clientY - downXY[1]) > DRAG_TOL_PX) {
|
|
8311
|
+
pending._nativeHinted = true;
|
|
8312
|
+
if (api && api.toast) api.toast('Dragging a whole member works in 2D. In 3D, drag its end-nodes, use the Position handle, or use the Move tool');
|
|
8313
|
+
}
|
|
8314
|
+
return;
|
|
8315
|
+
}
|
|
8306
8316
|
if (!pending.grab || !pending.origMm) return;
|
|
8307
8317
|
if (!dragging && Math.hypot(e.clientX - downXY[0], e.clientY - downXY[1]) <= DRAG_TOL_PX) return;
|
|
8308
8318
|
const canDrag = api && api.dragMoveEnabled && api.dragMoveEnabled(); // the toggle gates BOTH gestures — plain drag (move) AND Ctrl+drag (copy)
|