three-cad-viewer 1.5.5 → 1.5.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.
@@ -493,6 +493,8 @@ input[type="button"] {
493
493
  color: var(--tcv-z-color);
494
494
  }
495
495
 
496
+ /* Scrollbar styling for Chrome like browsers */
497
+
496
498
  .tcv_mac-scrollbar::-webkit-scrollbar {
497
499
  width: 5px !important;
498
500
  height: 5px !important;
@@ -507,16 +509,20 @@ input[type="button"] {
507
509
  background-color: transparent !important;
508
510
  }
509
511
 
512
+ .tcv_mac-scrollbar::-webkit-scrollbar-piece {
513
+ background-color: transparent !important;
514
+ }
515
+
510
516
  .tcv_mac-scrollbar::-webkit-scrollbar-corner {
511
517
  background-color: transparent !important;
512
518
  }
513
519
 
514
520
  .tcv_mac-scrollbar::-webkit-scrollbar-thumb:hover {
515
- background: var(--tcv-scrollbar-hover) !important;
521
+ background-color: var(--tcv-scrollbar-hover) !important;
516
522
  }
517
523
 
518
524
  .tcv_mac-scrollbar::-webkit-scrollbar-thumb:active {
519
- background: var(--tcv-scrollbar-active) !important;
525
+ background-color: var(--tcv-scrollbar-hover) !important;
520
526
  }
521
527
 
522
528
  .tcv_mac-scrollbar .widget-html-content {
@@ -524,12 +530,20 @@ input[type="button"] {
524
530
  overflow-y: visible;
525
531
  }
526
532
 
533
+ /* Scrollbar styling for Firefox Browser */
534
+
527
535
  .tcv_scroller {
528
- /* scrollbar-color: #7f7f7f white; */
529
536
  scrollbar-width: thin;
537
+ scrollbar-color: var(--tcv-scrollbar-thumb) transparent;
530
538
  background-color: transparent !important;
531
539
  }
532
540
 
541
+ .tcv_scroller:hover {
542
+ scrollbar-width: thin;
543
+ scrollbar-color: var(--tcv-scrollbar-hover) transparent;
544
+ }
545
+
546
+ /* tooltips */
533
547
  [data-tooltip]:before {
534
548
  position: absolute;
535
549
  pointer-events: none;
@@ -493,6 +493,8 @@ input[type="button"] {
493
493
  color: var(--tcv-z-color);
494
494
  }
495
495
 
496
+ /* Scrollbar styling for Chrome like browsers */
497
+
496
498
  .tcv_mac-scrollbar::-webkit-scrollbar {
497
499
  width: 5px !important;
498
500
  height: 5px !important;
@@ -507,16 +509,20 @@ input[type="button"] {
507
509
  background-color: transparent !important;
508
510
  }
509
511
 
512
+ .tcv_mac-scrollbar::-webkit-scrollbar-piece {
513
+ background-color: transparent !important;
514
+ }
515
+
510
516
  .tcv_mac-scrollbar::-webkit-scrollbar-corner {
511
517
  background-color: transparent !important;
512
518
  }
513
519
 
514
520
  .tcv_mac-scrollbar::-webkit-scrollbar-thumb:hover {
515
- background: var(--tcv-scrollbar-hover) !important;
521
+ background-color: var(--tcv-scrollbar-hover) !important;
516
522
  }
517
523
 
518
524
  .tcv_mac-scrollbar::-webkit-scrollbar-thumb:active {
519
- background: var(--tcv-scrollbar-active) !important;
525
+ background-color: var(--tcv-scrollbar-hover) !important;
520
526
  }
521
527
 
522
528
  .tcv_mac-scrollbar .widget-html-content {
@@ -524,12 +530,20 @@ input[type="button"] {
524
530
  overflow-y: visible;
525
531
  }
526
532
 
533
+ /* Scrollbar styling for Firefox Browser */
534
+
527
535
  .tcv_scroller {
528
- /* scrollbar-color: #7f7f7f white; */
529
536
  scrollbar-width: thin;
537
+ scrollbar-color: var(--tcv-scrollbar-thumb) transparent;
530
538
  background-color: transparent !important;
531
539
  }
532
540
 
541
+ .tcv_scroller:hover {
542
+ scrollbar-width: thin;
543
+ scrollbar-color: var(--tcv-scrollbar-hover) transparent;
544
+ }
545
+
546
+ /* tooltips */
533
547
  [data-tooltip]:before {
534
548
  position: absolute;
535
549
  pointer-events: none;
@@ -51657,10 +51657,14 @@ class Display {
51657
51657
 
51658
51658
  this.viewer = null;
51659
51659
  this._glassMode = false;
51660
+ this.tools = true;
51660
51661
  this._events = [];
51661
51662
  this.cadWidth = options.cadWidth;
51662
51663
  this.height = options.height;
51663
51664
  this.treeWidth = options.treeWidth;
51665
+
51666
+ this.showTools(options.tools);
51667
+ this.glassMode(options.glass);
51664
51668
  this.setSizes(options);
51665
51669
 
51666
51670
  this.activeTab = "tree";
@@ -51754,14 +51758,22 @@ class Display {
51754
51758
  options.treeWidth,
51755
51759
  );
51756
51760
  }
51757
- const treeHeight = Math.round(options.height * ratio);
51758
- this.cadTree.parentElement.parentElement.style.height = px(treeHeight);
51759
- this.cadInfo.parentElement.parentElement.style.height = px(
51760
- options.height - treeHeight - 4,
51761
- );
51761
+ if (!options.glass) {
51762
+ const treeHeight = Math.round(options.height * ratio);
51763
+ this.cadTree.parentElement.parentElement.style.height = px(treeHeight);
51764
+ this.cadInfo.parentElement.parentElement.style.height = px(
51765
+ options.height - treeHeight - 4,
51766
+ );
51767
+ }
51768
+
51769
+ if (options.tools && !options.glass) {
51770
+ this.cadTool.style.width = px(options.treeWidth + options.cadWidth + 4);
51771
+ this.cadBody.style.width = px(options.treeWidth + options.cadWidth + 4);
51772
+ } else {
51773
+ this.cadTool.style.width = px(options.cadWidth + 2);
51774
+ this.cadBody.style.width = px(options.cadWidth + 2);
51775
+ }
51762
51776
 
51763
- this.cadTool.style.width = px(options.treeWidth + options.cadWidth + 4);
51764
- this.cadBody.style.width = px(options.treeWidth + options.cadWidth + 4);
51765
51777
  this.cadBody.style.height = px(options.height + 4);
51766
51778
  }
51767
51779
 
@@ -51808,9 +51820,9 @@ class Display {
51808
51820
  this._setupClickEvent(name, this.setView);
51809
51821
  });
51810
51822
 
51811
- this._setupClickEvent("tcv_collapse_singles", this.collapseNodes1);
51812
- this._setupClickEvent("tcv_collapse_all", this.collapseNodes);
51813
- this._setupClickEvent("tcv_expand", this.expandNodes);
51823
+ this._setupClickEvent("tcv_collapse_singles", this.handleCollapseNodes);
51824
+ this._setupClickEvent("tcv_collapse_all", this.handleCollapseNodes);
51825
+ this._setupClickEvent("tcv_expand", this.handleCollapseNodes);
51814
51826
 
51815
51827
  this._setupClickEvent("tcv_toggle_info", this.toggleInfo);
51816
51828
 
@@ -51870,15 +51882,13 @@ class Display {
51870
51882
  * @property {boolean} [blackEdges = false] - show edges in black and not in edgeColor.
51871
51883
  * @property {boolean} [clipIntersection = false] - use intersection clipping
51872
51884
  * @property {boolean} [clipPlaneHelpers = false] - show clipping planes
51873
- * @property {boolean} [tools = true] - Show/hide all tools.
51874
51885
  */
51875
- updateUI(axes, axes0, ortho, transparent, blackEdges, tools) {
51886
+ updateUI(axes, axes0, ortho, transparent, blackEdges) {
51876
51887
  this.checkElement("tcv_axes", axes);
51877
51888
  this.checkElement("tcv_axes0", axes0);
51878
51889
  this.checkElement("tcv_ortho", ortho);
51879
51890
  this.checkElement("tcv_transparent", transparent);
51880
51891
  this.checkElement("tcv_black_edges", blackEdges);
51881
- this.showTools(tools);
51882
51892
  }
51883
51893
  // setup functions
51884
51894
 
@@ -52093,6 +52103,7 @@ class Display {
52093
52103
  * @param {boolean} flag - whether to show or hide the CAD tools
52094
52104
  */
52095
52105
  showTools = (flag) => {
52106
+ this.tools = flag;
52096
52107
  var tb = this._getElement("tcv_cad_toolbar");
52097
52108
  var cn = this._getElement("tcv_cad_navigation");
52098
52109
  for (var el of [cn, tb]) {
@@ -52272,35 +52283,28 @@ class Display {
52272
52283
  }
52273
52284
 
52274
52285
  /**
52275
- * Collapse all nodes with one leaf only
52286
+ * Collapse nodes handler
52276
52287
  * @function
52277
52288
  * @param {Event} e - a DOM click event
52278
52289
  */
52279
- // eslint-disable-next-line no-unused-vars
52280
- collapseNodes1 = (e) => {
52281
- this.viewer.treeview.expandNodes(2);
52282
- this.viewer.treeview.collapseNodes(1);
52290
+ handleCollapseNodes = (e) => {
52291
+ this.collapseNodes(e.target.value);
52283
52292
  };
52284
52293
 
52285
52294
  /**
52286
- * Collapse all nodes
52287
- * @function
52288
- * @param {Event} e - a DOM click event
52289
- */
52290
- // eslint-disable-next-line no-unused-vars
52291
- collapseNodes = (e) => {
52292
- this.viewer.treeview.collapseNodes(2);
52293
- };
52294
-
52295
- /**
52296
- * Expand all nodes
52297
- * @function
52298
- * @param {Event} e - a DOM click event
52295
+ * Collapse nodes handler
52296
+ * @param {string} value - 1: collapse all leaf nodes, 2: collapse all nodes, "E": expand all nodes
52299
52297
  */
52300
- // eslint-disable-next-line no-unused-vars
52301
- expandNodes = (e) => {
52302
- this.viewer.treeview.expandNodes(2);
52303
- };
52298
+ collapseNodes(value) {
52299
+ if (value === "1") {
52300
+ this.viewer.treeview.expandNodes();
52301
+ this.viewer.treeview.collapseNodes(1);
52302
+ } else if (value === "C") {
52303
+ this.viewer.treeview.collapseNodes(2);
52304
+ } else if (value === "E") {
52305
+ this.viewer.treeview.expandNodes();
52306
+ }
52307
+ }
52304
52308
 
52305
52309
  /**
52306
52310
  * Set minimum and maximum of the sliders
@@ -52428,9 +52432,6 @@ class Display {
52428
52432
  this._getElement("tcv_cad_info").classList.add("tcv_cad_info_glass");
52429
52433
  this._getElement("tcv_cad_view").classList.add("tcv_cad_view_glass");
52430
52434
 
52431
- this._getElement("tcv_cad_toolbar").style.width = px(this.cadWidth);
52432
- this._getElement("tcv_cad_body").style.width = px(this.cadWidth);
52433
-
52434
52435
  this._getElement("tcv_toggle_info_wrapper").style.display = "block";
52435
52436
 
52436
52437
  this.showInfo(false);
@@ -52444,18 +52445,19 @@ class Display {
52444
52445
  this._getElement("tcv_cad_info").classList.remove("tcv_cad_info_glass");
52445
52446
  this._getElement("tcv_cad_view").classList.remove("tcv_cad_view_glass");
52446
52447
 
52447
- this._getElement("tcv_cad_toolbar").style.width = px(
52448
- this.cadWidth + this.treeWidth,
52449
- );
52450
- this._getElement("tcv_cad_body").style.width = px(
52451
- this.cadWidth + this.treeWidth + 4,
52452
- );
52453
-
52454
52448
  this._getElement("tcv_toggle_info_wrapper").style.display = "none";
52455
52449
 
52456
52450
  this.showInfo(true);
52457
52451
  this._glassMode = false;
52458
52452
  }
52453
+ const options = {
52454
+ cadWidth: this.cadWidth,
52455
+ glass: this._glassMode,
52456
+ height: this.height,
52457
+ tools: this.tools,
52458
+ treeWidth: (flag) ? 0 : this.treeWidth
52459
+ };
52460
+ this.setSizes(options);
52459
52461
  }
52460
52462
  }
52461
52463
 
@@ -54962,8 +54964,8 @@ class TreeView {
54962
54964
  this._toggleNodes(mode, true);
54963
54965
  }
54964
54966
 
54965
- expandNodes(mode) {
54966
- this._toggleNodes(mode, false);
54967
+ expandNodes() {
54968
+ this._toggleNodes(2, false);
54967
54969
  }
54968
54970
 
54969
54971
  getIcon(icon_id, state) {
@@ -57389,13 +57391,15 @@ class Viewer {
57389
57391
  this.setDisplayDefaults(options);
57390
57392
  this.theme = options.theme;
57391
57393
 
57392
- this.display = new Display(container, options);
57393
- this.display.setSizes({
57394
+ this.display = new Display(container, {
57395
+ theme: this.theme,
57394
57396
  cadWidth: this.cadWidth,
57395
- height: this.height,
57396
57397
  treeWidth: this.treeWidth,
57398
+ height: this.height,
57399
+ pinning: this.pinning,
57400
+ glass: this.glass,
57401
+ tools: this.tools,
57397
57402
  });
57398
- this.display.glassMode(options.glass);
57399
57403
 
57400
57404
  window.THREE = THREE;
57401
57405
 
@@ -57464,6 +57468,7 @@ class Viewer {
57464
57468
  this.height = 600;
57465
57469
  this.pinning = false;
57466
57470
  this.glass = false;
57471
+ this.tools = true;
57467
57472
 
57468
57473
  for (var option in options) {
57469
57474
  if (this[option] == null) {
@@ -58138,9 +58143,13 @@ class Viewer {
58138
58143
  this.ortho,
58139
58144
  this.transparent,
58140
58145
  this.blackEdges,
58141
- this.tools,
58142
58146
  );
58143
58147
 
58148
+ if (this.cadWidth < 600 && this.display._glassMode) {
58149
+ console.info("Small view, collapsing tree");
58150
+ this.display.collapseNodes("C");
58151
+ }
58152
+
58144
58153
  //
58145
58154
  // show the rendering
58146
58155
  //
@@ -59131,6 +59140,25 @@ class Viewer {
59131
59140
  }
59132
59141
  this.initAnimation(duration, speed, "E", false);
59133
59142
  }
59143
+
59144
+ trimUI(tags, flag) {
59145
+ var display = flag ? "inline-block" : "none";
59146
+ for (var tag of tags) {
59147
+ var el;
59148
+ if (["axes", "axes0", "grid", "ortho", "more", "help"].includes(tag)) {
59149
+ if (tag != "more") {
59150
+ el = this.display._getElement(`tcv_${tag}`);
59151
+ el.style.display = display;
59152
+ if (tag !== "help") {
59153
+ el.nextElementSibling.style.display = display;
59154
+ }
59155
+ } else {
59156
+ el = this.display._getElement(`tcv_${tag}-dropdown`);
59157
+ el.style.display = display;
59158
+ }
59159
+ }
59160
+ }
59161
+ }
59134
59162
  }
59135
59163
 
59136
59164
  export { Display, Timer, Viewer };
@@ -493,6 +493,8 @@ input[type="button"] {
493
493
  color: var(--tcv-z-color);
494
494
  }
495
495
 
496
+ /* Scrollbar styling for Chrome like browsers */
497
+
496
498
  .tcv_mac-scrollbar::-webkit-scrollbar {
497
499
  width: 5px !important;
498
500
  height: 5px !important;
@@ -507,16 +509,20 @@ input[type="button"] {
507
509
  background-color: transparent !important;
508
510
  }
509
511
 
512
+ .tcv_mac-scrollbar::-webkit-scrollbar-piece {
513
+ background-color: transparent !important;
514
+ }
515
+
510
516
  .tcv_mac-scrollbar::-webkit-scrollbar-corner {
511
517
  background-color: transparent !important;
512
518
  }
513
519
 
514
520
  .tcv_mac-scrollbar::-webkit-scrollbar-thumb:hover {
515
- background: var(--tcv-scrollbar-hover) !important;
521
+ background-color: var(--tcv-scrollbar-hover) !important;
516
522
  }
517
523
 
518
524
  .tcv_mac-scrollbar::-webkit-scrollbar-thumb:active {
519
- background: var(--tcv-scrollbar-active) !important;
525
+ background-color: var(--tcv-scrollbar-hover) !important;
520
526
  }
521
527
 
522
528
  .tcv_mac-scrollbar .widget-html-content {
@@ -524,12 +530,20 @@ input[type="button"] {
524
530
  overflow-y: visible;
525
531
  }
526
532
 
533
+ /* Scrollbar styling for Firefox Browser */
534
+
527
535
  .tcv_scroller {
528
- /* scrollbar-color: #7f7f7f white; */
529
536
  scrollbar-width: thin;
537
+ scrollbar-color: var(--tcv-scrollbar-thumb) transparent;
530
538
  background-color: transparent !important;
531
539
  }
532
540
 
541
+ .tcv_scroller:hover {
542
+ scrollbar-width: thin;
543
+ scrollbar-color: var(--tcv-scrollbar-hover) transparent;
544
+ }
545
+
546
+ /* tooltips */
533
547
  [data-tooltip]:before {
534
548
  position: absolute;
535
549
  pointer-events: none;