@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.
- package/dist/xeokit-sdk.cjs.js +110 -140
- package/dist/xeokit-sdk.es.js +110 -140
- package/dist/xeokit-sdk.es5.js +252 -246
- package/dist/xeokit-sdk.min.cjs.js +5 -5
- package/dist/xeokit-sdk.min.es.js +5 -5
- package/dist/xeokit-sdk.min.es5.js +4 -4
- package/package.json +1 -1
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js +23 -3
- package/src/plugins/GLTFLoaderPlugin/GLTFDefaultDataSource.js +0 -6
- package/src/plugins/StoreyViewsPlugin/StoreyViewsPlugin.js +7 -1
- package/src/viewer/scene/model/vbo/batching/points/VBOBatchingPointsLayer.js +80 -115
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.d.ts +14 -0
- package/types/plugins/StoreyViewsPlugin/StoreyViewsPlugin.d.ts +5 -5
- package/src/viewer/scene/model/vbo/batching/points/VBOBatchingPointsBuffer.js +0 -20
package/dist/xeokit-sdk.es.js
CHANGED
|
@@ -67636,27 +67636,6 @@ function getRenderers$3(scene) {
|
|
|
67636
67636
|
return renderers;
|
|
67637
67637
|
}
|
|
67638
67638
|
|
|
67639
|
-
/**
|
|
67640
|
-
* @private
|
|
67641
|
-
*/
|
|
67642
|
-
class VBOBatchingPointsBuffer {
|
|
67643
|
-
|
|
67644
|
-
constructor(maxGeometryBatchSize = 5000000) {
|
|
67645
|
-
|
|
67646
|
-
if (maxGeometryBatchSize > 5000000) {
|
|
67647
|
-
maxGeometryBatchSize = 5000000;
|
|
67648
|
-
}
|
|
67649
|
-
|
|
67650
|
-
this.maxVerts = maxGeometryBatchSize;
|
|
67651
|
-
this.maxIndices = maxGeometryBatchSize * 3; // Rough rule-of-thumb
|
|
67652
|
-
this.positions = [];
|
|
67653
|
-
this.colors = [];
|
|
67654
|
-
this.intensities = [];
|
|
67655
|
-
this.pickColors = [];
|
|
67656
|
-
this.offsets = [];
|
|
67657
|
-
}
|
|
67658
|
-
}
|
|
67659
|
-
|
|
67660
67639
|
/**
|
|
67661
67640
|
* @private
|
|
67662
67641
|
*/
|
|
@@ -67695,7 +67674,58 @@ class VBOBatchingPointsLayer {
|
|
|
67695
67674
|
|
|
67696
67675
|
this._renderers = getRenderers$3(cfg.model.scene);
|
|
67697
67676
|
|
|
67698
|
-
|
|
67677
|
+
const maxGeometryBatchSize = Math.min(5000000, cfg.maxGeometryBatchSize || window.Infinity);
|
|
67678
|
+
|
|
67679
|
+
const attribute = function() {
|
|
67680
|
+
const portions = [ ];
|
|
67681
|
+
|
|
67682
|
+
return {
|
|
67683
|
+
append: function(data, times = 1, denormalizeScale = 1.0) {
|
|
67684
|
+
portions.push({ data: data, times: times, denormalizeScale: denormalizeScale });
|
|
67685
|
+
},
|
|
67686
|
+
compileBuffer: function(type) {
|
|
67687
|
+
let len = 0;
|
|
67688
|
+
portions.forEach(p => { len += p.times * p.data.length; });
|
|
67689
|
+
const buf = new type(len);
|
|
67690
|
+
|
|
67691
|
+
let begin = 0;
|
|
67692
|
+
portions.forEach(p => {
|
|
67693
|
+
const data = p.data;
|
|
67694
|
+
const dScale = p.denormalizeScale;
|
|
67695
|
+
const subBuf = buf.subarray(begin);
|
|
67696
|
+
|
|
67697
|
+
if (dScale === 1.0) {
|
|
67698
|
+
subBuf.set(data, 0);
|
|
67699
|
+
} else {
|
|
67700
|
+
for (let i = 0; i < data.length; ++i) {
|
|
67701
|
+
subBuf[i] = data[i] * dScale;
|
|
67702
|
+
}
|
|
67703
|
+
}
|
|
67704
|
+
|
|
67705
|
+
let soFar = data.length;
|
|
67706
|
+
const allDataLen = p.times * data.length;
|
|
67707
|
+
while (soFar < allDataLen) {
|
|
67708
|
+
const toCopy = Math.min(soFar, allDataLen - soFar);
|
|
67709
|
+
subBuf.set(subBuf.subarray(0, toCopy), soFar);
|
|
67710
|
+
soFar += toCopy;
|
|
67711
|
+
}
|
|
67712
|
+
|
|
67713
|
+
begin += soFar;
|
|
67714
|
+
});
|
|
67715
|
+
|
|
67716
|
+
return buf;
|
|
67717
|
+
}
|
|
67718
|
+
};
|
|
67719
|
+
};
|
|
67720
|
+
|
|
67721
|
+
this._buffer = {
|
|
67722
|
+
maxVerts: maxGeometryBatchSize,
|
|
67723
|
+
positions: attribute(),
|
|
67724
|
+
colors: attribute(),
|
|
67725
|
+
pickColors: attribute(),
|
|
67726
|
+
vertsIndex: 0
|
|
67727
|
+
};
|
|
67728
|
+
|
|
67699
67729
|
this._scratchMemory = cfg.scratchMemory;
|
|
67700
67730
|
|
|
67701
67731
|
this._state = new RenderState({
|
|
@@ -67760,7 +67790,7 @@ class VBOBatchingPointsLayer {
|
|
|
67760
67790
|
if (this._finalized) {
|
|
67761
67791
|
throw "Already finalized";
|
|
67762
67792
|
}
|
|
67763
|
-
return (
|
|
67793
|
+
return (this._buffer.vertsIndex + (lenPositions / 3)) < this._buffer.maxVerts;
|
|
67764
67794
|
}
|
|
67765
67795
|
|
|
67766
67796
|
/**
|
|
@@ -67785,97 +67815,40 @@ class VBOBatchingPointsLayer {
|
|
|
67785
67815
|
throw "Already finalized";
|
|
67786
67816
|
}
|
|
67787
67817
|
|
|
67788
|
-
const positions = cfg.positions;
|
|
67789
|
-
const positionsCompressed = cfg.positionsCompressed;
|
|
67790
|
-
const color = cfg.color;
|
|
67791
|
-
const colorsCompressed = cfg.colorsCompressed;
|
|
67792
|
-
const colors = cfg.colors;
|
|
67793
|
-
const pickColor = cfg.pickColor;
|
|
67794
|
-
|
|
67795
67818
|
const buffer = this._buffer;
|
|
67796
|
-
const positionsIndex = buffer.positions.length;
|
|
67797
|
-
const vertsIndex = positionsIndex / 3;
|
|
67798
|
-
|
|
67799
|
-
let numVerts;
|
|
67800
|
-
|
|
67801
|
-
math.expandAABB3(this._modelAABB, cfg.aabb);
|
|
67802
|
-
|
|
67803
|
-
if (this._preCompressedPositionsExpected) {
|
|
67804
|
-
|
|
67805
|
-
if (!positionsCompressed) {
|
|
67806
|
-
throw "positionsCompressed expected";
|
|
67807
|
-
}
|
|
67808
|
-
|
|
67809
|
-
for (let i = 0, len = positionsCompressed.length; i < len; i++) {
|
|
67810
|
-
buffer.positions.push(positionsCompressed[i]);
|
|
67811
|
-
}
|
|
67812
|
-
|
|
67813
|
-
numVerts = positionsCompressed.length / 3;
|
|
67814
67819
|
|
|
67815
|
-
|
|
67816
|
-
|
|
67817
|
-
|
|
67818
|
-
|
|
67819
|
-
}
|
|
67820
|
+
const positions = this._preCompressedPositionsExpected ? cfg.positionsCompressed : cfg.positions;
|
|
67821
|
+
if (! positions) {
|
|
67822
|
+
throw ((this._preCompressedPositionsExpected ? "positionsCompressed" : "positions") + " expected");
|
|
67823
|
+
}
|
|
67820
67824
|
|
|
67821
|
-
|
|
67825
|
+
buffer.positions.append(positions);
|
|
67822
67826
|
|
|
67823
|
-
|
|
67824
|
-
buffer.positions.length;
|
|
67827
|
+
const numVerts = positions.length / 3;
|
|
67825
67828
|
|
|
67826
|
-
|
|
67827
|
-
|
|
67828
|
-
|
|
67829
|
-
|
|
67829
|
+
const color = cfg.color;
|
|
67830
|
+
const colorsCompressed = cfg.colorsCompressed;
|
|
67831
|
+
const colors = cfg.colors;
|
|
67832
|
+
const pickColor = cfg.pickColor;
|
|
67830
67833
|
|
|
67831
67834
|
if (colorsCompressed) {
|
|
67832
|
-
|
|
67833
|
-
buffer.colors.push(colorsCompressed[i]);
|
|
67834
|
-
}
|
|
67835
|
-
|
|
67835
|
+
buffer.colors.append(colorsCompressed);
|
|
67836
67836
|
} else if (colors) {
|
|
67837
|
-
|
|
67838
|
-
buffer.colors.push(colors[i] * 255);
|
|
67839
|
-
}
|
|
67840
|
-
|
|
67837
|
+
buffer.colors.append(colors, 1, 255.0);
|
|
67841
67838
|
} else if (color) {
|
|
67842
|
-
|
|
67843
|
-
|
|
67844
|
-
const g = color[1];
|
|
67845
|
-
const b = color[2];
|
|
67846
|
-
const a = 1.0;
|
|
67847
|
-
|
|
67848
|
-
for (let i = 0; i < numVerts; i++) {
|
|
67849
|
-
buffer.colors.push(r);
|
|
67850
|
-
buffer.colors.push(g);
|
|
67851
|
-
buffer.colors.push(b);
|
|
67852
|
-
buffer.colors.push(a);
|
|
67853
|
-
}
|
|
67839
|
+
// Color is pre-quantized by VBOSceneModel
|
|
67840
|
+
buffer.colors.append([ color[0], color[1], color[2], 1.0 ], numVerts);
|
|
67854
67841
|
}
|
|
67855
67842
|
|
|
67856
|
-
|
|
67857
|
-
const pickColorsBase = buffer.pickColors.length;
|
|
67858
|
-
const lenPickColors = numVerts * 4;
|
|
67859
|
-
for (let i = pickColorsBase, len = pickColorsBase + lenPickColors; i < len; i += 4) {
|
|
67860
|
-
buffer.pickColors.push(pickColor[0]);
|
|
67861
|
-
buffer.pickColors.push(pickColor[1]);
|
|
67862
|
-
buffer.pickColors.push(pickColor[2]);
|
|
67863
|
-
buffer.pickColors.push(pickColor[3]);
|
|
67864
|
-
}
|
|
67865
|
-
}
|
|
67843
|
+
buffer.pickColors.append(pickColor.slice(0, 4), numVerts);
|
|
67866
67844
|
|
|
67867
|
-
|
|
67868
|
-
for (let i = 0; i < numVerts; i++) {
|
|
67869
|
-
buffer.offsets.push(0);
|
|
67870
|
-
buffer.offsets.push(0);
|
|
67871
|
-
buffer.offsets.push(0);
|
|
67872
|
-
}
|
|
67873
|
-
}
|
|
67845
|
+
math.expandAABB3(this._modelAABB, cfg.aabb);
|
|
67874
67846
|
|
|
67875
67847
|
const portionId = this._portions.length / 2;
|
|
67876
67848
|
|
|
67877
|
-
this._portions.push(vertsIndex);
|
|
67849
|
+
this._portions.push(this._buffer.vertsIndex);
|
|
67878
67850
|
this._portions.push(numVerts);
|
|
67851
|
+
this._buffer.vertsIndex += numVerts;
|
|
67879
67852
|
|
|
67880
67853
|
this._numPortions++;
|
|
67881
67854
|
this.model.numPortions++;
|
|
@@ -67896,43 +67869,20 @@ class VBOBatchingPointsLayer {
|
|
|
67896
67869
|
const state = this._state;
|
|
67897
67870
|
const gl = this.model.scene.canvas.gl;
|
|
67898
67871
|
const buffer = this._buffer;
|
|
67872
|
+
const maybeCreateGlBuffer = (srcData, size, usage) => (srcData.length > 0) ? new ArrayBuf(gl, gl.ARRAY_BUFFER, srcData, srcData.length, size, usage) : null;
|
|
67899
67873
|
|
|
67900
|
-
|
|
67901
|
-
|
|
67902
|
-
|
|
67903
|
-
|
|
67904
|
-
} else {
|
|
67905
|
-
const positions = new Float32Array(buffer.positions);
|
|
67906
|
-
const quantizedPositions = quantizePositions(positions, this._modelAABB, state.positionsDecodeMatrix);
|
|
67907
|
-
state.positionsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, quantizedPositions, buffer.positions.length, 3, gl.STATIC_DRAW);
|
|
67908
|
-
}
|
|
67909
|
-
}
|
|
67874
|
+
const positions = (this._preCompressedPositionsExpected
|
|
67875
|
+
? buffer.positions.compileBuffer(Uint16Array)
|
|
67876
|
+
: (quantizePositions(buffer.positions.compileBuffer(Float32Array), this._modelAABB, state.positionsDecodeMatrix)));
|
|
67877
|
+
state.positionsBuf = maybeCreateGlBuffer(positions, 3, gl.STATIC_DRAW);
|
|
67910
67878
|
|
|
67911
|
-
|
|
67912
|
-
const colors = new Uint8Array(buffer.colors);
|
|
67913
|
-
let normalized = false;
|
|
67914
|
-
state.colorsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, colors, buffer.colors.length, 4, gl.STATIC_DRAW, normalized);
|
|
67915
|
-
}
|
|
67879
|
+
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
|
|
67916
67880
|
|
|
67917
|
-
|
|
67918
|
-
const flagsLength = buffer.positions.length / 3;
|
|
67919
|
-
const flags = new Float32Array(flagsLength);
|
|
67920
|
-
let notNormalized = false;
|
|
67921
|
-
state.flagsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, flags, flags.length, 1, gl.DYNAMIC_DRAW, notNormalized);
|
|
67922
|
-
}
|
|
67881
|
+
state.colorsBuf = maybeCreateGlBuffer(buffer.colors.compileBuffer(Uint8Array), 4, gl.STATIC_DRAW);
|
|
67923
67882
|
|
|
67924
|
-
|
|
67925
|
-
const pickColors = new Uint8Array(buffer.pickColors);
|
|
67926
|
-
let normalized = false;
|
|
67927
|
-
state.pickColorsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, pickColors, buffer.pickColors.length, 4, gl.STATIC_DRAW, normalized);
|
|
67928
|
-
}
|
|
67883
|
+
state.pickColorsBuf = maybeCreateGlBuffer(buffer.pickColors.compileBuffer(Uint8Array), 4, gl.STATIC_DRAW);
|
|
67929
67884
|
|
|
67930
|
-
|
|
67931
|
-
if (buffer.offsets.length > 0) {
|
|
67932
|
-
const offsets = new Float32Array(buffer.offsets);
|
|
67933
|
-
state.offsetsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, offsets, buffer.offsets.length, 3, gl.DYNAMIC_DRAW);
|
|
67934
|
-
}
|
|
67935
|
-
}
|
|
67885
|
+
state.offsetsBuf = this.model.scene.entityOffsetsEnabled ? maybeCreateGlBuffer(new Float32Array(this._buffer.vertsIndex * 3), 3, gl.DYNAMIC_DRAW) : null;
|
|
67936
67886
|
|
|
67937
67887
|
this._buffer = null;
|
|
67938
67888
|
this._finalized = true;
|
|
@@ -88170,6 +88120,7 @@ class DistanceMeasurement extends Component {
|
|
|
88170
88120
|
this._visible = false;
|
|
88171
88121
|
this._originVisible = false;
|
|
88172
88122
|
this._targetVisible = false;
|
|
88123
|
+
this._useRotationAdjustment = false;
|
|
88173
88124
|
this._wireVisible = false;
|
|
88174
88125
|
this._axisVisible = false;
|
|
88175
88126
|
this._xAxisVisible = false;
|
|
@@ -88246,7 +88197,7 @@ class DistanceMeasurement extends Component {
|
|
|
88246
88197
|
this.lengthLabelEnabled = cfg.lengthLabelEnabled;
|
|
88247
88198
|
this.labelsVisible = cfg.labelsVisible;
|
|
88248
88199
|
this.labelsOnWires = cfg.labelsOnWires;
|
|
88249
|
-
this.
|
|
88200
|
+
this._useRotationAdjustment = cfg.useRotationAdjustment;
|
|
88250
88201
|
|
|
88251
88202
|
/**
|
|
88252
88203
|
* @type {number[]}
|
|
@@ -88308,7 +88259,7 @@ class DistanceMeasurement extends Component {
|
|
|
88308
88259
|
this._factors = math.transformVec3(this._axesBasis, delta);
|
|
88309
88260
|
|
|
88310
88261
|
this._measurementOrientation = determineMeasurementOrientation(this._originWorld, this._targetWorld, 0);
|
|
88311
|
-
if(this._measurementOrientation === 'Vertical' && this.
|
|
88262
|
+
if (this._measurementOrientation === 'Vertical' && this._useRotationAdjustment) {
|
|
88312
88263
|
this._wp[0] = this._originWorld[0];
|
|
88313
88264
|
this._wp[1] = this._originWorld[1];
|
|
88314
88265
|
this._wp[2] = this._originWorld[2];
|
|
@@ -88518,7 +88469,7 @@ class DistanceMeasurement extends Component {
|
|
|
88518
88469
|
}
|
|
88519
88470
|
|
|
88520
88471
|
if (!this._zAxisLabelCulled) {
|
|
88521
|
-
if(this._measurementOrientation === 'Vertical' && this.
|
|
88472
|
+
if (this._measurementOrientation === 'Vertical' && this._useRotationAdjustment) {
|
|
88522
88473
|
this._zAxisLabel.setPrefix("");
|
|
88523
88474
|
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);
|
|
88524
88475
|
}
|
|
@@ -88713,6 +88664,25 @@ class DistanceMeasurement extends Component {
|
|
|
88713
88664
|
return this._targetVisible;
|
|
88714
88665
|
}
|
|
88715
88666
|
|
|
88667
|
+
/**
|
|
88668
|
+
* Sets if the measurement is adjusted based on rotation
|
|
88669
|
+
*
|
|
88670
|
+
* @type {Boolean}
|
|
88671
|
+
*/
|
|
88672
|
+
set useRotationAdjustment(value) {
|
|
88673
|
+
value = value !== undefined ? Boolean(value) : this.plugin.useRotationAdjustment;
|
|
88674
|
+
this._useRotationAdjustment = value;
|
|
88675
|
+
}
|
|
88676
|
+
|
|
88677
|
+
/**
|
|
88678
|
+
* Gets if the measurement is adjusted based on rotation
|
|
88679
|
+
*
|
|
88680
|
+
* @type {Boolean}
|
|
88681
|
+
*/
|
|
88682
|
+
get useRotationAdjustment() {
|
|
88683
|
+
return this._useRotationAdjustment;
|
|
88684
|
+
}
|
|
88685
|
+
|
|
88716
88686
|
/**
|
|
88717
88687
|
* Sets if the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are enabled.
|
|
88718
88688
|
*
|
|
@@ -91482,12 +91452,6 @@ class FastNavPlugin extends Plugin {
|
|
|
91482
91452
|
class GLTFDefaultDataSource {
|
|
91483
91453
|
|
|
91484
91454
|
constructor(cfg = {}) {
|
|
91485
|
-
|
|
91486
|
-
/**
|
|
91487
|
-
* Set `true` to enable cache busting for HTTP GETs.
|
|
91488
|
-
* This is `true` by default.
|
|
91489
|
-
* @type {boolean}
|
|
91490
|
-
*/
|
|
91491
91455
|
this.cacheBuster = (cfg.cacheBuster !== false);
|
|
91492
91456
|
}
|
|
91493
91457
|
|
|
@@ -123753,7 +123717,13 @@ class StoreyViewsPlugin extends Plugin {
|
|
|
123753
123717
|
return null;
|
|
123754
123718
|
}
|
|
123755
123719
|
|
|
123756
|
-
|
|
123720
|
+
/**
|
|
123721
|
+
* Returns whether a position is above or below a building
|
|
123722
|
+
*
|
|
123723
|
+
* @param {Number[]} worldPos 3D World-space position.
|
|
123724
|
+
* @returns {String} ID of the lowest/highest story or null.
|
|
123725
|
+
*/
|
|
123726
|
+
isPositionAboveOrBelowBuilding(worldPos) {
|
|
123757
123727
|
const keys = Object.keys(this.storeys);
|
|
123758
123728
|
const ids = [keys[0], keys[keys.length-1]];
|
|
123759
123729
|
if(worldPos[1] < this.storeys[ids[0]].storeyAABB[1])
|