@xeokit/xeokit-sdk 2.4.2-beta-29 → 2.4.2-beta-30

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.
@@ -48260,29 +48260,11 @@ class BCFViewpointsPlugin extends Plugin {
48260
48260
  * @param {String} [cfg.id="BCFViewpoints"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
48261
48261
  * @param {String} [cfg.originatingSystem] Identifies the originating system for BCF records.
48262
48262
  * @param {String} [cfg.authoringTool] Identifies the authoring tool for BCF records.
48263
- * @param {Boolean} [cfg.xrayAsZeroAlpha=false] Specifies how xeokit's X-ray emphasis effect is handled in BCF viewpoints. See {@link BCFViewpointsPlugin#xrayAsZeroAlpha} for details.
48264
48263
  */
48265
48264
  constructor(viewer, cfg = {}) {
48266
48265
 
48267
48266
  super("BCFViewpoints", viewer, cfg);
48268
48267
 
48269
- /**
48270
- * Specifies how xeokit's X-ray emphasis effect is handled in BCF viewpoints.
48271
- *
48272
- * When `xrayAsZeroAlpha` is `true`:
48273
- *
48274
- * * when saving a viewpoint, set the `A` channel of each `coloring` component to `0` for each X-rayed object, and
48275
- * * 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`
48276
- *
48277
- * When `xrayAsZeroAlpha` is `false`:
48278
- *
48279
- * * don't save any X-ray information in viewpoints, and
48280
- * * reset all objects as not X-rayed whenever loading a viewpoint.
48281
- *
48282
- * @type {boolean}
48283
- */
48284
- this.xrayAsZeroAlpha = !!cfg.xrayAsZeroAlpha;
48285
-
48286
48268
  /**
48287
48269
  * Identifies the originating system to include in BCF viewpoints saved by this plugin.
48288
48270
  * @property originatingSystem
@@ -48307,6 +48289,9 @@ class BCFViewpointsPlugin extends Plugin {
48307
48289
  * @param {Boolean} [options.spacesVisible=false] Indicates whether ````IfcSpace```` types should be forced visible in the viewpoint.
48308
48290
  * @param {Boolean} [options.openingsVisible=false] Indicates whether ````IfcOpening```` types should be forced visible in the viewpoint.
48309
48291
  * @param {Boolean} [options.spaceBoundariesVisible=false] Indicates whether the boundaries of ````IfcSpace```` types should be visible in the viewpoint.
48292
+ * @param {Boolean} [options.spacesTranslucent=false] Indicates whether ````IfcSpace```` types should be forced translucent in the viewpoint.
48293
+ * @param {Boolean} [options.spaceBoundariesTranslucent=false] Indicates whether the boundaries of ````IfcSpace```` types should be forced translucent in the viewpoint.
48294
+ * @param {Boolean} [options.openingsTranslucent=true] Indicates whether ````IfcOpening```` types should be forced translucent in the viewpoint.
48310
48295
  * @param {Boolean} [options.snapshot=true] Indicates whether the snapshot should be included in the viewpoint.
48311
48296
  * @param {Boolean} [options.defaultInvisible=false] When ````true````, will save the default visibility of all objects
48312
48297
  * as ````false````. This means that when we load the viewpoint again, and there are additional models loaded that
@@ -48454,7 +48439,10 @@ class BCFViewpointsPlugin extends Plugin {
48454
48439
  view_setup_hints: {
48455
48440
  spaces_visible: !!options.spacesVisible,
48456
48441
  space_boundaries_visible: !!options.spaceBoundariesVisible,
48457
- openings_visible: !!options.openingsVisible
48442
+ openings_visible: !!options.openingsVisible,
48443
+ spaces_translucent: !!options.spaces_translucent,
48444
+ space_boundaries_translucent: !!options.space_boundaries_translucent,
48445
+ openings_translucent: !!options.openings_translucent
48458
48446
  }
48459
48447
  }
48460
48448
  };
@@ -48471,15 +48459,11 @@ class BCFViewpointsPlugin extends Plugin {
48471
48459
  let alpha;
48472
48460
 
48473
48461
  if (entity.xrayed) {
48474
- if (this.xrayAsZeroAlpha) {
48475
- alpha = 0;
48462
+ if (scene.xrayMaterial.fillAlpha === 0.0 && scene.xrayMaterial.edgeAlpha !== 0.0) {
48463
+ // BCF can't deal with edges. If xRay is implemented only with edges, set an arbitrary opacity
48464
+ alpha = 0.1;
48476
48465
  } else {
48477
- if (scene.xrayMaterial.fillAlpha === 0.0 && scene.xrayMaterial.edgeAlpha !== 0.0) {
48478
- // BCF can't deal with edges. If xRay is implemented only with edges, set an arbitrary opacity
48479
- alpha = 0.1;
48480
- } else {
48481
- alpha = scene.xrayMaterial.fillAlpha;
48482
- }
48466
+ alpha = scene.xrayMaterial.fillAlpha;
48483
48467
  }
48484
48468
  alpha = Math.round(alpha * 255).toString(16).padStart(2, "0");
48485
48469
  color = alpha + color;
@@ -48530,6 +48514,8 @@ class BCFViewpointsPlugin extends Plugin {
48530
48514
 
48531
48515
  bcfViewpoint.components.selection = this._createBCFComponents(selectedObjectIds);
48532
48516
 
48517
+ bcfViewpoint.components.translucency = this._createBCFComponents(scene.xrayedObjectIds);
48518
+
48533
48519
  if (options.snapshot !== false) {
48534
48520
  bcfViewpoint.snapshot = {
48535
48521
  snapshot_type: "png",
@@ -48715,12 +48701,19 @@ class BCFViewpointsPlugin extends Plugin {
48715
48701
  const view_setup_hints = bcfViewpoint.components.visibility.view_setup_hints;
48716
48702
  if (view_setup_hints) {
48717
48703
  if (view_setup_hints.spaces_visible === false) {
48718
- scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcSpace"), false);
48704
+ scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcSpace"), true);
48719
48705
  }
48720
- if (view_setup_hints.openings_visible === false) {
48721
- scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcOpening"), false);
48706
+ if (view_setup_hints.spaces_translucent !== undefined) {
48707
+ scene.setObjectsXRayed(viewer.metaScene.getObjectIDsByType("IfcSpace"), true);
48722
48708
  }
48723
48709
  if (view_setup_hints.space_boundaries_visible !== undefined) ;
48710
+ if (view_setup_hints.openings_visible === false) {
48711
+ scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcOpening"), true);
48712
+ }
48713
+ if (view_setup_hints.space_boundaries_translucent !== undefined) ;
48714
+ if (view_setup_hints.openings_translucent !== undefined) {
48715
+ scene.setObjectsXRayed(viewer.metaScene.getObjectIDsByType("IfcOpening"), true);
48716
+ }
48724
48717
  }
48725
48718
  }
48726
48719
 
@@ -48730,6 +48723,11 @@ class BCFViewpointsPlugin extends Plugin {
48730
48723
 
48731
48724
  }
48732
48725
 
48726
+ if (bcfViewpoint.components.translucency) {
48727
+ scene.setObjectsXRayed(scene.xrayedObjectIds, false);
48728
+ bcfViewpoint.components.translucency.forEach(component => this._withBCFComponent(options, component, entity => entity.xrayed = true));
48729
+ }
48730
+
48733
48731
  if (bcfViewpoint.components.coloring) {
48734
48732
  bcfViewpoint.components.coloring.forEach(coloring => {
48735
48733
 
@@ -48756,16 +48754,7 @@ class BCFViewpointsPlugin extends Plugin {
48756
48754
  this._withBCFComponent(options, component, entity => {
48757
48755
  entity.colorize = colorize;
48758
48756
  if (alphaDefined) {
48759
- if (alpha === 0 && this.xrayAsZeroAlpha) {
48760
- const savedFromXeokit = (component.originating_system === this.originatingSystem);
48761
- if (savedFromXeokit) {
48762
- entity.xrayed = true;
48763
- } else {
48764
- entity.opacity = alpha;
48765
- }
48766
- } else {
48767
- entity.opacity = alpha;
48768
- }
48757
+ entity.opacity = alpha;
48769
48758
  }
48770
48759
  }));
48771
48760
  });
@@ -48256,29 +48256,11 @@ class BCFViewpointsPlugin extends Plugin {
48256
48256
  * @param {String} [cfg.id="BCFViewpoints"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
48257
48257
  * @param {String} [cfg.originatingSystem] Identifies the originating system for BCF records.
48258
48258
  * @param {String} [cfg.authoringTool] Identifies the authoring tool for BCF records.
48259
- * @param {Boolean} [cfg.xrayAsZeroAlpha=false] Specifies how xeokit's X-ray emphasis effect is handled in BCF viewpoints. See {@link BCFViewpointsPlugin#xrayAsZeroAlpha} for details.
48260
48259
  */
48261
48260
  constructor(viewer, cfg = {}) {
48262
48261
 
48263
48262
  super("BCFViewpoints", viewer, cfg);
48264
48263
 
48265
- /**
48266
- * Specifies how xeokit's X-ray emphasis effect is handled in BCF viewpoints.
48267
- *
48268
- * When `xrayAsZeroAlpha` is `true`:
48269
- *
48270
- * * when saving a viewpoint, set the `A` channel of each `coloring` component to `0` for each X-rayed object, and
48271
- * * 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`
48272
- *
48273
- * When `xrayAsZeroAlpha` is `false`:
48274
- *
48275
- * * don't save any X-ray information in viewpoints, and
48276
- * * reset all objects as not X-rayed whenever loading a viewpoint.
48277
- *
48278
- * @type {boolean}
48279
- */
48280
- this.xrayAsZeroAlpha = !!cfg.xrayAsZeroAlpha;
48281
-
48282
48264
  /**
48283
48265
  * Identifies the originating system to include in BCF viewpoints saved by this plugin.
48284
48266
  * @property originatingSystem
@@ -48303,6 +48285,9 @@ class BCFViewpointsPlugin extends Plugin {
48303
48285
  * @param {Boolean} [options.spacesVisible=false] Indicates whether ````IfcSpace```` types should be forced visible in the viewpoint.
48304
48286
  * @param {Boolean} [options.openingsVisible=false] Indicates whether ````IfcOpening```` types should be forced visible in the viewpoint.
48305
48287
  * @param {Boolean} [options.spaceBoundariesVisible=false] Indicates whether the boundaries of ````IfcSpace```` types should be visible in the viewpoint.
48288
+ * @param {Boolean} [options.spacesTranslucent=false] Indicates whether ````IfcSpace```` types should be forced translucent in the viewpoint.
48289
+ * @param {Boolean} [options.spaceBoundariesTranslucent=false] Indicates whether the boundaries of ````IfcSpace```` types should be forced translucent in the viewpoint.
48290
+ * @param {Boolean} [options.openingsTranslucent=true] Indicates whether ````IfcOpening```` types should be forced translucent in the viewpoint.
48306
48291
  * @param {Boolean} [options.snapshot=true] Indicates whether the snapshot should be included in the viewpoint.
48307
48292
  * @param {Boolean} [options.defaultInvisible=false] When ````true````, will save the default visibility of all objects
48308
48293
  * as ````false````. This means that when we load the viewpoint again, and there are additional models loaded that
@@ -48450,7 +48435,10 @@ class BCFViewpointsPlugin extends Plugin {
48450
48435
  view_setup_hints: {
48451
48436
  spaces_visible: !!options.spacesVisible,
48452
48437
  space_boundaries_visible: !!options.spaceBoundariesVisible,
48453
- openings_visible: !!options.openingsVisible
48438
+ openings_visible: !!options.openingsVisible,
48439
+ spaces_translucent: !!options.spaces_translucent,
48440
+ space_boundaries_translucent: !!options.space_boundaries_translucent,
48441
+ openings_translucent: !!options.openings_translucent
48454
48442
  }
48455
48443
  }
48456
48444
  };
@@ -48467,15 +48455,11 @@ class BCFViewpointsPlugin extends Plugin {
48467
48455
  let alpha;
48468
48456
 
48469
48457
  if (entity.xrayed) {
48470
- if (this.xrayAsZeroAlpha) {
48471
- alpha = 0;
48458
+ if (scene.xrayMaterial.fillAlpha === 0.0 && scene.xrayMaterial.edgeAlpha !== 0.0) {
48459
+ // BCF can't deal with edges. If xRay is implemented only with edges, set an arbitrary opacity
48460
+ alpha = 0.1;
48472
48461
  } else {
48473
- if (scene.xrayMaterial.fillAlpha === 0.0 && scene.xrayMaterial.edgeAlpha !== 0.0) {
48474
- // BCF can't deal with edges. If xRay is implemented only with edges, set an arbitrary opacity
48475
- alpha = 0.1;
48476
- } else {
48477
- alpha = scene.xrayMaterial.fillAlpha;
48478
- }
48462
+ alpha = scene.xrayMaterial.fillAlpha;
48479
48463
  }
48480
48464
  alpha = Math.round(alpha * 255).toString(16).padStart(2, "0");
48481
48465
  color = alpha + color;
@@ -48526,6 +48510,8 @@ class BCFViewpointsPlugin extends Plugin {
48526
48510
 
48527
48511
  bcfViewpoint.components.selection = this._createBCFComponents(selectedObjectIds);
48528
48512
 
48513
+ bcfViewpoint.components.translucency = this._createBCFComponents(scene.xrayedObjectIds);
48514
+
48529
48515
  if (options.snapshot !== false) {
48530
48516
  bcfViewpoint.snapshot = {
48531
48517
  snapshot_type: "png",
@@ -48711,12 +48697,19 @@ class BCFViewpointsPlugin extends Plugin {
48711
48697
  const view_setup_hints = bcfViewpoint.components.visibility.view_setup_hints;
48712
48698
  if (view_setup_hints) {
48713
48699
  if (view_setup_hints.spaces_visible === false) {
48714
- scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcSpace"), false);
48700
+ scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcSpace"), true);
48715
48701
  }
48716
- if (view_setup_hints.openings_visible === false) {
48717
- scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcOpening"), false);
48702
+ if (view_setup_hints.spaces_translucent !== undefined) {
48703
+ scene.setObjectsXRayed(viewer.metaScene.getObjectIDsByType("IfcSpace"), true);
48718
48704
  }
48719
48705
  if (view_setup_hints.space_boundaries_visible !== undefined) ;
48706
+ if (view_setup_hints.openings_visible === false) {
48707
+ scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcOpening"), true);
48708
+ }
48709
+ if (view_setup_hints.space_boundaries_translucent !== undefined) ;
48710
+ if (view_setup_hints.openings_translucent !== undefined) {
48711
+ scene.setObjectsXRayed(viewer.metaScene.getObjectIDsByType("IfcOpening"), true);
48712
+ }
48720
48713
  }
48721
48714
  }
48722
48715
 
@@ -48726,6 +48719,11 @@ class BCFViewpointsPlugin extends Plugin {
48726
48719
 
48727
48720
  }
48728
48721
 
48722
+ if (bcfViewpoint.components.translucency) {
48723
+ scene.setObjectsXRayed(scene.xrayedObjectIds, false);
48724
+ bcfViewpoint.components.translucency.forEach(component => this._withBCFComponent(options, component, entity => entity.xrayed = true));
48725
+ }
48726
+
48729
48727
  if (bcfViewpoint.components.coloring) {
48730
48728
  bcfViewpoint.components.coloring.forEach(coloring => {
48731
48729
 
@@ -48752,16 +48750,7 @@ class BCFViewpointsPlugin extends Plugin {
48752
48750
  this._withBCFComponent(options, component, entity => {
48753
48751
  entity.colorize = colorize;
48754
48752
  if (alphaDefined) {
48755
- if (alpha === 0 && this.xrayAsZeroAlpha) {
48756
- const savedFromXeokit = (component.originating_system === this.originatingSystem);
48757
- if (savedFromXeokit) {
48758
- entity.xrayed = true;
48759
- } else {
48760
- entity.opacity = alpha;
48761
- }
48762
- } else {
48763
- entity.opacity = alpha;
48764
- }
48753
+ entity.opacity = alpha;
48765
48754
  }
48766
48755
  }));
48767
48756
  });
@@ -14177,22 +14177,7 @@ var positions=K3D.edit.unwrap(m.i_verts,m.c_verts,3);var normals=K3D.edit.unwrap
14177
14177
  * @param {String} [cfg.id="BCFViewpoints"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
14178
14178
  * @param {String} [cfg.originatingSystem] Identifies the originating system for BCF records.
14179
14179
  * @param {String} [cfg.authoringTool] Identifies the authoring tool for BCF records.
14180
- * @param {Boolean} [cfg.xrayAsZeroAlpha=false] Specifies how xeokit's X-ray emphasis effect is handled in BCF viewpoints. See {@link BCFViewpointsPlugin#xrayAsZeroAlpha} for details.
14181
14180
  */function BCFViewpointsPlugin(viewer){var _this67;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,BCFViewpointsPlugin);_this67=_super46.call(this,"BCFViewpoints",viewer,cfg);/**
14182
- * Specifies how xeokit's X-ray emphasis effect is handled in BCF viewpoints.
14183
- *
14184
- * When `xrayAsZeroAlpha` is `true`:
14185
- *
14186
- * * when saving a viewpoint, set the `A` channel of each `coloring` component to `0` for each X-rayed object, and
14187
- * * 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`
14188
- *
14189
- * When `xrayAsZeroAlpha` is `false`:
14190
- *
14191
- * * don't save any X-ray information in viewpoints, and
14192
- * * reset all objects as not X-rayed whenever loading a viewpoint.
14193
- *
14194
- * @type {boolean}
14195
- */_this67.xrayAsZeroAlpha=!!cfg.xrayAsZeroAlpha;/**
14196
14181
  * Identifies the originating system to include in BCF viewpoints saved by this plugin.
14197
14182
  * @property originatingSystem
14198
14183
  * @type {string}
@@ -14209,6 +14194,9 @@ var positions=K3D.edit.unwrap(m.i_verts,m.c_verts,3);var normals=K3D.edit.unwrap
14209
14194
  * @param {Boolean} [options.spacesVisible=false] Indicates whether ````IfcSpace```` types should be forced visible in the viewpoint.
14210
14195
  * @param {Boolean} [options.openingsVisible=false] Indicates whether ````IfcOpening```` types should be forced visible in the viewpoint.
14211
14196
  * @param {Boolean} [options.spaceBoundariesVisible=false] Indicates whether the boundaries of ````IfcSpace```` types should be visible in the viewpoint.
14197
+ * @param {Boolean} [options.spacesTranslucent=false] Indicates whether ````IfcSpace```` types should be forced translucent in the viewpoint.
14198
+ * @param {Boolean} [options.spaceBoundariesTranslucent=false] Indicates whether the boundaries of ````IfcSpace```` types should be forced translucent in the viewpoint.
14199
+ * @param {Boolean} [options.openingsTranslucent=true] Indicates whether ````IfcOpening```` types should be forced translucent in the viewpoint.
14212
14200
  * @param {Boolean} [options.snapshot=true] Indicates whether the snapshot should be included in the viewpoint.
14213
14201
  * @param {Boolean} [options.defaultInvisible=false] When ````true````, will save the default visibility of all objects
14214
14202
  * as ````false````. This means that when we load the viewpoint again, and there are additional models loaded that
@@ -14224,8 +14212,8 @@ location=YToZ(location);_direction=YToZ(_direction);}math.addVec3(location,realW
14224
14212
  var lineSets=scene.lineSets;for(var _id2 in lineSets){if(lineSets.hasOwnProperty(_id2)){var lineSet=lineSets[_id2];if(!bcfViewpoint.lines){bcfViewpoint.lines=[];}var positions=lineSet.positions;var indices=lineSet.indices;for(var _i155=0,len=indices.length/2;_i155<len;_i155++){var _a2=indices[_i155*2];var b=indices[_i155*2+1];bcfViewpoint.lines.push({start_point:{x:positions[_a2*3+0],y:positions[_a2*3+1],z:positions[_a2*3+2]},end_point:{x:positions[b*3+0],y:positions[b*3+1],z:positions[b*3+2]}});}}}// Bitmaps
14225
14213
  var bitmaps=scene.bitmaps;for(var _id3 in bitmaps){if(bitmaps.hasOwnProperty(_id3)){var bitmap=bitmaps[_id3];var _location=bitmap.pos;var normal=bitmap.normal;var _up=bitmap.up;if(camera.yUp){// BCF is Z up
14226
14214
  _location=YToZ(_location);normal=YToZ(normal);_up=YToZ(_up);}math.addVec3(_location,realWorldOffset);if(!bcfViewpoint.bitmaps){bcfViewpoint.bitmaps=[];}bcfViewpoint.bitmaps.push({bitmap_type:bitmap.type,bitmap_data:bitmap.imageData,location:xyzArrayToObject(_location),normal:xyzArrayToObject(normal),up:xyzArrayToObject(_up),height:bitmap.height});}}// Entity states
14227
- bcfViewpoint.components={visibility:{view_setup_hints:{spaces_visible:!!options.spacesVisible,space_boundaries_visible:!!options.spaceBoundariesVisible,openings_visible:!!options.openingsVisible}}};var opacityObjectIds=new Set(scene.opacityObjectIds);var xrayedObjectIds=new Set(scene.xrayedObjectIds);var colorizedObjectIds=new Set(scene.colorizedObjectIds);var coloringMap=Object.values(scene.objects).filter(function(entity){return opacityObjectIds.has(entity.id)||colorizedObjectIds.has(entity.id)||xrayedObjectIds.has(entity.id);}).reduce(function(coloringMap,entity){var color=colorizeToRGB(entity.colorize);var alpha;if(entity.xrayed){if(_this68.xrayAsZeroAlpha){alpha=0;}else{if(scene.xrayMaterial.fillAlpha===0.0&&scene.xrayMaterial.edgeAlpha!==0.0){// BCF can't deal with edges. If xRay is implemented only with edges, set an arbitrary opacity
14228
- alpha=0.1;}else{alpha=scene.xrayMaterial.fillAlpha;}}alpha=Math.round(alpha*255).toString(16).padStart(2,"0");color=alpha+color;}else if(opacityObjectIds.has(entity.id)){alpha=Math.round(entity.opacity*255).toString(16).padStart(2,"0");color=alpha+color;}if(!coloringMap[color]){coloringMap[color]=[];}var objectId=entity.id;var originalSystemId=entity.originalSystemId;var component={ifc_guid:originalSystemId,originating_system:_this68.originatingSystem};if(originalSystemId!==objectId){component.authoring_tool_id=objectId;}coloringMap[color].push(component);return coloringMap;},{});var coloringArray=Object.entries(coloringMap).map(function(_ref6){var _ref7=_slicedToArray(_ref6,2),color=_ref7[0],components=_ref7[1];return{color:color,components:components};});bcfViewpoint.components.coloring=coloringArray;var objectIds=scene.objectIds;var visibleObjects=scene.visibleObjects;var visibleObjectIds=scene.visibleObjectIds;var invisibleObjectIds=objectIds.filter(function(id){return!visibleObjects[id];});var selectedObjectIds=scene.selectedObjectIds;if(options.defaultInvisible||visibleObjectIds.length<invisibleObjectIds.length){bcfViewpoint.components.visibility.exceptions=this._createBCFComponents(visibleObjectIds);bcfViewpoint.components.visibility.default_visibility=false;}else{bcfViewpoint.components.visibility.exceptions=this._createBCFComponents(invisibleObjectIds);bcfViewpoint.components.visibility.default_visibility=true;}bcfViewpoint.components.selection=this._createBCFComponents(selectedObjectIds);if(options.snapshot!==false){bcfViewpoint.snapshot={snapshot_type:"png",snapshot_data:this.viewer.getSnapshot({format:"png"})};}return bcfViewpoint;}},{key:"_createBCFComponents",value:function _createBCFComponents(objectIds){var scene=this.viewer.scene;var components=[];for(var _i156=0,len=objectIds.length;_i156<len;_i156++){var objectId=objectIds[_i156];var entity=scene.objects[objectId];if(entity){var component={ifc_guid:entity.originalSystemId,originating_system:this.originatingSystem};if(entity.originalSystemId!==objectId){component.authoring_tool_id=objectId;}components.push(component);}}return components;}/**
14215
+ bcfViewpoint.components={visibility:{view_setup_hints:{spaces_visible:!!options.spacesVisible,space_boundaries_visible:!!options.spaceBoundariesVisible,openings_visible:!!options.openingsVisible,spaces_translucent:!!options.spaces_translucent,space_boundaries_translucent:!!options.space_boundaries_translucent,openings_translucent:!!options.openings_translucent}}};var opacityObjectIds=new Set(scene.opacityObjectIds);var xrayedObjectIds=new Set(scene.xrayedObjectIds);var colorizedObjectIds=new Set(scene.colorizedObjectIds);var coloringMap=Object.values(scene.objects).filter(function(entity){return opacityObjectIds.has(entity.id)||colorizedObjectIds.has(entity.id)||xrayedObjectIds.has(entity.id);}).reduce(function(coloringMap,entity){var color=colorizeToRGB(entity.colorize);var alpha;if(entity.xrayed){if(scene.xrayMaterial.fillAlpha===0.0&&scene.xrayMaterial.edgeAlpha!==0.0){// BCF can't deal with edges. If xRay is implemented only with edges, set an arbitrary opacity
14216
+ alpha=0.1;}else{alpha=scene.xrayMaterial.fillAlpha;}alpha=Math.round(alpha*255).toString(16).padStart(2,"0");color=alpha+color;}else if(opacityObjectIds.has(entity.id)){alpha=Math.round(entity.opacity*255).toString(16).padStart(2,"0");color=alpha+color;}if(!coloringMap[color]){coloringMap[color]=[];}var objectId=entity.id;var originalSystemId=entity.originalSystemId;var component={ifc_guid:originalSystemId,originating_system:_this68.originatingSystem};if(originalSystemId!==objectId){component.authoring_tool_id=objectId;}coloringMap[color].push(component);return coloringMap;},{});var coloringArray=Object.entries(coloringMap).map(function(_ref6){var _ref7=_slicedToArray(_ref6,2),color=_ref7[0],components=_ref7[1];return{color:color,components:components};});bcfViewpoint.components.coloring=coloringArray;var objectIds=scene.objectIds;var visibleObjects=scene.visibleObjects;var visibleObjectIds=scene.visibleObjectIds;var invisibleObjectIds=objectIds.filter(function(id){return!visibleObjects[id];});var selectedObjectIds=scene.selectedObjectIds;if(options.defaultInvisible||visibleObjectIds.length<invisibleObjectIds.length){bcfViewpoint.components.visibility.exceptions=this._createBCFComponents(visibleObjectIds);bcfViewpoint.components.visibility.default_visibility=false;}else{bcfViewpoint.components.visibility.exceptions=this._createBCFComponents(invisibleObjectIds);bcfViewpoint.components.visibility.default_visibility=true;}bcfViewpoint.components.selection=this._createBCFComponents(selectedObjectIds);bcfViewpoint.components.translucency=this._createBCFComponents(scene.xrayedObjectIds);if(options.snapshot!==false){bcfViewpoint.snapshot={snapshot_type:"png",snapshot_data:this.viewer.getSnapshot({format:"png"})};}return bcfViewpoint;}},{key:"_createBCFComponents",value:function _createBCFComponents(objectIds){var scene=this.viewer.scene;var components=[];for(var _i156=0,len=objectIds.length;_i156<len;_i156++){var objectId=objectIds[_i156];var entity=scene.objects[objectId];if(entity){var component={ifc_guid:entity.originalSystemId,originating_system:this.originatingSystem};if(entity.originalSystemId!==objectId){component.authoring_tool_id=objectId;}components.push(component);}}return components;}/**
14229
14217
  * Sets viewer state to the given BCF viewpoint.
14230
14218
  *
14231
14219
  * Note that xeokit's {@link Camera#look} is the **point-of-interest**, whereas the BCF ````camera_direction```` is a
@@ -14249,7 +14237,7 @@ alpha=0.1;}else{alpha=scene.xrayMaterial.fillAlpha;}}alpha=Math.round(alpha*255)
14249
14237
  * then this method will apply the updates to objects within those composites.
14250
14238
  */},{key:"setViewpoint",value:function setViewpoint(bcfViewpoint){var _this69=this;var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(!bcfViewpoint){return;}var viewer=this.viewer;var scene=viewer.scene;var camera=scene.camera;var rayCast=options.rayCast!==false;var immediate=options.immediate!==false;var reset=options.reset!==false;var realWorldOffset=scene.realWorldOffset;var reverseClippingPlanes=options.reverseClippingPlanes===true;scene.clearSectionPlanes();if(bcfViewpoint.clipping_planes&&bcfViewpoint.clipping_planes.length>0){bcfViewpoint.clipping_planes.forEach(function(e){var pos=xyzObjectToArray(e.location,tempVec3$5);var dir=xyzObjectToArray(e.direction,tempVec3$5);if(reverseClippingPlanes){math.negateVec3(dir);}math.subVec3(pos,realWorldOffset);if(camera.yUp){pos=ZToY(pos);dir=ZToY(dir);}new SectionPlane(scene,{pos:pos,dir:dir});});}scene.clearLines();if(bcfViewpoint.lines&&bcfViewpoint.lines.length>0){var positions=[];var indices=[];var _i157=0;bcfViewpoint.lines.forEach(function(e){if(!e.start_point){return;}if(!e.end_point){return;}positions.push(e.start_point.x);positions.push(e.start_point.y);positions.push(e.start_point.z);positions.push(e.end_point.x);positions.push(e.end_point.y);positions.push(e.end_point.z);indices.push(_i157++);indices.push(_i157++);});new LineSet(scene,{positions:positions,indices:indices,clippable:false,collidable:true});}scene.clearBitmaps();if(bcfViewpoint.bitmaps&&bcfViewpoint.bitmaps.length>0){bcfViewpoint.bitmaps.forEach(function(e){var bitmap_type=e.bitmap_type||"jpg";// "jpg" | "png"
14251
14239
  var bitmap_data=e.bitmap_data;// base64
14252
- var location=xyzObjectToArray(e.location,tempVec3a$u);var normal=xyzObjectToArray(e.normal,tempVec3b$p);var up=xyzObjectToArray(e.up,tempVec3c$l);var height=e.height||1;if(!bitmap_type){return;}if(!bitmap_data){return;}if(!location){return;}if(!normal){return;}if(!up){return;}if(camera.yUp){location=ZToY(location);normal=ZToY(normal);up=ZToY(up);}new Bitmap(scene,{src:bitmap_data,type:bitmap_type,pos:location,normal:normal,up:up,clippable:false,collidable:true,height:height});});}if(reset){scene.setObjectsXRayed(scene.xrayedObjectIds,false);scene.setObjectsHighlighted(scene.highlightedObjectIds,false);scene.setObjectsSelected(scene.selectedObjectIds,false);}if(bcfViewpoint.components){if(bcfViewpoint.components.visibility){if(!bcfViewpoint.components.visibility.default_visibility){scene.setObjectsVisible(scene.objectIds,false);if(bcfViewpoint.components.visibility.exceptions){bcfViewpoint.components.visibility.exceptions.forEach(function(component){return _this69._withBCFComponent(options,component,function(entity){return entity.visible=true;});});}}else{scene.setObjectsVisible(scene.objectIds,true);if(bcfViewpoint.components.visibility.exceptions){bcfViewpoint.components.visibility.exceptions.forEach(function(component){return _this69._withBCFComponent(options,component,function(entity){return entity.visible=false;});});}}var view_setup_hints=bcfViewpoint.components.visibility.view_setup_hints;if(view_setup_hints){if(view_setup_hints.spaces_visible===false){scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcSpace"),false);}if(view_setup_hints.openings_visible===false){scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcOpening"),false);}if(view_setup_hints.space_boundaries_visible!==undefined);}}if(bcfViewpoint.components.selection){scene.setObjectsSelected(scene.selectedObjectIds,false);bcfViewpoint.components.selection.forEach(function(component){return _this69._withBCFComponent(options,component,function(entity){return entity.selected=true;});});}if(bcfViewpoint.components.coloring){bcfViewpoint.components.coloring.forEach(function(coloring){var color=coloring.color;var alpha=0;var alphaDefined=false;if(color.length===8){alpha=parseInt(color.substring(0,2),16)/256;if(alpha<=1.0&&alpha>=0.95){alpha=1.0;}color=color.substring(2);alphaDefined=true;}var colorize=[parseInt(color.substring(0,2),16)/256,parseInt(color.substring(2,4),16)/256,parseInt(color.substring(4,6),16)/256];coloring.components.map(function(component){return _this69._withBCFComponent(options,component,function(entity){entity.colorize=colorize;if(alphaDefined){if(alpha===0&&_this69.xrayAsZeroAlpha){var savedFromXeokit=component.originating_system===_this69.originatingSystem;if(savedFromXeokit){entity.xrayed=true;}else{entity.opacity=alpha;}}else{entity.opacity=alpha;}}});});});}}if(bcfViewpoint.perspective_camera||bcfViewpoint.orthogonal_camera){var eye;var look;var up;var projection;if(bcfViewpoint.perspective_camera){eye=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_view_point,tempVec3$5);look=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_direction,tempVec3$5);up=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_up_vector,tempVec3$5);camera.perspective.fov=bcfViewpoint.perspective_camera.field_of_view;projection="perspective";}else{eye=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_view_point,tempVec3$5);look=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_direction,tempVec3$5);up=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_up_vector,tempVec3$5);camera.ortho.scale=bcfViewpoint.orthogonal_camera.view_to_world_scale;projection="ortho";}math.subVec3(eye,realWorldOffset);if(camera.yUp){eye=ZToY(eye);look=ZToY(look);up=ZToY(up);}if(rayCast){var hit=scene.pick({pickSurface:true,// <<------ This causes picking to find the intersection point on the entity
14240
+ var location=xyzObjectToArray(e.location,tempVec3a$u);var normal=xyzObjectToArray(e.normal,tempVec3b$p);var up=xyzObjectToArray(e.up,tempVec3c$l);var height=e.height||1;if(!bitmap_type){return;}if(!bitmap_data){return;}if(!location){return;}if(!normal){return;}if(!up){return;}if(camera.yUp){location=ZToY(location);normal=ZToY(normal);up=ZToY(up);}new Bitmap(scene,{src:bitmap_data,type:bitmap_type,pos:location,normal:normal,up:up,clippable:false,collidable:true,height:height});});}if(reset){scene.setObjectsXRayed(scene.xrayedObjectIds,false);scene.setObjectsHighlighted(scene.highlightedObjectIds,false);scene.setObjectsSelected(scene.selectedObjectIds,false);}if(bcfViewpoint.components){if(bcfViewpoint.components.visibility){if(!bcfViewpoint.components.visibility.default_visibility){scene.setObjectsVisible(scene.objectIds,false);if(bcfViewpoint.components.visibility.exceptions){bcfViewpoint.components.visibility.exceptions.forEach(function(component){return _this69._withBCFComponent(options,component,function(entity){return entity.visible=true;});});}}else{scene.setObjectsVisible(scene.objectIds,true);if(bcfViewpoint.components.visibility.exceptions){bcfViewpoint.components.visibility.exceptions.forEach(function(component){return _this69._withBCFComponent(options,component,function(entity){return entity.visible=false;});});}}var view_setup_hints=bcfViewpoint.components.visibility.view_setup_hints;if(view_setup_hints){if(view_setup_hints.spaces_visible===false){scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcSpace"),true);}if(view_setup_hints.spaces_translucent!==undefined){scene.setObjectsXRayed(viewer.metaScene.getObjectIDsByType("IfcSpace"),true);}if(view_setup_hints.space_boundaries_visible!==undefined);if(view_setup_hints.openings_visible===false){scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcOpening"),true);}if(view_setup_hints.space_boundaries_translucent!==undefined);if(view_setup_hints.openings_translucent!==undefined){scene.setObjectsXRayed(viewer.metaScene.getObjectIDsByType("IfcOpening"),true);}}}if(bcfViewpoint.components.selection){scene.setObjectsSelected(scene.selectedObjectIds,false);bcfViewpoint.components.selection.forEach(function(component){return _this69._withBCFComponent(options,component,function(entity){return entity.selected=true;});});}if(bcfViewpoint.components.translucency){scene.setObjectsXRayed(scene.xrayedObjectIds,false);bcfViewpoint.components.translucency.forEach(function(component){return _this69._withBCFComponent(options,component,function(entity){return entity.xrayed=true;});});}if(bcfViewpoint.components.coloring){bcfViewpoint.components.coloring.forEach(function(coloring){var color=coloring.color;var alpha=0;var alphaDefined=false;if(color.length===8){alpha=parseInt(color.substring(0,2),16)/256;if(alpha<=1.0&&alpha>=0.95){alpha=1.0;}color=color.substring(2);alphaDefined=true;}var colorize=[parseInt(color.substring(0,2),16)/256,parseInt(color.substring(2,4),16)/256,parseInt(color.substring(4,6),16)/256];coloring.components.map(function(component){return _this69._withBCFComponent(options,component,function(entity){entity.colorize=colorize;if(alphaDefined){entity.opacity=alpha;}});});});}}if(bcfViewpoint.perspective_camera||bcfViewpoint.orthogonal_camera){var eye;var look;var up;var projection;if(bcfViewpoint.perspective_camera){eye=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_view_point,tempVec3$5);look=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_direction,tempVec3$5);up=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_up_vector,tempVec3$5);camera.perspective.fov=bcfViewpoint.perspective_camera.field_of_view;projection="perspective";}else{eye=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_view_point,tempVec3$5);look=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_direction,tempVec3$5);up=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_up_vector,tempVec3$5);camera.ortho.scale=bcfViewpoint.orthogonal_camera.view_to_world_scale;projection="ortho";}math.subVec3(eye,realWorldOffset);if(camera.yUp){eye=ZToY(eye);look=ZToY(look);up=ZToY(up);}if(rayCast){var hit=scene.pick({pickSurface:true,// <<------ This causes picking to find the intersection point on the entity
14253
14241
  origin:eye,direction:look});look=hit?hit.worldPos:math.addVec3(eye,look,tempVec3$5);}else{look=math.addVec3(eye,look,tempVec3$5);}if(immediate){camera.eye=eye;camera.look=look;camera.up=up;camera.projection=projection;}else{viewer.cameraFlight.flyTo({eye:eye,look:look,up:up,duration:options.duration,projection:projection});}}}},{key:"_withBCFComponent",value:function _withBCFComponent(options,component,callback){var viewer=this.viewer;var scene=viewer.scene;if(component.authoring_tool_id&&component.originating_system===this.originatingSystem){var id=component.authoring_tool_id;var entity=scene.objects[id];if(entity){callback(entity);return;}if(options.updateCompositeObjects){var metaObject=viewer.metaScene.metaObjects[id];if(metaObject){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(id),callback);return;}}}if(component.ifc_guid){var originalSystemId=component.ifc_guid;var _entity=scene.objects[originalSystemId];if(_entity){callback(_entity);return;}if(options.updateCompositeObjects){var _metaObject=viewer.metaScene.metaObjects[originalSystemId];if(_metaObject){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(originalSystemId),callback);return;}}Object.keys(scene.models).forEach(function(modelId){var id=math.globalizeObjectId(modelId,originalSystemId);var entity=scene.objects[id];if(entity){callback(entity);return;}if(options.updateCompositeObjects){var _metaObject2=viewer.metaScene.metaObjects[id];if(_metaObject2){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(id),callback);}}});}}/**
14254
14242
  * Destroys this BCFViewpointsPlugin.
14255
14243
  */},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(BCFViewpointsPlugin.prototype),"destroy",this).call(this);}}]);return BCFViewpointsPlugin;}(Plugin);function xyzArrayToObject(arr){return{"x":arr[0],"y":arr[1],"z":arr[2]};}function xyzObjectToArray(xyz,arry){arry=new Float64Array(3);arry[0]=xyz.x;arry[1]=xyz.y;arry[2]=xyz.z;return arry;}function YToZ(vec){return new Float64Array([vec[0],-vec[2],vec[1]]);}function ZToY(vec){return new Float64Array([vec[0],vec[2],-vec[1]]);}function colorizeToRGB(color){var rgb="";rgb+=Math.round(color[0]*255).toString(16).padStart(2,"0");rgb+=Math.round(color[1]*255).toString(16).padStart(2,"0");rgb+=Math.round(color[2]*255).toString(16).padStart(2,"0");return rgb;}var distVec3=math.vec3();var lengthWire=function lengthWire(x1,y1,x2,y2){var a=x1-x2;var b=y1-y2;return Math.sqrt(a*a+b*b);};/**