@xeokit/xeokit-sdk 2.6.41 → 2.6.42

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.
@@ -67640,27 +67640,6 @@ function getRenderers$3(scene) {
67640
67640
  return renderers;
67641
67641
  }
67642
67642
 
67643
- /**
67644
- * @private
67645
- */
67646
- class VBOBatchingPointsBuffer {
67647
-
67648
- constructor(maxGeometryBatchSize = 5000000) {
67649
-
67650
- if (maxGeometryBatchSize > 5000000) {
67651
- maxGeometryBatchSize = 5000000;
67652
- }
67653
-
67654
- this.maxVerts = maxGeometryBatchSize;
67655
- this.maxIndices = maxGeometryBatchSize * 3; // Rough rule-of-thumb
67656
- this.positions = [];
67657
- this.colors = [];
67658
- this.intensities = [];
67659
- this.pickColors = [];
67660
- this.offsets = [];
67661
- }
67662
- }
67663
-
67664
67643
  /**
67665
67644
  * @private
67666
67645
  */
@@ -67699,7 +67678,58 @@ class VBOBatchingPointsLayer {
67699
67678
 
67700
67679
  this._renderers = getRenderers$3(cfg.model.scene);
67701
67680
 
67702
- this._buffer = new VBOBatchingPointsBuffer(cfg.maxGeometryBatchSize);
67681
+ const maxGeometryBatchSize = Math.min(5000000, cfg.maxGeometryBatchSize || window.Infinity);
67682
+
67683
+ const attribute = function() {
67684
+ const portions = [ ];
67685
+
67686
+ return {
67687
+ append: function(data, times = 1, denormalizeScale = 1.0) {
67688
+ portions.push({ data: data, times: times, denormalizeScale: denormalizeScale });
67689
+ },
67690
+ compileBuffer: function(type) {
67691
+ let len = 0;
67692
+ portions.forEach(p => { len += p.times * p.data.length; });
67693
+ const buf = new type(len);
67694
+
67695
+ let begin = 0;
67696
+ portions.forEach(p => {
67697
+ const data = p.data;
67698
+ const dScale = p.denormalizeScale;
67699
+ const subBuf = buf.subarray(begin);
67700
+
67701
+ if (dScale === 1.0) {
67702
+ subBuf.set(data, 0);
67703
+ } else {
67704
+ for (let i = 0; i < data.length; ++i) {
67705
+ subBuf[i] = data[i] * dScale;
67706
+ }
67707
+ }
67708
+
67709
+ let soFar = data.length;
67710
+ const allDataLen = p.times * data.length;
67711
+ while (soFar < allDataLen) {
67712
+ const toCopy = Math.min(soFar, allDataLen - soFar);
67713
+ subBuf.set(subBuf.subarray(0, toCopy), soFar);
67714
+ soFar += toCopy;
67715
+ }
67716
+
67717
+ begin += soFar;
67718
+ });
67719
+
67720
+ return buf;
67721
+ }
67722
+ };
67723
+ };
67724
+
67725
+ this._buffer = {
67726
+ maxVerts: maxGeometryBatchSize,
67727
+ positions: attribute(),
67728
+ colors: attribute(),
67729
+ pickColors: attribute(),
67730
+ vertsIndex: 0
67731
+ };
67732
+
67703
67733
  this._scratchMemory = cfg.scratchMemory;
67704
67734
 
67705
67735
  this._state = new RenderState({
@@ -67764,7 +67794,7 @@ class VBOBatchingPointsLayer {
67764
67794
  if (this._finalized) {
67765
67795
  throw "Already finalized";
67766
67796
  }
67767
- return ((this._buffer.positions.length + lenPositions) < (this._buffer.maxVerts * 3));
67797
+ return (this._buffer.vertsIndex + (lenPositions / 3)) < this._buffer.maxVerts;
67768
67798
  }
67769
67799
 
67770
67800
  /**
@@ -67789,97 +67819,40 @@ class VBOBatchingPointsLayer {
67789
67819
  throw "Already finalized";
67790
67820
  }
67791
67821
 
67792
- const positions = cfg.positions;
67793
- const positionsCompressed = cfg.positionsCompressed;
67794
- const color = cfg.color;
67795
- const colorsCompressed = cfg.colorsCompressed;
67796
- const colors = cfg.colors;
67797
- const pickColor = cfg.pickColor;
67798
-
67799
67822
  const buffer = this._buffer;
67800
- const positionsIndex = buffer.positions.length;
67801
- const vertsIndex = positionsIndex / 3;
67802
-
67803
- let numVerts;
67804
-
67805
- math.expandAABB3(this._modelAABB, cfg.aabb);
67806
-
67807
- if (this._preCompressedPositionsExpected) {
67808
-
67809
- if (!positionsCompressed) {
67810
- throw "positionsCompressed expected";
67811
- }
67812
-
67813
- for (let i = 0, len = positionsCompressed.length; i < len; i++) {
67814
- buffer.positions.push(positionsCompressed[i]);
67815
- }
67816
-
67817
- numVerts = positionsCompressed.length / 3;
67818
67823
 
67819
- } else {
67820
-
67821
- if (!positions) {
67822
- throw "positions expected";
67823
- }
67824
+ const positions = this._preCompressedPositionsExpected ? cfg.positionsCompressed : cfg.positions;
67825
+ if (! positions) {
67826
+ throw ((this._preCompressedPositionsExpected ? "positionsCompressed" : "positions") + " expected");
67827
+ }
67824
67828
 
67825
- numVerts = positions.length / 3;
67829
+ buffer.positions.append(positions);
67826
67830
 
67827
- positions.length;
67828
- buffer.positions.length;
67831
+ const numVerts = positions.length / 3;
67829
67832
 
67830
- for (let i = 0, len = positions.length; i < len; i++) {
67831
- buffer.positions.push(positions[i]);
67832
- }
67833
- }
67833
+ const color = cfg.color;
67834
+ const colorsCompressed = cfg.colorsCompressed;
67835
+ const colors = cfg.colors;
67836
+ const pickColor = cfg.pickColor;
67834
67837
 
67835
67838
  if (colorsCompressed) {
67836
- for (let i = 0, len = colorsCompressed.length; i < len; i++) {
67837
- buffer.colors.push(colorsCompressed[i]);
67838
- }
67839
-
67839
+ buffer.colors.append(colorsCompressed);
67840
67840
  } else if (colors) {
67841
- for (let i = 0, len = colors.length; i < len; i++) {
67842
- buffer.colors.push(colors[i] * 255);
67843
- }
67844
-
67841
+ buffer.colors.append(colors, 1, 255.0);
67845
67842
  } else if (color) {
67846
-
67847
- const r = color[0]; // Color is pre-quantized by VBOSceneModel
67848
- const g = color[1];
67849
- const b = color[2];
67850
- const a = 1.0;
67851
-
67852
- for (let i = 0; i < numVerts; i++) {
67853
- buffer.colors.push(r);
67854
- buffer.colors.push(g);
67855
- buffer.colors.push(b);
67856
- buffer.colors.push(a);
67857
- }
67843
+ // Color is pre-quantized by VBOSceneModel
67844
+ buffer.colors.append([ color[0], color[1], color[2], 1.0 ], numVerts);
67858
67845
  }
67859
67846
 
67860
- {
67861
- const pickColorsBase = buffer.pickColors.length;
67862
- const lenPickColors = numVerts * 4;
67863
- for (let i = pickColorsBase, len = pickColorsBase + lenPickColors; i < len; i += 4) {
67864
- buffer.pickColors.push(pickColor[0]);
67865
- buffer.pickColors.push(pickColor[1]);
67866
- buffer.pickColors.push(pickColor[2]);
67867
- buffer.pickColors.push(pickColor[3]);
67868
- }
67869
- }
67847
+ buffer.pickColors.append(pickColor.slice(0, 4), numVerts);
67870
67848
 
67871
- if (this.model.scene.entityOffsetsEnabled) {
67872
- for (let i = 0; i < numVerts; i++) {
67873
- buffer.offsets.push(0);
67874
- buffer.offsets.push(0);
67875
- buffer.offsets.push(0);
67876
- }
67877
- }
67849
+ math.expandAABB3(this._modelAABB, cfg.aabb);
67878
67850
 
67879
67851
  const portionId = this._portions.length / 2;
67880
67852
 
67881
- this._portions.push(vertsIndex);
67853
+ this._portions.push(this._buffer.vertsIndex);
67882
67854
  this._portions.push(numVerts);
67855
+ this._buffer.vertsIndex += numVerts;
67883
67856
 
67884
67857
  this._numPortions++;
67885
67858
  this.model.numPortions++;
@@ -67900,43 +67873,20 @@ class VBOBatchingPointsLayer {
67900
67873
  const state = this._state;
67901
67874
  const gl = this.model.scene.canvas.gl;
67902
67875
  const buffer = this._buffer;
67876
+ const maybeCreateGlBuffer = (srcData, size, usage) => (srcData.length > 0) ? new ArrayBuf(gl, gl.ARRAY_BUFFER, srcData, srcData.length, size, usage) : null;
67903
67877
 
67904
- if (buffer.positions.length > 0) {
67905
- if (this._preCompressedPositionsExpected) {
67906
- const positions = new Uint16Array(buffer.positions);
67907
- state.positionsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, positions, buffer.positions.length, 3, gl.STATIC_DRAW);
67908
- } else {
67909
- const positions = new Float32Array(buffer.positions);
67910
- const quantizedPositions = quantizePositions(positions, this._modelAABB, state.positionsDecodeMatrix);
67911
- state.positionsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, quantizedPositions, buffer.positions.length, 3, gl.STATIC_DRAW);
67912
- }
67913
- }
67878
+ const positions = (this._preCompressedPositionsExpected
67879
+ ? buffer.positions.compileBuffer(Uint16Array)
67880
+ : (quantizePositions(buffer.positions.compileBuffer(Float32Array), this._modelAABB, state.positionsDecodeMatrix)));
67881
+ state.positionsBuf = maybeCreateGlBuffer(positions, 3, gl.STATIC_DRAW);
67914
67882
 
67915
- if (buffer.colors.length > 0) {
67916
- const colors = new Uint8Array(buffer.colors);
67917
- let normalized = false;
67918
- state.colorsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, colors, buffer.colors.length, 4, gl.STATIC_DRAW, normalized);
67919
- }
67883
+ state.flagsBuf = maybeCreateGlBuffer(new Float32Array(this._buffer.vertsIndex), 1, gl.DYNAMIC_DRAW); // Because we build flags arrays here, get their length from the positions array
67920
67884
 
67921
- if (buffer.positions.length > 0) { // Because we build flags arrays here, get their length from the positions array
67922
- const flagsLength = buffer.positions.length / 3;
67923
- const flags = new Float32Array(flagsLength);
67924
- let notNormalized = false;
67925
- state.flagsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, flags, flags.length, 1, gl.DYNAMIC_DRAW, notNormalized);
67926
- }
67885
+ state.colorsBuf = maybeCreateGlBuffer(buffer.colors.compileBuffer(Uint8Array), 4, gl.STATIC_DRAW);
67927
67886
 
67928
- if (buffer.pickColors.length > 0) {
67929
- const pickColors = new Uint8Array(buffer.pickColors);
67930
- let normalized = false;
67931
- state.pickColorsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, pickColors, buffer.pickColors.length, 4, gl.STATIC_DRAW, normalized);
67932
- }
67887
+ state.pickColorsBuf = maybeCreateGlBuffer(buffer.pickColors.compileBuffer(Uint8Array), 4, gl.STATIC_DRAW);
67933
67888
 
67934
- if (this.model.scene.entityOffsetsEnabled) {
67935
- if (buffer.offsets.length > 0) {
67936
- const offsets = new Float32Array(buffer.offsets);
67937
- state.offsetsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, offsets, buffer.offsets.length, 3, gl.DYNAMIC_DRAW);
67938
- }
67939
- }
67889
+ state.offsetsBuf = this.model.scene.entityOffsetsEnabled ? maybeCreateGlBuffer(new Float32Array(this._buffer.vertsIndex * 3), 3, gl.DYNAMIC_DRAW) : null;
67940
67890
 
67941
67891
  this._buffer = null;
67942
67892
  this._finalized = true;
@@ -88174,6 +88124,7 @@ class DistanceMeasurement extends Component {
88174
88124
  this._visible = false;
88175
88125
  this._originVisible = false;
88176
88126
  this._targetVisible = false;
88127
+ this._useRotationAdjustment = false;
88177
88128
  this._wireVisible = false;
88178
88129
  this._axisVisible = false;
88179
88130
  this._xAxisVisible = false;
@@ -88250,7 +88201,7 @@ class DistanceMeasurement extends Component {
88250
88201
  this.lengthLabelEnabled = cfg.lengthLabelEnabled;
88251
88202
  this.labelsVisible = cfg.labelsVisible;
88252
88203
  this.labelsOnWires = cfg.labelsOnWires;
88253
- this.useRotationAdjustment = cfg.useRotationAdjustment;
88204
+ this._useRotationAdjustment = cfg.useRotationAdjustment;
88254
88205
 
88255
88206
  /**
88256
88207
  * @type {number[]}
@@ -88312,7 +88263,7 @@ class DistanceMeasurement extends Component {
88312
88263
  this._factors = math.transformVec3(this._axesBasis, delta);
88313
88264
 
88314
88265
  this._measurementOrientation = determineMeasurementOrientation(this._originWorld, this._targetWorld, 0);
88315
- if(this._measurementOrientation === 'Vertical' && this.useRotationAdjustment){
88266
+ if (this._measurementOrientation === 'Vertical' && this._useRotationAdjustment) {
88316
88267
  this._wp[0] = this._originWorld[0];
88317
88268
  this._wp[1] = this._originWorld[1];
88318
88269
  this._wp[2] = this._originWorld[2];
@@ -88522,7 +88473,7 @@ class DistanceMeasurement extends Component {
88522
88473
  }
88523
88474
 
88524
88475
  if (!this._zAxisLabelCulled) {
88525
- if(this._measurementOrientation === 'Vertical' && this.useRotationAdjustment) {
88476
+ if (this._measurementOrientation === 'Vertical' && this._useRotationAdjustment) {
88526
88477
  this._zAxisLabel.setPrefix("");
88527
88478
  this._zAxisLabel.setText(tilde + Math.abs(math.lenVec3(math.subVec3(this._targetWorld, [this._originWorld[0], this._targetWorld[1], this._originWorld[2]], distVec3)) * scale).toFixed(2) + unitAbbrev);
88528
88479
  }
@@ -88717,6 +88668,25 @@ class DistanceMeasurement extends Component {
88717
88668
  return this._targetVisible;
88718
88669
  }
88719
88670
 
88671
+ /**
88672
+ * Sets if the measurement is adjusted based on rotation
88673
+ *
88674
+ * @type {Boolean}
88675
+ */
88676
+ set useRotationAdjustment(value) {
88677
+ value = value !== undefined ? Boolean(value) : this.plugin.useRotationAdjustment;
88678
+ this._useRotationAdjustment = value;
88679
+ }
88680
+
88681
+ /**
88682
+ * Gets if the measurement is adjusted based on rotation
88683
+ *
88684
+ * @type {Boolean}
88685
+ */
88686
+ get useRotationAdjustment() {
88687
+ return this._useRotationAdjustment;
88688
+ }
88689
+
88720
88690
  /**
88721
88691
  * Sets if the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are enabled.
88722
88692
  *
@@ -91486,12 +91456,6 @@ class FastNavPlugin extends Plugin {
91486
91456
  class GLTFDefaultDataSource {
91487
91457
 
91488
91458
  constructor(cfg = {}) {
91489
-
91490
- /**
91491
- * Set `true` to enable cache busting for HTTP GETs.
91492
- * This is `true` by default.
91493
- * @type {boolean}
91494
- */
91495
91459
  this.cacheBuster = (cfg.cacheBuster !== false);
91496
91460
  }
91497
91461
 
@@ -123757,7 +123721,13 @@ class StoreyViewsPlugin extends Plugin {
123757
123721
  return null;
123758
123722
  }
123759
123723
 
123760
- isPositionAboveOrBelowBuilding(worldPos){
123724
+ /**
123725
+ * Returns whether a position is above or below a building
123726
+ *
123727
+ * @param {Number[]} worldPos 3D World-space position.
123728
+ * @returns {String} ID of the lowest/highest story or null.
123729
+ */
123730
+ isPositionAboveOrBelowBuilding(worldPos) {
123761
123731
  const keys = Object.keys(this.storeys);
123762
123732
  const ids = [keys[0], keys[keys.length-1]];
123763
123733
  if(worldPos[1] < this.storeys[ids[0]].storeyAABB[1])