@xeokit/xeokit-sdk 2.4.2-beta-9 → 2.4.2-beta-11

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": "@xeokit/xeokit-sdk",
3
- "version": "2.4.2-beta-9",
3
+ "version": "2.4.2-beta-11",
4
4
  "description": "Web Programming Toolkit for 3D/2D BIM and AEC Graphics",
5
5
  "module": "./dist/xeokit-sdk.es.js",
6
6
  "main": "./dist/xeokit-sdk.cjs.js",
@@ -316,11 +316,29 @@ class BCFViewpointsPlugin extends Plugin {
316
316
  * @param {String} [cfg.id="BCFViewpoints"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
317
317
  * @param {String} [cfg.originatingSystem] Identifies the originating system for BCF records.
318
318
  * @param {String} [cfg.authoringTool] Identifies the authoring tool for BCF records.
319
+ * @param {Boolean} [cfg.xrayAsZeroAlpha=false] Specifies how xeokit's X-ray emphasis effect is handled in BCF viewpoints. See {@link BCFViewpointsPlugin#xrayAsZeroAlpha} for details.
319
320
  */
320
321
  constructor(viewer, cfg = {}) {
321
322
 
322
323
  super("BCFViewpoints", viewer, cfg);
323
324
 
325
+ /**
326
+ * Specifies how xeokit's X-ray emphasis effect is handled in BCF viewpoints.
327
+ *
328
+ * When `xrayAsZeroAlpha` is `true`:
329
+ *
330
+ * * when saving a viewpoint, set the `A` channel of each `coloring` component to `0` for each X-rayed object, and
331
+ * * 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`
332
+ *
333
+ * When `xrayAsZeroAlpha` is `false`:
334
+ *
335
+ * * don't save any X-ray information in viewpoints, and
336
+ * * reset all objects as not X-rayed whenever loading a viewpoint.
337
+ *
338
+ * @type {boolean}
339
+ */
340
+ this.xrayAsZeroAlpha = !!cfg.xrayAsZeroAlpha;
341
+
324
342
  /**
325
343
  * Identifies the originating system to include in BCF viewpoints saved by this plugin.
326
344
  * @property originatingSystem
@@ -509,11 +527,15 @@ class BCFViewpointsPlugin extends Plugin {
509
527
  let alpha;
510
528
 
511
529
  if (entity.xrayed) {
512
- if (scene.xrayMaterial.fillAlpha === 0.0 && scene.xrayMaterial.edgeAlpha !== 0.0) {
513
- // BCF can't deal with edges. If xRay is implemented only with edges, set an arbitrary opacity
514
- alpha = 0.1;
530
+ if (this.xrayAsZeroAlpha) {
531
+ alpha = 0;
515
532
  } else {
516
- alpha = scene.xrayMaterial.fillAlpha;
533
+ if (scene.xrayMaterial.fillAlpha === 0.0 && scene.xrayMaterial.edgeAlpha !== 0.0) {
534
+ // BCF can't deal with edges. If xRay is implemented only with edges, set an arbitrary opacity
535
+ alpha = 0.1;
536
+ } else {
537
+ alpha = scene.xrayMaterial.fillAlpha;
538
+ }
517
539
  }
518
540
  alpha = Math.round(alpha * 255).toString(16).padStart(2, "0");
519
541
  color = alpha + color;
@@ -792,7 +814,16 @@ class BCFViewpointsPlugin extends Plugin {
792
814
  this._withBCFComponent(options, component, entity => {
793
815
  entity.colorize = colorize;
794
816
  if (alphaDefined) {
795
- entity.opacity = alpha;
817
+ if (alpha === 0 && this.xrayAsZeroAlpha) {
818
+ const savedFromXeokit = (component.originating_system === this.originatingSystem);
819
+ if (savedFromXeokit) {
820
+ entity.xrayed = true;
821
+ } else {
822
+ entity.opacity = alpha;
823
+ }
824
+ } else {
825
+ entity.opacity = alpha;
826
+ }
796
827
  }
797
828
  }));
798
829
  });
@@ -366,7 +366,7 @@ export class TrianglesDataTextureSnapDepthBufInitRenderer {
366
366
  if (clipping) {
367
367
  src.push("vFlags2 = flags2.r;");
368
368
  }
369
- src.push("vPickColor = vec4(texelFetch (uTexturePerObjectIdColorsAndFlags, ivec2(objectIndexCoords.x*8+1, objectIndexCoords.y), 0));");
369
+ src.push("vPickColor = vec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+1, objectIndexCoords.y), 0));");
370
370
  src.push("vec4 clipPos = projMatrix * viewPosition;");
371
371
  src.push("float tmp = clipPos.w;")
372
372
  src.push("clipPos.xyzw /= tmp;")