three-cad-viewer 2.2.1 → 2.2.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-cad-viewer",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
package/src/_version.js CHANGED
@@ -1 +1 @@
1
- export const version = "2.2.1";
1
+ export const version = "2.2.3";
@@ -176,7 +176,9 @@ class ObjectGroup extends THREE.Group {
176
176
  }
177
177
 
178
178
  setShapeVisible(flag) {
179
- this.types.front.material.visible = flag;
179
+ if (this.types.front) {
180
+ this.types.front.material.visible = flag;
181
+ }
180
182
  for (var t of ["clipping-0", "clipping-1", "clipping-2"]) {
181
183
  if (this.types[t]) {
182
184
  this.types[t].children[0].material.visible = flag;
package/src/viewer.js CHANGED
@@ -1127,6 +1127,9 @@ class Viewer {
1127
1127
 
1128
1128
  this.display.autoCollapse();
1129
1129
 
1130
+ // ensure all for all deselected objects the stencil planes are invisible
1131
+ this.setObjects(this.states, true, true);
1132
+
1130
1133
  //
1131
1134
  // show the rendering
1132
1135
  //
@@ -1291,12 +1294,12 @@ class Viewer {
1291
1294
  * @param {States} states
1292
1295
  * @param {boolean} [notify=true] - whether to send notification or not.
1293
1296
  */
1294
- setObjects = (states, notify = true) => {
1297
+ setObjects = (states, force = false, notify = true) => {
1295
1298
  for (var key in this.states) {
1296
1299
  var oldState = this.states[key];
1297
1300
  var newState = states[key];
1298
1301
  var objectGroup = this.nestedGroup.groups[key];
1299
- if (oldState[0] != newState[0]) {
1302
+ if (force || oldState[0] != newState[0]) {
1300
1303
  objectGroup.setShapeVisible(newState[0] === 1);
1301
1304
  this.states[key][0] = newState[0];
1302
1305
  }
@@ -2056,6 +2059,17 @@ class Viewer {
2056
2059
  return this.states;
2057
2060
  }
2058
2061
 
2062
+ /**
2063
+ * Get state of a treeview leafs for a path.
2064
+ * separator can be / or |
2065
+ * @param {string} path - path of the object
2066
+ * @returns {number[]} state value in the form of [mesh, edges] = [0/1, 0/1]
2067
+ **/
2068
+ getState(path) {
2069
+ var p = path.replaceAll("|", "/");
2070
+ return this.getStates()[p];
2071
+ }
2072
+
2059
2073
  /**
2060
2074
  * Set states of a treeview leafs
2061
2075
  * @function