@xeokit/xeokit-sdk 2.3.0-beta-19 → 2.3.0-beta-22

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.
@@ -104,7 +104,7 @@ class Item {
104
104
  * * Dynamically enable or disable items
105
105
  * * Dynamically show or hide items
106
106
  * * Supports cascading sub-menus
107
- * * Configure custom style with custom CSS (see examples above)
107
+ * * Configure custom style with CSS (see examples above)
108
108
  *
109
109
  * ## Usage
110
110
  *
@@ -1279,7 +1279,7 @@ const math = {
1279
1279
  * Returns true if the two 3-element vectors are the same.
1280
1280
  * @param v1
1281
1281
  * @param v2
1282
- * @returns {boolean}
1282
+ * @returns {Boolean}
1283
1283
  */
1284
1284
  compareVec3(v1, v2) {
1285
1285
  return (v1[0] === v2[0] && v1[1] === v2[1] && v1[2] === v2[2]);
@@ -3435,7 +3435,7 @@ const math = {
3435
3435
  * Returns true if the two 4x4 matrices are the same.
3436
3436
  * @param m1
3437
3437
  * @param m2
3438
- * @returns {boolean}
3438
+ * @returns {Boolean}
3439
3439
  */
3440
3440
  compareMat4(m1, m2) {
3441
3441
  return m1[0] === m2[0] &&
@@ -4342,7 +4342,7 @@ const math = {
4342
4342
  /** Returns true if the first AABB contains the second AABB.
4343
4343
  * @param aabb1
4344
4344
  * @param aabb2
4345
- * @returns {boolean}
4345
+ * @returns {Boolean}
4346
4346
  */
4347
4347
  containsAABB3: function (aabb1, aabb2) {
4348
4348
  const result = (
@@ -6738,7 +6738,7 @@ function isArray(value) {
6738
6738
  /**
6739
6739
  Tests if the given value is a string
6740
6740
  @param value
6741
- @returns {boolean}
6741
+ @returns {Boolean}
6742
6742
  @private
6743
6743
  */
6744
6744
  function isString(value) {
@@ -6748,7 +6748,7 @@ function isString(value) {
6748
6748
  /**
6749
6749
  Tests if the given value is a number
6750
6750
  @param value
6751
- @returns {boolean}
6751
+ @returns {Boolean}
6752
6752
  @private
6753
6753
  */
6754
6754
  function isNumeric(value) {
@@ -6758,7 +6758,7 @@ function isNumeric(value) {
6758
6758
  /**
6759
6759
  Tests if the given value is an ID
6760
6760
  @param value
6761
- @returns {boolean}
6761
+ @returns {Boolean}
6762
6762
  @private
6763
6763
  */
6764
6764
  function isID(value) {
@@ -6769,7 +6769,7 @@ function isID(value) {
6769
6769
  Tests if the given components are the same, where the components can be either IDs or instances.
6770
6770
  @param c1
6771
6771
  @param c2
6772
- @returns {boolean}
6772
+ @returns {Boolean}
6773
6773
  @private
6774
6774
  */
6775
6775
  function isSameComponent(c1, c2) {
@@ -6784,7 +6784,7 @@ function isSameComponent(c1, c2) {
6784
6784
  /**
6785
6785
  Tests if the given value is a function
6786
6786
  @param value
6787
- @returns {boolean}
6787
+ @returns {Boolean}
6788
6788
  @private
6789
6789
  */
6790
6790
  function isFunction$1(value) {
@@ -6794,7 +6794,7 @@ function isFunction$1(value) {
6794
6794
  /**
6795
6795
  Tests if the given value is a JavaScript JSON object, eg, ````{ foo: "bar" }````.
6796
6796
  @param value
6797
- @returns {boolean}
6797
+ @returns {Boolean}
6798
6798
  @private
6799
6799
  */
6800
6800
  function isObject$1(value) {
@@ -6852,7 +6852,7 @@ function applyIf(o, o2) {
6852
6852
  /**
6853
6853
  Returns true if the given map is empty.
6854
6854
  @param obj
6855
- @returns {boolean}
6855
+ @returns {Boolean}
6856
6856
  @private
6857
6857
  */
6858
6858
  function isEmptyObject$1(obj) {
@@ -9868,10 +9868,23 @@ class AngleMeasurement extends Component {
9868
9868
  return this._angle;
9869
9869
  }
9870
9870
 
9871
+ /**
9872
+ * Gets the color of the angle measurement.
9873
+ *
9874
+ * The color is an HTML string representation, eg. "#00BBFF" and "blue".
9875
+ *
9876
+ * @type {String}
9877
+ */
9871
9878
  get color() {
9872
9879
  return this._color;
9873
9880
  }
9874
9881
 
9882
+ /** Sets the color of the angle measurement.
9883
+ *
9884
+ * The color is given as an HTML string representation, eg. "#00BBFF" and "blue".
9885
+ *
9886
+ * @type {String}
9887
+ */
9875
9888
  set color(value) {
9876
9889
  this._originDot.setFillColor(value);
9877
9890
  this._cornerDot.setFillColor(value);
@@ -9886,7 +9899,7 @@ class AngleMeasurement extends Component {
9886
9899
  /**
9887
9900
  * Sets whether this AngleMeasurement is visible or not.
9888
9901
  *
9889
- * @type Boolean
9902
+ * @type {Boolean}
9890
9903
  */
9891
9904
  set visible(value) {
9892
9905
  value = value !== false;
@@ -9902,7 +9915,7 @@ class AngleMeasurement extends Component {
9902
9915
  /**
9903
9916
  * Gets whether this AngleMeasurement is visible or not.
9904
9917
  *
9905
- * @type Boolean
9918
+ * @type {Boolean}
9906
9919
  */
9907
9920
  get visible() {
9908
9921
  return this._visible;
@@ -10098,7 +10111,7 @@ class AngleMeasurementsControl extends Component {
10098
10111
 
10099
10112
  /** Gets if this AngleMeasurementsControl is currently active, where it is responding to input.
10100
10113
  *
10101
- * @returns {boolean}
10114
+ * @returns {Boolean}
10102
10115
  */
10103
10116
  get active() {
10104
10117
  return this._active;
@@ -13746,7 +13759,7 @@ class OcclusionTester {
13746
13759
  /**
13747
13760
  * Returns true if an occlusion test is needed.
13748
13761
  *
13749
- * @returns {boolean}
13762
+ * @returns {Boolean}
13750
13763
  */
13751
13764
  get needOcclusionTest() {
13752
13765
  return this._occlusionTestListDirty;
@@ -15499,7 +15512,7 @@ const Renderer = function (scene, options) {
15499
15512
 
15500
15513
  /**
15501
15514
  * Returns true if the next call to render() will draw something
15502
- * @returns {boolean}
15515
+ * @returns {Boolean}
15503
15516
  */
15504
15517
  this.needsRender = function () {
15505
15518
  return (imageDirty || drawableListDirty || stateSortDirty);
@@ -19882,7 +19895,7 @@ class Camera extends Component {
19882
19895
 
19883
19896
  /**
19884
19897
  * Gets if the World-space X-axis is "up".
19885
- * @returns {boolean}
19898
+ * @returns {Boolean}
19886
19899
  */
19887
19900
  get xUp() {
19888
19901
  return this._worldUp[0] > this._worldUp[1] && this._worldUp[0] > this._worldUp[2];
@@ -19890,7 +19903,7 @@ class Camera extends Component {
19890
19903
 
19891
19904
  /**
19892
19905
  * Gets if the World-space Y-axis is "up".
19893
- * @returns {boolean}
19906
+ * @returns {Boolean}
19894
19907
  */
19895
19908
  get yUp() {
19896
19909
  return this._worldUp[1] > this._worldUp[0] && this._worldUp[1] > this._worldUp[2];
@@ -19898,7 +19911,7 @@ class Camera extends Component {
19898
19911
 
19899
19912
  /**
19900
19913
  * Gets if the World-space Z-axis is "up".
19901
- * @returns {boolean}
19914
+ * @returns {Boolean}
19902
19915
  */
19903
19916
  get zUp() {
19904
19917
  return this._worldUp[2] > this._worldUp[0] && this._worldUp[2] > this._worldUp[1];
@@ -21294,7 +21307,7 @@ class ReadableGeometry extends Geometry {
21294
21307
 
21295
21308
  /**
21296
21309
  * @private
21297
- * @returns {boolean}
21310
+ * @returns {Boolean}
21298
21311
  */
21299
21312
  get isReadableGeometry() {
21300
21313
  return true;
@@ -24491,7 +24504,7 @@ class SAO extends Component {
24491
24504
  * Returns true if SAO is currently possible, where it is supported, enabled, and the current scene state is compatible.
24492
24505
  * Called internally by renderer logic.
24493
24506
  * @private
24494
- * @returns {boolean}
24507
+ * @returns {Boolean}
24495
24508
  */
24496
24509
  get possible() {
24497
24510
  if (!this._supported) {
@@ -25912,16 +25925,16 @@ class Scene extends Component {
25912
25925
  this.reflectionMaps = {};
25913
25926
 
25914
25927
  /**
25915
- * The {@link Bitmaps}s in this Scene, each mapped to its {@link Bitmap#id}.
25928
+ * The {@link Bitmap}s in this Scene, each mapped to its {@link Bitmap#id}.
25916
25929
  *
25917
25930
  * @type {{String:Bitmap}}
25918
25931
  */
25919
25932
  this.bitmaps = {};
25920
25933
 
25921
25934
  /**
25922
- * The {@link Line}s in this Scene, each mapped to its {@link Line#id}.
25935
+ * The {@link LineSet}s in this Scene, each mapped to its {@link LineSet#id}.
25923
25936
  *
25924
- * @type {{String:Line}}
25937
+ * @type {{String:LineSet}}
25925
25938
  */
25926
25939
  this.lineSets = {};
25927
25940
 
@@ -27846,9 +27859,24 @@ class Scene extends Component {
27846
27859
  }
27847
27860
  }
27848
27861
 
27862
+ /**
27863
+ * Texture repeat wrapping mode.
27864
+ * @type {number}
27865
+ */
27849
27866
  const RepeatWrapping = 1000;
27867
+
27868
+ /**
27869
+ * Texture clamp-to-edge wrapping mode.
27870
+ * @type {number}
27871
+ */
27850
27872
  const ClampToEdgeWrapping = 1001;
27873
+
27874
+ /**
27875
+ * Texture mirrored-repeat wrapping mode.
27876
+ * @type {number}
27877
+ */
27851
27878
  const MirroredRepeatWrapping = 1002;
27879
+
27852
27880
  const NearestFilter = 1003;
27853
27881
  const NearestMipMapNearestFilter = 1004;
27854
27882
  const NearestMipmapNearestFilter = 1004;
@@ -42390,7 +42418,7 @@ class VBOGeometry extends Geometry {
42390
42418
 
42391
42419
  /**
42392
42420
  * @private
42393
- * @returns {boolean}
42421
+ * @returns {Boolean}
42394
42422
  */
42395
42423
  get isVBOGeometry() {
42396
42424
  return true;
@@ -44439,14 +44467,14 @@ function buildTorusGeometry(cfg = {}) {
44439
44467
  *
44440
44468
  * * Creates a 3D quad containing our bitmap, located and oriented using ````pos````, ````normal```` and ````up```` vectors.
44441
44469
  * * Registered by {@link Bitmap#id} in {@link Scene#bitmaps}.
44442
- * * Created when we use {@link BCFViewpointsPlugin#setViewpoint} to load a BCF viewpoint that contains bitmaps.
44470
+ * * {@link BCFViewpointsPlugin} will save and load Bitmaps in BCF viewpoints.
44443
44471
  *
44444
44472
  * ## Usage
44445
44473
  *
44446
44474
  * In the example below, we'll load the Schependomlaan model, then use
44447
44475
  * an ````Bitmap```` to show a storey plan next to the model.
44448
44476
  *
44449
- * [<img src="http://xeokit.github.io/xeokit-sdk/assets/images/Bitmap_grid.png">](http://xeokit.github.io/xeokit-sdk/examples/#Bitmap_grid)
44477
+ * [<img src="http://xeokit.github.io/xeokit-sdk/assets/images/Bitmap_storeyPlan.png">](http://xeokit.github.io/xeokit-sdk/examples/#Bitmap_storeyPlan)
44450
44478
  *
44451
44479
  * [[Run this example](http://xeokit.github.io/xeokit-sdk/examples/#Bitmap_grid)]
44452
44480
  *
@@ -44486,6 +44514,10 @@ function buildTorusGeometry(cfg = {}) {
44486
44514
  class Bitmap extends Component {
44487
44515
 
44488
44516
  /**
44517
+ * Creates a new Bitmap.
44518
+ *
44519
+ * Registers the Bitmap in {@link Scene#bitmaps}; causes Scene to fire a "bitmapCreated" event.
44520
+ *
44489
44521
  * @constructor
44490
44522
  * @param {Component} [owner] Owner component. When destroyed, the owner will destroy this ````Bitmap```` as well.
44491
44523
  * @param {*} [cfg] ````Bitmap```` configuration
@@ -44877,7 +44909,9 @@ class Bitmap extends Component {
44877
44909
  }
44878
44910
 
44879
44911
  /**
44880
- * @destroy
44912
+ * Destroys this ````Bitmap````.
44913
+ *
44914
+ * Removes the ```Bitmap```` from {@link Scene#bitmaps}; causes Scene to fire a "bitmapDestroyed" event.
44881
44915
  */
44882
44916
  destroy() {
44883
44917
  super.destroy();
@@ -44896,13 +44930,13 @@ class Bitmap extends Component {
44896
44930
  * * Creates a set of 3D line segments.
44897
44931
  * * Registered by {@link LineSet#id} in {@link Scene#lineSets}.
44898
44932
  * * Configure color using the {@link LinesMaterial} located at {@link Scene#linesMaterial}.
44899
- * * Created when we use {@link BCFViewpointsPlugin#setViewpoint} to load a BCF viewpoint that contains lines.
44933
+ * * {@link BCFViewpointsPlugin} will save and load Linesets in BCF viewpoints.
44934
+ *
44935
+ * ## Usage
44900
44936
  *
44901
44937
  * In the example below, we'll load the Schependomlaan model, then use
44902
44938
  * a ````LineSet```` to show a grid underneath the model.
44903
44939
  *
44904
- * <img src="http://xeokit.io/img/docs/Bitmap/BCF_SaveViewpoint_BitmapsAndLines.png">
44905
- *
44906
44940
  * [<img src="http://xeokit.github.io/xeokit-sdk/assets/images/LineSet_grid.png">](http://xeokit.github.io/xeokit-sdk/examples/#LineSet_grid)
44907
44941
  *
44908
44942
  * [[Run this example](http://xeokit.github.io/xeokit-sdk/examples/#LineSet_grid)]
@@ -44926,8 +44960,7 @@ class Bitmap extends Component {
44926
44960
  * const model = xktLoader.load({
44927
44961
  * id: "myModel",
44928
44962
  * src: "../assets/models/xkt/v8/ifc/Schependomlaan.ifc.xkt",
44929
- *
44930
- * position: [0,1,0],
44963
+ * position: [0,1,0],
44931
44964
  * edges: true,
44932
44965
  * saoEnabled: true
44933
44966
  * });
@@ -44946,15 +44979,19 @@ class Bitmap extends Component {
44946
44979
  class LineSet extends Component {
44947
44980
 
44948
44981
  /**
44982
+ * Creates a new LineSet.
44983
+ *
44984
+ * Registers the LineSet in {@link Scene#lineSets}; causes Scene to fire a "lineSetCreated" event.
44985
+ *
44949
44986
  * @constructor
44950
44987
  * @param {Component} [owner] Owner component. When destroyed, the owner will destroy this ````LineSet```` as well.
44951
44988
  * @param {*} [cfg] ````LineSet```` configuration
44952
44989
  * @param {String} [cfg.id] Optional ID, unique among all components in the parent {@link Scene}, generated automatically when omitted.
44953
- * @param {Number[]} cfg.positions World-space vertex positions.
44954
- * @param {Number[]} [cfg.indices] Indices
44955
- * @param {Number[]} [cfg.color=[0,0,0]] The color of this ````LineSet````.
44990
+ * @param {Number[]} cfg.positions World-space 3D vertex positions.
44991
+ * @param {Number[]} [cfg.indices] Indices to connect ````positions```` into line segments. Note that these are separate line segments, not a polyline.
44992
+ * @param {Number[]} [cfg.color=[0,0,0]] The color of this ````LineSet````. This is both emissive and diffuse.
44956
44993
  * @param {Boolean} [cfg.visible=true] Indicates whether or not this ````LineSet```` is visible.
44957
- * @param {Number} [cfg.opacity=1.0] ````LineSet````'s initial opacity factor, multiplies by the rendered fragment alpha.
44994
+ * @param {Number} [cfg.opacity=1.0] ````LineSet````'s initial opacity factor.
44958
44995
  */
44959
44996
  constructor(owner, cfg = {}) {
44960
44997
 
@@ -44994,7 +45031,7 @@ class LineSet extends Component {
44994
45031
  }
44995
45032
 
44996
45033
  /**
44997
- * Sets if this ````LineSet```` is visible or not.
45034
+ * Sets if this ````LineSet```` is visible.
44998
45035
  *
44999
45036
  * Default value is ````true````.
45000
45037
  *
@@ -45005,7 +45042,7 @@ class LineSet extends Component {
45005
45042
  }
45006
45043
 
45007
45044
  /**
45008
- * Gets if this ````LineSet```` is visible or not.
45045
+ * Gets if this ````LineSet```` is visible.
45009
45046
  *
45010
45047
  * Default value is ````true````.
45011
45048
  *
@@ -45016,7 +45053,7 @@ class LineSet extends Component {
45016
45053
  }
45017
45054
 
45018
45055
  /**
45019
- * Gets the vertex positions of the lines in this ````LineSet````.
45056
+ * Gets the 3D World-space vertex positions of the lines in this ````LineSet````.
45020
45057
  *
45021
45058
  * @returns {Number[]}
45022
45059
  */
@@ -45034,7 +45071,9 @@ class LineSet extends Component {
45034
45071
  }
45035
45072
 
45036
45073
  /**
45037
- * @destroy
45074
+ * Destroys this ````LineSet````.
45075
+ *
45076
+ * Removes the ```LineSet```` from {@link Scene#lineSets}; causes Scene to fire a "lineSetDestroyed" event.
45038
45077
  */
45039
45078
  destroy() {
45040
45079
  super.destroy();
@@ -45050,19 +45089,46 @@ const tempVec3c$6 = math.vec3();
45050
45089
  /**
45051
45090
  * {@link Viewer} plugin that saves and loads BCF viewpoints as JSON objects.
45052
45091
  *
45053
- * BCF is a format for managing issues on a BIM project. This plugin's viewpoints conform to
45054
- * the <a href="https://github.com/buildingSMART/BCF-API">BCF Version 2.1</a> specification.
45092
+ * [<img src="http://xeokit.github.io/xeokit-sdk/assets/images/BCFViewpointsPlugin.png">](http://xeokit.github.io/xeokit-sdk/examples/#BCF_SaveViewpoint)
45093
+ *
45094
+ * * [[Example 1: Saving viewer state to a BCF viewpoint](https://xeokit.github.io/xeokit-sdk/examples/#BCF_SaveViewpoint)]
45095
+ * * [[Example 2: Loading viewer state from a BCF viewpoint](https://xeokit.github.io/xeokit-sdk/examples/#BCF_LoadViewpoint)]
45096
+ *
45097
+ * ## Overview
45098
+ *
45099
+ * BCF is an open standard that enables workflow communications between BIM software tools. An XML schema, called
45100
+ * Building Collaboration Format (BCF), encodes messages that inform one BIM tool of issues found by another.
45101
+ *
45102
+ * A BCF viewpoint captures a viewpoint of a model that highlights an issue. The viewpoint can then be loaded by another
45103
+ * viewer to examine the issue.
45104
+ *
45105
+ * Using this plugin, a xeokit {@link Viewer} can exchange BCF-encoded viewpoints with other BIM software,
45106
+ * allowing us to use the Viewer to report and view issues in BIM models.
45107
+ *
45108
+ * This plugin's viewpoints conform to the <a href="https://github.com/buildingSMART/BCF-API">BCF Version 2.1</a> specification.
45109
+ *
45110
+ * ## Supported BCF Elements
45111
+ *
45112
+ * BCFViewpointsPlugin saves and loads the following state in BCF viewpoints:
45113
+ *
45114
+ * * {@link Camera} position, orientation and projection
45115
+ * * {@link Entity} visibilities and selection states
45116
+ * * {@link SectionPlane}s to slice the model
45117
+ * * {@link LineSet}s to show 3D lines
45118
+ * * {@link Bitmap}s to show images
45055
45119
  *
45056
45120
  * ## Saving a BCF Viewpoint
45057
45121
  *
45058
45122
  * In the example below we'll create a {@link Viewer}, load an ````.XKT```` model into it using an {@link XKTLoaderPlugin},
45059
- * slice the model in half using a {@link SectionPlanesPlugin}, then use a {@link BCFViewpointsPlugin#getViewpoint}
45123
+ * slice the model in half using a {@link SectionPlanesPlugin}, create a grid ground plane using a {@link LineSet} and a 2D
45124
+ * plan view using a {@link Bitmap}, then use a {@link BCFViewpointsPlugin#getViewpoint}
45060
45125
  * to save a viewpoint to JSON, which we'll log to the JavaScript developer console.
45061
45126
  *
45062
- * * [[Run this example](http://xeokit.github.io/xeokit-sdk/examples/#BCF_SaveViewpoint)]
45127
+ * * [[Run this example](https://xeokit.github.io/xeokit-sdk/examples/#BCF_SaveViewpoint)]
45063
45128
  *
45064
45129
  * ````javascript
45065
- * import {Viewer, XKTLoaderPlugin, SectionPlanesPlugin, BCFViewpointsPlugin} from "xeokit-sdk.es.js";
45130
+ * import {Viewer, XKTLoaderPlugin, SectionPlanesPlugin,
45131
+ * LineSet, Bitmap, buildGridGeometry, BCFViewpointsPlugin} from "xeokit-sdk.es.js";
45066
45132
  *
45067
45133
  * // Create a Viewer
45068
45134
  * const viewer = new Viewer({
@@ -45070,6 +45136,12 @@ const tempVec3c$6 = math.vec3();
45070
45136
  * transparent: true
45071
45137
  * });
45072
45138
  *
45139
+ * // Set camera position and orientation
45140
+ * viewer.scene.camera.eye = [-48.93, 54.54, 50.41];
45141
+ * viewer.scene.camera.look = [0.55, -0.61, -0.55];
45142
+ * viewer.scene.camera.up = [0, -1, 0];
45143
+ * viewer.scene.camera.perspective.fov = 60;
45144
+ *
45073
45145
  * // Add a XKTLoaderPlugin
45074
45146
  * const xktLoader = new XKTLoaderPlugin(viewer);
45075
45147
  *
@@ -45093,15 +45165,37 @@ const tempVec3c$6 = math.vec3();
45093
45165
  * dir: [0.5, 0.0, 0.5]
45094
45166
  * });
45095
45167
  *
45096
- * // When model is loaded, set camera, select some objects and capture a BCF viewpoint to the console
45168
+ * // Create a bitmap
45169
+ * const bitmap = new Bitmap(viewer.scene, {
45170
+ * src: "../assets/images/schependomlaanPlanView.png",
45171
+ * visible: true,
45172
+ * height: 24.0,
45173
+ * pos: [-15, 0, -10],
45174
+ * normal: [0, -1, 0],
45175
+ * up: [0, 0, 1],
45176
+ * collidable: false,
45177
+ * opacity: 1.0,
45178
+ * clippable: false,
45179
+ * pickable: true
45180
+ * });
45181
+ *
45182
+ * // Create a grid ground plane
45183
+ * const geometryArrays = buildGridGeometry({
45184
+ * size: 60,
45185
+ * divisions: 10
45186
+ * });
45187
+ *
45188
+ * new LineSet(viewer.scene, {
45189
+ * positions: geometryArrays.positions,
45190
+ * indices: geometryArrays.indices,
45191
+ * position: [10,0,10],
45192
+ * clippable: false
45193
+ * });
45194
+ *
45195
+ * // When model is loaded, select some objects and capture a BCF viewpoint to the console
45097
45196
  * modelNode.on("loaded", () => {
45098
45197
  *
45099
45198
  * const scene = viewer.scene;
45100
- * const camera = scene.camera;
45101
- *
45102
- * camera.eye = [-2.37, 18.97, -26.12];
45103
- * camera.look = [10.97, 5.82, -11.22];
45104
- * camera.up = [0.36, 0.83, 0.40];
45105
45199
  *
45106
45200
  * scene.setObjectsSelected([
45107
45201
  * "3b2U496P5Ebhz5FROhTwFH",
@@ -45118,6 +45212,57 @@ const tempVec3c$6 = math.vec3();
45118
45212
  * });
45119
45213
  * ````
45120
45214
  *
45215
+ * The saved BCF viewpoint would look something like below. Note that some elements are truncated for brevity.
45216
+ *
45217
+ * ````json
45218
+ * {
45219
+ * "perspective_camera": {
45220
+ * "camera_view_point": { "x": -48.93, "y": 54.54, "z": 50.41 },
45221
+ * "camera_direction": { "x": 0.55, "y": -0.61, "z": -0.55},
45222
+ * "camera_up_vector": { "x": 0.37, "y": -0.41, "z": 0.83 },
45223
+ * "field_of_view": 60.0
45224
+ * },
45225
+ * "lines": [{
45226
+ * "start_point": { "x": 1.0, "y": 1.0, "z": 1.0 },
45227
+ * "end_point": { "x": 0.0, "y": 0.0, "z": 0.0 },
45228
+ * //...(truncated)
45229
+ * }],
45230
+ * "bitmaps": [{
45231
+ * "bitmap_type": "png",
45232
+ * "bitmap_data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB9AAAAdp...", //...(truncated)
45233
+ * "location": { "x": -15, "y": 10, "z": 0 },
45234
+ * "normal": { "x": 0, "y": 0, "z": -1 },
45235
+ * "up": { "x": 0, "y": -1, "z": 0 },
45236
+ * "height": 24
45237
+ * }],
45238
+ * "clipping_planes": [{
45239
+ * "location": { "x": 0.0, "y": 0.0, "z": 0.0 },
45240
+ * "direction": { "x": 0.5, "y": 0.0, "z": 0.5 }
45241
+ * }],
45242
+ * "snapshot": {
45243
+ * "snapshot_type": "png",
45244
+ * "snapshot_data": "data:image/png;base64,......"
45245
+ * },
45246
+ * "components": {
45247
+ * "visibility": {
45248
+ * "default_visibility": false,
45249
+ * "exceptions": [{
45250
+ * "ifc_guid": "4$cshxZO9AJBebsni$z9Yk",
45251
+ * "originating_system": "xeokit.io",
45252
+ * "authoring_tool_id": "xeokit/v3.2"
45253
+ * },
45254
+ * //...
45255
+ * ]
45256
+ * },
45257
+ * "selection": [{
45258
+ * "ifc_guid": "4$cshxZO9AJBebsni$z9Yk",
45259
+ * },
45260
+ * //...
45261
+ * ]
45262
+ * }
45263
+ * }
45264
+ * ````
45265
+ *
45121
45266
  * ## Saving View Setup Hints
45122
45267
  *
45123
45268
  * BCFViewpointsPlugin can optionally save hints in the viewpoint, which indicate how to set up the view when
@@ -45161,7 +45306,7 @@ const tempVec3c$6 = math.vec3();
45161
45306
  * });
45162
45307
  * ````
45163
45308
  *
45164
- * ## Dealing With Loaded Models That Are Not in the Viewpoint
45309
+ * ## Dealing With Loaded Models that are not in the Viewpoint
45165
45310
  *
45166
45311
  * If, for example, we load model "duplex", hide some objects, then save a BCF viewpoint with
45167
45312
  * ````BCFViewpointsPlugin#getViewpoint````, then load another model, "schependomlaan", then load the viewpoint again
@@ -45270,8 +45415,7 @@ class BCFViewpointsPlugin extends Plugin {
45270
45415
  /**
45271
45416
  * Saves viewer state to a BCF viewpoint.
45272
45417
  *
45273
- * Note that xeokit's {@link Camera#look} is the **point-of-interest**, whereas the BCF ````camera_direction```` is a
45274
- * direction vector. Therefore, we save ````camera_direction```` as the vector from {@link Camera#eye} to {@link Camera#look}.
45418
+ * See ````BCFViewpointsPlugin```` class comments for more info.
45275
45419
  *
45276
45420
  * @param {*} [options] Options for getting the viewpoint.
45277
45421
  * @param {Boolean} [options.spacesVisible=false] Indicates whether ````IfcSpace```` types should be forced visible in the viewpoint.
@@ -45284,84 +45428,6 @@ class BCFViewpointsPlugin extends Plugin {
45284
45428
  * objects in the viewpoint will be visible.
45285
45429
  * @param {Boolean} [options.reverseClippingPlanes=false] When ````true````, clipping planes are reversed (https://github.com/buildingSMART/BCF-XML/issues/193)
45286
45430
  * @returns {*} BCF JSON viewpoint object
45287
- * @example
45288
- *
45289
- * const viewer = new Viewer();
45290
- *
45291
- * const bcfPlugin = new BCFPlugin(viewer, {
45292
- * //...
45293
- * });
45294
- *
45295
- * const viewpoint = bcfPlugin.getViewpoint({ // Options - see constructor
45296
- * spacesVisible: false, // Default
45297
- * spaceBoundariesVisible: false, // Default
45298
- * openingsVisible: false // Default
45299
- * });
45300
- *
45301
- * // viewpoint will resemble the following:
45302
- *
45303
- * {
45304
- * perspective_camera: {
45305
- * camera_view_point: {
45306
- * x: 0.0,
45307
- * y: 0.0,
45308
- * z: 0.0
45309
- * },
45310
- * camera_direction: {
45311
- * x: 1.0,
45312
- * y: 1.0,
45313
- * z: 2.0
45314
- * },
45315
- * camera_up_vector: {
45316
- * x: 0.0,
45317
- * y: 0.0,
45318
- * z: 1.0
45319
- * },
45320
- * field_of_view: 90.0
45321
- * },
45322
- * lineSets: [{
45323
- * start_point: {
45324
- * x: 1.0,
45325
- * y: 1.0,
45326
- * z: 1.0
45327
- * },
45328
- * end_point: {
45329
- * x: 0.0,
45330
- * y: 0.0,
45331
- * z: 0.0
45332
- * }
45333
- * }],
45334
- * clipping_planes: [{
45335
- * location: {
45336
- * x: 0.5,
45337
- * y: 0.5,
45338
- * z: 0.5
45339
- * },
45340
- * direction: {
45341
- * x: 1.0,
45342
- * y: 0.0,
45343
- * z: 0.0
45344
- * }
45345
- * }],
45346
- * bitmaps: [],
45347
- * snapshot: {
45348
- * snapshot_type: png,
45349
- * snapshot_data: "data:image/png;base64,......"
45350
- * },
45351
- * components: {
45352
- * visibility: {
45353
- * default_visibility: false,
45354
- * exceptions: [{
45355
- * ifc_guid: 4$cshxZO9AJBebsni$z9Yk,
45356
- * originating_system: xeokit.io,
45357
- * authoring_tool_id: xeokit/v1.0
45358
- * }]
45359
- * },
45360
- * selection: [{
45361
- * ifc_guid: "4$cshxZO9AJBebsni$z9Yk",
45362
- * }]
45363
- * }
45364
- * }
45365
45431
  */
45366
45432
  getViewpoint(options = {}) {
45367
45433
  const scene = this.viewer.scene;
@@ -45683,7 +45749,9 @@ class BCFViewpointsPlugin extends Plugin {
45683
45749
  });
45684
45750
  new LineSet(scene, {
45685
45751
  positions,
45686
- indices
45752
+ indices,
45753
+ clippable: false,
45754
+ collidable: true
45687
45755
  });
45688
45756
  }
45689
45757
 
@@ -45696,6 +45764,7 @@ class BCFViewpointsPlugin extends Plugin {
45696
45764
  let location = xyzObjectToArray(e.location, tempVec3a$X);
45697
45765
  let normal = xyzObjectToArray(e.normal, tempVec3b$9);
45698
45766
  let up = xyzObjectToArray(e.up, tempVec3c$6);
45767
+ let height = e.height || 1;
45699
45768
  if (!bitmap_type) {
45700
45769
  return;
45701
45770
  }
@@ -45721,7 +45790,10 @@ class BCFViewpointsPlugin extends Plugin {
45721
45790
  type: bitmap_type,
45722
45791
  pos: location,
45723
45792
  normal: normal,
45724
- up: up
45793
+ up: up,
45794
+ clippable: false,
45795
+ collidable: true,
45796
+ height
45725
45797
  });
45726
45798
  });
45727
45799
  }
@@ -46360,7 +46432,7 @@ class DistanceMeasurement extends Component {
46360
46432
  /**
46361
46433
  * Sets whether this DistanceMeasurement is visible or not.
46362
46434
  *
46363
- * @type Boolean
46435
+ * @type {Boolean}
46364
46436
  */
46365
46437
  set visible(value) {
46366
46438
  value = value !== undefined ? Boolean(value) : this.plugin.defaultVisible;
@@ -46381,7 +46453,7 @@ class DistanceMeasurement extends Component {
46381
46453
  /**
46382
46454
  * Gets whether this DistanceMeasurement is visible or not.
46383
46455
  *
46384
- * @type Boolean
46456
+ * @type {Boolean}
46385
46457
  */
46386
46458
  get visible() {
46387
46459
  return this._visible;
@@ -46562,7 +46634,7 @@ class DistanceMeasurementsControl extends Component {
46562
46634
 
46563
46635
  /** Gets if this DistanceMeasurementsControl is currently active, where it is responding to input.
46564
46636
  *
46565
- * @returns {boolean}
46637
+ * @returns {Boolean}
46566
46638
  */
46567
46639
  get active() {
46568
46640
  return this._active;
@@ -54294,7 +54366,7 @@ class TrianglesBatchingLayer {
54294
54366
  *
54295
54367
  * @param lenPositions Number of positions we'd like to create in the portion.
54296
54368
  * @param lenIndices Number of indices we'd like to create in this portion.
54297
- * @returns {boolean} True if OK to create another portion.
54369
+ * @returns {Boolean} True if OK to create another portion.
54298
54370
  */
54299
54371
  canCreatePortion(lenPositions, lenIndices) {
54300
54372
  if (this._finalized) {
@@ -63724,7 +63796,7 @@ class LinesBatchingLayer {
63724
63796
  *
63725
63797
  * @param lenPositions Number of positions we'd like to create in the portion.
63726
63798
  * @param lenIndices Number of indices we'd like to create in this portion.
63727
- * @returns {boolean} True if OK to create another portion.
63799
+ * @returns {Boolean} True if OK to create another portion.
63728
63800
  */
63729
63801
  canCreatePortion(lenPositions, lenIndices) {
63730
63802
  if (this._finalized) {
@@ -67669,7 +67741,7 @@ class PointsBatchingLayer {
67669
67741
  * Tests if there is room for another portion in this PointsBatchingLayer.
67670
67742
  *
67671
67743
  * @param lenPositions Number of positions we'd like to create in the portion.
67672
- * @returns {boolean} True if OK to create another portion.
67744
+ * @returns {Boolean} True if OK to create another portion.
67673
67745
  */
67674
67746
  canCreatePortion(lenPositions) {
67675
67747
  if (this._finalized) {
@@ -72807,6 +72879,34 @@ class SceneModel {
72807
72879
  }
72808
72880
  }
72809
72881
 
72882
+ const Cache = {
72883
+
72884
+ enabled: false,
72885
+ files: {},
72886
+
72887
+ add: function (key, file) {
72888
+ if (this.enabled === false) {
72889
+ return;
72890
+ }
72891
+ this.files[key] = file;
72892
+ },
72893
+
72894
+ get: function (key) {
72895
+ if (this.enabled === false) {
72896
+ return;
72897
+ }
72898
+ return this.files[key];
72899
+ },
72900
+
72901
+ remove: function (key) {
72902
+ delete this.files[key];
72903
+ },
72904
+
72905
+ clear: function () {
72906
+ this.files = {};
72907
+ }
72908
+ };
72909
+
72810
72910
  class LoadingManager {
72811
72911
 
72812
72912
  constructor(onLoad, onProgress, onError) {
@@ -72944,138 +73044,6 @@ class Loader {
72944
73044
  }
72945
73045
  }
72946
73046
 
72947
- /**
72948
- * @author Deepkolos / https://github.com/deepkolos
72949
- */
72950
-
72951
- class WorkerPool$1 {
72952
-
72953
- constructor(pool = 4) {
72954
- this.pool = pool;
72955
- this.queue = [];
72956
- this.workers = [];
72957
- this.workersResolve = [];
72958
- this.workerStatus = 0;
72959
- }
72960
-
72961
- _initWorker(workerId) {
72962
- if (!this.workers[workerId]) {
72963
- const worker = this.workerCreator();
72964
- worker.addEventListener('message', this._onMessage.bind(this, workerId));
72965
- this.workers[workerId] = worker;
72966
- }
72967
- }
72968
-
72969
- _getIdleWorker() {
72970
- for (let i = 0; i < this.pool; i++)
72971
- if (!(this.workerStatus & (1 << i))) return i;
72972
- return -1;
72973
- }
72974
-
72975
- _onMessage(workerId, msg) {
72976
- const resolve = this.workersResolve[workerId];
72977
- resolve && resolve(msg);
72978
- if (this.queue.length) {
72979
- const {resolve, msg, transfer} = this.queue.shift();
72980
- this.workersResolve[workerId] = resolve;
72981
- this.workers[workerId].postMessage(msg, transfer);
72982
- } else {
72983
- this.workerStatus ^= 1 << workerId;
72984
- }
72985
- }
72986
-
72987
- setWorkerCreator(workerCreator) {
72988
- this.workerCreator = workerCreator;
72989
- }
72990
-
72991
- setWorkerLimit(pool) {
72992
- this.pool = pool;
72993
- }
72994
-
72995
- postMessage(msg, transfer) {
72996
- return new Promise((resolve) => {
72997
- const workerId = this._getIdleWorker();
72998
- if (workerId !== -1) {
72999
- this._initWorker(workerId);
73000
- this.workerStatus |= 1 << workerId;
73001
- this.workersResolve[workerId] = resolve;
73002
- this.workers[workerId].postMessage(msg, transfer);
73003
- } else {
73004
- this.queue.push({resolve, msg, transfer});
73005
- }
73006
- });
73007
- }
73008
-
73009
- destroy() {
73010
-
73011
- this.workers.forEach((worker) => worker.terminate());
73012
- this.workersResolve.length = 0;
73013
- this.workers.length = 0;
73014
- this.queue.length = 0;
73015
- this.workerStatus = 0;
73016
-
73017
- }
73018
-
73019
- }
73020
-
73021
- /**
73022
- * Transcodes texture data.
73023
- *
73024
- * A {@link SceneModel} configured with an appropriate TextureTranscoder will allow us to add textures from
73025
- * transcoded buffers or files. For a concrete example, see {@link VBOSceneModel}, which can be configured with
73026
- * a {@link KTX2TextureTranscoder}, which allows us to add textures from KTX2 buffers and files.
73027
- *
73028
- * @interface
73029
- */
73030
- class TextureTranscoder {
73031
-
73032
- /**
73033
- * Transcodes texture data from transcoded buffers into a {@link Texture2D}.
73034
- *
73035
- * @param {ArrayBuffer[]} buffers Transcoded texture data. Given as an array of buffers so that we can support
73036
- * multi-image textures, such as cube maps.
73037
- * @param {*} config Transcoding options.
73038
- * @param {Texture2D} texture The texture to load.
73039
- * @returns {Promise} Resolves when the texture has loaded.
73040
- */
73041
- transcode(buffers, texture, config = {}) {
73042
- }
73043
-
73044
- /**
73045
- * Destroys this transcoder.
73046
- */
73047
- destroy() {
73048
- }
73049
- }
73050
-
73051
- const Cache = {
73052
-
73053
- enabled: false,
73054
- files: {},
73055
-
73056
- add: function (key, file) {
73057
- if (this.enabled === false) {
73058
- return;
73059
- }
73060
- this.files[key] = file;
73061
- },
73062
-
73063
- get: function (key) {
73064
- if (this.enabled === false) {
73065
- return;
73066
- }
73067
- return this.files[key];
73068
- },
73069
-
73070
- remove: function (key) {
73071
- delete this.files[key];
73072
- },
73073
-
73074
- clear: function () {
73075
- this.files = {};
73076
- }
73077
- };
73078
-
73079
73047
  const loading = {};
73080
73048
 
73081
73049
  class FileLoader extends Loader {
@@ -73231,6 +73199,80 @@ class FileLoader extends Loader {
73231
73199
  }
73232
73200
  }
73233
73201
 
73202
+ /**
73203
+ * @author Deepkolos / https://github.com/deepkolos
73204
+ */
73205
+
73206
+ class WorkerPool$1 {
73207
+
73208
+ constructor(pool = 4) {
73209
+ this.pool = pool;
73210
+ this.queue = [];
73211
+ this.workers = [];
73212
+ this.workersResolve = [];
73213
+ this.workerStatus = 0;
73214
+ }
73215
+
73216
+ _initWorker(workerId) {
73217
+ if (!this.workers[workerId]) {
73218
+ const worker = this.workerCreator();
73219
+ worker.addEventListener('message', this._onMessage.bind(this, workerId));
73220
+ this.workers[workerId] = worker;
73221
+ }
73222
+ }
73223
+
73224
+ _getIdleWorker() {
73225
+ for (let i = 0; i < this.pool; i++)
73226
+ if (!(this.workerStatus & (1 << i))) return i;
73227
+ return -1;
73228
+ }
73229
+
73230
+ _onMessage(workerId, msg) {
73231
+ const resolve = this.workersResolve[workerId];
73232
+ resolve && resolve(msg);
73233
+ if (this.queue.length) {
73234
+ const {resolve, msg, transfer} = this.queue.shift();
73235
+ this.workersResolve[workerId] = resolve;
73236
+ this.workers[workerId].postMessage(msg, transfer);
73237
+ } else {
73238
+ this.workerStatus ^= 1 << workerId;
73239
+ }
73240
+ }
73241
+
73242
+ setWorkerCreator(workerCreator) {
73243
+ this.workerCreator = workerCreator;
73244
+ }
73245
+
73246
+ setWorkerLimit(pool) {
73247
+ this.pool = pool;
73248
+ }
73249
+
73250
+ postMessage(msg, transfer) {
73251
+ return new Promise((resolve) => {
73252
+ const workerId = this._getIdleWorker();
73253
+ if (workerId !== -1) {
73254
+ this._initWorker(workerId);
73255
+ this.workerStatus |= 1 << workerId;
73256
+ this.workersResolve[workerId] = resolve;
73257
+ this.workers[workerId].postMessage(msg, transfer);
73258
+ } else {
73259
+ this.queue.push({resolve, msg, transfer});
73260
+ }
73261
+ });
73262
+ }
73263
+
73264
+ destroy() {
73265
+
73266
+ this.workers.forEach((worker) => worker.terminate());
73267
+ this.workersResolve.length = 0;
73268
+ this.workers.length = 0;
73269
+ this.queue.length = 0;
73270
+ this.workerStatus = 0;
73271
+
73272
+ }
73273
+
73274
+ }
73275
+
73234
73276
  const KTX2TransferSRGB = 2;
73235
73277
  const KTX2_ALPHA_PREMULTIPLIED = 1;
73236
73278
 
@@ -77114,848 +77156,6 @@ class VBOSceneModel extends Component {
77114
77156
  }
77115
77157
  }
77116
77158
 
77117
- /**
77118
- * @private
77119
- */
77120
- class GLTFSceneGraphLoader {
77121
-
77122
- constructor(cfg) { // TODO: Loading options fallbacks on loader, eg. handleGLTFNode etc
77123
- }
77124
-
77125
- load(plugin, modelNode, src, options, ok, error) {
77126
- options = options || {};
77127
- var spinner = modelNode.scene.canvas.spinner;
77128
- spinner.processes++;
77129
- loadGLTF$1(plugin, modelNode, src, options, function () {
77130
- spinner.processes--;
77131
- core.scheduleTask(function () {
77132
- modelNode.scene.fire("modelLoaded", modelNode.id); // FIXME: Assumes listeners know order of these two events
77133
- modelNode.fire("loaded", true, false);
77134
- });
77135
- if (ok) {
77136
- ok();
77137
- }
77138
- },
77139
- function (msg) {
77140
- spinner.processes--;
77141
- modelNode.error(msg);
77142
- if (error) {
77143
- error(msg);
77144
- }
77145
- modelNode.fire("error", msg);
77146
- });
77147
- }
77148
-
77149
- parse(plugin, modelNode, gltf, options, ok, error) {
77150
- options = options || {};
77151
- var spinner = modelNode.scene.canvas.spinner;
77152
- spinner.processes++;
77153
- parseGLTF$2(plugin, gltf, "", options, modelNode, function () {
77154
- spinner.processes--;
77155
- modelNode.scene.fire("modelLoaded", modelNode.id); // FIXME: Assumes listeners know order of these two events
77156
- modelNode.fire("loaded", true, false);
77157
- if (ok) {
77158
- ok();
77159
- }
77160
- },
77161
- function (msg) {
77162
- spinner.processes--;
77163
- modelNode.error(msg);
77164
- modelNode.fire("error", msg);
77165
- if (error) {
77166
- error(msg);
77167
- }
77168
- });
77169
- }
77170
- }
77171
-
77172
-
77173
- var loadGLTF$1 = (function () {
77174
- return function (plugin, modelNode, src, options, ok, error) {
77175
- plugin.dataSource.getGLTF(src, function (json) { // OK
77176
- options.basePath = getBasePath(src);
77177
- parseGLTF$2(plugin, json, src, options, modelNode, ok, error);
77178
- },
77179
- error);
77180
- };
77181
-
77182
- function getBasePath(src) {
77183
- var i = src.lastIndexOf("/");
77184
- return (i !== 0) ? src.substring(0, i + 1) : "";
77185
- }
77186
- })();
77187
-
77188
- var parseGLTF$2 = (function () {
77189
-
77190
- const WEBGL_COMPONENT_TYPES = {
77191
- 5120: Int8Array,
77192
- 5121: Uint8Array,
77193
- 5122: Int16Array,
77194
- 5123: Uint16Array,
77195
- 5125: Uint32Array,
77196
- 5126: Float32Array
77197
- };
77198
-
77199
- const WEBGL_TYPE_SIZES = {
77200
- 'SCALAR': 1,
77201
- 'VEC2': 2,
77202
- 'VEC3': 3,
77203
- 'VEC4': 4,
77204
- 'MAT2': 4,
77205
- 'MAT3': 9,
77206
- 'MAT4': 16
77207
- };
77208
-
77209
- return function (plugin, json, src, options, modelNode, ok) {
77210
- modelNode.clear();
77211
- var ctx = {
77212
- src: src,
77213
- loadBuffer: options.loadBuffer,
77214
- basePath: options.basePath,
77215
- prioritizeGLTFNode: options.prioritizeGLTFNode,
77216
- handleGLTFNode: options.handleGLTFNode,
77217
- ignoreMaterials: !!options.ignoreMaterials,
77218
- edgeThreshold: options.edgeThreshold,
77219
- readableGeometry: !!options.readableGeometry,
77220
- json: json,
77221
- scene: modelNode.scene,
77222
- plugin: plugin,
77223
- modelNode: modelNode,
77224
- modelNodeProps: {
77225
- visible: modelNode.visible,
77226
- culled: modelNode.culled,
77227
- xrayed: modelNode.xrayed,
77228
- highlighted: modelNode.highlighted,
77229
- selected: modelNode.selected,
77230
- outlined: modelNode.outlined,
77231
- clippable: modelNode.clippable,
77232
- pickable: modelNode.pickable,
77233
- collidable: modelNode.collidable,
77234
- castsShadow: modelNode.castsShadow,
77235
- receivesShadow: modelNode.receivesShadow,
77236
- colorize: modelNode.colorize,
77237
- opacity: modelNode.opacity,
77238
- edges: modelNode.edges
77239
- }
77240
- };
77241
-
77242
- modelNode.scene.loading++; // Disables (re)compilation
77243
-
77244
- loadBuffers(ctx, function () {
77245
-
77246
- loadBufferViews(ctx);
77247
- loadAccessors(ctx);
77248
- loadTextures(ctx);
77249
- loadMaterials(ctx);
77250
- loadMeshes(ctx);
77251
- loadDefaultScene(ctx);
77252
-
77253
- modelNode.scene.loading--; // Re-enables (re)compilation
77254
-
77255
- ok();
77256
- });
77257
- };
77258
-
77259
- function loadBuffers(ctx, ok) {
77260
- var buffers = ctx.json.buffers;
77261
- if (buffers) {
77262
- var numToLoad = buffers.length;
77263
- for (var i = 0, len = buffers.length; i < len; i++) {
77264
- loadBuffer(ctx, buffers[i], function () {
77265
- if (--numToLoad === 0) {
77266
- ok();
77267
- }
77268
- }, function (msg) {
77269
- ctx.plugin.error(msg);
77270
- if (--numToLoad === 0) {
77271
- ok();
77272
- }
77273
- });
77274
- }
77275
- } else {
77276
- ok();
77277
- }
77278
- }
77279
-
77280
- function loadBuffer(ctx, bufferInfo, ok, err) {
77281
- var uri = bufferInfo.uri;
77282
- if (uri) {
77283
- ctx.plugin.dataSource.getArrayBuffer(ctx.src, uri, function (data) {
77284
- bufferInfo._buffer = data;
77285
- ok();
77286
- },
77287
- err);
77288
- } else {
77289
- err('gltf/handleBuffer missing uri in ' + JSON.stringify(bufferInfo));
77290
- }
77291
- }
77292
-
77293
- function loadBufferViews(ctx) {
77294
- var bufferViewsInfo = ctx.json.bufferViews;
77295
- if (bufferViewsInfo) {
77296
- for (var i = 0, len = bufferViewsInfo.length; i < len; i++) {
77297
- loadBufferView(ctx, bufferViewsInfo[i]);
77298
- }
77299
- }
77300
- }
77301
-
77302
- function loadBufferView(ctx, bufferViewInfo) {
77303
-
77304
- var buffer = ctx.json.buffers[bufferViewInfo.buffer];
77305
-
77306
- bufferViewInfo._typedArray = null;
77307
-
77308
- var byteLength = bufferViewInfo.byteLength || 0;
77309
- var byteOffset = bufferViewInfo.byteOffset || 0;
77310
-
77311
- bufferViewInfo._buffer = buffer._buffer.slice(byteOffset, byteOffset + byteLength);
77312
- }
77313
-
77314
- function loadAccessors(ctx) {
77315
- var accessorsInfo = ctx.json.accessors;
77316
- if (accessorsInfo) {
77317
- for (var i = 0, len = accessorsInfo.length; i < len; i++) {
77318
- loadAccessor(ctx, accessorsInfo[i]);
77319
- }
77320
- }
77321
- }
77322
-
77323
- function loadAccessor(ctx, accessorInfo) {
77324
- var bufferViewInfo = ctx.json.bufferViews[accessorInfo.bufferView];
77325
- var itemSize = WEBGL_TYPE_SIZES[accessorInfo.type];
77326
- var TypedArray = WEBGL_COMPONENT_TYPES[accessorInfo.componentType];
77327
-
77328
- // For VEC3: itemSize is 3, elementBytes is 4, itemBytes is 12.
77329
- var elementBytes = TypedArray.BYTES_PER_ELEMENT;
77330
- var itemBytes = elementBytes * itemSize;
77331
-
77332
- // The buffer is not interleaved if the stride is the item size in bytes.
77333
- if (accessorInfo.byteStride && accessorInfo.byteStride !== itemBytes) ; else {
77334
- accessorInfo._typedArray = new TypedArray(bufferViewInfo._buffer, accessorInfo.byteOffset || 0, accessorInfo.count * itemSize);
77335
- accessorInfo._itemSize = itemSize;
77336
- }
77337
- }
77338
-
77339
-
77340
- function loadTextures(ctx) {
77341
- var texturesInfo = ctx.json.textures;
77342
- if (texturesInfo) {
77343
- for (var i = 0, len = texturesInfo.length; i < len; i++) {
77344
- loadTexture(ctx, texturesInfo[i]);
77345
- }
77346
- }
77347
- }
77348
-
77349
- function loadTexture(ctx, textureInfo) {
77350
- let uri = ctx.json.images[textureInfo.source].uri;
77351
- if (uri && !uri.match(/^data:(.*?)(;base64)?,(.*)$/)) {
77352
- uri = ctx.basePath + uri;
77353
- }
77354
- textureInfo._texture = new Texture(ctx.modelNode, {
77355
- src: uri,
77356
- flipY: !!textureInfo.flipY,
77357
- //encoding: "sRGB"
77358
- encoding: "linear"
77359
- });
77360
- }
77361
-
77362
- function loadMaterials(ctx) {
77363
- var materialsInfo = ctx.json.materials;
77364
- if (materialsInfo) {
77365
- var materialInfo;
77366
- var material;
77367
- for (var i = 0, len = materialsInfo.length; i < len; i++) {
77368
- materialInfo = materialsInfo[i];
77369
- material = loadMaterial(ctx, materialInfo);
77370
- materialInfo._material = material;
77371
- }
77372
- }
77373
- }
77374
-
77375
- function loadMaterial(ctx, materialInfo) {
77376
-
77377
- var json = ctx.json;
77378
- var cfg = {};
77379
- var textureInfo;
77380
-
77381
- // Common attributes
77382
-
77383
- var normalTexture = materialInfo.normalTexture;
77384
- if (normalTexture) {
77385
- textureInfo = json.textures[normalTexture.index];
77386
- if (textureInfo) {
77387
- cfg.normalMap = textureInfo._texture;
77388
- //cfg.normalMap.encoding = "linear";
77389
- }
77390
- }
77391
-
77392
- var occlusionTexture = materialInfo.occlusionTexture;
77393
- if (occlusionTexture) {
77394
- textureInfo = json.textures[occlusionTexture.index];
77395
- if (textureInfo) {
77396
- cfg.occlusionMap = textureInfo._texture;
77397
- }
77398
- }
77399
-
77400
- var emissiveTexture = materialInfo.emissiveTexture;
77401
- if (emissiveTexture) {
77402
- textureInfo = json.textures[emissiveTexture.index];
77403
- if (textureInfo) {
77404
- cfg.emissiveMap = textureInfo._texture;
77405
- //cfg.emissiveMap.encoding = "sRGB";
77406
- }
77407
- }
77408
-
77409
- var emissiveFactor = materialInfo.emissiveFactor;
77410
- if (emissiveFactor) {
77411
- cfg.emissive = emissiveFactor;
77412
- }
77413
-
77414
- cfg.backfaces = !!materialInfo.doubleSided;
77415
-
77416
- var alphaMode = materialInfo.alphaMode;
77417
- switch (alphaMode) {
77418
- case "NORMAL_OPAQUE":
77419
- cfg.alphaMode = "opaque";
77420
- break;
77421
- case "MASK":
77422
- cfg.alphaMode = "mask";
77423
- break;
77424
- case "BLEND":
77425
- cfg.alphaMode = "blend";
77426
- break;
77427
- }
77428
-
77429
- var alphaCutoff = materialInfo.alphaCutoff;
77430
- if (alphaCutoff !== undefined) {
77431
- cfg.alphaCutoff = alphaCutoff;
77432
- }
77433
-
77434
- var extensions = materialInfo.extensions;
77435
- if (extensions) {
77436
-
77437
- // Specular PBR material
77438
-
77439
- var specularPBR = extensions["KHR_materials_pbrSpecularGlossiness"];
77440
- if (specularPBR) {
77441
-
77442
- var diffuseFactor = specularPBR.diffuseFactor;
77443
- if (diffuseFactor !== null && diffuseFactor !== undefined) {
77444
- cfg.diffuse = diffuseFactor.slice(0, 3);
77445
- cfg.alpha = diffuseFactor[3];
77446
- }
77447
-
77448
- var diffuseTexture = specularPBR.diffuseTexture;
77449
- if (diffuseTexture) {
77450
- textureInfo = json.textures[diffuseTexture.index];
77451
- if (textureInfo) {
77452
- cfg.diffuseMap = textureInfo._texture;
77453
- //cfg.diffuseMap.encoding = "sRGB";
77454
- }
77455
- }
77456
-
77457
- var specularFactor = specularPBR.specularFactor;
77458
- if (specularFactor !== null && specularFactor !== undefined) {
77459
- cfg.specular = specularFactor.slice(0, 3);
77460
- }
77461
-
77462
- var glossinessFactor = specularPBR.glossinessFactor;
77463
- if (glossinessFactor !== null && glossinessFactor !== undefined) {
77464
- cfg.glossiness = glossinessFactor;
77465
- }
77466
-
77467
- var specularGlossinessTexture = specularPBR.specularGlossinessTexture;
77468
- if (specularGlossinessTexture) {
77469
- textureInfo = json.textures[specularGlossinessTexture.index];
77470
- if (textureInfo) {
77471
- cfg.specularGlossinessMap = textureInfo._texture;
77472
- //cfg.specularGlossinessMap.encoding = "linear";
77473
- }
77474
- }
77475
-
77476
- return new SpecularMaterial(ctx.modelNode, cfg);
77477
- }
77478
-
77479
- // Common Phong, Blinn, Lambert or Constant materials
77480
-
77481
- var common = extensions["KHR_materials_common"];
77482
- if (common) {
77483
-
77484
- var technique = common.technique;
77485
- var values = common.values || {};
77486
-
77487
- var blinn = technique === "BLINN";
77488
- var phong = technique === "PHONG";
77489
- var lambert = technique === "LAMBERT";
77490
-
77491
- var shininess = values.shininess;
77492
- if ((blinn || phong) && shininess !== null && shininess !== undefined) {
77493
- cfg.shininess = shininess;
77494
- } else {
77495
- cfg.shininess = 0;
77496
- }
77497
- var texture;
77498
- var diffuse = values.diffuse;
77499
- if (diffuse && (blinn || phong || lambert)) {
77500
- if (utils.isString(diffuse)) {
77501
- texture = json.textures[diffuse];
77502
- if (texture) {
77503
- cfg.diffuseMap = texture;
77504
- // cfg.diffuseMap.encoding = "sRGB";
77505
- }
77506
- } else {
77507
- cfg.diffuse = diffuse.slice(0, 3);
77508
- }
77509
- } else {
77510
- cfg.diffuse = [0, 0, 0];
77511
- }
77512
-
77513
- var specular = values.specular;
77514
- if (specular && (blinn || phong)) {
77515
- if (utils.isString(specular)) {
77516
- texture = json.textures[specular];
77517
- if (texture) {
77518
- cfg.specularMap = texture;
77519
- }
77520
- } else {
77521
- cfg.specular = specular.slice(0, 3);
77522
- }
77523
- } else {
77524
- cfg.specular = [0, 0, 0];
77525
- }
77526
-
77527
- var emission = values.emission;
77528
- if (emission) {
77529
- if (utils.isString(emission)) {
77530
- texture = json.textures[emission];
77531
- if (texture) {
77532
- cfg.emissiveMap = texture;
77533
- }
77534
- } else {
77535
- cfg.emissive = emission.slice(0, 3);
77536
- }
77537
- } else {
77538
- cfg.emissive = [0, 0, 0];
77539
- }
77540
-
77541
- var transparency = values.transparency;
77542
- if (transparency !== null && transparency !== undefined) {
77543
- cfg.alpha = transparency;
77544
- } else {
77545
- cfg.alpha = 1.0;
77546
- }
77547
-
77548
- values.transparent;
77549
-
77550
- return new PhongMaterial(ctx.scene, cfg);
77551
- }
77552
- }
77553
-
77554
- // Metallic PBR naterial
77555
-
77556
- var metallicPBR = materialInfo.pbrMetallicRoughness;
77557
- if (metallicPBR) {
77558
-
77559
- var baseColorFactor = metallicPBR.baseColorFactor;
77560
- if (baseColorFactor) {
77561
- cfg.baseColor = baseColorFactor.slice(0, 3);
77562
- cfg.alpha = baseColorFactor[3];
77563
- }
77564
-
77565
- var colorTexture = metallicPBR.colorTexture;
77566
- if (colorTexture) {
77567
- textureInfo = json.textures[colorTexture.index];
77568
- if (textureInfo) {
77569
- cfg.baseColorMap = textureInfo._texture;
77570
- //cfg.baseColorMap.encoding = "sRGB";
77571
- }
77572
- }
77573
-
77574
- var metallicFactor = metallicPBR.metallicFactor;
77575
- if (metallicFactor !== null && metallicFactor !== undefined) {
77576
- cfg.metallic = metallicFactor;
77577
- }
77578
-
77579
- var roughnessFactor = metallicPBR.roughnessFactor;
77580
- if (roughnessFactor !== null && roughnessFactor !== undefined) {
77581
- cfg.roughness = roughnessFactor;
77582
- }
77583
-
77584
- var metallicRoughnessTexture = metallicPBR.metallicRoughnessTexture;
77585
- if (metallicRoughnessTexture) {
77586
- textureInfo = json.textures[metallicRoughnessTexture.index];
77587
- if (textureInfo) {
77588
- cfg.metallicRoughnessMap = textureInfo._texture;
77589
- // cfg.metallicRoughnessMap.encoding = "linear";
77590
- }
77591
- }
77592
-
77593
- return new MetallicMaterial(ctx.scene, cfg);
77594
- }
77595
-
77596
- // Default material
77597
-
77598
- return new PhongMaterial(ctx.scene, cfg);
77599
- }
77600
-
77601
- function loadMeshes(ctx) {
77602
- var meshes = ctx.json.meshes;
77603
- if (meshes) {
77604
- for (var i = 0, len = meshes.length; i < len; i++) {
77605
- loadMesh(ctx, meshes[i]);
77606
- }
77607
- }
77608
- }
77609
-
77610
- function loadMesh(ctx, meshInfo) {
77611
- var json = ctx.json;
77612
- var mesh = [];
77613
- var primitivesInfo = meshInfo.primitives;
77614
- var materialIndex;
77615
- var materialInfo;
77616
- var accessorInfo;
77617
- var attributes;
77618
-
77619
- if (primitivesInfo) {
77620
-
77621
- var primitiveInfo;
77622
- var indicesIndex;
77623
- var positionsIndex;
77624
- var normalsIndex;
77625
- var uv0Index;
77626
- var geometryCfg;
77627
- var meshCfg;
77628
- var geometry;
77629
-
77630
- for (var i = 0, len = primitivesInfo.length; i < len; i++) {
77631
- primitiveInfo = primitivesInfo[i];
77632
- if (primitiveInfo.mode < 4 ) {
77633
- continue;
77634
- }
77635
- geometryCfg = {
77636
- primitive: "triangles",
77637
- compressGeometry: true,
77638
- edgeThreshold: ctx.edgeThreshold
77639
- };
77640
-
77641
- indicesIndex = primitiveInfo.indices;
77642
-
77643
- if (indicesIndex !== null && indicesIndex !== undefined) {
77644
- accessorInfo = json.accessors[indicesIndex];
77645
- geometryCfg.indices = accessorInfo._typedArray;
77646
- }
77647
-
77648
- attributes = primitiveInfo.attributes;
77649
- if (!attributes) {
77650
- continue;
77651
- }
77652
-
77653
- positionsIndex = attributes.POSITION;
77654
-
77655
- if (positionsIndex !== null && positionsIndex !== undefined) {
77656
- accessorInfo = json.accessors[positionsIndex];
77657
- geometryCfg.positions = accessorInfo._typedArray;
77658
- }
77659
-
77660
- normalsIndex = attributes.NORMAL;
77661
-
77662
- if (normalsIndex !== null && normalsIndex !== undefined) {
77663
- accessorInfo = json.accessors[normalsIndex];
77664
- geometryCfg.normals = accessorInfo._typedArray;
77665
- }
77666
-
77667
- uv0Index = attributes.TEXCOORD_0;
77668
-
77669
- if (uv0Index !== null && uv0Index !== undefined) {
77670
- accessorInfo = json.accessors[uv0Index];
77671
- geometryCfg.uv = accessorInfo._typedArray;
77672
- }
77673
-
77674
- meshCfg = {};
77675
-
77676
- if (ctx.readableGeometry) {
77677
- geometry = new ReadableGeometry(ctx.modelNode, geometryCfg);
77678
- } else {
77679
- geometry = new VBOGeometry(ctx.modelNode, geometryCfg);
77680
- }
77681
-
77682
- meshCfg.geometry = geometry;
77683
-
77684
- materialIndex = primitiveInfo.material;
77685
- if (materialIndex !== null && materialIndex !== undefined) {
77686
- materialInfo = json.materials[materialIndex];
77687
- if (materialInfo) {
77688
- meshCfg.material = materialInfo._material;
77689
- }
77690
- }
77691
-
77692
- mesh.push(meshCfg);
77693
- }
77694
- }
77695
- meshInfo._mesh = mesh;
77696
- }
77697
-
77698
- function loadDefaultScene(ctx) {
77699
- var json = ctx.json;
77700
- var scene = json.scene || 0;
77701
- var defaultSceneInfo = json.scenes[scene];
77702
- if (!defaultSceneInfo) {
77703
- error(ctx, "glTF has no default scene");
77704
- return;
77705
- }
77706
- loadScene(ctx, defaultSceneInfo);
77707
- }
77708
-
77709
- function loadScene(ctx, sceneInfo) {
77710
- var nodes = sceneInfo.nodes;
77711
- if (!nodes) {
77712
- return;
77713
- }
77714
- var json = ctx.json;
77715
- var glTFNode;
77716
- for (var i = 0, len = nodes.length; i < len; i++) {
77717
- glTFNode = json.nodes[nodes[i]];
77718
- if (!glTFNode) {
77719
- error(ctx, "Node not found: " + i);
77720
- continue;
77721
- }
77722
- loadNode(ctx, glTFNode, null, null);
77723
- }
77724
- }
77725
-
77726
- function loadNode(ctx, glTFNode, matrix, parent) {
77727
-
77728
- parent = parent || ctx.modelNode;
77729
-
77730
- var createEntity;
77731
-
77732
- if (ctx.prioritizeGLTFNode) {
77733
- const priority = ctx.prioritizeGLTFNode(ctx.modelNode.id, glTFNode);
77734
- if (priority === undefined || priority === null) {
77735
- return;
77736
- }
77737
- }
77738
-
77739
- if (ctx.handleGLTFNode) {
77740
- var actions = {};
77741
- if (!ctx.handleGLTFNode(ctx.modelNode.id, glTFNode, actions)) {
77742
- return;
77743
- }
77744
- if (actions.createEntity) {
77745
- createEntity = actions.createEntity;
77746
- }
77747
- }
77748
-
77749
- const json = ctx.json;
77750
- const modelNode = ctx.modelNode;
77751
- const hasChildNodes = glTFNode.children && glTFNode.children.length > 0;
77752
-
77753
- var localMatrix;
77754
-
77755
- if (glTFNode.matrix) {
77756
- localMatrix = glTFNode.matrix;
77757
- if (matrix) {
77758
- matrix = math.mulMat4(matrix, localMatrix, math.mat4());
77759
- } else {
77760
- matrix = localMatrix;
77761
- }
77762
- }
77763
-
77764
- if (glTFNode.translation) {
77765
- localMatrix = math.translationMat4v(glTFNode.translation);
77766
- if (matrix) {
77767
- matrix = math.mulMat4(matrix, localMatrix, localMatrix);
77768
- } else {
77769
- matrix = localMatrix;
77770
- }
77771
- }
77772
-
77773
- if (glTFNode.rotation) {
77774
- localMatrix = math.quaternionToMat4(glTFNode.rotation);
77775
- if (matrix) {
77776
- matrix = math.mulMat4(matrix, localMatrix, localMatrix);
77777
- } else {
77778
- matrix = localMatrix;
77779
- }
77780
- }
77781
-
77782
- if (glTFNode.scale) {
77783
- localMatrix = math.scalingMat4v(glTFNode.scale);
77784
- if (matrix) {
77785
- matrix = math.mulMat4(matrix, localMatrix, localMatrix);
77786
- } else {
77787
- matrix = localMatrix;
77788
- }
77789
- }
77790
-
77791
- if (glTFNode.mesh !== undefined) {
77792
-
77793
- var meshInfo = json.meshes[glTFNode.mesh];
77794
-
77795
- if (meshInfo) {
77796
-
77797
- var meshesInfo = meshInfo._mesh;
77798
- var meshesInfoMesh;
77799
- var mesh;
77800
- var numMeshes = meshesInfo.length;
77801
-
77802
- if (!createEntity && numMeshes > 0 && !hasChildNodes) {
77803
-
77804
- // Case 1: Not creating object, node has meshes, node has no child nodes
77805
-
77806
- for (var i = 0, len = numMeshes; i < len; i++) {
77807
- meshesInfoMesh = meshesInfo[i];
77808
- let meshCfg = {
77809
- geometry: meshesInfoMesh.geometry,
77810
- matrix: matrix
77811
- };
77812
- utils.apply(ctx.modelNodeProps, meshCfg);
77813
- meshCfg.material = meshesInfoMesh.material;
77814
- mesh = new Mesh(modelNode, meshCfg);
77815
- parent.addChild(mesh, false); // Don't automatically inherit properties
77816
- }
77817
- return;
77818
- }
77819
-
77820
- if (createEntity && numMeshes === 1 && !hasChildNodes) {
77821
-
77822
- // Case 2: Creating object, node has one mesh, node has no child nodes
77823
-
77824
- meshesInfoMesh = meshesInfo[0];
77825
- let meshCfg = {
77826
- geometry: meshesInfoMesh.geometry,
77827
- matrix: matrix
77828
- };
77829
- utils.apply(ctx.modelNodeProps, meshCfg);
77830
- meshCfg.material = meshesInfoMesh.material;
77831
- utils.apply(createEntity, meshCfg);
77832
- mesh = new Mesh(modelNode, meshCfg);
77833
- parent.addChild(mesh, false); // Don't automatically inherit properties
77834
- return;
77835
- }
77836
-
77837
- if (createEntity && numMeshes > 0 && !hasChildNodes) {
77838
-
77839
- // Case 3: Creating object, node has meshes, node has no child nodes
77840
-
77841
- let nodeCfg = {
77842
- matrix: matrix
77843
- };
77844
- utils.apply(ctx.modelNodeProps, nodeCfg);
77845
- utils.apply(createEntity, nodeCfg);
77846
- let childNode = new Node$1(modelNode, nodeCfg);
77847
- parent.addChild(childNode, false);
77848
- for (let i = 0, len = numMeshes; i < len; i++) {
77849
- meshesInfoMesh = meshesInfo[i];
77850
- let meshCfg = {
77851
- geometry: meshesInfoMesh.geometry
77852
- };
77853
- utils.apply(ctx.modelNodeProps, meshCfg);
77854
- meshCfg.material = meshesInfoMesh.material;
77855
- utils.apply(createEntity, meshCfg);
77856
- meshCfg.id = null; // Avoid ID clash with parent Node
77857
- mesh = new Mesh(modelNode, meshCfg);
77858
- childNode.addChild(mesh, false);
77859
- }
77860
- return;
77861
- }
77862
-
77863
- if (!createEntity && numMeshes > 0 && hasChildNodes) {
77864
-
77865
- // Case 4: Not creating object, node has meshes, node has child nodes
77866
-
77867
- let nodeCfg = {
77868
- matrix: matrix
77869
- };
77870
- utils.apply(ctx.modelNodeProps, nodeCfg);
77871
- let childNode = new Node$1(modelNode, nodeCfg);
77872
- parent.addChild(childNode, false);
77873
- for (let i = 0, len = numMeshes; i < len; i++) {
77874
- meshesInfoMesh = meshesInfo[i];
77875
- let meshCfg = {
77876
- geometry: meshesInfoMesh.geometry
77877
- };
77878
- utils.apply(nodeCfg, meshCfg);
77879
- meshCfg.id = null; // Avoid ID clash with parent Node
77880
- meshCfg.matrix = null; // Node has matrix
77881
- meshCfg.material = meshesInfoMesh.material;
77882
- mesh = new Mesh(modelNode, meshCfg);
77883
- childNode.addChild(mesh, false);
77884
- }
77885
- matrix = null;
77886
- parent = childNode;
77887
- }
77888
-
77889
- if (createEntity && numMeshes === 0 && hasChildNodes) {
77890
-
77891
- // Case 5: Creating explicit object, node has meshes OR node has child nodes
77892
-
77893
- let nodeCfg = {
77894
- matrix: matrix
77895
- };
77896
- utils.apply(ctx.modelNodeProps, nodeCfg);
77897
- utils.apply(createEntity, nodeCfg);
77898
- createEntity.matrix = matrix;
77899
- let childNode = new Node$1(modelNode, nodeCfg);
77900
- parent.addChild(childNode, false); // Don't automatically inherit properties
77901
- matrix = null;
77902
- parent = childNode;
77903
- }
77904
-
77905
- if (createEntity && numMeshes > 0 || hasChildNodes) {
77906
-
77907
- // Case 6: Creating explicit object, node has meshes OR node has child nodes
77908
-
77909
- let nodeCfg = {
77910
- matrix: matrix
77911
- };
77912
- utils.apply(ctx.modelNodeProps, nodeCfg);
77913
- if (createEntity) {
77914
- utils.apply(createEntity, nodeCfg);
77915
- }
77916
- let childNode = new Node$1(modelNode, nodeCfg);
77917
- parent.addChild(childNode, false); // Don't automatically inherit properties
77918
- for (let i = 0, len = numMeshes; i < len; i++) {
77919
- meshesInfoMesh = meshesInfo[i];
77920
- let meshCfg = {
77921
- geometry: meshesInfoMesh.geometry
77922
- };
77923
- utils.apply(ctx.modelProps, meshCfg);
77924
- meshCfg.material = meshesInfoMesh.material;
77925
- if (createEntity) {
77926
- utils.apply(createEntity, meshCfg);
77927
- }
77928
- meshCfg.id = null; // Avoid ID clash with parent Node
77929
- mesh = new Mesh(modelNode, meshCfg);
77930
- childNode.addChild(mesh, false); // Don't automatically inherit properties
77931
- }
77932
- matrix = null;
77933
- parent = childNode;
77934
- }
77935
- }
77936
- }
77937
-
77938
- if (glTFNode.children) {
77939
- var children = glTFNode.children;
77940
- var childNodeInfo;
77941
- var childNodeIdx;
77942
- for (let i = 0, len = children.length; i < len; i++) {
77943
- childNodeIdx = children[i];
77944
- childNodeInfo = json.nodes[childNodeIdx];
77945
- if (!childNodeInfo) {
77946
- error(ctx, "Node not found: " + i);
77947
- continue;
77948
- }
77949
- loadNode(ctx, childNodeInfo, matrix, parent);
77950
- }
77951
- }
77952
- }
77953
-
77954
- function error(ctx, msg) {
77955
- ctx.plugin.error(msg);
77956
- }
77957
- })();
77958
-
77959
77159
  function assert$5(condition, message) {
77960
77160
  if (!condition) {
77961
77161
  throw new Error(message || 'loader assertion failed.');
@@ -85271,7 +84471,7 @@ async function parse$1(arrayBuffer, options = {}, context) {
85271
84471
  /**
85272
84472
  * @private
85273
84473
  */
85274
- class GLTFPerformanceModelLoader {
84474
+ class GLTFVBOSceneModelLoader {
85275
84475
 
85276
84476
  constructor(cfg) {
85277
84477
  }
@@ -85772,9 +84972,14 @@ const IFCObjectDefaults = {
85772
84972
  /**
85773
84973
  * {@link Viewer} plugin that loads models from [glTF](https://www.khronos.org/gltf/).
85774
84974
  *
84975
+ * * Loads all glTF formats, including embedded and binary formats.
84976
+ * * Loads physically-based materials and textures.
85775
84977
  * * Creates an {@link Entity} representing each model it loads, which will have {@link Entity#isModel} set ````true```` and will be registered by {@link Entity#id} in {@link Scene#models}.
85776
84978
  * * Creates an {@link Entity} for each object within the model, which is indicated by each glTF ````node```` that has a ````name```` attribute. Those Entities will have {@link Entity#isObject} set ````true```` and will be registered by {@link Entity#id} in {@link Scene#objects}.
85777
84979
  * * When loading, can set the World-space position, scale and rotation of each model within World space, along with initial properties for all the model's {@link Entity}s.
84980
+ * * Not recommended for large models. For best performance with large glTF datasets, we recommend first converting them
84981
+ * to ````.xkt```` format (eg. using [convert2xkt](https://github.com/xeokit/xeokit-convert)), then loading
84982
+ * the ````.xkt```` using {@link XKTLoaderPlugin}.
85778
84983
  *
85779
84984
  * ## Metadata
85780
84985
  *
@@ -85785,23 +84990,6 @@ const IFCObjectDefaults = {
85785
84990
  * metadata, we can also provide GLTFLoaderPlugin with a custom lookup table of initial values to set on the properties of each type of {@link Entity}. By default, GLTFLoaderPlugin
85786
84991
  * uses its own map of default colors and visibilities for IFC element types.
85787
84992
  *
85788
- * ## Quality Setting
85789
- *
85790
- * By default, GLTFLoaderPlugin will load a high-performance scene representation that's optimized for low memory usage and
85791
- * optimal rendering. The high-performance representation renders large numbers of objects efficiently, using geometry
85792
- * batching and instancing, with simple Lambertian shading that ignores any textures and realistic materials in the glTF.
85793
- *
85794
- * Specifying ````performance:false```` to {@link GLTFLoaderPlugin#load} will internally load a heavier scene
85795
- * representation comprised of {@link Node}, {@link Mesh}, {@link Geometry}, {@link Material} and {@link Texture} components,
85796
- * that will exactly preserve the materials specified in the glTF. Use this when you want to load a model for a realistic preview,
85797
- * maybe using PBR etc.
85798
- *
85799
- * We tend to use the default ````performance:true```` setting for CAD and BIM models, where structure is more important that
85800
- * surface appearance.
85801
- *
85802
- * Publically, GLTFLoaderPlugin creates the same {@link Entity}s for both levels of performance. Privately, however, it implements
85803
- * {@link Entity}s using two different sets of concrete subtypes, for its two different internally-managed scene representations.
85804
- *
85805
84993
  * ## Usage
85806
84994
  *
85807
84995
  * In the example below we'll load the Schependomlaan model from a [glTF file](http://xeokit.github.io/xeokit-sdk/examples/models/gltf/schependomlaan/), along
@@ -85815,8 +85003,6 @@ const IFCObjectDefaults = {
85815
85003
  *
85816
85004
  * Read more about this example in the user guide on [Viewing BIM Models Offline](https://www.notion.so/xeokit/Viewing-an-IFC-Model-with-xeokit-c373e48bc4094ff5b6e5c5700ff580ee).
85817
85005
  *
85818
- * We're leaving ````performance: true```` since our model has many objects and we're not interested in realistic rendering.
85819
- *
85820
85006
  * [[Run this example](http://xeokit.github.io/xeokit-sdk/examples/#BIMOffline_glTF_OTCConferenceCenter)]
85821
85007
  *
85822
85008
  * ````javascript
@@ -85855,8 +85041,7 @@ const IFCObjectDefaults = {
85855
85041
  * id: "myModel",
85856
85042
  * src: "./models/gltf/OTCConferenceCenter/scene.gltf",
85857
85043
  * metaModelSrc: "./models/gltf/OTCConferenceCenter/metaModel.json", // Creates a MetaModel (see below)
85858
- * edges: true,
85859
- * performance: true // Load high-performance scene representation (default is false)
85044
+ * edges: true
85860
85045
  * });
85861
85046
  *
85862
85047
  * model.on("loaded", () => {
@@ -85958,16 +85143,8 @@ class GLTFLoaderPlugin extends Plugin {
85958
85143
  constructor(viewer, cfg = {}) {
85959
85144
 
85960
85145
  super("GLTFLoader", viewer, cfg);
85961
-
85962
- /**
85963
- * @private
85964
- */
85965
- this._sceneGraphLoader = new GLTFSceneGraphLoader(this, cfg);
85966
-
85967
- /**
85968
- * @private
85969
- */
85970
- this._performanceModelLoader = new GLTFPerformanceModelLoader(this, cfg);
85146
+
85147
+ this._sceneModelLoader = new GLTFVBOSceneModelLoader(this, cfg);
85971
85148
 
85972
85149
  this.dataSource = cfg.dataSource;
85973
85150
  this.objectDefaults = cfg.objectDefaults;
@@ -86040,8 +85217,7 @@ class GLTFLoaderPlugin extends Plugin {
86040
85217
  * @param {Boolean} [params.colorTextureEnabled=true] Indicates if base color texture rendering is enabled for the model. Overridden by ````pbrEnabled````. Only works when {@link Scene#colorTextureEnabled} is also ````true````.
86041
85218
  * @param {Boolean} [params.backfaces=false] When true, allows visible backfaces, wherever specified in the glTF. When false, ignores backfaces.
86042
85219
  * @param {Number} [params.edgeThreshold=10] When xraying, highlighting, selecting or edging, this is the threshold angle between normals of adjacent triangles, below which their shared wireframe edge is not drawn.
86043
- * @param {Boolean} [params.performance=true] Set ````false```` to load all the materials and textures provided by the glTF file, otherwise leave ````true```` to load the default high-performance representation optimized for low memory usage and efficient rendering.
86044
- * @returns {Entity} Entity representing the model, which will have {@link Entity#isModel} set ````true```` and will be registered by {@link Entity#id} in {@link Scene#models}
85220
+ * @returns {Entity} Entity representing the model, which will have {@link Entity#isModel} set ````true```` and will be registered by {@link Entity#id} in {@link Scene#models}
86045
85221
  */
86046
85222
  load(params = {}) {
86047
85223
 
@@ -86050,20 +85226,7 @@ class GLTFLoaderPlugin extends Plugin {
86050
85226
  delete params.id;
86051
85227
  }
86052
85228
 
86053
- const performance = params.performance !== false;
86054
-
86055
- const sceneModel = performance
86056
-
86057
- // VBOSceneModel provides performance-oriented scene representation
86058
- // converting glTF materials to simple flat-shading without textures
86059
-
86060
- ? new VBOSceneModel(this.viewer.scene, utils.apply(params, {
86061
- isModel: true
86062
- }))
86063
-
86064
- // Scene Node graph supports original glTF materials
86065
-
86066
- : new Node$1(this.viewer.scene, utils.apply(params, {
85229
+ const sceneModel = new VBOSceneModel(this.viewer.scene, utils.apply(params, {
86067
85230
  isModel: true
86068
85231
  }));
86069
85232
 
@@ -86074,8 +85237,6 @@ class GLTFLoaderPlugin extends Plugin {
86074
85237
  return sceneModel; // Return new empty model
86075
85238
  }
86076
85239
 
86077
- const loader = performance ? this._performanceModelLoader : this._sceneGraphLoader;
86078
-
86079
85240
  if (params.metaModelSrc || params.metaModelData) {
86080
85241
 
86081
85242
  const objectDefaults = params.objectDefaults || this._objectDefaults || IFCObjectDefaults;
@@ -86149,9 +85310,9 @@ class GLTFLoaderPlugin extends Plugin {
86149
85310
  };
86150
85311
 
86151
85312
  if (params.src) {
86152
- loader.load(this, sceneModel, params.src, params);
85313
+ this._sceneModelLoader.load(this, sceneModel, params.src, params);
86153
85314
  } else {
86154
- loader.parse(this, sceneModel, params.gltf, params);
85315
+ this._sceneModelLoader.parse(this, sceneModel, params.gltf, params);
86155
85316
  }
86156
85317
  };
86157
85318
 
@@ -86198,9 +85359,9 @@ class GLTFLoaderPlugin extends Plugin {
86198
85359
  };
86199
85360
 
86200
85361
  if (params.src) {
86201
- loader.load(this, sceneModel, params.src, params);
85362
+ this._sceneModelLoader.load(this, sceneModel, params.src, params);
86202
85363
  } else {
86203
- loader.parse(this, sceneModel, params.gltf, params);
85364
+ this._sceneModelLoader.parse(this, sceneModel, params.gltf, params);
86204
85365
  }
86205
85366
  }
86206
85367
 
@@ -89779,6 +88940,7 @@ const tempVec3$3 = math.vec3();
89779
88940
  * this example).
89780
88941
  * * Click a plane in the overview to activate a 3D control with which you can interactively
89781
88942
  * reposition its SectionPlane in the main canvas.
88943
+ * * Use {@lin BCFViewpointsPlugin} to save and load SectionPlanes in BCF viewpoints.
89782
88944
  *
89783
88945
  * ## Usage
89784
88946
  *
@@ -89844,7 +89006,7 @@ const tempVec3$3 = math.vec3();
89844
89006
  * // Programmatically reposition one of our SectionPlanes
89845
89007
  * // This also updates its position as shown in the overview gizmo
89846
89008
  *
89847
- * mySectionPlane2.pos = [11.0, 6.-, -12];
89009
+ * mySectionPlane2.pos = [11.0, 6.0, -12];
89848
89010
  * mySectionPlane2.dir = [0.4, 0.0, 0.5];
89849
89011
  * ````
89850
89012
  */
@@ -156014,6 +155176,36 @@ class PerformanceModel extends VBOSceneModel {
156014
155176
  }
156015
155177
  }
156016
155178
 
155179
+ /**
155180
+ * Transcodes texture data.
155181
+ *
155182
+ * A {@link SceneModel} configured with an appropriate TextureTranscoder will allow us to add textures from
155183
+ * transcoded buffers or files. For a concrete example, see {@link VBOSceneModel}, which can be configured with
155184
+ * a {@link KTX2TextureTranscoder}, which allows us to add textures from KTX2 buffers and files.
155185
+ *
155186
+ * @interface
155187
+ */
155188
+ class TextureTranscoder {
155189
+
155190
+ /**
155191
+ * Transcodes texture data from transcoded buffers into a {@link Texture2D}.
155192
+ *
155193
+ * @param {ArrayBuffer[]} buffers Transcoded texture data. Given as an array of buffers so that we can support
155194
+ * multi-image textures, such as cube maps.
155195
+ * @param {*} config Transcoding options.
155196
+ * @param {Texture2D} texture The texture to load.
155197
+ * @returns {Promise} Resolves when the texture has loaded.
155198
+ */
155199
+ transcode(buffers, texture, config = {}) {
155200
+ }
155201
+
155202
+ /**
155203
+ * Destroys this transcoder.
155204
+ */
155205
+ destroy() {
155206
+ }
155207
+ }
155208
+
156017
155209
  const screenPos = math.vec4();
156018
155210
  const viewPos = math.vec4();
156019
155211
 
@@ -156258,7 +155450,7 @@ class PivotController {
156258
155450
  /**
156259
155451
  * Returns true if we are currently pivoting.
156260
155452
  *
156261
- * @returns {boolean}
155453
+ * @returns {Boolean}
156262
155454
  */
156263
155455
  getPivoting() {
156264
155456
  return this._pivoting;
@@ -156756,8 +155948,9 @@ class MousePanRotateDollyHandler {
156756
155948
  // Scaling drag-rotate to canvas boundary
156757
155949
 
156758
155950
  const canvasBoundary = scene.canvas.boundary;
156759
- const canvasWidth = canvasBoundary[2] - canvasBoundary[0];
156760
- const canvasHeight = canvasBoundary[3] - canvasBoundary[1];
155951
+
155952
+ const canvasWidth = canvasBoundary[2];
155953
+ const canvasHeight = canvasBoundary[3];
156761
155954
  const x = states.pointerCanvasPos[0];
156762
155955
  const y = states.pointerCanvasPos[1];
156763
155956
 
@@ -158082,8 +157275,8 @@ class TouchPanRotateAndDollyHandler {
158082
157275
  // Scaling drag-rotate to canvas boundary
158083
157276
 
158084
157277
  const canvasBoundary = scene.canvas.boundary;
158085
- const canvasWidth = canvasBoundary[2] - canvasBoundary[0];
158086
- const canvasHeight = canvasBoundary[3] - canvasBoundary[1];
157278
+ const canvasWidth = canvasBoundary[0];
157279
+ const canvasHeight = canvasBoundary[1];
158087
157280
 
158088
157281
  const touches = event.touches;
158089
157282
 
@@ -161380,7 +160573,7 @@ class Configs {
161380
160573
  *
161381
160574
  * This should only be set once, before creating any Viewers.
161382
160575
  *
161383
- * @returns {boolean}
160576
+ * @returns {Boolean}
161384
160577
  */
161385
160578
  set doublePrecisionEnabled(doublePrecision) {
161386
160579
  math.setDoublePrecisionEnabled(doublePrecision);
@@ -161389,7 +160582,7 @@ class Configs {
161389
160582
  /**
161390
160583
  * Gets whether double precision mode is enabled for all Viewers.
161391
160584
  *
161392
- * @returns {boolean}
160585
+ * @returns {Boolean}
161393
160586
  */
161394
160587
  get doublePrecisionEnabled() {
161395
160588
  return math.getDoublePrecisionEnabled();
@@ -163613,9 +162806,11 @@ const tempVec3c = math.vec3();
163613
162806
  * ## Overview
163614
162807
  *
163615
162808
  * * Loads small-to-medium sized models directly from [CityJSON 1.0.0](https://www.cityjson.org/specs/1.0.0/) files.
163616
- * * Not recommended for large models. For best performance with large CityJSON datasets, we recommend using {@link XKTLoaderPlugin}.
163617
162809
  * * Loads double-precision coordinates, enabling models to be viewed at global coordinates without accuracy loss.
163618
162810
  * * Allows to set the position, scale and rotation of each model as you load it.
162811
+ * * Not recommended for large models. For best performance with large CityJSON datasets, we recommend
162812
+ * converting them to ````.xkt```` format (eg. using [convert2xkt](https://github.com/xeokit/xeokit-convert)), then loading
162813
+ * the ````.xkt```` using {@link XKTLoaderPlugin}.
163619
162814
  *
163620
162815
  * ## Limitations
163621
162816
  *