@xeokit/xeokit-sdk 2.6.41 → 2.6.43

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.
@@ -682,9 +682,8 @@ class ContextMenu {
682
682
  if (itemSubMenu) {
683
683
 
684
684
  html.push(
685
- '<li id="' + item.id + '" class="xeokit-context-menu-item">' +
685
+ '<li id="' + item.id + '" class="xeokit-context-menu-item xeokit-context-menu-submenu">' +
686
686
  actionTitle +
687
- ' [MORE]' +
688
687
  '</li>');
689
688
  if (!((groupIdx === groupLen - 1) || (j < lenj - 1))) {
690
689
  html.push(
@@ -11353,7 +11352,7 @@ function activateDraggableDots(cfg) {
11353
11352
  };
11354
11353
  }
11355
11354
 
11356
- const touchPointSelector$1 = function(viewer, pointerCircle, ray2WorldPos) {
11355
+ const touchPointSelector = function(viewer, pointerCircle, ray2WorldPos) {
11357
11356
  return function(onCancel, onChange, onCommit) {
11358
11357
  const scene = viewer.scene;
11359
11358
  const canvas = scene.canvas.canvas;
@@ -67640,27 +67639,6 @@ function getRenderers$3(scene) {
67640
67639
  return renderers;
67641
67640
  }
67642
67641
 
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
67642
  /**
67665
67643
  * @private
67666
67644
  */
@@ -67699,7 +67677,58 @@ class VBOBatchingPointsLayer {
67699
67677
 
67700
67678
  this._renderers = getRenderers$3(cfg.model.scene);
67701
67679
 
67702
- this._buffer = new VBOBatchingPointsBuffer(cfg.maxGeometryBatchSize);
67680
+ const maxGeometryBatchSize = cfg.maxGeometryBatchSize || 5000000;
67681
+
67682
+ const attribute = function() {
67683
+ const portions = [ ];
67684
+
67685
+ return {
67686
+ append: function(data, times = 1, denormalizeScale = 1.0) {
67687
+ portions.push({ data: data, times: times, denormalizeScale: denormalizeScale });
67688
+ },
67689
+ compileBuffer: function(type) {
67690
+ let len = 0;
67691
+ portions.forEach(p => { len += p.times * p.data.length; });
67692
+ const buf = new type(len);
67693
+
67694
+ let begin = 0;
67695
+ portions.forEach(p => {
67696
+ const data = p.data;
67697
+ const dScale = p.denormalizeScale;
67698
+ const subBuf = buf.subarray(begin);
67699
+
67700
+ if (dScale === 1.0) {
67701
+ subBuf.set(data, 0);
67702
+ } else {
67703
+ for (let i = 0; i < data.length; ++i) {
67704
+ subBuf[i] = data[i] * dScale;
67705
+ }
67706
+ }
67707
+
67708
+ let soFar = data.length;
67709
+ const allDataLen = p.times * data.length;
67710
+ while (soFar < allDataLen) {
67711
+ const toCopy = Math.min(soFar, allDataLen - soFar);
67712
+ subBuf.set(subBuf.subarray(0, toCopy), soFar);
67713
+ soFar += toCopy;
67714
+ }
67715
+
67716
+ begin += soFar;
67717
+ });
67718
+
67719
+ return buf;
67720
+ }
67721
+ };
67722
+ };
67723
+
67724
+ this._buffer = {
67725
+ maxVerts: maxGeometryBatchSize,
67726
+ positions: attribute(),
67727
+ colors: attribute(),
67728
+ pickColors: attribute(),
67729
+ vertsIndex: 0
67730
+ };
67731
+
67703
67732
  this._scratchMemory = cfg.scratchMemory;
67704
67733
 
67705
67734
  this._state = new RenderState({
@@ -67764,7 +67793,7 @@ class VBOBatchingPointsLayer {
67764
67793
  if (this._finalized) {
67765
67794
  throw "Already finalized";
67766
67795
  }
67767
- return ((this._buffer.positions.length + lenPositions) < (this._buffer.maxVerts * 3));
67796
+ return (this._buffer.vertsIndex + (lenPositions / 3)) <= this._buffer.maxVerts;
67768
67797
  }
67769
67798
 
67770
67799
  /**
@@ -67789,97 +67818,40 @@ class VBOBatchingPointsLayer {
67789
67818
  throw "Already finalized";
67790
67819
  }
67791
67820
 
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
67821
  const buffer = this._buffer;
67800
- const positionsIndex = buffer.positions.length;
67801
- const vertsIndex = positionsIndex / 3;
67802
67822
 
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
-
67819
- } else {
67820
-
67821
- if (!positions) {
67822
- throw "positions expected";
67823
- }
67823
+ const positions = this._preCompressedPositionsExpected ? cfg.positionsCompressed : cfg.positions;
67824
+ if (! positions) {
67825
+ throw ((this._preCompressedPositionsExpected ? "positionsCompressed" : "positions") + " expected");
67826
+ }
67824
67827
 
67825
- numVerts = positions.length / 3;
67828
+ buffer.positions.append(positions);
67826
67829
 
67827
- positions.length;
67828
- buffer.positions.length;
67830
+ const numVerts = positions.length / 3;
67829
67831
 
67830
- for (let i = 0, len = positions.length; i < len; i++) {
67831
- buffer.positions.push(positions[i]);
67832
- }
67833
- }
67832
+ const color = cfg.color;
67833
+ const colorsCompressed = cfg.colorsCompressed;
67834
+ const colors = cfg.colors;
67835
+ const pickColor = cfg.pickColor;
67834
67836
 
67835
67837
  if (colorsCompressed) {
67836
- for (let i = 0, len = colorsCompressed.length; i < len; i++) {
67837
- buffer.colors.push(colorsCompressed[i]);
67838
- }
67839
-
67838
+ buffer.colors.append(colorsCompressed);
67840
67839
  } else if (colors) {
67841
- for (let i = 0, len = colors.length; i < len; i++) {
67842
- buffer.colors.push(colors[i] * 255);
67843
- }
67844
-
67840
+ buffer.colors.append(colors, 1, 255.0);
67845
67841
  } 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
- }
67842
+ // Color is pre-quantized by VBOSceneModel
67843
+ buffer.colors.append([ color[0], color[1], color[2], 1.0 ], numVerts);
67858
67844
  }
67859
67845
 
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
- }
67846
+ buffer.pickColors.append(pickColor.slice(0, 4), numVerts);
67870
67847
 
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
- }
67848
+ math.expandAABB3(this._modelAABB, cfg.aabb);
67878
67849
 
67879
67850
  const portionId = this._portions.length / 2;
67880
67851
 
67881
- this._portions.push(vertsIndex);
67852
+ this._portions.push(this._buffer.vertsIndex);
67882
67853
  this._portions.push(numVerts);
67854
+ this._buffer.vertsIndex += numVerts;
67883
67855
 
67884
67856
  this._numPortions++;
67885
67857
  this.model.numPortions++;
@@ -67900,43 +67872,20 @@ class VBOBatchingPointsLayer {
67900
67872
  const state = this._state;
67901
67873
  const gl = this.model.scene.canvas.gl;
67902
67874
  const buffer = this._buffer;
67875
+ const maybeCreateGlBuffer = (srcData, size, usage) => (srcData.length > 0) ? new ArrayBuf(gl, gl.ARRAY_BUFFER, srcData, srcData.length, size, usage) : null;
67903
67876
 
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
- }
67877
+ const positions = (this._preCompressedPositionsExpected
67878
+ ? buffer.positions.compileBuffer(Uint16Array)
67879
+ : (quantizePositions(buffer.positions.compileBuffer(Float32Array), this._modelAABB, state.positionsDecodeMatrix)));
67880
+ state.positionsBuf = maybeCreateGlBuffer(positions, 3, gl.STATIC_DRAW);
67914
67881
 
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
- }
67882
+ 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
67883
 
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
- }
67884
+ state.colorsBuf = maybeCreateGlBuffer(buffer.colors.compileBuffer(Uint8Array), 4, gl.STATIC_DRAW);
67927
67885
 
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
- }
67886
+ state.pickColorsBuf = maybeCreateGlBuffer(buffer.pickColors.compileBuffer(Uint8Array), 4, gl.STATIC_DRAW);
67933
67887
 
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
- }
67888
+ state.offsetsBuf = this.model.scene.entityOffsetsEnabled ? maybeCreateGlBuffer(new Float32Array(this._buffer.vertsIndex * 3), 3, gl.DYNAMIC_DRAW) : null;
67940
67889
 
67941
67890
  this._buffer = null;
67942
67891
  this._finalized = true;
@@ -80209,14 +80158,14 @@ class DTXTrianglesLayer {
80209
80158
  // object colors
80210
80159
  textureState.texturePerObjectColorsAndFlags._textureData.set(tempUint8Array4, subPortionId * 32);
80211
80160
  if (this._deferredSetFlagsActive) {
80212
- console.info("_subPortionSetColor defer");
80161
+ //console.info("_subPortionSetColor defer");
80213
80162
  this._deferredSetFlagsDirty = true;
80214
80163
  return;
80215
80164
  }
80216
80165
  if (++this._numUpdatesInFrame >= MAX_OBJECT_UPDATES_IN_FRAME_WITHOUT_BATCHED_UPDATE) {
80217
80166
  this._beginDeferredFlags(); // Subsequent flags updates now deferred
80218
80167
  }
80219
- console.info("_subPortionSetColor write through");
80168
+ //console.info("_subPortionSetColor write through");
80220
80169
  gl.bindTexture(gl.TEXTURE_2D, textureState.texturePerObjectColorsAndFlags._texture);
80221
80170
  gl.texSubImage2D(
80222
80171
  gl.TEXTURE_2D,
@@ -88174,6 +88123,7 @@ class DistanceMeasurement extends Component {
88174
88123
  this._visible = false;
88175
88124
  this._originVisible = false;
88176
88125
  this._targetVisible = false;
88126
+ this._useRotationAdjustment = false;
88177
88127
  this._wireVisible = false;
88178
88128
  this._axisVisible = false;
88179
88129
  this._xAxisVisible = false;
@@ -88250,7 +88200,7 @@ class DistanceMeasurement extends Component {
88250
88200
  this.lengthLabelEnabled = cfg.lengthLabelEnabled;
88251
88201
  this.labelsVisible = cfg.labelsVisible;
88252
88202
  this.labelsOnWires = cfg.labelsOnWires;
88253
- this.useRotationAdjustment = cfg.useRotationAdjustment;
88203
+ this._useRotationAdjustment = cfg.useRotationAdjustment;
88254
88204
 
88255
88205
  /**
88256
88206
  * @type {number[]}
@@ -88312,7 +88262,7 @@ class DistanceMeasurement extends Component {
88312
88262
  this._factors = math.transformVec3(this._axesBasis, delta);
88313
88263
 
88314
88264
  this._measurementOrientation = determineMeasurementOrientation(this._originWorld, this._targetWorld, 0);
88315
- if(this._measurementOrientation === 'Vertical' && this.useRotationAdjustment){
88265
+ if (this._measurementOrientation === 'Vertical' && this._useRotationAdjustment) {
88316
88266
  this._wp[0] = this._originWorld[0];
88317
88267
  this._wp[1] = this._originWorld[1];
88318
88268
  this._wp[2] = this._originWorld[2];
@@ -88522,7 +88472,7 @@ class DistanceMeasurement extends Component {
88522
88472
  }
88523
88473
 
88524
88474
  if (!this._zAxisLabelCulled) {
88525
- if(this._measurementOrientation === 'Vertical' && this.useRotationAdjustment) {
88475
+ if (this._measurementOrientation === 'Vertical' && this._useRotationAdjustment) {
88526
88476
  this._zAxisLabel.setPrefix("");
88527
88477
  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
88478
  }
@@ -88717,6 +88667,25 @@ class DistanceMeasurement extends Component {
88717
88667
  return this._targetVisible;
88718
88668
  }
88719
88669
 
88670
+ /**
88671
+ * Sets if the measurement is adjusted based on rotation
88672
+ *
88673
+ * @type {Boolean}
88674
+ */
88675
+ set useRotationAdjustment(value) {
88676
+ value = value !== undefined ? Boolean(value) : this.plugin.useRotationAdjustment;
88677
+ this._useRotationAdjustment = value;
88678
+ }
88679
+
88680
+ /**
88681
+ * Gets if the measurement is adjusted based on rotation
88682
+ *
88683
+ * @type {Boolean}
88684
+ */
88685
+ get useRotationAdjustment() {
88686
+ return this._useRotationAdjustment;
88687
+ }
88688
+
88720
88689
  /**
88721
88690
  * Sets if the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are enabled.
88722
88691
  *
@@ -91486,12 +91455,6 @@ class FastNavPlugin extends Plugin {
91486
91455
  class GLTFDefaultDataSource {
91487
91456
 
91488
91457
  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
91458
  this.cacheBuster = (cfg.cacheBuster !== false);
91496
91459
  }
91497
91460
 
@@ -123757,7 +123720,13 @@ class StoreyViewsPlugin extends Plugin {
123757
123720
  return null;
123758
123721
  }
123759
123722
 
123760
- isPositionAboveOrBelowBuilding(worldPos){
123723
+ /**
123724
+ * Returns whether a position is above or below a building
123725
+ *
123726
+ * @param {Number[]} worldPos 3D World-space position.
123727
+ * @returns {String} ID of the lowest/highest story or null.
123728
+ */
123729
+ isPositionAboveOrBelowBuilding(worldPos) {
123761
123730
  const keys = Object.keys(this.storeys);
123762
123731
  const ids = [keys[0], keys[keys.length-1]];
123763
123732
  if(worldPos[1] < this.storeys[ids[0]].storeyAABB[1])
@@ -137854,6 +137823,7 @@ class LASLoaderPlugin extends Plugin {
137854
137823
  }
137855
137824
 
137856
137825
  const sceneModel = new SceneModel(this.viewer.scene, utils.apply(params, {
137826
+ maxGeometryBatchSize: MAX_VERTICES,
137857
137827
  isModel: true
137858
137828
  }));
137859
137829
 
@@ -142189,7 +142159,7 @@ exports.rtcToWorldPos = rtcToWorldPos;
142189
142159
  exports.sRGBEncoding = sRGBEncoding;
142190
142160
  exports.setFrustum = setFrustum;
142191
142161
  exports.stats = stats;
142192
- exports.touchPointSelector = touchPointSelector$1;
142162
+ exports.touchPointSelector = touchPointSelector;
142193
142163
  exports.transformToNode = transformToNode;
142194
142164
  exports.utils = utils;
142195
142165
  exports.worldToRTCPos = worldToRTCPos;