three-cad-viewer 5.0.3 → 5.0.5

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.
@@ -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
- * Only affects edges (not vertices). Should only be called while in
314
- * Studio mode; the saved CAD edge visibility is not affected.
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.vertices.material.visible = flag;
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
- * Only affects edges (not vertices). Should only be called while in
82910
- * Studio mode; the saved CAD edge visibility is not affected.
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.3";
97353
+ const version = "5.0.5";
97332
97354
 
97333
97355
  /**
97334
97356
  * `PickedComponent` over a GPU id-pick result. Drives the shader
@@ -112446,7 +112468,14 @@ class Viewer {
112446
112468
  KeyMapper.set(modifiers);
112447
112469
  this.display.updateHelp(before, modifiers);
112448
112470
  }
112449
- KeyMapper.setActionShortcuts(actions);
112471
+ if (Object.keys(actions).length > 0) {
112472
+ // Merge over the existing table: a partial config (e.g. modifiers only)
112473
+ // must not wipe the action shortcuts
112474
+ KeyMapper.setActionShortcuts({
112475
+ ...KeyMapper.getActionShortcuts(),
112476
+ ...actions,
112477
+ });
112478
+ }
112450
112479
  this.display.updateTooltips();
112451
112480
  }
112452
112481
  // ---------------------------------------------------------------------------
@@ -113358,6 +113387,8 @@ class Display {
113358
113387
  /**
113359
113388
  * Checkbox Handler for setting the tools mode.
113360
113389
  * Delegates state mutations to Viewer.activateTool() to maintain unidirectional data flow.
113390
+ * The active tab is left untouched: a measure/select tool can run on any tab,
113391
+ * including Clip, so a sectioned model can be measured.
113361
113392
  */
113362
113393
  this.setTool = (name, flag) => {
113363
113394
  // Block tool activation while Studio mode is active
@@ -113365,15 +113396,9 @@ class Display {
113365
113396
  return;
113366
113397
  }
113367
113398
  this.viewer.toggleAnimationLoop(flag);
113368
- const activeTool = this.state.get("activeTool");
113369
- const currentTool = typeof activeTool === "string" ? activeTool : "";
113370
113399
  if (flag) {
113371
113400
  // Delegate state mutations to Viewer
113372
113401
  this.viewer.activateTool(name, true);
113373
- if (["distance", "properties", "select"].includes(name) &&
113374
- !["distance", "properties", "select"].includes(currentTool)) {
113375
- this.viewer.toggleTab(true);
113376
- }
113377
113402
  this.viewer.setSelectionInput(flag);
113378
113403
  if (name === "distance") {
113379
113404
  this.viewer.cadTools.enable(ToolTypes.DISTANCE);
@@ -113389,9 +113414,6 @@ class Display {
113389
113414
  }
113390
113415
  }
113391
113416
  else {
113392
- if (currentTool === name || name === "explode") {
113393
- this.viewer.toggleTab(false);
113394
- }
113395
113417
  if (name === "distance") {
113396
113418
  this.viewer.cadTools.disable();
113397
113419
  }
@@ -114937,9 +114959,6 @@ class Display {
114937
114959
  ["distance", "properties", "select"].includes(activeTool)) {
114938
114960
  this.clickButtons[activeTool]?.set(false);
114939
114961
  this.setTool(activeTool, false);
114940
- // setTool→toggleTab(false) silently sets activeTab to "tree" (no notification).
114941
- // Restore to "studio" so the next tab click correctly detects Studio as oldTab.
114942
- this.state.set("activeTab", "studio", false);
114943
114962
  }
114944
114963
  // Hide tool buttons
114945
114964
  this.showMeasureTools(false);
@@ -114955,22 +114974,6 @@ class Display {
114955
114974
  this.showMeasureTools(this.measureTools);
114956
114975
  this.showSelectTool(this.selectTool);
114957
114976
  }
114958
- /**
114959
- * Entering Clip mode: hide the measure + select tool buttons (a measure/select
114960
- * tool can't be active here — it disables the clip tab — but the buttons must not
114961
- * be invocable while clipping). Mirrors {@link _deactivateToolsForStudio};
114962
- * explode/zscale stay enabled for consistency with studio mode. Restored by
114963
- * {@link _restoreToolsAfterClip} on leave.
114964
- */
114965
- _deactivateToolsForClip() {
114966
- this.showMeasureTools(false);
114967
- this.showSelectTool(false);
114968
- }
114969
- /** Leaving Clip mode: restore measure + select buttons per their feature flags. */
114970
- _restoreToolsAfterClip() {
114971
- this.showMeasureTools(this.measureTools);
114972
- this.showSelectTool(this.selectTool);
114973
- }
114974
114977
  /**
114975
114978
  * Show/hide pinning button
114976
114979
  */
@@ -114990,9 +114993,6 @@ class Display {
114990
114993
  if (oldTab === "zebra" && newTab !== "zebra") {
114991
114994
  this.viewer.enableZebraTool(false);
114992
114995
  }
114993
- if (oldTab === "clip" && newTab !== "clip") {
114994
- this._restoreToolsAfterClip();
114995
- }
114996
114996
  if (oldTab === "studio" && newTab !== "studio") {
114997
114997
  this.closeMatEditor();
114998
114998
  this._saveMatEditorChanges();
@@ -115031,7 +115031,6 @@ class Display {
115031
115031
  }
115032
115032
  else if (newTab === "clip") {
115033
115033
  _updateVisibility(false, true, false, false, false);
115034
- this._deactivateToolsForClip();
115035
115034
  this.viewer.nestedGroup.setBackVisible(true);
115036
115035
  const clipIntersection = this.viewer.state.get("clipIntersection");
115037
115036
  if (typeof clipIntersection === "boolean") {