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
package/dist/three-cad-viewer.js
CHANGED
|
@@ -82241,6 +82241,7 @@ void main() {
|
|
|
82241
82241
|
this._cadOriginalBackColor = null;
|
|
82242
82242
|
this._isStudioMode = false;
|
|
82243
82243
|
this._cadEdgesVisible = null;
|
|
82244
|
+
this._cadVerticesVisible = null;
|
|
82244
82245
|
}
|
|
82245
82246
|
/**
|
|
82246
82247
|
* Get the zebra tool, creating it on first access.
|
|
@@ -82282,6 +82283,7 @@ void main() {
|
|
|
82282
82283
|
this._cadOriginalBackColor = null;
|
|
82283
82284
|
this._isStudioMode = false;
|
|
82284
82285
|
this._cadEdgesVisible = null;
|
|
82286
|
+
this._cadVerticesVisible = null;
|
|
82285
82287
|
}
|
|
82286
82288
|
/**
|
|
82287
82289
|
* Set the front face mesh.
|
|
@@ -82637,7 +82639,13 @@ void main() {
|
|
|
82637
82639
|
}
|
|
82638
82640
|
}
|
|
82639
82641
|
if (this.vertices) {
|
|
82640
|
-
this.
|
|
82642
|
+
if (this._isStudioMode) {
|
|
82643
|
+
// Same rule as edges: Studio hides vertices, record the CAD intent only.
|
|
82644
|
+
this._cadVerticesVisible = flag;
|
|
82645
|
+
}
|
|
82646
|
+
else {
|
|
82647
|
+
this.vertices.material.visible = flag;
|
|
82648
|
+
}
|
|
82641
82649
|
}
|
|
82642
82650
|
this._syncPickVertices();
|
|
82643
82651
|
}
|
|
@@ -82846,10 +82854,14 @@ void main() {
|
|
|
82846
82854
|
this._cadOriginalBackColor = this.originalBackColor
|
|
82847
82855
|
? this.originalBackColor.clone()
|
|
82848
82856
|
: null;
|
|
82849
|
-
// Save edge visibility state
|
|
82857
|
+
// Save edge and vertex visibility state (also for edge-only / vertex-only
|
|
82858
|
+
// groups, which have no front mesh and get no studio material)
|
|
82850
82859
|
this._cadEdgesVisible = this.edgeMaterial
|
|
82851
82860
|
? this.edgeMaterial.visible
|
|
82852
82861
|
: null;
|
|
82862
|
+
this._cadVerticesVisible = this.vertices
|
|
82863
|
+
? this.vertices.material.visible
|
|
82864
|
+
: null;
|
|
82853
82865
|
// --- Swap front material ---
|
|
82854
82866
|
if (this.front && studioFront) {
|
|
82855
82867
|
// Transfer per-object visibility to mesh.visible (NOT material.visible)
|
|
@@ -82903,24 +82915,30 @@ void main() {
|
|
|
82903
82915
|
if (this._cadOriginalBackColor) {
|
|
82904
82916
|
this.originalBackColor = this._cadOriginalBackColor.clone();
|
|
82905
82917
|
}
|
|
82906
|
-
// --- Restore edge visibility ---
|
|
82918
|
+
// --- Restore edge and vertex visibility ---
|
|
82907
82919
|
if (this.edgeMaterial && this._cadEdgesVisible !== null) {
|
|
82908
82920
|
this.edgeMaterial.visible = this._cadEdgesVisible;
|
|
82909
82921
|
}
|
|
82922
|
+
if (this.vertices && this._cadVerticesVisible !== null) {
|
|
82923
|
+
this.vertices.material.visible = this._cadVerticesVisible;
|
|
82924
|
+
}
|
|
82910
82925
|
this._isStudioMode = false;
|
|
82911
82926
|
}
|
|
82912
82927
|
/**
|
|
82913
|
-
* Toggle edge visibility while in Studio mode.
|
|
82928
|
+
* Toggle edge and vertex visibility while in Studio mode.
|
|
82914
82929
|
*
|
|
82915
|
-
*
|
|
82916
|
-
*
|
|
82930
|
+
* Should only be called while in Studio mode; the saved CAD edge/vertex
|
|
82931
|
+
* visibility is not affected and is restored by `leaveStudioMode()`.
|
|
82917
82932
|
*
|
|
82918
|
-
* @param visible - Whether edges should be visible
|
|
82933
|
+
* @param visible - Whether edges and vertices should be visible
|
|
82919
82934
|
*/
|
|
82920
82935
|
setStudioShowEdges(visible) {
|
|
82921
82936
|
if (this.edgeMaterial) {
|
|
82922
82937
|
this.edgeMaterial.visible = visible;
|
|
82923
82938
|
}
|
|
82939
|
+
if (this.vertices) {
|
|
82940
|
+
this.vertices.material.visible = visible;
|
|
82941
|
+
}
|
|
82924
82942
|
}
|
|
82925
82943
|
}
|
|
82926
82944
|
/**
|
|
@@ -88258,13 +88276,17 @@ float metalnessFactor = metalness;
|
|
|
88258
88276
|
}
|
|
88259
88277
|
// Track material tags that failed to resolve
|
|
88260
88278
|
const unresolvedTags = new Set();
|
|
88261
|
-
// Iterate all ObjectGroups with front meshes
|
|
88262
88279
|
for (const path in this.groups) {
|
|
88263
88280
|
const obj = this.groups[path];
|
|
88264
88281
|
if (!(obj instanceof ObjectGroup))
|
|
88265
88282
|
continue;
|
|
88266
|
-
if (!obj.front)
|
|
88283
|
+
if (!obj.front) {
|
|
88284
|
+
// Edge-only / vertex-only group: no studio material, but it must still
|
|
88285
|
+
// enter studio mode so its CAD edge/vertex visibility is saved and
|
|
88286
|
+
// restored on leave (setStudioShowEdges hides both in studio).
|
|
88287
|
+
obj.enterStudioMode(null, null);
|
|
88267
88288
|
continue;
|
|
88289
|
+
}
|
|
88268
88290
|
// Determine material tag, leaf color, and leaf alpha
|
|
88269
88291
|
const tag = obj.materialTag || "";
|
|
88270
88292
|
const leafColor = obj.originalColor
|
|
@@ -97334,7 +97356,7 @@ float metalnessFactor = metalness;
|
|
|
97334
97356
|
}
|
|
97335
97357
|
}
|
|
97336
97358
|
|
|
97337
|
-
const version = "5.0.
|
|
97359
|
+
const version = "5.0.6";
|
|
97338
97360
|
|
|
97339
97361
|
/**
|
|
97340
97362
|
* `PickedComponent` over a GPU id-pick result. Drives the shader
|
|
@@ -112510,12 +112532,21 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, const in float depth,
|
|
|
112510
112532
|
this.renderer.setSize(cadWidth, height);
|
|
112511
112533
|
// Resize the id pick target to match the canvas
|
|
112512
112534
|
this.idPicker?.setSize(cadWidth, height);
|
|
112513
|
-
// Adapt display dimensions
|
|
112535
|
+
// Adapt display dimensions. `glass` and `tools` are part of the sizes:
|
|
112536
|
+
// setSizes widens the toolbar and the body by the tree only when the tree
|
|
112537
|
+
// sits beside the canvas (`tools && !glass`), and updates the tree and
|
|
112538
|
+
// info heights only outside glass mode. Leaving them out meant neither
|
|
112539
|
+
// branch could ever be taken from a resize, so a non-glass viewer got a
|
|
112540
|
+
// toolbar and a body of `cadWidth + 2` with a `treeWidth + cadWidth` row
|
|
112541
|
+
// inside them - measured as a 550px toolbar over 802px of content - and a
|
|
112542
|
+
// tree that kept its old height. `glassMode` passes both and was right.
|
|
112514
112543
|
this.display.setSizes({
|
|
112515
112544
|
treeWidth: treeWidth,
|
|
112516
112545
|
treeHeight: this.state.get("treeHeight"),
|
|
112517
112546
|
cadWidth: cadWidth,
|
|
112518
112547
|
height: height,
|
|
112548
|
+
glass: glass,
|
|
112549
|
+
tools: this.state.get("tools"),
|
|
112519
112550
|
});
|
|
112520
112551
|
// Set glass state - subscription will update UI
|
|
112521
112552
|
this.state.set("glass", glass);
|
|
@@ -113371,6 +113402,8 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, const in float depth,
|
|
|
113371
113402
|
/**
|
|
113372
113403
|
* Checkbox Handler for setting the tools mode.
|
|
113373
113404
|
* Delegates state mutations to Viewer.activateTool() to maintain unidirectional data flow.
|
|
113405
|
+
* The active tab is left untouched: a measure/select tool can run on any tab,
|
|
113406
|
+
* including Clip, so a sectioned model can be measured.
|
|
113374
113407
|
*/
|
|
113375
113408
|
this.setTool = (name, flag) => {
|
|
113376
113409
|
// Block tool activation while Studio mode is active
|
|
@@ -113378,15 +113411,9 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, const in float depth,
|
|
|
113378
113411
|
return;
|
|
113379
113412
|
}
|
|
113380
113413
|
this.viewer.toggleAnimationLoop(flag);
|
|
113381
|
-
const activeTool = this.state.get("activeTool");
|
|
113382
|
-
const currentTool = typeof activeTool === "string" ? activeTool : "";
|
|
113383
113414
|
if (flag) {
|
|
113384
113415
|
// Delegate state mutations to Viewer
|
|
113385
113416
|
this.viewer.activateTool(name, true);
|
|
113386
|
-
if (["distance", "properties", "select"].includes(name) &&
|
|
113387
|
-
!["distance", "properties", "select"].includes(currentTool)) {
|
|
113388
|
-
this.viewer.toggleTab(true);
|
|
113389
|
-
}
|
|
113390
113417
|
this.viewer.setSelectionInput(flag);
|
|
113391
113418
|
if (name === "distance") {
|
|
113392
113419
|
this.viewer.cadTools.enable(ToolTypes.DISTANCE);
|
|
@@ -113402,9 +113429,6 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, const in float depth,
|
|
|
113402
113429
|
}
|
|
113403
113430
|
}
|
|
113404
113431
|
else {
|
|
113405
|
-
if (currentTool === name || name === "explode") {
|
|
113406
|
-
this.viewer.toggleTab(false);
|
|
113407
|
-
}
|
|
113408
113432
|
if (name === "distance") {
|
|
113409
113433
|
this.viewer.cadTools.disable();
|
|
113410
113434
|
}
|
|
@@ -114950,9 +114974,6 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, const in float depth,
|
|
|
114950
114974
|
["distance", "properties", "select"].includes(activeTool)) {
|
|
114951
114975
|
this.clickButtons[activeTool]?.set(false);
|
|
114952
114976
|
this.setTool(activeTool, false);
|
|
114953
|
-
// setTool→toggleTab(false) silently sets activeTab to "tree" (no notification).
|
|
114954
|
-
// Restore to "studio" so the next tab click correctly detects Studio as oldTab.
|
|
114955
|
-
this.state.set("activeTab", "studio", false);
|
|
114956
114977
|
}
|
|
114957
114978
|
// Hide tool buttons
|
|
114958
114979
|
this.showMeasureTools(false);
|
|
@@ -114968,22 +114989,6 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, const in float depth,
|
|
|
114968
114989
|
this.showMeasureTools(this.measureTools);
|
|
114969
114990
|
this.showSelectTool(this.selectTool);
|
|
114970
114991
|
}
|
|
114971
|
-
/**
|
|
114972
|
-
* Entering Clip mode: hide the measure + select tool buttons (a measure/select
|
|
114973
|
-
* tool can't be active here — it disables the clip tab — but the buttons must not
|
|
114974
|
-
* be invocable while clipping). Mirrors {@link _deactivateToolsForStudio};
|
|
114975
|
-
* explode/zscale stay enabled for consistency with studio mode. Restored by
|
|
114976
|
-
* {@link _restoreToolsAfterClip} on leave.
|
|
114977
|
-
*/
|
|
114978
|
-
_deactivateToolsForClip() {
|
|
114979
|
-
this.showMeasureTools(false);
|
|
114980
|
-
this.showSelectTool(false);
|
|
114981
|
-
}
|
|
114982
|
-
/** Leaving Clip mode: restore measure + select buttons per their feature flags. */
|
|
114983
|
-
_restoreToolsAfterClip() {
|
|
114984
|
-
this.showMeasureTools(this.measureTools);
|
|
114985
|
-
this.showSelectTool(this.selectTool);
|
|
114986
|
-
}
|
|
114987
114992
|
/**
|
|
114988
114993
|
* Show/hide pinning button
|
|
114989
114994
|
*/
|
|
@@ -115003,9 +115008,6 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, const in float depth,
|
|
|
115003
115008
|
if (oldTab === "zebra" && newTab !== "zebra") {
|
|
115004
115009
|
this.viewer.enableZebraTool(false);
|
|
115005
115010
|
}
|
|
115006
|
-
if (oldTab === "clip" && newTab !== "clip") {
|
|
115007
|
-
this._restoreToolsAfterClip();
|
|
115008
|
-
}
|
|
115009
115011
|
if (oldTab === "studio" && newTab !== "studio") {
|
|
115010
115012
|
this.closeMatEditor();
|
|
115011
115013
|
this._saveMatEditorChanges();
|
|
@@ -115044,7 +115046,6 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, const in float depth,
|
|
|
115044
115046
|
}
|
|
115045
115047
|
else if (newTab === "clip") {
|
|
115046
115048
|
_updateVisibility(false, true, false, false, false);
|
|
115047
|
-
this._deactivateToolsForClip();
|
|
115048
115049
|
this.viewer.nestedGroup.setBackVisible(true);
|
|
115049
115050
|
const clipIntersection = this.viewer.state.get("clipIntersection");
|
|
115050
115051
|
if (typeof clipIntersection === "boolean") {
|