@xeokit/xeokit-sdk 2.4.2-beta-8 → 2.4.2-beta-10

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.
@@ -47356,11 +47356,29 @@ class BCFViewpointsPlugin extends Plugin {
47356
47356
  * @param {String} [cfg.id="BCFViewpoints"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
47357
47357
  * @param {String} [cfg.originatingSystem] Identifies the originating system for BCF records.
47358
47358
  * @param {String} [cfg.authoringTool] Identifies the authoring tool for BCF records.
47359
+ * @param {Boolean} [cfg.xrayAsZeroAlpha=false] Specifies how xeokit's X-ray emphasis effect is handled in BCF viewpoints. See {@link BCFViewpointsPlugin#xrayAsZeroAlpha} for details.
47359
47360
  */
47360
47361
  constructor(viewer, cfg = {}) {
47361
47362
 
47362
47363
  super("BCFViewpoints", viewer, cfg);
47363
47364
 
47365
+ /**
47366
+ * Specifies how xeokit's X-ray emphasis effect is handled in BCF viewpoints.
47367
+ *
47368
+ * When `xrayAsZeroAlpha` is `true`:
47369
+ *
47370
+ * * when saving a viewpoint, set the `A` channel of each `coloring` component to `0` for each X-rayed object, and
47371
+ * * when loading a viewpoint saved from a xeokit application (i.e. when the viewpoint's `originating_system == "xeokit.io"`), set an object X-rayed if the `A` channel of its corresponding `coloring` component equals `0`
47372
+ *
47373
+ * When `xrayAsZeroAlpha` is `false`:
47374
+ *
47375
+ * * don't save any X-ray information in viewpoints, and
47376
+ * * reset all objects as not X-rayed whenever loading a viewpoint.
47377
+ *
47378
+ * @type {boolean}
47379
+ */
47380
+ this.xrayAsZeroAlpha = !!cfg.xrayAsZeroAlpha;
47381
+
47364
47382
  /**
47365
47383
  * Identifies the originating system to include in BCF viewpoints saved by this plugin.
47366
47384
  * @property originatingSystem
@@ -47549,11 +47567,15 @@ class BCFViewpointsPlugin extends Plugin {
47549
47567
  let alpha;
47550
47568
 
47551
47569
  if (entity.xrayed) {
47552
- if (scene.xrayMaterial.fillAlpha === 0.0 && scene.xrayMaterial.edgeAlpha !== 0.0) {
47553
- // BCF can't deal with edges. If xRay is implemented only with edges, set an arbitrary opacity
47554
- alpha = 0.1;
47570
+ if (this.xrayAsZeroAlpha) {
47571
+ alpha = 0;
47555
47572
  } else {
47556
- alpha = scene.xrayMaterial.fillAlpha;
47573
+ if (scene.xrayMaterial.fillAlpha === 0.0 && scene.xrayMaterial.edgeAlpha !== 0.0) {
47574
+ // BCF can't deal with edges. If xRay is implemented only with edges, set an arbitrary opacity
47575
+ alpha = 0.1;
47576
+ } else {
47577
+ alpha = scene.xrayMaterial.fillAlpha;
47578
+ }
47557
47579
  }
47558
47580
  alpha = Math.round(alpha * 255).toString(16).padStart(2, "0");
47559
47581
  color = alpha + color;
@@ -47830,7 +47852,16 @@ class BCFViewpointsPlugin extends Plugin {
47830
47852
  this._withBCFComponent(options, component, entity => {
47831
47853
  entity.colorize = colorize;
47832
47854
  if (alphaDefined) {
47833
- entity.opacity = alpha;
47855
+ if (alpha === 0 && this.xrayAsZeroAlpha) {
47856
+ const savedFromXeokit = (component.originating_system === this.originatingSystem);
47857
+ if (savedFromXeokit) {
47858
+ entity.xrayed = true;
47859
+ } else {
47860
+ entity.opacity = alpha;
47861
+ }
47862
+ } else {
47863
+ entity.opacity = alpha;
47864
+ }
47834
47865
  }
47835
47866
  }));
47836
47867
  });
@@ -66193,28 +66224,33 @@ class TrianglesInstancingLayer {
66193
66224
  if (!this._finalized) {
66194
66225
  throw "Not finalized";
66195
66226
  }
66196
- var offset = portionId * 4;
66197
66227
 
66198
- tempFloat32Vec4$2[0] = matrix[0];
66199
- tempFloat32Vec4$2[1] = matrix[4];
66200
- tempFloat32Vec4$2[2] = matrix[8];
66201
- tempFloat32Vec4$2[3] = matrix[12];
66228
+ ////////////////////////////////////////
66229
+ // TODO: Update portion matrix
66230
+ ////////////////////////////////////////
66231
+
66232
+ var offset = portionId * 4;
66202
66233
 
66203
- this._state.modelMatrixCol0Buf.setData(tempFloat32Vec4$2, offset);
66234
+ tempFloat32Vec4$2[0] = matrix[0];
66235
+ tempFloat32Vec4$2[1] = matrix[4];
66236
+ tempFloat32Vec4$2[2] = matrix[8];
66237
+ tempFloat32Vec4$2[3] = matrix[12];
66204
66238
 
66205
- tempFloat32Vec4$2[0] = matrix[1];
66206
- tempFloat32Vec4$2[1] = matrix[5];
66207
- tempFloat32Vec4$2[2] = matrix[9];
66208
- tempFloat32Vec4$2[3] = matrix[13];
66239
+ this._state.modelMatrixCol0Buf.setData(tempFloat32Vec4$2, offset);
66209
66240
 
66210
- this._state.modelMatrixCol1Buf.setData(tempFloat32Vec4$2, offset);
66241
+ tempFloat32Vec4$2[0] = matrix[1];
66242
+ tempFloat32Vec4$2[1] = matrix[5];
66243
+ tempFloat32Vec4$2[2] = matrix[9];
66244
+ tempFloat32Vec4$2[3] = matrix[13];
66211
66245
 
66212
- tempFloat32Vec4$2[0] = matrix[2];
66213
- tempFloat32Vec4$2[1] = matrix[6];
66214
- tempFloat32Vec4$2[2] = matrix[10];
66215
- tempFloat32Vec4$2[3] = matrix[14];
66246
+ this._state.modelMatrixCol1Buf.setData(tempFloat32Vec4$2, offset);
66216
66247
 
66217
- this._state.modelMatrixCol2Buf.setData(tempFloat32Vec4$2, offset);
66248
+ tempFloat32Vec4$2[0] = matrix[2];
66249
+ tempFloat32Vec4$2[1] = matrix[6];
66250
+ tempFloat32Vec4$2[2] = matrix[10];
66251
+ tempFloat32Vec4$2[3] = matrix[14];
66252
+
66253
+ this._state.modelMatrixCol2Buf.setData(tempFloat32Vec4$2, offset);
66218
66254
  }
66219
66255
 
66220
66256
  // ---------------------- COLOR RENDERING -----------------------------------
@@ -68559,6 +68595,11 @@ class LinesInstancingLayer {
68559
68595
  }
68560
68596
 
68561
68597
  setMatrix(portionId, matrix) {
68598
+
68599
+ ////////////////////////////////////////
68600
+ // TODO: Update portion matrix
68601
+ ////////////////////////////////////////
68602
+
68562
68603
  if (!this._finalized) {
68563
68604
  throw "Not finalized";
68564
68605
  }
@@ -71946,6 +71987,10 @@ class PointsInstancingLayer {
71946
71987
  }
71947
71988
 
71948
71989
  // setMatrix(portionId, matrix) {
71990
+
71991
+ ////////////////////////////////////////
71992
+ // TODO: Update portion matrix
71993
+ ////////////////////////////////////////
71949
71994
  //
71950
71995
  // if (!this._finalized) {
71951
71996
  // throw "Not finalized";
@@ -90953,8 +90998,7 @@ class MetaModel {
90953
90998
  * @property rootMetaObject
90954
90999
  * @type {MetaObject|null}
90955
91000
  */
90956
- get rootMetaObject()
90957
- {
91001
+ get rootMetaObject() {
90958
91002
  if (this.rootMetaObjects.length == 1) {
90959
91003
  return this.rootMetaObjects[0];
90960
91004
  }
@@ -90974,6 +91018,7 @@ class MetaModel {
90974
91018
  this._globalizeIDs(metaModelData, options);
90975
91019
 
90976
91020
  const metaScene = this.metaScene;
91021
+ const propertyLookup = metaModelData.properties;
90977
91022
 
90978
91023
  // Create global Property Sets
90979
91024
 
@@ -90982,6 +91027,9 @@ class MetaModel {
90982
91027
  const propertySetData = metaModelData.propertySets[i];
90983
91028
  let propertySet = metaScene.propertySets[propertySetData.id];
90984
91029
  if (!propertySet) {
91030
+ if (propertyLookup) {
91031
+ this._decompressProperties(propertyLookup, propertySetData.properties);
91032
+ }
90985
91033
  propertySet = new PropertySet({
90986
91034
  id: propertySetData.id,
90987
91035
  originalSystemId: propertySetData.originalSystemId || propertySetData.id,
@@ -91027,6 +91075,18 @@ class MetaModel {
91027
91075
  }
91028
91076
  }
91029
91077
 
91078
+ _decompressProperties(propertyLookup, properties) {
91079
+ for (let i = 0, len = properties.length; i < len; i++) {
91080
+ const property = properties[i];
91081
+ if (Number.isInteger(property)) {
91082
+ const lookupProperty = propertyLookup[property];
91083
+ if (lookupProperty) {
91084
+ properties[i] = lookupProperty;
91085
+ }
91086
+ }
91087
+ }
91088
+ }
91089
+
91030
91090
  finalize() {
91031
91091
 
91032
91092
  if (this.finalized) {
@@ -47352,11 +47352,29 @@ class BCFViewpointsPlugin extends Plugin {
47352
47352
  * @param {String} [cfg.id="BCFViewpoints"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
47353
47353
  * @param {String} [cfg.originatingSystem] Identifies the originating system for BCF records.
47354
47354
  * @param {String} [cfg.authoringTool] Identifies the authoring tool for BCF records.
47355
+ * @param {Boolean} [cfg.xrayAsZeroAlpha=false] Specifies how xeokit's X-ray emphasis effect is handled in BCF viewpoints. See {@link BCFViewpointsPlugin#xrayAsZeroAlpha} for details.
47355
47356
  */
47356
47357
  constructor(viewer, cfg = {}) {
47357
47358
 
47358
47359
  super("BCFViewpoints", viewer, cfg);
47359
47360
 
47361
+ /**
47362
+ * Specifies how xeokit's X-ray emphasis effect is handled in BCF viewpoints.
47363
+ *
47364
+ * When `xrayAsZeroAlpha` is `true`:
47365
+ *
47366
+ * * when saving a viewpoint, set the `A` channel of each `coloring` component to `0` for each X-rayed object, and
47367
+ * * when loading a viewpoint saved from a xeokit application (i.e. when the viewpoint's `originating_system == "xeokit.io"`), set an object X-rayed if the `A` channel of its corresponding `coloring` component equals `0`
47368
+ *
47369
+ * When `xrayAsZeroAlpha` is `false`:
47370
+ *
47371
+ * * don't save any X-ray information in viewpoints, and
47372
+ * * reset all objects as not X-rayed whenever loading a viewpoint.
47373
+ *
47374
+ * @type {boolean}
47375
+ */
47376
+ this.xrayAsZeroAlpha = !!cfg.xrayAsZeroAlpha;
47377
+
47360
47378
  /**
47361
47379
  * Identifies the originating system to include in BCF viewpoints saved by this plugin.
47362
47380
  * @property originatingSystem
@@ -47545,11 +47563,15 @@ class BCFViewpointsPlugin extends Plugin {
47545
47563
  let alpha;
47546
47564
 
47547
47565
  if (entity.xrayed) {
47548
- if (scene.xrayMaterial.fillAlpha === 0.0 && scene.xrayMaterial.edgeAlpha !== 0.0) {
47549
- // BCF can't deal with edges. If xRay is implemented only with edges, set an arbitrary opacity
47550
- alpha = 0.1;
47566
+ if (this.xrayAsZeroAlpha) {
47567
+ alpha = 0;
47551
47568
  } else {
47552
- alpha = scene.xrayMaterial.fillAlpha;
47569
+ if (scene.xrayMaterial.fillAlpha === 0.0 && scene.xrayMaterial.edgeAlpha !== 0.0) {
47570
+ // BCF can't deal with edges. If xRay is implemented only with edges, set an arbitrary opacity
47571
+ alpha = 0.1;
47572
+ } else {
47573
+ alpha = scene.xrayMaterial.fillAlpha;
47574
+ }
47553
47575
  }
47554
47576
  alpha = Math.round(alpha * 255).toString(16).padStart(2, "0");
47555
47577
  color = alpha + color;
@@ -47826,7 +47848,16 @@ class BCFViewpointsPlugin extends Plugin {
47826
47848
  this._withBCFComponent(options, component, entity => {
47827
47849
  entity.colorize = colorize;
47828
47850
  if (alphaDefined) {
47829
- entity.opacity = alpha;
47851
+ if (alpha === 0 && this.xrayAsZeroAlpha) {
47852
+ const savedFromXeokit = (component.originating_system === this.originatingSystem);
47853
+ if (savedFromXeokit) {
47854
+ entity.xrayed = true;
47855
+ } else {
47856
+ entity.opacity = alpha;
47857
+ }
47858
+ } else {
47859
+ entity.opacity = alpha;
47860
+ }
47830
47861
  }
47831
47862
  }));
47832
47863
  });
@@ -66189,28 +66220,33 @@ class TrianglesInstancingLayer {
66189
66220
  if (!this._finalized) {
66190
66221
  throw "Not finalized";
66191
66222
  }
66192
- var offset = portionId * 4;
66193
66223
 
66194
- tempFloat32Vec4$2[0] = matrix[0];
66195
- tempFloat32Vec4$2[1] = matrix[4];
66196
- tempFloat32Vec4$2[2] = matrix[8];
66197
- tempFloat32Vec4$2[3] = matrix[12];
66224
+ ////////////////////////////////////////
66225
+ // TODO: Update portion matrix
66226
+ ////////////////////////////////////////
66227
+
66228
+ var offset = portionId * 4;
66198
66229
 
66199
- this._state.modelMatrixCol0Buf.setData(tempFloat32Vec4$2, offset);
66230
+ tempFloat32Vec4$2[0] = matrix[0];
66231
+ tempFloat32Vec4$2[1] = matrix[4];
66232
+ tempFloat32Vec4$2[2] = matrix[8];
66233
+ tempFloat32Vec4$2[3] = matrix[12];
66200
66234
 
66201
- tempFloat32Vec4$2[0] = matrix[1];
66202
- tempFloat32Vec4$2[1] = matrix[5];
66203
- tempFloat32Vec4$2[2] = matrix[9];
66204
- tempFloat32Vec4$2[3] = matrix[13];
66235
+ this._state.modelMatrixCol0Buf.setData(tempFloat32Vec4$2, offset);
66205
66236
 
66206
- this._state.modelMatrixCol1Buf.setData(tempFloat32Vec4$2, offset);
66237
+ tempFloat32Vec4$2[0] = matrix[1];
66238
+ tempFloat32Vec4$2[1] = matrix[5];
66239
+ tempFloat32Vec4$2[2] = matrix[9];
66240
+ tempFloat32Vec4$2[3] = matrix[13];
66207
66241
 
66208
- tempFloat32Vec4$2[0] = matrix[2];
66209
- tempFloat32Vec4$2[1] = matrix[6];
66210
- tempFloat32Vec4$2[2] = matrix[10];
66211
- tempFloat32Vec4$2[3] = matrix[14];
66242
+ this._state.modelMatrixCol1Buf.setData(tempFloat32Vec4$2, offset);
66212
66243
 
66213
- this._state.modelMatrixCol2Buf.setData(tempFloat32Vec4$2, offset);
66244
+ tempFloat32Vec4$2[0] = matrix[2];
66245
+ tempFloat32Vec4$2[1] = matrix[6];
66246
+ tempFloat32Vec4$2[2] = matrix[10];
66247
+ tempFloat32Vec4$2[3] = matrix[14];
66248
+
66249
+ this._state.modelMatrixCol2Buf.setData(tempFloat32Vec4$2, offset);
66214
66250
  }
66215
66251
 
66216
66252
  // ---------------------- COLOR RENDERING -----------------------------------
@@ -68555,6 +68591,11 @@ class LinesInstancingLayer {
68555
68591
  }
68556
68592
 
68557
68593
  setMatrix(portionId, matrix) {
68594
+
68595
+ ////////////////////////////////////////
68596
+ // TODO: Update portion matrix
68597
+ ////////////////////////////////////////
68598
+
68558
68599
  if (!this._finalized) {
68559
68600
  throw "Not finalized";
68560
68601
  }
@@ -71942,6 +71983,10 @@ class PointsInstancingLayer {
71942
71983
  }
71943
71984
 
71944
71985
  // setMatrix(portionId, matrix) {
71986
+
71987
+ ////////////////////////////////////////
71988
+ // TODO: Update portion matrix
71989
+ ////////////////////////////////////////
71945
71990
  //
71946
71991
  // if (!this._finalized) {
71947
71992
  // throw "Not finalized";
@@ -90949,8 +90994,7 @@ class MetaModel {
90949
90994
  * @property rootMetaObject
90950
90995
  * @type {MetaObject|null}
90951
90996
  */
90952
- get rootMetaObject()
90953
- {
90997
+ get rootMetaObject() {
90954
90998
  if (this.rootMetaObjects.length == 1) {
90955
90999
  return this.rootMetaObjects[0];
90956
91000
  }
@@ -90970,6 +91014,7 @@ class MetaModel {
90970
91014
  this._globalizeIDs(metaModelData, options);
90971
91015
 
90972
91016
  const metaScene = this.metaScene;
91017
+ const propertyLookup = metaModelData.properties;
90973
91018
 
90974
91019
  // Create global Property Sets
90975
91020
 
@@ -90978,6 +91023,9 @@ class MetaModel {
90978
91023
  const propertySetData = metaModelData.propertySets[i];
90979
91024
  let propertySet = metaScene.propertySets[propertySetData.id];
90980
91025
  if (!propertySet) {
91026
+ if (propertyLookup) {
91027
+ this._decompressProperties(propertyLookup, propertySetData.properties);
91028
+ }
90981
91029
  propertySet = new PropertySet({
90982
91030
  id: propertySetData.id,
90983
91031
  originalSystemId: propertySetData.originalSystemId || propertySetData.id,
@@ -91023,6 +91071,18 @@ class MetaModel {
91023
91071
  }
91024
91072
  }
91025
91073
 
91074
+ _decompressProperties(propertyLookup, properties) {
91075
+ for (let i = 0, len = properties.length; i < len; i++) {
91076
+ const property = properties[i];
91077
+ if (Number.isInteger(property)) {
91078
+ const lookupProperty = propertyLookup[property];
91079
+ if (lookupProperty) {
91080
+ properties[i] = lookupProperty;
91081
+ }
91082
+ }
91083
+ }
91084
+ }
91085
+
91026
91086
  finalize() {
91027
91087
 
91028
91088
  if (this.finalized) {