three-cad-viewer 5.0.4 → 5.0.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.
- package/dist/scene/objectgroup.d.ts +5 -4
- package/dist/three-cad-viewer.esm.js +44 -43
- package/dist/three-cad-viewer.esm.js.map +1 -1
- package/dist/three-cad-viewer.esm.min.js +3 -3
- package/dist/three-cad-viewer.js +44 -43
- package/dist/three-cad-viewer.min.js +2 -2
- package/dist/ui/display.d.ts +2 -10
- package/package.json +1 -1
|
@@ -87,6 +87,7 @@ declare class ObjectGroup extends THREE.Group {
|
|
|
87
87
|
private _cadOriginalBackColor;
|
|
88
88
|
private _isStudioMode;
|
|
89
89
|
private _cadEdgesVisible;
|
|
90
|
+
private _cadVerticesVisible;
|
|
90
91
|
/**
|
|
91
92
|
* Create an ObjectGroup for managing a CAD object's visual representation.
|
|
92
93
|
* @param opacity - Default opacity value (0.0 to 1.0).
|
|
@@ -308,12 +309,12 @@ declare class ObjectGroup extends THREE.Group {
|
|
|
308
309
|
*/
|
|
309
310
|
leaveStudioMode(): void;
|
|
310
311
|
/**
|
|
311
|
-
* Toggle edge visibility while in Studio mode.
|
|
312
|
+
* Toggle edge and vertex visibility while in Studio mode.
|
|
312
313
|
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
314
|
+
* Should only be called while in Studio mode; the saved CAD edge/vertex
|
|
315
|
+
* visibility is not affected and is restored by `leaveStudioMode()`.
|
|
315
316
|
*
|
|
316
|
-
* @param visible - Whether edges should be visible
|
|
317
|
+
* @param visible - Whether edges and vertices should be visible
|
|
317
318
|
*/
|
|
318
319
|
setStudioShowEdges(visible: boolean): void;
|
|
319
320
|
}
|
|
@@ -82235,6 +82235,7 @@ class ObjectGroup extends Group {
|
|
|
82235
82235
|
this._cadOriginalBackColor = null;
|
|
82236
82236
|
this._isStudioMode = false;
|
|
82237
82237
|
this._cadEdgesVisible = null;
|
|
82238
|
+
this._cadVerticesVisible = null;
|
|
82238
82239
|
}
|
|
82239
82240
|
/**
|
|
82240
82241
|
* Get the zebra tool, creating it on first access.
|
|
@@ -82276,6 +82277,7 @@ class ObjectGroup extends Group {
|
|
|
82276
82277
|
this._cadOriginalBackColor = null;
|
|
82277
82278
|
this._isStudioMode = false;
|
|
82278
82279
|
this._cadEdgesVisible = null;
|
|
82280
|
+
this._cadVerticesVisible = null;
|
|
82279
82281
|
}
|
|
82280
82282
|
/**
|
|
82281
82283
|
* Set the front face mesh.
|
|
@@ -82631,7 +82633,13 @@ class ObjectGroup extends Group {
|
|
|
82631
82633
|
}
|
|
82632
82634
|
}
|
|
82633
82635
|
if (this.vertices) {
|
|
82634
|
-
this.
|
|
82636
|
+
if (this._isStudioMode) {
|
|
82637
|
+
// Same rule as edges: Studio hides vertices, record the CAD intent only.
|
|
82638
|
+
this._cadVerticesVisible = flag;
|
|
82639
|
+
}
|
|
82640
|
+
else {
|
|
82641
|
+
this.vertices.material.visible = flag;
|
|
82642
|
+
}
|
|
82635
82643
|
}
|
|
82636
82644
|
this._syncPickVertices();
|
|
82637
82645
|
}
|
|
@@ -82840,10 +82848,14 @@ class ObjectGroup extends Group {
|
|
|
82840
82848
|
this._cadOriginalBackColor = this.originalBackColor
|
|
82841
82849
|
? this.originalBackColor.clone()
|
|
82842
82850
|
: null;
|
|
82843
|
-
// Save edge visibility state
|
|
82851
|
+
// Save edge and vertex visibility state (also for edge-only / vertex-only
|
|
82852
|
+
// groups, which have no front mesh and get no studio material)
|
|
82844
82853
|
this._cadEdgesVisible = this.edgeMaterial
|
|
82845
82854
|
? this.edgeMaterial.visible
|
|
82846
82855
|
: null;
|
|
82856
|
+
this._cadVerticesVisible = this.vertices
|
|
82857
|
+
? this.vertices.material.visible
|
|
82858
|
+
: null;
|
|
82847
82859
|
// --- Swap front material ---
|
|
82848
82860
|
if (this.front && studioFront) {
|
|
82849
82861
|
// Transfer per-object visibility to mesh.visible (NOT material.visible)
|
|
@@ -82897,24 +82909,30 @@ class ObjectGroup extends Group {
|
|
|
82897
82909
|
if (this._cadOriginalBackColor) {
|
|
82898
82910
|
this.originalBackColor = this._cadOriginalBackColor.clone();
|
|
82899
82911
|
}
|
|
82900
|
-
// --- Restore edge visibility ---
|
|
82912
|
+
// --- Restore edge and vertex visibility ---
|
|
82901
82913
|
if (this.edgeMaterial && this._cadEdgesVisible !== null) {
|
|
82902
82914
|
this.edgeMaterial.visible = this._cadEdgesVisible;
|
|
82903
82915
|
}
|
|
82916
|
+
if (this.vertices && this._cadVerticesVisible !== null) {
|
|
82917
|
+
this.vertices.material.visible = this._cadVerticesVisible;
|
|
82918
|
+
}
|
|
82904
82919
|
this._isStudioMode = false;
|
|
82905
82920
|
}
|
|
82906
82921
|
/**
|
|
82907
|
-
* Toggle edge visibility while in Studio mode.
|
|
82922
|
+
* Toggle edge and vertex visibility while in Studio mode.
|
|
82908
82923
|
*
|
|
82909
|
-
*
|
|
82910
|
-
*
|
|
82924
|
+
* Should only be called while in Studio mode; the saved CAD edge/vertex
|
|
82925
|
+
* visibility is not affected and is restored by `leaveStudioMode()`.
|
|
82911
82926
|
*
|
|
82912
|
-
* @param visible - Whether edges should be visible
|
|
82927
|
+
* @param visible - Whether edges and vertices should be visible
|
|
82913
82928
|
*/
|
|
82914
82929
|
setStudioShowEdges(visible) {
|
|
82915
82930
|
if (this.edgeMaterial) {
|
|
82916
82931
|
this.edgeMaterial.visible = visible;
|
|
82917
82932
|
}
|
|
82933
|
+
if (this.vertices) {
|
|
82934
|
+
this.vertices.material.visible = visible;
|
|
82935
|
+
}
|
|
82918
82936
|
}
|
|
82919
82937
|
}
|
|
82920
82938
|
/**
|
|
@@ -88252,13 +88270,17 @@ class NestedGroup {
|
|
|
88252
88270
|
}
|
|
88253
88271
|
// Track material tags that failed to resolve
|
|
88254
88272
|
const unresolvedTags = new Set();
|
|
88255
|
-
// Iterate all ObjectGroups with front meshes
|
|
88256
88273
|
for (const path in this.groups) {
|
|
88257
88274
|
const obj = this.groups[path];
|
|
88258
88275
|
if (!(obj instanceof ObjectGroup))
|
|
88259
88276
|
continue;
|
|
88260
|
-
if (!obj.front)
|
|
88277
|
+
if (!obj.front) {
|
|
88278
|
+
// Edge-only / vertex-only group: no studio material, but it must still
|
|
88279
|
+
// enter studio mode so its CAD edge/vertex visibility is saved and
|
|
88280
|
+
// restored on leave (setStudioShowEdges hides both in studio).
|
|
88281
|
+
obj.enterStudioMode(null, null);
|
|
88261
88282
|
continue;
|
|
88283
|
+
}
|
|
88262
88284
|
// Determine material tag, leaf color, and leaf alpha
|
|
88263
88285
|
const tag = obj.materialTag || "";
|
|
88264
88286
|
const leafColor = obj.originalColor
|
|
@@ -97328,7 +97350,7 @@ class Tools {
|
|
|
97328
97350
|
}
|
|
97329
97351
|
}
|
|
97330
97352
|
|
|
97331
|
-
const version = "5.0.
|
|
97353
|
+
const version = "5.0.6";
|
|
97332
97354
|
|
|
97333
97355
|
/**
|
|
97334
97356
|
* `PickedComponent` over a GPU id-pick result. Drives the shader
|
|
@@ -112504,12 +112526,21 @@ class Viewer {
|
|
|
112504
112526
|
this.renderer.setSize(cadWidth, height);
|
|
112505
112527
|
// Resize the id pick target to match the canvas
|
|
112506
112528
|
this.idPicker?.setSize(cadWidth, height);
|
|
112507
|
-
// Adapt display dimensions
|
|
112529
|
+
// Adapt display dimensions. `glass` and `tools` are part of the sizes:
|
|
112530
|
+
// setSizes widens the toolbar and the body by the tree only when the tree
|
|
112531
|
+
// sits beside the canvas (`tools && !glass`), and updates the tree and
|
|
112532
|
+
// info heights only outside glass mode. Leaving them out meant neither
|
|
112533
|
+
// branch could ever be taken from a resize, so a non-glass viewer got a
|
|
112534
|
+
// toolbar and a body of `cadWidth + 2` with a `treeWidth + cadWidth` row
|
|
112535
|
+
// inside them - measured as a 550px toolbar over 802px of content - and a
|
|
112536
|
+
// tree that kept its old height. `glassMode` passes both and was right.
|
|
112508
112537
|
this.display.setSizes({
|
|
112509
112538
|
treeWidth: treeWidth,
|
|
112510
112539
|
treeHeight: this.state.get("treeHeight"),
|
|
112511
112540
|
cadWidth: cadWidth,
|
|
112512
112541
|
height: height,
|
|
112542
|
+
glass: glass,
|
|
112543
|
+
tools: this.state.get("tools"),
|
|
112513
112544
|
});
|
|
112514
112545
|
// Set glass state - subscription will update UI
|
|
112515
112546
|
this.state.set("glass", glass);
|
|
@@ -113365,6 +113396,8 @@ class Display {
|
|
|
113365
113396
|
/**
|
|
113366
113397
|
* Checkbox Handler for setting the tools mode.
|
|
113367
113398
|
* Delegates state mutations to Viewer.activateTool() to maintain unidirectional data flow.
|
|
113399
|
+
* The active tab is left untouched: a measure/select tool can run on any tab,
|
|
113400
|
+
* including Clip, so a sectioned model can be measured.
|
|
113368
113401
|
*/
|
|
113369
113402
|
this.setTool = (name, flag) => {
|
|
113370
113403
|
// Block tool activation while Studio mode is active
|
|
@@ -113372,15 +113405,9 @@ class Display {
|
|
|
113372
113405
|
return;
|
|
113373
113406
|
}
|
|
113374
113407
|
this.viewer.toggleAnimationLoop(flag);
|
|
113375
|
-
const activeTool = this.state.get("activeTool");
|
|
113376
|
-
const currentTool = typeof activeTool === "string" ? activeTool : "";
|
|
113377
113408
|
if (flag) {
|
|
113378
113409
|
// Delegate state mutations to Viewer
|
|
113379
113410
|
this.viewer.activateTool(name, true);
|
|
113380
|
-
if (["distance", "properties", "select"].includes(name) &&
|
|
113381
|
-
!["distance", "properties", "select"].includes(currentTool)) {
|
|
113382
|
-
this.viewer.toggleTab(true);
|
|
113383
|
-
}
|
|
113384
113411
|
this.viewer.setSelectionInput(flag);
|
|
113385
113412
|
if (name === "distance") {
|
|
113386
113413
|
this.viewer.cadTools.enable(ToolTypes.DISTANCE);
|
|
@@ -113396,9 +113423,6 @@ class Display {
|
|
|
113396
113423
|
}
|
|
113397
113424
|
}
|
|
113398
113425
|
else {
|
|
113399
|
-
if (currentTool === name || name === "explode") {
|
|
113400
|
-
this.viewer.toggleTab(false);
|
|
113401
|
-
}
|
|
113402
113426
|
if (name === "distance") {
|
|
113403
113427
|
this.viewer.cadTools.disable();
|
|
113404
113428
|
}
|
|
@@ -114944,9 +114968,6 @@ class Display {
|
|
|
114944
114968
|
["distance", "properties", "select"].includes(activeTool)) {
|
|
114945
114969
|
this.clickButtons[activeTool]?.set(false);
|
|
114946
114970
|
this.setTool(activeTool, false);
|
|
114947
|
-
// setTool→toggleTab(false) silently sets activeTab to "tree" (no notification).
|
|
114948
|
-
// Restore to "studio" so the next tab click correctly detects Studio as oldTab.
|
|
114949
|
-
this.state.set("activeTab", "studio", false);
|
|
114950
114971
|
}
|
|
114951
114972
|
// Hide tool buttons
|
|
114952
114973
|
this.showMeasureTools(false);
|
|
@@ -114962,22 +114983,6 @@ class Display {
|
|
|
114962
114983
|
this.showMeasureTools(this.measureTools);
|
|
114963
114984
|
this.showSelectTool(this.selectTool);
|
|
114964
114985
|
}
|
|
114965
|
-
/**
|
|
114966
|
-
* Entering Clip mode: hide the measure + select tool buttons (a measure/select
|
|
114967
|
-
* tool can't be active here — it disables the clip tab — but the buttons must not
|
|
114968
|
-
* be invocable while clipping). Mirrors {@link _deactivateToolsForStudio};
|
|
114969
|
-
* explode/zscale stay enabled for consistency with studio mode. Restored by
|
|
114970
|
-
* {@link _restoreToolsAfterClip} on leave.
|
|
114971
|
-
*/
|
|
114972
|
-
_deactivateToolsForClip() {
|
|
114973
|
-
this.showMeasureTools(false);
|
|
114974
|
-
this.showSelectTool(false);
|
|
114975
|
-
}
|
|
114976
|
-
/** Leaving Clip mode: restore measure + select buttons per their feature flags. */
|
|
114977
|
-
_restoreToolsAfterClip() {
|
|
114978
|
-
this.showMeasureTools(this.measureTools);
|
|
114979
|
-
this.showSelectTool(this.selectTool);
|
|
114980
|
-
}
|
|
114981
114986
|
/**
|
|
114982
114987
|
* Show/hide pinning button
|
|
114983
114988
|
*/
|
|
@@ -114997,9 +115002,6 @@ class Display {
|
|
|
114997
115002
|
if (oldTab === "zebra" && newTab !== "zebra") {
|
|
114998
115003
|
this.viewer.enableZebraTool(false);
|
|
114999
115004
|
}
|
|
115000
|
-
if (oldTab === "clip" && newTab !== "clip") {
|
|
115001
|
-
this._restoreToolsAfterClip();
|
|
115002
|
-
}
|
|
115003
115005
|
if (oldTab === "studio" && newTab !== "studio") {
|
|
115004
115006
|
this.closeMatEditor();
|
|
115005
115007
|
this._saveMatEditorChanges();
|
|
@@ -115038,7 +115040,6 @@ class Display {
|
|
|
115038
115040
|
}
|
|
115039
115041
|
else if (newTab === "clip") {
|
|
115040
115042
|
_updateVisibility(false, true, false, false, false);
|
|
115041
|
-
this._deactivateToolsForClip();
|
|
115042
115043
|
this.viewer.nestedGroup.setBackVisible(true);
|
|
115043
115044
|
const clipIntersection = this.viewer.state.get("clipIntersection");
|
|
115044
115045
|
if (typeof clipIntersection === "boolean") {
|