brep-io-kernel 1.0.16 → 1.0.18
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-kernel/brep-kernel.js +12652 -11749
- package/package.json +1 -1
- package/src/PartHistory.js +106 -0
- package/src/UI/CADmaterials.js +2 -2
- package/src/UI/MainToolbar.js +39 -2
- package/src/UI/SelectionFilter.js +194 -0
- package/src/UI/featureDialogWidgets/booleanOperationField.js +33 -52
- package/src/UI/featureDialogWidgets/referenceSelectionField.js +10 -0
- package/src/UI/featureDialogs.js +593 -7
- package/src/UI/toolbarButtons/orientToFaceButton.js +3 -0
- package/src/UI/toolbarButtons/registerDefaultButtons.js +0 -6
- package/src/UI/toolbarButtons/registerSelectionButtons.js +68 -0
- package/src/UI/viewer.js +22 -4
|
@@ -4,10 +4,7 @@
|
|
|
4
4
|
import { createSaveButton } from './saveButton.js';
|
|
5
5
|
import { createUndoButton, createRedoButton } from './undoRedoButtons.js';
|
|
6
6
|
import { createZoomToFitButton } from './zoomToFitButton.js';
|
|
7
|
-
import { createOrientToFaceButton } from './orientToFaceButton.js';
|
|
8
7
|
import { createWireframeToggleButton } from './wireframeToggleButton.js';
|
|
9
|
-
import { createInspectorToggleButton } from './inspectorToggleButton.js';
|
|
10
|
-
import { createMetadataButton } from './metadataButton.js';
|
|
11
8
|
import { createImportButton } from './importButton.js';
|
|
12
9
|
import { createExportButton } from './exportButton.js';
|
|
13
10
|
import { createFlatPatternButton } from './flatPatternButton.js';
|
|
@@ -21,10 +18,7 @@ export function registerDefaultToolbarButtons(viewer) {
|
|
|
21
18
|
const creators = [
|
|
22
19
|
createSaveButton,
|
|
23
20
|
createZoomToFitButton,
|
|
24
|
-
createOrientToFaceButton,
|
|
25
21
|
createWireframeToggleButton,
|
|
26
|
-
createInspectorToggleButton,
|
|
27
|
-
createMetadataButton,
|
|
28
22
|
createImportButton,
|
|
29
23
|
createExportButton,
|
|
30
24
|
createFlatPatternButton,
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { SelectionFilter } from '../SelectionFilter.js';
|
|
2
|
+
import { createOrientToFaceButton } from './orientToFaceButton.js';
|
|
3
|
+
import { createInspectorToggleButton } from './inspectorToggleButton.js';
|
|
4
|
+
import { createMetadataButton } from './metadataButton.js';
|
|
5
|
+
|
|
6
|
+
const hasSelection = (items) => Array.isArray(items) && items.length > 0;
|
|
7
|
+
const hasType = (items, types) => {
|
|
8
|
+
if (!Array.isArray(items) || items.length === 0) return false;
|
|
9
|
+
const typeSet = new Set((types || []).map((t) => String(t || '').toUpperCase()));
|
|
10
|
+
if (typeSet.size === 0) return false;
|
|
11
|
+
return items.some((obj) => typeSet.has(String(obj?.type || '').toUpperCase()));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function registerSelectionToolbarButtons(viewer) {
|
|
15
|
+
if (!viewer || typeof SelectionFilter?.registerSelectionAction !== 'function') return;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
SelectionFilter.registerSelectionAction({
|
|
20
|
+
id: 'selection-action-clear',
|
|
21
|
+
label: '␛',
|
|
22
|
+
title: 'Clear selection',
|
|
23
|
+
onClick: () => {
|
|
24
|
+
const scene = viewer?.partHistory?.scene || viewer?.scene || null;
|
|
25
|
+
if (scene) SelectionFilter.unselectAll(scene);
|
|
26
|
+
try { viewer?._hideSelectionOverlay?.(); } catch { }
|
|
27
|
+
},
|
|
28
|
+
shouldShow: (selection) => hasSelection(selection),
|
|
29
|
+
});
|
|
30
|
+
} catch { }
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const perpSpec = createOrientToFaceButton(viewer);
|
|
36
|
+
if (perpSpec) {
|
|
37
|
+
SelectionFilter.registerSelectionAction({
|
|
38
|
+
id: 'selection-action-perp',
|
|
39
|
+
...perpSpec,
|
|
40
|
+
shouldShow: (selection) => hasType(selection, ['FACE', 'PLANE']),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
} catch { }
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
const inspectorSpec = createInspectorToggleButton(viewer);
|
|
47
|
+
if (inspectorSpec) {
|
|
48
|
+
SelectionFilter.registerSelectionAction({
|
|
49
|
+
id: 'selection-action-inspector',
|
|
50
|
+
...inspectorSpec,
|
|
51
|
+
shouldShow: (selection) => hasSelection(selection),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
} catch { }
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const metadataSpec = createMetadataButton(viewer);
|
|
60
|
+
if (metadataSpec) {
|
|
61
|
+
SelectionFilter.registerSelectionAction({
|
|
62
|
+
id: 'selection-action-metadata',
|
|
63
|
+
...metadataSpec,
|
|
64
|
+
shouldShow: (selection) => hasSelection(selection),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
} catch { }
|
|
68
|
+
}
|
package/src/UI/viewer.js
CHANGED
|
@@ -20,6 +20,7 @@ import './expressionsManager.js'
|
|
|
20
20
|
import { expressionsManager } from './expressionsManager.js';
|
|
21
21
|
import { MainToolbar } from './MainToolbar.js';
|
|
22
22
|
import { registerDefaultToolbarButtons } from './toolbarButtons/registerDefaultButtons.js';
|
|
23
|
+
import { registerSelectionToolbarButtons } from './toolbarButtons/registerSelectionButtons.js';
|
|
23
24
|
import { FileManagerWidget } from './fileManagerWidget.js';
|
|
24
25
|
import './mobile.js';
|
|
25
26
|
import { SketchMode3D } from './sketcher/SketchMode3D.js';
|
|
@@ -1239,6 +1240,9 @@ export class Viewer {
|
|
|
1239
1240
|
this.mainToolbar = new MainToolbar(this);
|
|
1240
1241
|
// Register core/default toolbar buttons via the public API
|
|
1241
1242
|
try { registerDefaultToolbarButtons(this); } catch { }
|
|
1243
|
+
// Register selection-context toolbar buttons (shown based on selection)
|
|
1244
|
+
try { registerSelectionToolbarButtons(this); } catch { }
|
|
1245
|
+
try { SelectionFilter.refreshSelectionActions?.(); } catch { }
|
|
1242
1246
|
// Drain any queued custom toolbar buttons from early plugin registration
|
|
1243
1247
|
try {
|
|
1244
1248
|
const q = Array.isArray(this._pendingToolbarButtons) ? this._pendingToolbarButtons : [];
|
|
@@ -3471,15 +3475,29 @@ export class Viewer {
|
|
|
3471
3475
|
// Inspector panel (toggle + update-on-click)
|
|
3472
3476
|
// ----------------------------------------
|
|
3473
3477
|
toggleInspectorPanel() { this._inspectorOpen ? this._closeInspectorPanel() : this._openInspectorPanel(); }
|
|
3478
|
+
_getInspectorSelectionTarget() {
|
|
3479
|
+
const last = this._lastInspectorTarget;
|
|
3480
|
+
if (last && last.selected) return last;
|
|
3481
|
+
const scene = this.partHistory?.scene || this.scene || null;
|
|
3482
|
+
if (!scene || typeof scene.traverse !== 'function') return null;
|
|
3483
|
+
let found = null;
|
|
3484
|
+
scene.traverse((obj) => {
|
|
3485
|
+
if (found || !obj || !obj.selected) return;
|
|
3486
|
+
found = obj;
|
|
3487
|
+
});
|
|
3488
|
+
return found;
|
|
3489
|
+
}
|
|
3474
3490
|
_openInspectorPanel() {
|
|
3475
3491
|
if (this._inspectorOpen) return;
|
|
3476
3492
|
this._ensureInspectorPanel();
|
|
3477
3493
|
this._inspectorEl.style.display = 'flex';
|
|
3478
3494
|
this._inspectorOpen = true;
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
this.
|
|
3482
|
-
|
|
3495
|
+
const target = this._getInspectorSelectionTarget();
|
|
3496
|
+
if (target) {
|
|
3497
|
+
try { this._updateInspectorFor(target); } catch { }
|
|
3498
|
+
return;
|
|
3499
|
+
}
|
|
3500
|
+
try { this._setInspectorPlaceholder('Click an object in the scene to inspect.'); } catch { }
|
|
3483
3501
|
}
|
|
3484
3502
|
_closeInspectorPanel() {
|
|
3485
3503
|
if (!this._inspectorOpen) return;
|