@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.
@@ -100,7 +100,7 @@ class Item {
100
100
  * * Dynamically enable or disable items
101
101
  * * Dynamically show or hide items
102
102
  * * Supports cascading sub-menus
103
- * * Configure custom style with custom CSS (see examples above)
103
+ * * Configure custom style with CSS (see examples above)
104
104
  *
105
105
  * ## Usage
106
106
  *
@@ -1275,7 +1275,7 @@ const math = {
1275
1275
  * Returns true if the two 3-element vectors are the same.
1276
1276
  * @param v1
1277
1277
  * @param v2
1278
- * @returns {boolean}
1278
+ * @returns {Boolean}
1279
1279
  */
1280
1280
  compareVec3(v1, v2) {
1281
1281
  return (v1[0] === v2[0] && v1[1] === v2[1] && v1[2] === v2[2]);
@@ -3431,7 +3431,7 @@ const math = {
3431
3431
  * Returns true if the two 4x4 matrices are the same.
3432
3432
  * @param m1
3433
3433
  * @param m2
3434
- * @returns {boolean}
3434
+ * @returns {Boolean}
3435
3435
  */
3436
3436
  compareMat4(m1, m2) {
3437
3437
  return m1[0] === m2[0] &&
@@ -4338,7 +4338,7 @@ const math = {
4338
4338
  /** Returns true if the first AABB contains the second AABB.
4339
4339
  * @param aabb1
4340
4340
  * @param aabb2
4341
- * @returns {boolean}
4341
+ * @returns {Boolean}
4342
4342
  */
4343
4343
  containsAABB3: function (aabb1, aabb2) {
4344
4344
  const result = (
@@ -6734,7 +6734,7 @@ function isArray(value) {
6734
6734
  /**
6735
6735
  Tests if the given value is a string
6736
6736
  @param value
6737
- @returns {boolean}
6737
+ @returns {Boolean}
6738
6738
  @private
6739
6739
  */
6740
6740
  function isString(value) {
@@ -6744,7 +6744,7 @@ function isString(value) {
6744
6744
  /**
6745
6745
  Tests if the given value is a number
6746
6746
  @param value
6747
- @returns {boolean}
6747
+ @returns {Boolean}
6748
6748
  @private
6749
6749
  */
6750
6750
  function isNumeric(value) {
@@ -6754,7 +6754,7 @@ function isNumeric(value) {
6754
6754
  /**
6755
6755
  Tests if the given value is an ID
6756
6756
  @param value
6757
- @returns {boolean}
6757
+ @returns {Boolean}
6758
6758
  @private
6759
6759
  */
6760
6760
  function isID(value) {
@@ -6765,7 +6765,7 @@ function isID(value) {
6765
6765
  Tests if the given components are the same, where the components can be either IDs or instances.
6766
6766
  @param c1
6767
6767
  @param c2
6768
- @returns {boolean}
6768
+ @returns {Boolean}
6769
6769
  @private
6770
6770
  */
6771
6771
  function isSameComponent(c1, c2) {
@@ -6780,7 +6780,7 @@ function isSameComponent(c1, c2) {
6780
6780
  /**
6781
6781
  Tests if the given value is a function
6782
6782
  @param value
6783
- @returns {boolean}
6783
+ @returns {Boolean}
6784
6784
  @private
6785
6785
  */
6786
6786
  function isFunction$1(value) {
@@ -6790,7 +6790,7 @@ function isFunction$1(value) {
6790
6790
  /**
6791
6791
  Tests if the given value is a JavaScript JSON object, eg, ````{ foo: "bar" }````.
6792
6792
  @param value
6793
- @returns {boolean}
6793
+ @returns {Boolean}
6794
6794
  @private
6795
6795
  */
6796
6796
  function isObject$1(value) {
@@ -6848,7 +6848,7 @@ function applyIf(o, o2) {
6848
6848
  /**
6849
6849
  Returns true if the given map is empty.
6850
6850
  @param obj
6851
- @returns {boolean}
6851
+ @returns {Boolean}
6852
6852
  @private
6853
6853
  */
6854
6854
  function isEmptyObject$1(obj) {
@@ -9864,10 +9864,23 @@ class AngleMeasurement extends Component {
9864
9864
  return this._angle;
9865
9865
  }
9866
9866
 
9867
+ /**
9868
+ * Gets the color of the angle measurement.
9869
+ *
9870
+ * The color is an HTML string representation, eg. "#00BBFF" and "blue".
9871
+ *
9872
+ * @type {String}
9873
+ */
9867
9874
  get color() {
9868
9875
  return this._color;
9869
9876
  }
9870
9877
 
9878
+ /** Sets the color of the angle measurement.
9879
+ *
9880
+ * The color is given as an HTML string representation, eg. "#00BBFF" and "blue".
9881
+ *
9882
+ * @type {String}
9883
+ */
9871
9884
  set color(value) {
9872
9885
  this._originDot.setFillColor(value);
9873
9886
  this._cornerDot.setFillColor(value);
@@ -9882,7 +9895,7 @@ class AngleMeasurement extends Component {
9882
9895
  /**
9883
9896
  * Sets whether this AngleMeasurement is visible or not.
9884
9897
  *
9885
- * @type Boolean
9898
+ * @type {Boolean}
9886
9899
  */
9887
9900
  set visible(value) {
9888
9901
  value = value !== false;
@@ -9898,7 +9911,7 @@ class AngleMeasurement extends Component {
9898
9911
  /**
9899
9912
  * Gets whether this AngleMeasurement is visible or not.
9900
9913
  *
9901
- * @type Boolean
9914
+ * @type {Boolean}
9902
9915
  */
9903
9916
  get visible() {
9904
9917
  return this._visible;
@@ -10094,7 +10107,7 @@ class AngleMeasurementsControl extends Component {
10094
10107
 
10095
10108
  /** Gets if this AngleMeasurementsControl is currently active, where it is responding to input.
10096
10109
  *
10097
- * @returns {boolean}
10110
+ * @returns {Boolean}
10098
10111
  */
10099
10112
  get active() {
10100
10113
  return this._active;
@@ -13742,7 +13755,7 @@ class OcclusionTester {
13742
13755
  /**
13743
13756
  * Returns true if an occlusion test is needed.
13744
13757
  *
13745
- * @returns {boolean}
13758
+ * @returns {Boolean}
13746
13759
  */
13747
13760
  get needOcclusionTest() {
13748
13761
  return this._occlusionTestListDirty;
@@ -15495,7 +15508,7 @@ const Renderer = function (scene, options) {
15495
15508
 
15496
15509
  /**
15497
15510
  * Returns true if the next call to render() will draw something
15498
- * @returns {boolean}
15511
+ * @returns {Boolean}
15499
15512
  */
15500
15513
  this.needsRender = function () {
15501
15514
  return (imageDirty || drawableListDirty || stateSortDirty);
@@ -19878,7 +19891,7 @@ class Camera extends Component {
19878
19891
 
19879
19892
  /**
19880
19893
  * Gets if the World-space X-axis is "up".
19881
- * @returns {boolean}
19894
+ * @returns {Boolean}
19882
19895
  */
19883
19896
  get xUp() {
19884
19897
  return this._worldUp[0] > this._worldUp[1] && this._worldUp[0] > this._worldUp[2];
@@ -19886,7 +19899,7 @@ class Camera extends Component {
19886
19899
 
19887
19900
  /**
19888
19901
  * Gets if the World-space Y-axis is "up".
19889
- * @returns {boolean}
19902
+ * @returns {Boolean}
19890
19903
  */
19891
19904
  get yUp() {
19892
19905
  return this._worldUp[1] > this._worldUp[0] && this._worldUp[1] > this._worldUp[2];
@@ -19894,7 +19907,7 @@ class Camera extends Component {
19894
19907
 
19895
19908
  /**
19896
19909
  * Gets if the World-space Z-axis is "up".
19897
- * @returns {boolean}
19910
+ * @returns {Boolean}
19898
19911
  */
19899
19912
  get zUp() {
19900
19913
  return this._worldUp[2] > this._worldUp[0] && this._worldUp[2] > this._worldUp[1];
@@ -21290,7 +21303,7 @@ class ReadableGeometry extends Geometry {
21290
21303
 
21291
21304
  /**
21292
21305
  * @private
21293
- * @returns {boolean}
21306
+ * @returns {Boolean}
21294
21307
  */
21295
21308
  get isReadableGeometry() {
21296
21309
  return true;
@@ -24487,7 +24500,7 @@ class SAO extends Component {
24487
24500
  * Returns true if SAO is currently possible, where it is supported, enabled, and the current scene state is compatible.
24488
24501
  * Called internally by renderer logic.
24489
24502
  * @private
24490
- * @returns {boolean}
24503
+ * @returns {Boolean}
24491
24504
  */
24492
24505
  get possible() {
24493
24506
  if (!this._supported) {
@@ -25908,16 +25921,16 @@ class Scene extends Component {
25908
25921
  this.reflectionMaps = {};
25909
25922
 
25910
25923
  /**
25911
- * The {@link Bitmaps}s in this Scene, each mapped to its {@link Bitmap#id}.
25924
+ * The {@link Bitmap}s in this Scene, each mapped to its {@link Bitmap#id}.
25912
25925
  *
25913
25926
  * @type {{String:Bitmap}}
25914
25927
  */
25915
25928
  this.bitmaps = {};
25916
25929
 
25917
25930
  /**
25918
- * The {@link Line}s in this Scene, each mapped to its {@link Line#id}.
25931
+ * The {@link LineSet}s in this Scene, each mapped to its {@link LineSet#id}.
25919
25932
  *
25920
- * @type {{String:Line}}
25933
+ * @type {{String:LineSet}}
25921
25934
  */
25922
25935
  this.lineSets = {};
25923
25936
 
@@ -27842,9 +27855,24 @@ class Scene extends Component {
27842
27855
  }
27843
27856
  }
27844
27857
 
27858
+ /**
27859
+ * Texture repeat wrapping mode.
27860
+ * @type {number}
27861
+ */
27845
27862
  const RepeatWrapping = 1000;
27863
+
27864
+ /**
27865
+ * Texture clamp-to-edge wrapping mode.
27866
+ * @type {number}
27867
+ */
27846
27868
  const ClampToEdgeWrapping = 1001;
27869
+
27870
+ /**
27871
+ * Texture mirrored-repeat wrapping mode.
27872
+ * @type {number}
27873
+ */
27847
27874
  const MirroredRepeatWrapping = 1002;
27875
+
27848
27876
  const NearestFilter = 1003;
27849
27877
  const NearestMipMapNearestFilter = 1004;
27850
27878
  const NearestMipmapNearestFilter = 1004;
@@ -42386,7 +42414,7 @@ class VBOGeometry extends Geometry {
42386
42414
 
42387
42415
  /**
42388
42416
  * @private
42389
- * @returns {boolean}
42417
+ * @returns {Boolean}
42390
42418
  */
42391
42419
  get isVBOGeometry() {
42392
42420
  return true;
@@ -44435,14 +44463,14 @@ function buildTorusGeometry(cfg = {}) {
44435
44463
  *
44436
44464
  * * Creates a 3D quad containing our bitmap, located and oriented using ````pos````, ````normal```` and ````up```` vectors.
44437
44465
  * * Registered by {@link Bitmap#id} in {@link Scene#bitmaps}.
44438
- * * Created when we use {@link BCFViewpointsPlugin#setViewpoint} to load a BCF viewpoint that contains bitmaps.
44466
+ * * {@link BCFViewpointsPlugin} will save and load Bitmaps in BCF viewpoints.
44439
44467
  *
44440
44468
  * ## Usage
44441
44469
  *
44442
44470
  * In the example below, we'll load the Schependomlaan model, then use
44443
44471
  * an ````Bitmap```` to show a storey plan next to the model.
44444
44472
  *
44445
- * [<img src="http://xeokit.github.io/xeokit-sdk/assets/images/Bitmap_grid.png">](http://xeokit.github.io/xeokit-sdk/examples/#Bitmap_grid)
44473
+ * [<img src="http://xeokit.github.io/xeokit-sdk/assets/images/Bitmap_storeyPlan.png">](http://xeokit.github.io/xeokit-sdk/examples/#Bitmap_storeyPlan)
44446
44474
  *
44447
44475
  * [[Run this example](http://xeokit.github.io/xeokit-sdk/examples/#Bitmap_grid)]
44448
44476
  *
@@ -44482,6 +44510,10 @@ function buildTorusGeometry(cfg = {}) {
44482
44510
  class Bitmap extends Component {
44483
44511
 
44484
44512
  /**
44513
+ * Creates a new Bitmap.
44514
+ *
44515
+ * Registers the Bitmap in {@link Scene#bitmaps}; causes Scene to fire a "bitmapCreated" event.
44516
+ *
44485
44517
  * @constructor
44486
44518
  * @param {Component} [owner] Owner component. When destroyed, the owner will destroy this ````Bitmap```` as well.
44487
44519
  * @param {*} [cfg] ````Bitmap```` configuration
@@ -44873,7 +44905,9 @@ class Bitmap extends Component {
44873
44905
  }
44874
44906
 
44875
44907
  /**
44876
- * @destroy
44908
+ * Destroys this ````Bitmap````.
44909
+ *
44910
+ * Removes the ```Bitmap```` from {@link Scene#bitmaps}; causes Scene to fire a "bitmapDestroyed" event.
44877
44911
  */
44878
44912
  destroy() {
44879
44913
  super.destroy();
@@ -44892,13 +44926,13 @@ class Bitmap extends Component {
44892
44926
  * * Creates a set of 3D line segments.
44893
44927
  * * Registered by {@link LineSet#id} in {@link Scene#lineSets}.
44894
44928
  * * Configure color using the {@link LinesMaterial} located at {@link Scene#linesMaterial}.
44895
- * * Created when we use {@link BCFViewpointsPlugin#setViewpoint} to load a BCF viewpoint that contains lines.
44929
+ * * {@link BCFViewpointsPlugin} will save and load Linesets in BCF viewpoints.
44930
+ *
44931
+ * ## Usage
44896
44932
  *
44897
44933
  * In the example below, we'll load the Schependomlaan model, then use
44898
44934
  * a ````LineSet```` to show a grid underneath the model.
44899
44935
  *
44900
- * <img src="http://xeokit.io/img/docs/Bitmap/BCF_SaveViewpoint_BitmapsAndLines.png">
44901
- *
44902
44936
  * [<img src="http://xeokit.github.io/xeokit-sdk/assets/images/LineSet_grid.png">](http://xeokit.github.io/xeokit-sdk/examples/#LineSet_grid)
44903
44937
  *
44904
44938
  * [[Run this example](http://xeokit.github.io/xeokit-sdk/examples/#LineSet_grid)]
@@ -44922,8 +44956,7 @@ class Bitmap extends Component {
44922
44956
  * const model = xktLoader.load({
44923
44957
  * id: "myModel",
44924
44958
  * src: "../assets/models/xkt/v8/ifc/Schependomlaan.ifc.xkt",
44925
- *
44926
- * position: [0,1,0],
44959
+ * position: [0,1,0],
44927
44960
  * edges: true,
44928
44961
  * saoEnabled: true
44929
44962
  * });
@@ -44942,15 +44975,19 @@ class Bitmap extends Component {
44942
44975
  class LineSet extends Component {
44943
44976
 
44944
44977
  /**
44978
+ * Creates a new LineSet.
44979
+ *
44980
+ * Registers the LineSet in {@link Scene#lineSets}; causes Scene to fire a "lineSetCreated" event.
44981
+ *
44945
44982
  * @constructor
44946
44983
  * @param {Component} [owner] Owner component. When destroyed, the owner will destroy this ````LineSet```` as well.
44947
44984
  * @param {*} [cfg] ````LineSet```` configuration
44948
44985
  * @param {String} [cfg.id] Optional ID, unique among all components in the parent {@link Scene}, generated automatically when omitted.
44949
- * @param {Number[]} cfg.positions World-space vertex positions.
44950
- * @param {Number[]} [cfg.indices] Indices
44951
- * @param {Number[]} [cfg.color=[0,0,0]] The color of this ````LineSet````.
44986
+ * @param {Number[]} cfg.positions World-space 3D vertex positions.
44987
+ * @param {Number[]} [cfg.indices] Indices to connect ````positions```` into line segments. Note that these are separate line segments, not a polyline.
44988
+ * @param {Number[]} [cfg.color=[0,0,0]] The color of this ````LineSet````. This is both emissive and diffuse.
44952
44989
  * @param {Boolean} [cfg.visible=true] Indicates whether or not this ````LineSet```` is visible.
44953
- * @param {Number} [cfg.opacity=1.0] ````LineSet````'s initial opacity factor, multiplies by the rendered fragment alpha.
44990
+ * @param {Number} [cfg.opacity=1.0] ````LineSet````'s initial opacity factor.
44954
44991
  */
44955
44992
  constructor(owner, cfg = {}) {
44956
44993
 
@@ -44990,7 +45027,7 @@ class LineSet extends Component {
44990
45027
  }
44991
45028
 
44992
45029
  /**
44993
- * Sets if this ````LineSet```` is visible or not.
45030
+ * Sets if this ````LineSet```` is visible.
44994
45031
  *
44995
45032
  * Default value is ````true````.
44996
45033
  *
@@ -45001,7 +45038,7 @@ class LineSet extends Component {
45001
45038
  }
45002
45039
 
45003
45040
  /**
45004
- * Gets if this ````LineSet```` is visible or not.
45041
+ * Gets if this ````LineSet```` is visible.
45005
45042
  *
45006
45043
  * Default value is ````true````.
45007
45044
  *
@@ -45012,7 +45049,7 @@ class LineSet extends Component {
45012
45049
  }
45013
45050
 
45014
45051
  /**
45015
- * Gets the vertex positions of the lines in this ````LineSet````.
45052
+ * Gets the 3D World-space vertex positions of the lines in this ````LineSet````.
45016
45053
  *
45017
45054
  * @returns {Number[]}
45018
45055
  */
@@ -45030,7 +45067,9 @@ class LineSet extends Component {
45030
45067
  }
45031
45068
 
45032
45069
  /**
45033
- * @destroy
45070
+ * Destroys this ````LineSet````.
45071
+ *
45072
+ * Removes the ```LineSet```` from {@link Scene#lineSets}; causes Scene to fire a "lineSetDestroyed" event.
45034
45073
  */
45035
45074
  destroy() {
45036
45075
  super.destroy();
@@ -45046,19 +45085,46 @@ const tempVec3c$6 = math.vec3();
45046
45085
  /**
45047
45086
  * {@link Viewer} plugin that saves and loads BCF viewpoints as JSON objects.
45048
45087
  *
45049
- * BCF is a format for managing issues on a BIM project. This plugin's viewpoints conform to
45050
- * the <a href="https://github.com/buildingSMART/BCF-API">BCF Version 2.1</a> specification.
45088
+ * [<img src="http://xeokit.github.io/xeokit-sdk/assets/images/BCFViewpointsPlugin.png">](http://xeokit.github.io/xeokit-sdk/examples/#BCF_SaveViewpoint)
45089
+ *
45090
+ * * [[Example 1: Saving viewer state to a BCF viewpoint](https://xeokit.github.io/xeokit-sdk/examples/#BCF_SaveViewpoint)]
45091
+ * * [[Example 2: Loading viewer state from a BCF viewpoint](https://xeokit.github.io/xeokit-sdk/examples/#BCF_LoadViewpoint)]
45092
+ *
45093
+ * ## Overview
45094
+ *
45095
+ * BCF is an open standard that enables workflow communications between BIM software tools. An XML schema, called
45096
+ * Building Collaboration Format (BCF), encodes messages that inform one BIM tool of issues found by another.
45097
+ *
45098
+ * A BCF viewpoint captures a viewpoint of a model that highlights an issue. The viewpoint can then be loaded by another
45099
+ * viewer to examine the issue.
45100
+ *
45101
+ * Using this plugin, a xeokit {@link Viewer} can exchange BCF-encoded viewpoints with other BIM software,
45102
+ * allowing us to use the Viewer to report and view issues in BIM models.
45103
+ *
45104
+ * This plugin's viewpoints conform to the <a href="https://github.com/buildingSMART/BCF-API">BCF Version 2.1</a> specification.
45105
+ *
45106
+ * ## Supported BCF Elements
45107
+ *
45108
+ * BCFViewpointsPlugin saves and loads the following state in BCF viewpoints:
45109
+ *
45110
+ * * {@link Camera} position, orientation and projection
45111
+ * * {@link Entity} visibilities and selection states
45112
+ * * {@link SectionPlane}s to slice the model
45113
+ * * {@link LineSet}s to show 3D lines
45114
+ * * {@link Bitmap}s to show images
45051
45115
  *
45052
45116
  * ## Saving a BCF Viewpoint
45053
45117
  *
45054
45118
  * In the example below we'll create a {@link Viewer}, load an ````.XKT```` model into it using an {@link XKTLoaderPlugin},
45055
- * slice the model in half using a {@link SectionPlanesPlugin}, then use a {@link BCFViewpointsPlugin#getViewpoint}
45119
+ * slice the model in half using a {@link SectionPlanesPlugin}, create a grid ground plane using a {@link LineSet} and a 2D
45120
+ * plan view using a {@link Bitmap}, then use a {@link BCFViewpointsPlugin#getViewpoint}
45056
45121
  * to save a viewpoint to JSON, which we'll log to the JavaScript developer console.
45057
45122
  *
45058
- * * [[Run this example](http://xeokit.github.io/xeokit-sdk/examples/#BCF_SaveViewpoint)]
45123
+ * * [[Run this example](https://xeokit.github.io/xeokit-sdk/examples/#BCF_SaveViewpoint)]
45059
45124
  *
45060
45125
  * ````javascript
45061
- * import {Viewer, XKTLoaderPlugin, SectionPlanesPlugin, BCFViewpointsPlugin} from "xeokit-sdk.es.js";
45126
+ * import {Viewer, XKTLoaderPlugin, SectionPlanesPlugin,
45127
+ * LineSet, Bitmap, buildGridGeometry, BCFViewpointsPlugin} from "xeokit-sdk.es.js";
45062
45128
  *
45063
45129
  * // Create a Viewer
45064
45130
  * const viewer = new Viewer({
@@ -45066,6 +45132,12 @@ const tempVec3c$6 = math.vec3();
45066
45132
  * transparent: true
45067
45133
  * });
45068
45134
  *
45135
+ * // Set camera position and orientation
45136
+ * viewer.scene.camera.eye = [-48.93, 54.54, 50.41];
45137
+ * viewer.scene.camera.look = [0.55, -0.61, -0.55];
45138
+ * viewer.scene.camera.up = [0, -1, 0];
45139
+ * viewer.scene.camera.perspective.fov = 60;
45140
+ *
45069
45141
  * // Add a XKTLoaderPlugin
45070
45142
  * const xktLoader = new XKTLoaderPlugin(viewer);
45071
45143
  *
@@ -45089,15 +45161,37 @@ const tempVec3c$6 = math.vec3();
45089
45161
  * dir: [0.5, 0.0, 0.5]
45090
45162
  * });
45091
45163
  *
45092
- * // When model is loaded, set camera, select some objects and capture a BCF viewpoint to the console
45164
+ * // Create a bitmap
45165
+ * const bitmap = new Bitmap(viewer.scene, {
45166
+ * src: "../assets/images/schependomlaanPlanView.png",
45167
+ * visible: true,
45168
+ * height: 24.0,
45169
+ * pos: [-15, 0, -10],
45170
+ * normal: [0, -1, 0],
45171
+ * up: [0, 0, 1],
45172
+ * collidable: false,
45173
+ * opacity: 1.0,
45174
+ * clippable: false,
45175
+ * pickable: true
45176
+ * });
45177
+ *
45178
+ * // Create a grid ground plane
45179
+ * const geometryArrays = buildGridGeometry({
45180
+ * size: 60,
45181
+ * divisions: 10
45182
+ * });
45183
+ *
45184
+ * new LineSet(viewer.scene, {
45185
+ * positions: geometryArrays.positions,
45186
+ * indices: geometryArrays.indices,
45187
+ * position: [10,0,10],
45188
+ * clippable: false
45189
+ * });
45190
+ *
45191
+ * // When model is loaded, select some objects and capture a BCF viewpoint to the console
45093
45192
  * modelNode.on("loaded", () => {
45094
45193
  *
45095
45194
  * const scene = viewer.scene;
45096
- * const camera = scene.camera;
45097
- *
45098
- * camera.eye = [-2.37, 18.97, -26.12];
45099
- * camera.look = [10.97, 5.82, -11.22];
45100
- * camera.up = [0.36, 0.83, 0.40];
45101
45195
  *
45102
45196
  * scene.setObjectsSelected([
45103
45197
  * "3b2U496P5Ebhz5FROhTwFH",
@@ -45114,6 +45208,57 @@ const tempVec3c$6 = math.vec3();
45114
45208
  * });
45115
45209
  * ````
45116
45210
  *
45211
+ * The saved BCF viewpoint would look something like below. Note that some elements are truncated for brevity.
45212
+ *
45213
+ * ````json
45214
+ * {
45215
+ * "perspective_camera": {
45216
+ * "camera_view_point": { "x": -48.93, "y": 54.54, "z": 50.41 },
45217
+ * "camera_direction": { "x": 0.55, "y": -0.61, "z": -0.55},
45218
+ * "camera_up_vector": { "x": 0.37, "y": -0.41, "z": 0.83 },
45219
+ * "field_of_view": 60.0
45220
+ * },
45221
+ * "lines": [{
45222
+ * "start_point": { "x": 1.0, "y": 1.0, "z": 1.0 },
45223
+ * "end_point": { "x": 0.0, "y": 0.0, "z": 0.0 },
45224
+ * //...(truncated)
45225
+ * }],
45226
+ * "bitmaps": [{
45227
+ * "bitmap_type": "png",
45228
+ * "bitmap_data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB9AAAAdp...", //...(truncated)
45229
+ * "location": { "x": -15, "y": 10, "z": 0 },
45230
+ * "normal": { "x": 0, "y": 0, "z": -1 },
45231
+ * "up": { "x": 0, "y": -1, "z": 0 },
45232
+ * "height": 24
45233
+ * }],
45234
+ * "clipping_planes": [{
45235
+ * "location": { "x": 0.0, "y": 0.0, "z": 0.0 },
45236
+ * "direction": { "x": 0.5, "y": 0.0, "z": 0.5 }
45237
+ * }],
45238
+ * "snapshot": {
45239
+ * "snapshot_type": "png",
45240
+ * "snapshot_data": "data:image/png;base64,......"
45241
+ * },
45242
+ * "components": {
45243
+ * "visibility": {
45244
+ * "default_visibility": false,
45245
+ * "exceptions": [{
45246
+ * "ifc_guid": "4$cshxZO9AJBebsni$z9Yk",
45247
+ * "originating_system": "xeokit.io",
45248
+ * "authoring_tool_id": "xeokit/v3.2"
45249
+ * },
45250
+ * //...
45251
+ * ]
45252
+ * },
45253
+ * "selection": [{
45254
+ * "ifc_guid": "4$cshxZO9AJBebsni$z9Yk",
45255
+ * },
45256
+ * //...
45257
+ * ]
45258
+ * }
45259
+ * }
45260
+ * ````
45261
+ *
45117
45262
  * ## Saving View Setup Hints
45118
45263
  *
45119
45264
  * BCFViewpointsPlugin can optionally save hints in the viewpoint, which indicate how to set up the view when
@@ -45157,7 +45302,7 @@ const tempVec3c$6 = math.vec3();
45157
45302
  * });
45158
45303
  * ````
45159
45304
  *
45160
- * ## Dealing With Loaded Models That Are Not in the Viewpoint
45305
+ * ## Dealing With Loaded Models that are not in the Viewpoint
45161
45306
  *
45162
45307
  * If, for example, we load model "duplex", hide some objects, then save a BCF viewpoint with
45163
45308
  * ````BCFViewpointsPlugin#getViewpoint````, then load another model, "schependomlaan", then load the viewpoint again
@@ -45266,8 +45411,7 @@ class BCFViewpointsPlugin extends Plugin {
45266
45411
  /**
45267
45412
  * Saves viewer state to a BCF viewpoint.
45268
45413
  *
45269
- * Note that xeokit's {@link Camera#look} is the **point-of-interest**, whereas the BCF ````camera_direction```` is a
45270
- * direction vector. Therefore, we save ````camera_direction```` as the vector from {@link Camera#eye} to {@link Camera#look}.
45414
+ * See ````BCFViewpointsPlugin```` class comments for more info.
45271
45415
  *
45272
45416
  * @param {*} [options] Options for getting the viewpoint.
45273
45417
  * @param {Boolean} [options.spacesVisible=false] Indicates whether ````IfcSpace```` types should be forced visible in the viewpoint.
@@ -45280,84 +45424,6 @@ class BCFViewpointsPlugin extends Plugin {
45280
45424
  * objects in the viewpoint will be visible.
45281
45425
  * @param {Boolean} [options.reverseClippingPlanes=false] When ````true````, clipping planes are reversed (https://github.com/buildingSMART/BCF-XML/issues/193)
45282
45426
  * @returns {*} BCF JSON viewpoint object
45283
- * @example
45284
- *
45285
- * const viewer = new Viewer();
45286
- *
45287
- * const bcfPlugin = new BCFPlugin(viewer, {
45288
- * //...
45289
- * });
45290
- *
45291
- * const viewpoint = bcfPlugin.getViewpoint({ // Options - see constructor
45292
- * spacesVisible: false, // Default
45293
- * spaceBoundariesVisible: false, // Default
45294
- * openingsVisible: false // Default
45295
- * });
45296
- *
45297
- * // viewpoint will resemble the following:
45298
- *
45299
- * {
45300
- * perspective_camera: {
45301
- * camera_view_point: {
45302
- * x: 0.0,
45303
- * y: 0.0,
45304
- * z: 0.0
45305
- * },
45306
- * camera_direction: {
45307
- * x: 1.0,
45308
- * y: 1.0,
45309
- * z: 2.0
45310
- * },
45311
- * camera_up_vector: {
45312
- * x: 0.0,
45313
- * y: 0.0,
45314
- * z: 1.0
45315
- * },
45316
- * field_of_view: 90.0
45317
- * },
45318
- * lineSets: [{
45319
- * start_point: {
45320
- * x: 1.0,
45321
- * y: 1.0,
45322
- * z: 1.0
45323
- * },
45324
- * end_point: {
45325
- * x: 0.0,
45326
- * y: 0.0,
45327
- * z: 0.0
45328
- * }
45329
- * }],
45330
- * clipping_planes: [{
45331
- * location: {
45332
- * x: 0.5,
45333
- * y: 0.5,
45334
- * z: 0.5
45335
- * },
45336
- * direction: {
45337
- * x: 1.0,
45338
- * y: 0.0,
45339
- * z: 0.0
45340
- * }
45341
- * }],
45342
- * bitmaps: [],
45343
- * snapshot: {
45344
- * snapshot_type: png,
45345
- * snapshot_data: "data:image/png;base64,......"
45346
- * },
45347
- * components: {
45348
- * visibility: {
45349
- * default_visibility: false,
45350
- * exceptions: [{
45351
- * ifc_guid: 4$cshxZO9AJBebsni$z9Yk,
45352
- * originating_system: xeokit.io,
45353
- * authoring_tool_id: xeokit/v1.0
45354
- * }]
45355
- * },
45356
- * selection: [{
45357
- * ifc_guid: "4$cshxZO9AJBebsni$z9Yk",
45358
- * }]
45359
- * }
45360
- * }
45361
45427
  */
45362
45428
  getViewpoint(options = {}) {
45363
45429
  const scene = this.viewer.scene;
@@ -45679,7 +45745,9 @@ class BCFViewpointsPlugin extends Plugin {
45679
45745
  });
45680
45746
  new LineSet(scene, {
45681
45747
  positions,
45682
- indices
45748
+ indices,
45749
+ clippable: false,
45750
+ collidable: true
45683
45751
  });
45684
45752
  }
45685
45753
 
@@ -45692,6 +45760,7 @@ class BCFViewpointsPlugin extends Plugin {
45692
45760
  let location = xyzObjectToArray(e.location, tempVec3a$X);
45693
45761
  let normal = xyzObjectToArray(e.normal, tempVec3b$9);
45694
45762
  let up = xyzObjectToArray(e.up, tempVec3c$6);
45763
+ let height = e.height || 1;
45695
45764
  if (!bitmap_type) {
45696
45765
  return;
45697
45766
  }
@@ -45717,7 +45786,10 @@ class BCFViewpointsPlugin extends Plugin {
45717
45786
  type: bitmap_type,
45718
45787
  pos: location,
45719
45788
  normal: normal,
45720
- up: up
45789
+ up: up,
45790
+ clippable: false,
45791
+ collidable: true,
45792
+ height
45721
45793
  });
45722
45794
  });
45723
45795
  }
@@ -46356,7 +46428,7 @@ class DistanceMeasurement extends Component {
46356
46428
  /**
46357
46429
  * Sets whether this DistanceMeasurement is visible or not.
46358
46430
  *
46359
- * @type Boolean
46431
+ * @type {Boolean}
46360
46432
  */
46361
46433
  set visible(value) {
46362
46434
  value = value !== undefined ? Boolean(value) : this.plugin.defaultVisible;
@@ -46377,7 +46449,7 @@ class DistanceMeasurement extends Component {
46377
46449
  /**
46378
46450
  * Gets whether this DistanceMeasurement is visible or not.
46379
46451
  *
46380
- * @type Boolean
46452
+ * @type {Boolean}
46381
46453
  */
46382
46454
  get visible() {
46383
46455
  return this._visible;
@@ -46558,7 +46630,7 @@ class DistanceMeasurementsControl extends Component {
46558
46630
 
46559
46631
  /** Gets if this DistanceMeasurementsControl is currently active, where it is responding to input.
46560
46632
  *
46561
- * @returns {boolean}
46633
+ * @returns {Boolean}
46562
46634
  */
46563
46635
  get active() {
46564
46636
  return this._active;
@@ -54290,7 +54362,7 @@ class TrianglesBatchingLayer {
54290
54362
  *
54291
54363
  * @param lenPositions Number of positions we'd like to create in the portion.
54292
54364
  * @param lenIndices Number of indices we'd like to create in this portion.
54293
- * @returns {boolean} True if OK to create another portion.
54365
+ * @returns {Boolean} True if OK to create another portion.
54294
54366
  */
54295
54367
  canCreatePortion(lenPositions, lenIndices) {
54296
54368
  if (this._finalized) {
@@ -63720,7 +63792,7 @@ class LinesBatchingLayer {
63720
63792
  *
63721
63793
  * @param lenPositions Number of positions we'd like to create in the portion.
63722
63794
  * @param lenIndices Number of indices we'd like to create in this portion.
63723
- * @returns {boolean} True if OK to create another portion.
63795
+ * @returns {Boolean} True if OK to create another portion.
63724
63796
  */
63725
63797
  canCreatePortion(lenPositions, lenIndices) {
63726
63798
  if (this._finalized) {
@@ -67665,7 +67737,7 @@ class PointsBatchingLayer {
67665
67737
  * Tests if there is room for another portion in this PointsBatchingLayer.
67666
67738
  *
67667
67739
  * @param lenPositions Number of positions we'd like to create in the portion.
67668
- * @returns {boolean} True if OK to create another portion.
67740
+ * @returns {Boolean} True if OK to create another portion.
67669
67741
  */
67670
67742
  canCreatePortion(lenPositions) {
67671
67743
  if (this._finalized) {
@@ -72803,6 +72875,34 @@ class SceneModel {
72803
72875
  }
72804
72876
  }
72805
72877
 
72878
+ const Cache = {
72879
+
72880
+ enabled: false,
72881
+ files: {},
72882
+
72883
+ add: function (key, file) {
72884
+ if (this.enabled === false) {
72885
+ return;
72886
+ }
72887
+ this.files[key] = file;
72888
+ },
72889
+
72890
+ get: function (key) {
72891
+ if (this.enabled === false) {
72892
+ return;
72893
+ }
72894
+ return this.files[key];
72895
+ },
72896
+
72897
+ remove: function (key) {
72898
+ delete this.files[key];
72899
+ },
72900
+
72901
+ clear: function () {
72902
+ this.files = {};
72903
+ }
72904
+ };
72905
+
72806
72906
  class LoadingManager {
72807
72907
 
72808
72908
  constructor(onLoad, onProgress, onError) {
@@ -72940,138 +73040,6 @@ class Loader {
72940
73040
  }
72941
73041
  }
72942
73042
 
72943
- /**
72944
- * @author Deepkolos / https://github.com/deepkolos
72945
- */
72946
-
72947
- class WorkerPool$1 {
72948
-
72949
- constructor(pool = 4) {
72950
- this.pool = pool;
72951
- this.queue = [];
72952
- this.workers = [];
72953
- this.workersResolve = [];
72954
- this.workerStatus = 0;
72955
- }
72956
-
72957
- _initWorker(workerId) {
72958
- if (!this.workers[workerId]) {
72959
- const worker = this.workerCreator();
72960
- worker.addEventListener('message', this._onMessage.bind(this, workerId));
72961
- this.workers[workerId] = worker;
72962
- }
72963
- }
72964
-
72965
- _getIdleWorker() {
72966
- for (let i = 0; i < this.pool; i++)
72967
- if (!(this.workerStatus & (1 << i))) return i;
72968
- return -1;
72969
- }
72970
-
72971
- _onMessage(workerId, msg) {
72972
- const resolve = this.workersResolve[workerId];
72973
- resolve && resolve(msg);
72974
- if (this.queue.length) {
72975
- const {resolve, msg, transfer} = this.queue.shift();
72976
- this.workersResolve[workerId] = resolve;
72977
- this.workers[workerId].postMessage(msg, transfer);
72978
- } else {
72979
- this.workerStatus ^= 1 << workerId;
72980
- }
72981
- }
72982
-
72983
- setWorkerCreator(workerCreator) {
72984
- this.workerCreator = workerCreator;
72985
- }
72986
-
72987
- setWorkerLimit(pool) {
72988
- this.pool = pool;
72989
- }
72990
-
72991
- postMessage(msg, transfer) {
72992
- return new Promise((resolve) => {
72993
- const workerId = this._getIdleWorker();
72994
- if (workerId !== -1) {
72995
- this._initWorker(workerId);
72996
- this.workerStatus |= 1 << workerId;
72997
- this.workersResolve[workerId] = resolve;
72998
- this.workers[workerId].postMessage(msg, transfer);
72999
- } else {
73000
- this.queue.push({resolve, msg, transfer});
73001
- }
73002
- });
73003
- }
73004
-
73005
- destroy() {
73006
-
73007
- this.workers.forEach((worker) => worker.terminate());
73008
- this.workersResolve.length = 0;
73009
- this.workers.length = 0;
73010
- this.queue.length = 0;
73011
- this.workerStatus = 0;
73012
-
73013
- }
73014
-
73015
- }
73016
-
73017
- /**
73018
- * Transcodes texture data.
73019
- *
73020
- * A {@link SceneModel} configured with an appropriate TextureTranscoder will allow us to add textures from
73021
- * transcoded buffers or files. For a concrete example, see {@link VBOSceneModel}, which can be configured with
73022
- * a {@link KTX2TextureTranscoder}, which allows us to add textures from KTX2 buffers and files.
73023
- *
73024
- * @interface
73025
- */
73026
- class TextureTranscoder {
73027
-
73028
- /**
73029
- * Transcodes texture data from transcoded buffers into a {@link Texture2D}.
73030
- *
73031
- * @param {ArrayBuffer[]} buffers Transcoded texture data. Given as an array of buffers so that we can support
73032
- * multi-image textures, such as cube maps.
73033
- * @param {*} config Transcoding options.
73034
- * @param {Texture2D} texture The texture to load.
73035
- * @returns {Promise} Resolves when the texture has loaded.
73036
- */
73037
- transcode(buffers, texture, config = {}) {
73038
- }
73039
-
73040
- /**
73041
- * Destroys this transcoder.
73042
- */
73043
- destroy() {
73044
- }
73045
- }
73046
-
73047
- const Cache = {
73048
-
73049
- enabled: false,
73050
- files: {},
73051
-
73052
- add: function (key, file) {
73053
- if (this.enabled === false) {
73054
- return;
73055
- }
73056
- this.files[key] = file;
73057
- },
73058
-
73059
- get: function (key) {
73060
- if (this.enabled === false) {
73061
- return;
73062
- }
73063
- return this.files[key];
73064
- },
73065
-
73066
- remove: function (key) {
73067
- delete this.files[key];
73068
- },
73069
-
73070
- clear: function () {
73071
- this.files = {};
73072
- }
73073
- };
73074
-
73075
73043
  const loading = {};
73076
73044
 
73077
73045
  class FileLoader extends Loader {
@@ -73227,6 +73195,80 @@ class FileLoader extends Loader {
73227
73195
  }
73228
73196
  }
73229
73197
 
73198
+ /**
73199
+ * @author Deepkolos / https://github.com/deepkolos
73200
+ */
73201
+
73202
+ class WorkerPool$1 {
73203
+
73204
+ constructor(pool = 4) {
73205
+ this.pool = pool;
73206
+ this.queue = [];
73207
+ this.workers = [];
73208
+ this.workersResolve = [];
73209
+ this.workerStatus = 0;
73210
+ }
73211
+
73212
+ _initWorker(workerId) {
73213
+ if (!this.workers[workerId]) {
73214
+ const worker = this.workerCreator();
73215
+ worker.addEventListener('message', this._onMessage.bind(this, workerId));
73216
+ this.workers[workerId] = worker;
73217
+ }
73218
+ }
73219
+
73220
+ _getIdleWorker() {
73221
+ for (let i = 0; i < this.pool; i++)
73222
+ if (!(this.workerStatus & (1 << i))) return i;
73223
+ return -1;
73224
+ }
73225
+
73226
+ _onMessage(workerId, msg) {
73227
+ const resolve = this.workersResolve[workerId];
73228
+ resolve && resolve(msg);
73229
+ if (this.queue.length) {
73230
+ const {resolve, msg, transfer} = this.queue.shift();
73231
+ this.workersResolve[workerId] = resolve;
73232
+ this.workers[workerId].postMessage(msg, transfer);
73233
+ } else {
73234
+ this.workerStatus ^= 1 << workerId;
73235
+ }
73236
+ }
73237
+
73238
+ setWorkerCreator(workerCreator) {
73239
+ this.workerCreator = workerCreator;
73240
+ }
73241
+
73242
+ setWorkerLimit(pool) {
73243
+ this.pool = pool;
73244
+ }
73245
+
73246
+ postMessage(msg, transfer) {
73247
+ return new Promise((resolve) => {
73248
+ const workerId = this._getIdleWorker();
73249
+ if (workerId !== -1) {
73250
+ this._initWorker(workerId);
73251
+ this.workerStatus |= 1 << workerId;
73252
+ this.workersResolve[workerId] = resolve;
73253
+ this.workers[workerId].postMessage(msg, transfer);
73254
+ } else {
73255
+ this.queue.push({resolve, msg, transfer});
73256
+ }
73257
+ });
73258
+ }
73259
+
73260
+ destroy() {
73261
+
73262
+ this.workers.forEach((worker) => worker.terminate());
73263
+ this.workersResolve.length = 0;
73264
+ this.workers.length = 0;
73265
+ this.queue.length = 0;
73266
+ this.workerStatus = 0;
73267
+
73268
+ }
73269
+
73270
+ }
73271
+
73230
73272
  const KTX2TransferSRGB = 2;
73231
73273
  const KTX2_ALPHA_PREMULTIPLIED = 1;
73232
73274
 
@@ -77110,848 +77152,6 @@ class VBOSceneModel extends Component {
77110
77152
  }
77111
77153
  }
77112
77154
 
77113
- /**
77114
- * @private
77115
- */
77116
- class GLTFSceneGraphLoader {
77117
-
77118
- constructor(cfg) { // TODO: Loading options fallbacks on loader, eg. handleGLTFNode etc
77119
- }
77120
-
77121
- load(plugin, modelNode, src, options, ok, error) {
77122
- options = options || {};
77123
- var spinner = modelNode.scene.canvas.spinner;
77124
- spinner.processes++;
77125
- loadGLTF$1(plugin, modelNode, src, options, function () {
77126
- spinner.processes--;
77127
- core.scheduleTask(function () {
77128
- modelNode.scene.fire("modelLoaded", modelNode.id); // FIXME: Assumes listeners know order of these two events
77129
- modelNode.fire("loaded", true, false);
77130
- });
77131
- if (ok) {
77132
- ok();
77133
- }
77134
- },
77135
- function (msg) {
77136
- spinner.processes--;
77137
- modelNode.error(msg);
77138
- if (error) {
77139
- error(msg);
77140
- }
77141
- modelNode.fire("error", msg);
77142
- });
77143
- }
77144
-
77145
- parse(plugin, modelNode, gltf, options, ok, error) {
77146
- options = options || {};
77147
- var spinner = modelNode.scene.canvas.spinner;
77148
- spinner.processes++;
77149
- parseGLTF$2(plugin, gltf, "", options, modelNode, function () {
77150
- spinner.processes--;
77151
- modelNode.scene.fire("modelLoaded", modelNode.id); // FIXME: Assumes listeners know order of these two events
77152
- modelNode.fire("loaded", true, false);
77153
- if (ok) {
77154
- ok();
77155
- }
77156
- },
77157
- function (msg) {
77158
- spinner.processes--;
77159
- modelNode.error(msg);
77160
- modelNode.fire("error", msg);
77161
- if (error) {
77162
- error(msg);
77163
- }
77164
- });
77165
- }
77166
- }
77167
-
77168
-
77169
- var loadGLTF$1 = (function () {
77170
- return function (plugin, modelNode, src, options, ok, error) {
77171
- plugin.dataSource.getGLTF(src, function (json) { // OK
77172
- options.basePath = getBasePath(src);
77173
- parseGLTF$2(plugin, json, src, options, modelNode, ok, error);
77174
- },
77175
- error);
77176
- };
77177
-
77178
- function getBasePath(src) {
77179
- var i = src.lastIndexOf("/");
77180
- return (i !== 0) ? src.substring(0, i + 1) : "";
77181
- }
77182
- })();
77183
-
77184
- var parseGLTF$2 = (function () {
77185
-
77186
- const WEBGL_COMPONENT_TYPES = {
77187
- 5120: Int8Array,
77188
- 5121: Uint8Array,
77189
- 5122: Int16Array,
77190
- 5123: Uint16Array,
77191
- 5125: Uint32Array,
77192
- 5126: Float32Array
77193
- };
77194
-
77195
- const WEBGL_TYPE_SIZES = {
77196
- 'SCALAR': 1,
77197
- 'VEC2': 2,
77198
- 'VEC3': 3,
77199
- 'VEC4': 4,
77200
- 'MAT2': 4,
77201
- 'MAT3': 9,
77202
- 'MAT4': 16
77203
- };
77204
-
77205
- return function (plugin, json, src, options, modelNode, ok) {
77206
- modelNode.clear();
77207
- var ctx = {
77208
- src: src,
77209
- loadBuffer: options.loadBuffer,
77210
- basePath: options.basePath,
77211
- prioritizeGLTFNode: options.prioritizeGLTFNode,
77212
- handleGLTFNode: options.handleGLTFNode,
77213
- ignoreMaterials: !!options.ignoreMaterials,
77214
- edgeThreshold: options.edgeThreshold,
77215
- readableGeometry: !!options.readableGeometry,
77216
- json: json,
77217
- scene: modelNode.scene,
77218
- plugin: plugin,
77219
- modelNode: modelNode,
77220
- modelNodeProps: {
77221
- visible: modelNode.visible,
77222
- culled: modelNode.culled,
77223
- xrayed: modelNode.xrayed,
77224
- highlighted: modelNode.highlighted,
77225
- selected: modelNode.selected,
77226
- outlined: modelNode.outlined,
77227
- clippable: modelNode.clippable,
77228
- pickable: modelNode.pickable,
77229
- collidable: modelNode.collidable,
77230
- castsShadow: modelNode.castsShadow,
77231
- receivesShadow: modelNode.receivesShadow,
77232
- colorize: modelNode.colorize,
77233
- opacity: modelNode.opacity,
77234
- edges: modelNode.edges
77235
- }
77236
- };
77237
-
77238
- modelNode.scene.loading++; // Disables (re)compilation
77239
-
77240
- loadBuffers(ctx, function () {
77241
-
77242
- loadBufferViews(ctx);
77243
- loadAccessors(ctx);
77244
- loadTextures(ctx);
77245
- loadMaterials(ctx);
77246
- loadMeshes(ctx);
77247
- loadDefaultScene(ctx);
77248
-
77249
- modelNode.scene.loading--; // Re-enables (re)compilation
77250
-
77251
- ok();
77252
- });
77253
- };
77254
-
77255
- function loadBuffers(ctx, ok) {
77256
- var buffers = ctx.json.buffers;
77257
- if (buffers) {
77258
- var numToLoad = buffers.length;
77259
- for (var i = 0, len = buffers.length; i < len; i++) {
77260
- loadBuffer(ctx, buffers[i], function () {
77261
- if (--numToLoad === 0) {
77262
- ok();
77263
- }
77264
- }, function (msg) {
77265
- ctx.plugin.error(msg);
77266
- if (--numToLoad === 0) {
77267
- ok();
77268
- }
77269
- });
77270
- }
77271
- } else {
77272
- ok();
77273
- }
77274
- }
77275
-
77276
- function loadBuffer(ctx, bufferInfo, ok, err) {
77277
- var uri = bufferInfo.uri;
77278
- if (uri) {
77279
- ctx.plugin.dataSource.getArrayBuffer(ctx.src, uri, function (data) {
77280
- bufferInfo._buffer = data;
77281
- ok();
77282
- },
77283
- err);
77284
- } else {
77285
- err('gltf/handleBuffer missing uri in ' + JSON.stringify(bufferInfo));
77286
- }
77287
- }
77288
-
77289
- function loadBufferViews(ctx) {
77290
- var bufferViewsInfo = ctx.json.bufferViews;
77291
- if (bufferViewsInfo) {
77292
- for (var i = 0, len = bufferViewsInfo.length; i < len; i++) {
77293
- loadBufferView(ctx, bufferViewsInfo[i]);
77294
- }
77295
- }
77296
- }
77297
-
77298
- function loadBufferView(ctx, bufferViewInfo) {
77299
-
77300
- var buffer = ctx.json.buffers[bufferViewInfo.buffer];
77301
-
77302
- bufferViewInfo._typedArray = null;
77303
-
77304
- var byteLength = bufferViewInfo.byteLength || 0;
77305
- var byteOffset = bufferViewInfo.byteOffset || 0;
77306
-
77307
- bufferViewInfo._buffer = buffer._buffer.slice(byteOffset, byteOffset + byteLength);
77308
- }
77309
-
77310
- function loadAccessors(ctx) {
77311
- var accessorsInfo = ctx.json.accessors;
77312
- if (accessorsInfo) {
77313
- for (var i = 0, len = accessorsInfo.length; i < len; i++) {
77314
- loadAccessor(ctx, accessorsInfo[i]);
77315
- }
77316
- }
77317
- }
77318
-
77319
- function loadAccessor(ctx, accessorInfo) {
77320
- var bufferViewInfo = ctx.json.bufferViews[accessorInfo.bufferView];
77321
- var itemSize = WEBGL_TYPE_SIZES[accessorInfo.type];
77322
- var TypedArray = WEBGL_COMPONENT_TYPES[accessorInfo.componentType];
77323
-
77324
- // For VEC3: itemSize is 3, elementBytes is 4, itemBytes is 12.
77325
- var elementBytes = TypedArray.BYTES_PER_ELEMENT;
77326
- var itemBytes = elementBytes * itemSize;
77327
-
77328
- // The buffer is not interleaved if the stride is the item size in bytes.
77329
- if (accessorInfo.byteStride && accessorInfo.byteStride !== itemBytes) ; else {
77330
- accessorInfo._typedArray = new TypedArray(bufferViewInfo._buffer, accessorInfo.byteOffset || 0, accessorInfo.count * itemSize);
77331
- accessorInfo._itemSize = itemSize;
77332
- }
77333
- }
77334
-
77335
-
77336
- function loadTextures(ctx) {
77337
- var texturesInfo = ctx.json.textures;
77338
- if (texturesInfo) {
77339
- for (var i = 0, len = texturesInfo.length; i < len; i++) {
77340
- loadTexture(ctx, texturesInfo[i]);
77341
- }
77342
- }
77343
- }
77344
-
77345
- function loadTexture(ctx, textureInfo) {
77346
- let uri = ctx.json.images[textureInfo.source].uri;
77347
- if (uri && !uri.match(/^data:(.*?)(;base64)?,(.*)$/)) {
77348
- uri = ctx.basePath + uri;
77349
- }
77350
- textureInfo._texture = new Texture(ctx.modelNode, {
77351
- src: uri,
77352
- flipY: !!textureInfo.flipY,
77353
- //encoding: "sRGB"
77354
- encoding: "linear"
77355
- });
77356
- }
77357
-
77358
- function loadMaterials(ctx) {
77359
- var materialsInfo = ctx.json.materials;
77360
- if (materialsInfo) {
77361
- var materialInfo;
77362
- var material;
77363
- for (var i = 0, len = materialsInfo.length; i < len; i++) {
77364
- materialInfo = materialsInfo[i];
77365
- material = loadMaterial(ctx, materialInfo);
77366
- materialInfo._material = material;
77367
- }
77368
- }
77369
- }
77370
-
77371
- function loadMaterial(ctx, materialInfo) {
77372
-
77373
- var json = ctx.json;
77374
- var cfg = {};
77375
- var textureInfo;
77376
-
77377
- // Common attributes
77378
-
77379
- var normalTexture = materialInfo.normalTexture;
77380
- if (normalTexture) {
77381
- textureInfo = json.textures[normalTexture.index];
77382
- if (textureInfo) {
77383
- cfg.normalMap = textureInfo._texture;
77384
- //cfg.normalMap.encoding = "linear";
77385
- }
77386
- }
77387
-
77388
- var occlusionTexture = materialInfo.occlusionTexture;
77389
- if (occlusionTexture) {
77390
- textureInfo = json.textures[occlusionTexture.index];
77391
- if (textureInfo) {
77392
- cfg.occlusionMap = textureInfo._texture;
77393
- }
77394
- }
77395
-
77396
- var emissiveTexture = materialInfo.emissiveTexture;
77397
- if (emissiveTexture) {
77398
- textureInfo = json.textures[emissiveTexture.index];
77399
- if (textureInfo) {
77400
- cfg.emissiveMap = textureInfo._texture;
77401
- //cfg.emissiveMap.encoding = "sRGB";
77402
- }
77403
- }
77404
-
77405
- var emissiveFactor = materialInfo.emissiveFactor;
77406
- if (emissiveFactor) {
77407
- cfg.emissive = emissiveFactor;
77408
- }
77409
-
77410
- cfg.backfaces = !!materialInfo.doubleSided;
77411
-
77412
- var alphaMode = materialInfo.alphaMode;
77413
- switch (alphaMode) {
77414
- case "NORMAL_OPAQUE":
77415
- cfg.alphaMode = "opaque";
77416
- break;
77417
- case "MASK":
77418
- cfg.alphaMode = "mask";
77419
- break;
77420
- case "BLEND":
77421
- cfg.alphaMode = "blend";
77422
- break;
77423
- }
77424
-
77425
- var alphaCutoff = materialInfo.alphaCutoff;
77426
- if (alphaCutoff !== undefined) {
77427
- cfg.alphaCutoff = alphaCutoff;
77428
- }
77429
-
77430
- var extensions = materialInfo.extensions;
77431
- if (extensions) {
77432
-
77433
- // Specular PBR material
77434
-
77435
- var specularPBR = extensions["KHR_materials_pbrSpecularGlossiness"];
77436
- if (specularPBR) {
77437
-
77438
- var diffuseFactor = specularPBR.diffuseFactor;
77439
- if (diffuseFactor !== null && diffuseFactor !== undefined) {
77440
- cfg.diffuse = diffuseFactor.slice(0, 3);
77441
- cfg.alpha = diffuseFactor[3];
77442
- }
77443
-
77444
- var diffuseTexture = specularPBR.diffuseTexture;
77445
- if (diffuseTexture) {
77446
- textureInfo = json.textures[diffuseTexture.index];
77447
- if (textureInfo) {
77448
- cfg.diffuseMap = textureInfo._texture;
77449
- //cfg.diffuseMap.encoding = "sRGB";
77450
- }
77451
- }
77452
-
77453
- var specularFactor = specularPBR.specularFactor;
77454
- if (specularFactor !== null && specularFactor !== undefined) {
77455
- cfg.specular = specularFactor.slice(0, 3);
77456
- }
77457
-
77458
- var glossinessFactor = specularPBR.glossinessFactor;
77459
- if (glossinessFactor !== null && glossinessFactor !== undefined) {
77460
- cfg.glossiness = glossinessFactor;
77461
- }
77462
-
77463
- var specularGlossinessTexture = specularPBR.specularGlossinessTexture;
77464
- if (specularGlossinessTexture) {
77465
- textureInfo = json.textures[specularGlossinessTexture.index];
77466
- if (textureInfo) {
77467
- cfg.specularGlossinessMap = textureInfo._texture;
77468
- //cfg.specularGlossinessMap.encoding = "linear";
77469
- }
77470
- }
77471
-
77472
- return new SpecularMaterial(ctx.modelNode, cfg);
77473
- }
77474
-
77475
- // Common Phong, Blinn, Lambert or Constant materials
77476
-
77477
- var common = extensions["KHR_materials_common"];
77478
- if (common) {
77479
-
77480
- var technique = common.technique;
77481
- var values = common.values || {};
77482
-
77483
- var blinn = technique === "BLINN";
77484
- var phong = technique === "PHONG";
77485
- var lambert = technique === "LAMBERT";
77486
-
77487
- var shininess = values.shininess;
77488
- if ((blinn || phong) && shininess !== null && shininess !== undefined) {
77489
- cfg.shininess = shininess;
77490
- } else {
77491
- cfg.shininess = 0;
77492
- }
77493
- var texture;
77494
- var diffuse = values.diffuse;
77495
- if (diffuse && (blinn || phong || lambert)) {
77496
- if (utils.isString(diffuse)) {
77497
- texture = json.textures[diffuse];
77498
- if (texture) {
77499
- cfg.diffuseMap = texture;
77500
- // cfg.diffuseMap.encoding = "sRGB";
77501
- }
77502
- } else {
77503
- cfg.diffuse = diffuse.slice(0, 3);
77504
- }
77505
- } else {
77506
- cfg.diffuse = [0, 0, 0];
77507
- }
77508
-
77509
- var specular = values.specular;
77510
- if (specular && (blinn || phong)) {
77511
- if (utils.isString(specular)) {
77512
- texture = json.textures[specular];
77513
- if (texture) {
77514
- cfg.specularMap = texture;
77515
- }
77516
- } else {
77517
- cfg.specular = specular.slice(0, 3);
77518
- }
77519
- } else {
77520
- cfg.specular = [0, 0, 0];
77521
- }
77522
-
77523
- var emission = values.emission;
77524
- if (emission) {
77525
- if (utils.isString(emission)) {
77526
- texture = json.textures[emission];
77527
- if (texture) {
77528
- cfg.emissiveMap = texture;
77529
- }
77530
- } else {
77531
- cfg.emissive = emission.slice(0, 3);
77532
- }
77533
- } else {
77534
- cfg.emissive = [0, 0, 0];
77535
- }
77536
-
77537
- var transparency = values.transparency;
77538
- if (transparency !== null && transparency !== undefined) {
77539
- cfg.alpha = transparency;
77540
- } else {
77541
- cfg.alpha = 1.0;
77542
- }
77543
-
77544
- values.transparent;
77545
-
77546
- return new PhongMaterial(ctx.scene, cfg);
77547
- }
77548
- }
77549
-
77550
- // Metallic PBR naterial
77551
-
77552
- var metallicPBR = materialInfo.pbrMetallicRoughness;
77553
- if (metallicPBR) {
77554
-
77555
- var baseColorFactor = metallicPBR.baseColorFactor;
77556
- if (baseColorFactor) {
77557
- cfg.baseColor = baseColorFactor.slice(0, 3);
77558
- cfg.alpha = baseColorFactor[3];
77559
- }
77560
-
77561
- var colorTexture = metallicPBR.colorTexture;
77562
- if (colorTexture) {
77563
- textureInfo = json.textures[colorTexture.index];
77564
- if (textureInfo) {
77565
- cfg.baseColorMap = textureInfo._texture;
77566
- //cfg.baseColorMap.encoding = "sRGB";
77567
- }
77568
- }
77569
-
77570
- var metallicFactor = metallicPBR.metallicFactor;
77571
- if (metallicFactor !== null && metallicFactor !== undefined) {
77572
- cfg.metallic = metallicFactor;
77573
- }
77574
-
77575
- var roughnessFactor = metallicPBR.roughnessFactor;
77576
- if (roughnessFactor !== null && roughnessFactor !== undefined) {
77577
- cfg.roughness = roughnessFactor;
77578
- }
77579
-
77580
- var metallicRoughnessTexture = metallicPBR.metallicRoughnessTexture;
77581
- if (metallicRoughnessTexture) {
77582
- textureInfo = json.textures[metallicRoughnessTexture.index];
77583
- if (textureInfo) {
77584
- cfg.metallicRoughnessMap = textureInfo._texture;
77585
- // cfg.metallicRoughnessMap.encoding = "linear";
77586
- }
77587
- }
77588
-
77589
- return new MetallicMaterial(ctx.scene, cfg);
77590
- }
77591
-
77592
- // Default material
77593
-
77594
- return new PhongMaterial(ctx.scene, cfg);
77595
- }
77596
-
77597
- function loadMeshes(ctx) {
77598
- var meshes = ctx.json.meshes;
77599
- if (meshes) {
77600
- for (var i = 0, len = meshes.length; i < len; i++) {
77601
- loadMesh(ctx, meshes[i]);
77602
- }
77603
- }
77604
- }
77605
-
77606
- function loadMesh(ctx, meshInfo) {
77607
- var json = ctx.json;
77608
- var mesh = [];
77609
- var primitivesInfo = meshInfo.primitives;
77610
- var materialIndex;
77611
- var materialInfo;
77612
- var accessorInfo;
77613
- var attributes;
77614
-
77615
- if (primitivesInfo) {
77616
-
77617
- var primitiveInfo;
77618
- var indicesIndex;
77619
- var positionsIndex;
77620
- var normalsIndex;
77621
- var uv0Index;
77622
- var geometryCfg;
77623
- var meshCfg;
77624
- var geometry;
77625
-
77626
- for (var i = 0, len = primitivesInfo.length; i < len; i++) {
77627
- primitiveInfo = primitivesInfo[i];
77628
- if (primitiveInfo.mode < 4 ) {
77629
- continue;
77630
- }
77631
- geometryCfg = {
77632
- primitive: "triangles",
77633
- compressGeometry: true,
77634
- edgeThreshold: ctx.edgeThreshold
77635
- };
77636
-
77637
- indicesIndex = primitiveInfo.indices;
77638
-
77639
- if (indicesIndex !== null && indicesIndex !== undefined) {
77640
- accessorInfo = json.accessors[indicesIndex];
77641
- geometryCfg.indices = accessorInfo._typedArray;
77642
- }
77643
-
77644
- attributes = primitiveInfo.attributes;
77645
- if (!attributes) {
77646
- continue;
77647
- }
77648
-
77649
- positionsIndex = attributes.POSITION;
77650
-
77651
- if (positionsIndex !== null && positionsIndex !== undefined) {
77652
- accessorInfo = json.accessors[positionsIndex];
77653
- geometryCfg.positions = accessorInfo._typedArray;
77654
- }
77655
-
77656
- normalsIndex = attributes.NORMAL;
77657
-
77658
- if (normalsIndex !== null && normalsIndex !== undefined) {
77659
- accessorInfo = json.accessors[normalsIndex];
77660
- geometryCfg.normals = accessorInfo._typedArray;
77661
- }
77662
-
77663
- uv0Index = attributes.TEXCOORD_0;
77664
-
77665
- if (uv0Index !== null && uv0Index !== undefined) {
77666
- accessorInfo = json.accessors[uv0Index];
77667
- geometryCfg.uv = accessorInfo._typedArray;
77668
- }
77669
-
77670
- meshCfg = {};
77671
-
77672
- if (ctx.readableGeometry) {
77673
- geometry = new ReadableGeometry(ctx.modelNode, geometryCfg);
77674
- } else {
77675
- geometry = new VBOGeometry(ctx.modelNode, geometryCfg);
77676
- }
77677
-
77678
- meshCfg.geometry = geometry;
77679
-
77680
- materialIndex = primitiveInfo.material;
77681
- if (materialIndex !== null && materialIndex !== undefined) {
77682
- materialInfo = json.materials[materialIndex];
77683
- if (materialInfo) {
77684
- meshCfg.material = materialInfo._material;
77685
- }
77686
- }
77687
-
77688
- mesh.push(meshCfg);
77689
- }
77690
- }
77691
- meshInfo._mesh = mesh;
77692
- }
77693
-
77694
- function loadDefaultScene(ctx) {
77695
- var json = ctx.json;
77696
- var scene = json.scene || 0;
77697
- var defaultSceneInfo = json.scenes[scene];
77698
- if (!defaultSceneInfo) {
77699
- error(ctx, "glTF has no default scene");
77700
- return;
77701
- }
77702
- loadScene(ctx, defaultSceneInfo);
77703
- }
77704
-
77705
- function loadScene(ctx, sceneInfo) {
77706
- var nodes = sceneInfo.nodes;
77707
- if (!nodes) {
77708
- return;
77709
- }
77710
- var json = ctx.json;
77711
- var glTFNode;
77712
- for (var i = 0, len = nodes.length; i < len; i++) {
77713
- glTFNode = json.nodes[nodes[i]];
77714
- if (!glTFNode) {
77715
- error(ctx, "Node not found: " + i);
77716
- continue;
77717
- }
77718
- loadNode(ctx, glTFNode, null, null);
77719
- }
77720
- }
77721
-
77722
- function loadNode(ctx, glTFNode, matrix, parent) {
77723
-
77724
- parent = parent || ctx.modelNode;
77725
-
77726
- var createEntity;
77727
-
77728
- if (ctx.prioritizeGLTFNode) {
77729
- const priority = ctx.prioritizeGLTFNode(ctx.modelNode.id, glTFNode);
77730
- if (priority === undefined || priority === null) {
77731
- return;
77732
- }
77733
- }
77734
-
77735
- if (ctx.handleGLTFNode) {
77736
- var actions = {};
77737
- if (!ctx.handleGLTFNode(ctx.modelNode.id, glTFNode, actions)) {
77738
- return;
77739
- }
77740
- if (actions.createEntity) {
77741
- createEntity = actions.createEntity;
77742
- }
77743
- }
77744
-
77745
- const json = ctx.json;
77746
- const modelNode = ctx.modelNode;
77747
- const hasChildNodes = glTFNode.children && glTFNode.children.length > 0;
77748
-
77749
- var localMatrix;
77750
-
77751
- if (glTFNode.matrix) {
77752
- localMatrix = glTFNode.matrix;
77753
- if (matrix) {
77754
- matrix = math.mulMat4(matrix, localMatrix, math.mat4());
77755
- } else {
77756
- matrix = localMatrix;
77757
- }
77758
- }
77759
-
77760
- if (glTFNode.translation) {
77761
- localMatrix = math.translationMat4v(glTFNode.translation);
77762
- if (matrix) {
77763
- matrix = math.mulMat4(matrix, localMatrix, localMatrix);
77764
- } else {
77765
- matrix = localMatrix;
77766
- }
77767
- }
77768
-
77769
- if (glTFNode.rotation) {
77770
- localMatrix = math.quaternionToMat4(glTFNode.rotation);
77771
- if (matrix) {
77772
- matrix = math.mulMat4(matrix, localMatrix, localMatrix);
77773
- } else {
77774
- matrix = localMatrix;
77775
- }
77776
- }
77777
-
77778
- if (glTFNode.scale) {
77779
- localMatrix = math.scalingMat4v(glTFNode.scale);
77780
- if (matrix) {
77781
- matrix = math.mulMat4(matrix, localMatrix, localMatrix);
77782
- } else {
77783
- matrix = localMatrix;
77784
- }
77785
- }
77786
-
77787
- if (glTFNode.mesh !== undefined) {
77788
-
77789
- var meshInfo = json.meshes[glTFNode.mesh];
77790
-
77791
- if (meshInfo) {
77792
-
77793
- var meshesInfo = meshInfo._mesh;
77794
- var meshesInfoMesh;
77795
- var mesh;
77796
- var numMeshes = meshesInfo.length;
77797
-
77798
- if (!createEntity && numMeshes > 0 && !hasChildNodes) {
77799
-
77800
- // Case 1: Not creating object, node has meshes, node has no child nodes
77801
-
77802
- for (var i = 0, len = numMeshes; i < len; i++) {
77803
- meshesInfoMesh = meshesInfo[i];
77804
- let meshCfg = {
77805
- geometry: meshesInfoMesh.geometry,
77806
- matrix: matrix
77807
- };
77808
- utils.apply(ctx.modelNodeProps, meshCfg);
77809
- meshCfg.material = meshesInfoMesh.material;
77810
- mesh = new Mesh(modelNode, meshCfg);
77811
- parent.addChild(mesh, false); // Don't automatically inherit properties
77812
- }
77813
- return;
77814
- }
77815
-
77816
- if (createEntity && numMeshes === 1 && !hasChildNodes) {
77817
-
77818
- // Case 2: Creating object, node has one mesh, node has no child nodes
77819
-
77820
- meshesInfoMesh = meshesInfo[0];
77821
- let meshCfg = {
77822
- geometry: meshesInfoMesh.geometry,
77823
- matrix: matrix
77824
- };
77825
- utils.apply(ctx.modelNodeProps, meshCfg);
77826
- meshCfg.material = meshesInfoMesh.material;
77827
- utils.apply(createEntity, meshCfg);
77828
- mesh = new Mesh(modelNode, meshCfg);
77829
- parent.addChild(mesh, false); // Don't automatically inherit properties
77830
- return;
77831
- }
77832
-
77833
- if (createEntity && numMeshes > 0 && !hasChildNodes) {
77834
-
77835
- // Case 3: Creating object, node has meshes, node has no child nodes
77836
-
77837
- let nodeCfg = {
77838
- matrix: matrix
77839
- };
77840
- utils.apply(ctx.modelNodeProps, nodeCfg);
77841
- utils.apply(createEntity, nodeCfg);
77842
- let childNode = new Node$1(modelNode, nodeCfg);
77843
- parent.addChild(childNode, false);
77844
- for (let i = 0, len = numMeshes; i < len; i++) {
77845
- meshesInfoMesh = meshesInfo[i];
77846
- let meshCfg = {
77847
- geometry: meshesInfoMesh.geometry
77848
- };
77849
- utils.apply(ctx.modelNodeProps, meshCfg);
77850
- meshCfg.material = meshesInfoMesh.material;
77851
- utils.apply(createEntity, meshCfg);
77852
- meshCfg.id = null; // Avoid ID clash with parent Node
77853
- mesh = new Mesh(modelNode, meshCfg);
77854
- childNode.addChild(mesh, false);
77855
- }
77856
- return;
77857
- }
77858
-
77859
- if (!createEntity && numMeshes > 0 && hasChildNodes) {
77860
-
77861
- // Case 4: Not creating object, node has meshes, node has child nodes
77862
-
77863
- let nodeCfg = {
77864
- matrix: matrix
77865
- };
77866
- utils.apply(ctx.modelNodeProps, nodeCfg);
77867
- let childNode = new Node$1(modelNode, nodeCfg);
77868
- parent.addChild(childNode, false);
77869
- for (let i = 0, len = numMeshes; i < len; i++) {
77870
- meshesInfoMesh = meshesInfo[i];
77871
- let meshCfg = {
77872
- geometry: meshesInfoMesh.geometry
77873
- };
77874
- utils.apply(nodeCfg, meshCfg);
77875
- meshCfg.id = null; // Avoid ID clash with parent Node
77876
- meshCfg.matrix = null; // Node has matrix
77877
- meshCfg.material = meshesInfoMesh.material;
77878
- mesh = new Mesh(modelNode, meshCfg);
77879
- childNode.addChild(mesh, false);
77880
- }
77881
- matrix = null;
77882
- parent = childNode;
77883
- }
77884
-
77885
- if (createEntity && numMeshes === 0 && hasChildNodes) {
77886
-
77887
- // Case 5: Creating explicit object, node has meshes OR node has child nodes
77888
-
77889
- let nodeCfg = {
77890
- matrix: matrix
77891
- };
77892
- utils.apply(ctx.modelNodeProps, nodeCfg);
77893
- utils.apply(createEntity, nodeCfg);
77894
- createEntity.matrix = matrix;
77895
- let childNode = new Node$1(modelNode, nodeCfg);
77896
- parent.addChild(childNode, false); // Don't automatically inherit properties
77897
- matrix = null;
77898
- parent = childNode;
77899
- }
77900
-
77901
- if (createEntity && numMeshes > 0 || hasChildNodes) {
77902
-
77903
- // Case 6: Creating explicit object, node has meshes OR node has child nodes
77904
-
77905
- let nodeCfg = {
77906
- matrix: matrix
77907
- };
77908
- utils.apply(ctx.modelNodeProps, nodeCfg);
77909
- if (createEntity) {
77910
- utils.apply(createEntity, nodeCfg);
77911
- }
77912
- let childNode = new Node$1(modelNode, nodeCfg);
77913
- parent.addChild(childNode, false); // Don't automatically inherit properties
77914
- for (let i = 0, len = numMeshes; i < len; i++) {
77915
- meshesInfoMesh = meshesInfo[i];
77916
- let meshCfg = {
77917
- geometry: meshesInfoMesh.geometry
77918
- };
77919
- utils.apply(ctx.modelProps, meshCfg);
77920
- meshCfg.material = meshesInfoMesh.material;
77921
- if (createEntity) {
77922
- utils.apply(createEntity, meshCfg);
77923
- }
77924
- meshCfg.id = null; // Avoid ID clash with parent Node
77925
- mesh = new Mesh(modelNode, meshCfg);
77926
- childNode.addChild(mesh, false); // Don't automatically inherit properties
77927
- }
77928
- matrix = null;
77929
- parent = childNode;
77930
- }
77931
- }
77932
- }
77933
-
77934
- if (glTFNode.children) {
77935
- var children = glTFNode.children;
77936
- var childNodeInfo;
77937
- var childNodeIdx;
77938
- for (let i = 0, len = children.length; i < len; i++) {
77939
- childNodeIdx = children[i];
77940
- childNodeInfo = json.nodes[childNodeIdx];
77941
- if (!childNodeInfo) {
77942
- error(ctx, "Node not found: " + i);
77943
- continue;
77944
- }
77945
- loadNode(ctx, childNodeInfo, matrix, parent);
77946
- }
77947
- }
77948
- }
77949
-
77950
- function error(ctx, msg) {
77951
- ctx.plugin.error(msg);
77952
- }
77953
- })();
77954
-
77955
77155
  function assert$5(condition, message) {
77956
77156
  if (!condition) {
77957
77157
  throw new Error(message || 'loader assertion failed.');
@@ -85267,7 +84467,7 @@ async function parse$1(arrayBuffer, options = {}, context) {
85267
84467
  /**
85268
84468
  * @private
85269
84469
  */
85270
- class GLTFPerformanceModelLoader {
84470
+ class GLTFVBOSceneModelLoader {
85271
84471
 
85272
84472
  constructor(cfg) {
85273
84473
  }
@@ -85768,9 +84968,14 @@ const IFCObjectDefaults = {
85768
84968
  /**
85769
84969
  * {@link Viewer} plugin that loads models from [glTF](https://www.khronos.org/gltf/).
85770
84970
  *
84971
+ * * Loads all glTF formats, including embedded and binary formats.
84972
+ * * Loads physically-based materials and textures.
85771
84973
  * * 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}.
85772
84974
  * * 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}.
85773
84975
  * * 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.
84976
+ * * Not recommended for large models. For best performance with large glTF datasets, we recommend first converting them
84977
+ * to ````.xkt```` format (eg. using [convert2xkt](https://github.com/xeokit/xeokit-convert)), then loading
84978
+ * the ````.xkt```` using {@link XKTLoaderPlugin}.
85774
84979
  *
85775
84980
  * ## Metadata
85776
84981
  *
@@ -85781,23 +84986,6 @@ const IFCObjectDefaults = {
85781
84986
  * 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
85782
84987
  * uses its own map of default colors and visibilities for IFC element types.
85783
84988
  *
85784
- * ## Quality Setting
85785
- *
85786
- * By default, GLTFLoaderPlugin will load a high-performance scene representation that's optimized for low memory usage and
85787
- * optimal rendering. The high-performance representation renders large numbers of objects efficiently, using geometry
85788
- * batching and instancing, with simple Lambertian shading that ignores any textures and realistic materials in the glTF.
85789
- *
85790
- * Specifying ````performance:false```` to {@link GLTFLoaderPlugin#load} will internally load a heavier scene
85791
- * representation comprised of {@link Node}, {@link Mesh}, {@link Geometry}, {@link Material} and {@link Texture} components,
85792
- * that will exactly preserve the materials specified in the glTF. Use this when you want to load a model for a realistic preview,
85793
- * maybe using PBR etc.
85794
- *
85795
- * We tend to use the default ````performance:true```` setting for CAD and BIM models, where structure is more important that
85796
- * surface appearance.
85797
- *
85798
- * Publically, GLTFLoaderPlugin creates the same {@link Entity}s for both levels of performance. Privately, however, it implements
85799
- * {@link Entity}s using two different sets of concrete subtypes, for its two different internally-managed scene representations.
85800
- *
85801
84989
  * ## Usage
85802
84990
  *
85803
84991
  * 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
@@ -85811,8 +84999,6 @@ const IFCObjectDefaults = {
85811
84999
  *
85812
85000
  * 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).
85813
85001
  *
85814
- * We're leaving ````performance: true```` since our model has many objects and we're not interested in realistic rendering.
85815
- *
85816
85002
  * [[Run this example](http://xeokit.github.io/xeokit-sdk/examples/#BIMOffline_glTF_OTCConferenceCenter)]
85817
85003
  *
85818
85004
  * ````javascript
@@ -85851,8 +85037,7 @@ const IFCObjectDefaults = {
85851
85037
  * id: "myModel",
85852
85038
  * src: "./models/gltf/OTCConferenceCenter/scene.gltf",
85853
85039
  * metaModelSrc: "./models/gltf/OTCConferenceCenter/metaModel.json", // Creates a MetaModel (see below)
85854
- * edges: true,
85855
- * performance: true // Load high-performance scene representation (default is false)
85040
+ * edges: true
85856
85041
  * });
85857
85042
  *
85858
85043
  * model.on("loaded", () => {
@@ -85954,16 +85139,8 @@ class GLTFLoaderPlugin extends Plugin {
85954
85139
  constructor(viewer, cfg = {}) {
85955
85140
 
85956
85141
  super("GLTFLoader", viewer, cfg);
85957
-
85958
- /**
85959
- * @private
85960
- */
85961
- this._sceneGraphLoader = new GLTFSceneGraphLoader(this, cfg);
85962
-
85963
- /**
85964
- * @private
85965
- */
85966
- this._performanceModelLoader = new GLTFPerformanceModelLoader(this, cfg);
85142
+
85143
+ this._sceneModelLoader = new GLTFVBOSceneModelLoader(this, cfg);
85967
85144
 
85968
85145
  this.dataSource = cfg.dataSource;
85969
85146
  this.objectDefaults = cfg.objectDefaults;
@@ -86036,8 +85213,7 @@ class GLTFLoaderPlugin extends Plugin {
86036
85213
  * @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````.
86037
85214
  * @param {Boolean} [params.backfaces=false] When true, allows visible backfaces, wherever specified in the glTF. When false, ignores backfaces.
86038
85215
  * @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.
86039
- * @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.
86040
- * @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}
85216
+ * @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}
86041
85217
  */
86042
85218
  load(params = {}) {
86043
85219
 
@@ -86046,20 +85222,7 @@ class GLTFLoaderPlugin extends Plugin {
86046
85222
  delete params.id;
86047
85223
  }
86048
85224
 
86049
- const performance = params.performance !== false;
86050
-
86051
- const sceneModel = performance
86052
-
86053
- // VBOSceneModel provides performance-oriented scene representation
86054
- // converting glTF materials to simple flat-shading without textures
86055
-
86056
- ? new VBOSceneModel(this.viewer.scene, utils.apply(params, {
86057
- isModel: true
86058
- }))
86059
-
86060
- // Scene Node graph supports original glTF materials
86061
-
86062
- : new Node$1(this.viewer.scene, utils.apply(params, {
85225
+ const sceneModel = new VBOSceneModel(this.viewer.scene, utils.apply(params, {
86063
85226
  isModel: true
86064
85227
  }));
86065
85228
 
@@ -86070,8 +85233,6 @@ class GLTFLoaderPlugin extends Plugin {
86070
85233
  return sceneModel; // Return new empty model
86071
85234
  }
86072
85235
 
86073
- const loader = performance ? this._performanceModelLoader : this._sceneGraphLoader;
86074
-
86075
85236
  if (params.metaModelSrc || params.metaModelData) {
86076
85237
 
86077
85238
  const objectDefaults = params.objectDefaults || this._objectDefaults || IFCObjectDefaults;
@@ -86145,9 +85306,9 @@ class GLTFLoaderPlugin extends Plugin {
86145
85306
  };
86146
85307
 
86147
85308
  if (params.src) {
86148
- loader.load(this, sceneModel, params.src, params);
85309
+ this._sceneModelLoader.load(this, sceneModel, params.src, params);
86149
85310
  } else {
86150
- loader.parse(this, sceneModel, params.gltf, params);
85311
+ this._sceneModelLoader.parse(this, sceneModel, params.gltf, params);
86151
85312
  }
86152
85313
  };
86153
85314
 
@@ -86194,9 +85355,9 @@ class GLTFLoaderPlugin extends Plugin {
86194
85355
  };
86195
85356
 
86196
85357
  if (params.src) {
86197
- loader.load(this, sceneModel, params.src, params);
85358
+ this._sceneModelLoader.load(this, sceneModel, params.src, params);
86198
85359
  } else {
86199
- loader.parse(this, sceneModel, params.gltf, params);
85360
+ this._sceneModelLoader.parse(this, sceneModel, params.gltf, params);
86200
85361
  }
86201
85362
  }
86202
85363
 
@@ -89775,6 +88936,7 @@ const tempVec3$3 = math.vec3();
89775
88936
  * this example).
89776
88937
  * * Click a plane in the overview to activate a 3D control with which you can interactively
89777
88938
  * reposition its SectionPlane in the main canvas.
88939
+ * * Use {@lin BCFViewpointsPlugin} to save and load SectionPlanes in BCF viewpoints.
89778
88940
  *
89779
88941
  * ## Usage
89780
88942
  *
@@ -89840,7 +89002,7 @@ const tempVec3$3 = math.vec3();
89840
89002
  * // Programmatically reposition one of our SectionPlanes
89841
89003
  * // This also updates its position as shown in the overview gizmo
89842
89004
  *
89843
- * mySectionPlane2.pos = [11.0, 6.-, -12];
89005
+ * mySectionPlane2.pos = [11.0, 6.0, -12];
89844
89006
  * mySectionPlane2.dir = [0.4, 0.0, 0.5];
89845
89007
  * ````
89846
89008
  */
@@ -156010,6 +155172,36 @@ class PerformanceModel extends VBOSceneModel {
156010
155172
  }
156011
155173
  }
156012
155174
 
155175
+ /**
155176
+ * Transcodes texture data.
155177
+ *
155178
+ * A {@link SceneModel} configured with an appropriate TextureTranscoder will allow us to add textures from
155179
+ * transcoded buffers or files. For a concrete example, see {@link VBOSceneModel}, which can be configured with
155180
+ * a {@link KTX2TextureTranscoder}, which allows us to add textures from KTX2 buffers and files.
155181
+ *
155182
+ * @interface
155183
+ */
155184
+ class TextureTranscoder {
155185
+
155186
+ /**
155187
+ * Transcodes texture data from transcoded buffers into a {@link Texture2D}.
155188
+ *
155189
+ * @param {ArrayBuffer[]} buffers Transcoded texture data. Given as an array of buffers so that we can support
155190
+ * multi-image textures, such as cube maps.
155191
+ * @param {*} config Transcoding options.
155192
+ * @param {Texture2D} texture The texture to load.
155193
+ * @returns {Promise} Resolves when the texture has loaded.
155194
+ */
155195
+ transcode(buffers, texture, config = {}) {
155196
+ }
155197
+
155198
+ /**
155199
+ * Destroys this transcoder.
155200
+ */
155201
+ destroy() {
155202
+ }
155203
+ }
155204
+
156013
155205
  const screenPos = math.vec4();
156014
155206
  const viewPos = math.vec4();
156015
155207
 
@@ -156254,7 +155446,7 @@ class PivotController {
156254
155446
  /**
156255
155447
  * Returns true if we are currently pivoting.
156256
155448
  *
156257
- * @returns {boolean}
155449
+ * @returns {Boolean}
156258
155450
  */
156259
155451
  getPivoting() {
156260
155452
  return this._pivoting;
@@ -156752,8 +155944,9 @@ class MousePanRotateDollyHandler {
156752
155944
  // Scaling drag-rotate to canvas boundary
156753
155945
 
156754
155946
  const canvasBoundary = scene.canvas.boundary;
156755
- const canvasWidth = canvasBoundary[2] - canvasBoundary[0];
156756
- const canvasHeight = canvasBoundary[3] - canvasBoundary[1];
155947
+
155948
+ const canvasWidth = canvasBoundary[2];
155949
+ const canvasHeight = canvasBoundary[3];
156757
155950
  const x = states.pointerCanvasPos[0];
156758
155951
  const y = states.pointerCanvasPos[1];
156759
155952
 
@@ -158078,8 +157271,8 @@ class TouchPanRotateAndDollyHandler {
158078
157271
  // Scaling drag-rotate to canvas boundary
158079
157272
 
158080
157273
  const canvasBoundary = scene.canvas.boundary;
158081
- const canvasWidth = canvasBoundary[2] - canvasBoundary[0];
158082
- const canvasHeight = canvasBoundary[3] - canvasBoundary[1];
157274
+ const canvasWidth = canvasBoundary[0];
157275
+ const canvasHeight = canvasBoundary[1];
158083
157276
 
158084
157277
  const touches = event.touches;
158085
157278
 
@@ -161376,7 +160569,7 @@ class Configs {
161376
160569
  *
161377
160570
  * This should only be set once, before creating any Viewers.
161378
160571
  *
161379
- * @returns {boolean}
160572
+ * @returns {Boolean}
161380
160573
  */
161381
160574
  set doublePrecisionEnabled(doublePrecision) {
161382
160575
  math.setDoublePrecisionEnabled(doublePrecision);
@@ -161385,7 +160578,7 @@ class Configs {
161385
160578
  /**
161386
160579
  * Gets whether double precision mode is enabled for all Viewers.
161387
160580
  *
161388
- * @returns {boolean}
160581
+ * @returns {Boolean}
161389
160582
  */
161390
160583
  get doublePrecisionEnabled() {
161391
160584
  return math.getDoublePrecisionEnabled();
@@ -163609,9 +162802,11 @@ const tempVec3c = math.vec3();
163609
162802
  * ## Overview
163610
162803
  *
163611
162804
  * * Loads small-to-medium sized models directly from [CityJSON 1.0.0](https://www.cityjson.org/specs/1.0.0/) files.
163612
- * * Not recommended for large models. For best performance with large CityJSON datasets, we recommend using {@link XKTLoaderPlugin}.
163613
162805
  * * Loads double-precision coordinates, enabling models to be viewed at global coordinates without accuracy loss.
163614
162806
  * * Allows to set the position, scale and rotation of each model as you load it.
162807
+ * * Not recommended for large models. For best performance with large CityJSON datasets, we recommend
162808
+ * converting them to ````.xkt```` format (eg. using [convert2xkt](https://github.com/xeokit/xeokit-convert)), then loading
162809
+ * the ````.xkt```` using {@link XKTLoaderPlugin}.
163615
162810
  *
163616
162811
  * ## Limitations
163617
162812
  *