@xeokit/xeokit-sdk 2.4.1 → 2.4.2-beta-1
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 +139 -76
- package/dist/xeokit-sdk.es.js +139 -76
- package/dist/xeokit-sdk.es5.js +149 -127
- package/dist/xeokit-sdk.min.cjs.js +2 -2
- package/dist/xeokit-sdk.min.es.js +2 -2
- package/dist/xeokit-sdk.min.es5.js +2 -2
- package/package.json +1 -1
- package/src/plugins/LODCullingPlugin/LODCullingPlugin.js +209 -0
- package/src/plugins/LODCullingPlugin/LODManager.js +82 -0
- package/src/plugins/LODCullingPlugin/LODState.js +130 -0
- package/src/plugins/LODCullingPlugin/index.js +1 -0
- package/src/viewer/scene/model/dtx/triangles/DataTextureGenerator.js +72 -44
- package/src/viewer/scene/model/dtx/triangles/TrianglesDataTextureBuffer.js +15 -0
- package/src/viewer/scene/model/dtx/triangles/TrianglesDataTextureLayer.js +39 -29
- package/src/viewer/scene/model/vbo/trianglesInstancing/TrianglesInstancingLayer.js +13 -3
- package/src/viewer/scene/webgl/Renderer2.js +1830 -0
|
@@ -5,13 +5,28 @@ export class TrianglesDataTextureBuffer {
|
|
|
5
5
|
|
|
6
6
|
constructor() {
|
|
7
7
|
this.positionsCompressed = [];
|
|
8
|
+
this.lenPositionsCompressed = 0;
|
|
9
|
+
|
|
8
10
|
this.metallicRoughness = [];
|
|
11
|
+
|
|
9
12
|
this.indices8Bits = [];
|
|
13
|
+
this.lenIndices8Bits = 0;
|
|
14
|
+
|
|
10
15
|
this.indices16Bits = [];
|
|
16
|
+
this.lenIndices16Bits = 0;
|
|
17
|
+
|
|
11
18
|
this.indices32Bits = [];
|
|
19
|
+
this.lenIndices32Bits = 0;
|
|
20
|
+
|
|
12
21
|
this.edgeIndices8Bits = [];
|
|
22
|
+
this.lenEdgeIndices8Bits = 0;
|
|
23
|
+
|
|
13
24
|
this.edgeIndices16Bits = [];
|
|
25
|
+
this.lenEdgeIndices16Bits = 0;
|
|
26
|
+
|
|
14
27
|
this.edgeIndices32Bits = [];
|
|
28
|
+
this.lenEdgeIndices32Bits = 0;
|
|
29
|
+
|
|
15
30
|
this.perObjectColors = [];
|
|
16
31
|
this.perObjectPickColors = [];
|
|
17
32
|
this.perObjectSolid = [];
|
|
@@ -70,7 +70,6 @@ export class TrianglesDataTextureLayer {
|
|
|
70
70
|
this._state = new RenderState({
|
|
71
71
|
origin: math.vec3(cfg.origin),
|
|
72
72
|
metallicRoughnessBuf: null,
|
|
73
|
-
positionsDecodeMatrix: math.mat4(),
|
|
74
73
|
textureState: this._dataTextureState,
|
|
75
74
|
numIndices8Bits: 0,
|
|
76
75
|
numIndices16Bits: 0,
|
|
@@ -255,12 +254,11 @@ export class TrianglesDataTextureLayer {
|
|
|
255
254
|
const indices = bucket.indices;
|
|
256
255
|
const edgeIndices = bucket.edgeIndices;
|
|
257
256
|
const buffer = this._buffer;
|
|
258
|
-
const vertexBase = buffer.positionsCompressed.length / 3;
|
|
259
|
-
const numVertices = positionsCompressed.length / 3;
|
|
260
257
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
258
|
+
buffer.positionsCompressed.push(positionsCompressed)
|
|
259
|
+
const vertexBase = buffer.lenPositionsCompressed / 3;
|
|
260
|
+
const numVertices = positionsCompressed.length / 3;
|
|
261
|
+
buffer.lenPositionsCompressed += positionsCompressed.length;
|
|
264
262
|
|
|
265
263
|
let indicesBase;
|
|
266
264
|
let numTriangles = 0;
|
|
@@ -269,15 +267,18 @@ export class TrianglesDataTextureLayer {
|
|
|
269
267
|
let indicesBuffer;
|
|
270
268
|
if (numVertices <= (1 << 8)) {
|
|
271
269
|
indicesBuffer = buffer.indices8Bits;
|
|
270
|
+
indicesBase = buffer.lenIndices8Bits / 3;
|
|
271
|
+
buffer.lenIndices8Bits += indices.length;
|
|
272
272
|
} else if (numVertices <= (1 << 16)) {
|
|
273
273
|
indicesBuffer = buffer.indices16Bits;
|
|
274
|
+
indicesBase = buffer.lenIndices16Bits / 3;
|
|
275
|
+
buffer.lenIndices16Bits += indices.length;
|
|
274
276
|
} else {
|
|
275
277
|
indicesBuffer = buffer.indices32Bits;
|
|
278
|
+
indicesBase = buffer.lenIndices32Bits / 3;
|
|
279
|
+
buffer.lenIndices32Bits += indices.length;
|
|
276
280
|
}
|
|
277
|
-
|
|
278
|
-
for (let i = 0, len = indices.length; i < len; i++) {
|
|
279
|
-
indicesBuffer.push(indices[i]);
|
|
280
|
-
}
|
|
281
|
+
indicesBuffer.push(indices);
|
|
281
282
|
}
|
|
282
283
|
|
|
283
284
|
let edgeIndicesBase;
|
|
@@ -287,15 +288,18 @@ export class TrianglesDataTextureLayer {
|
|
|
287
288
|
let edgeIndicesBuffer;
|
|
288
289
|
if (numVertices <= (1 << 8)) {
|
|
289
290
|
edgeIndicesBuffer = buffer.edgeIndices8Bits;
|
|
291
|
+
edgeIndicesBase = buffer.lenEdgeIndices8Bits / 2;
|
|
292
|
+
buffer.lenEdgeIndices8Bits += edgeIndices.length;
|
|
290
293
|
} else if (numVertices <= (1 << 16)) {
|
|
291
294
|
edgeIndicesBuffer = buffer.edgeIndices16Bits;
|
|
295
|
+
edgeIndicesBase = buffer.lenEdgeIndices16Bits / 2;
|
|
296
|
+
buffer.lenEdgeIndices16Bits += edgeIndices.length;
|
|
292
297
|
} else {
|
|
293
298
|
edgeIndicesBuffer = buffer.edgeIndices32Bits;
|
|
299
|
+
edgeIndicesBase = buffer.lenEdgeIndices32Bits / 2;
|
|
300
|
+
buffer.lenEdgeIndices32Bits += edgeIndices.length;
|
|
294
301
|
}
|
|
295
|
-
|
|
296
|
-
for (let i = 0, len = edgeIndices.length; i < len; i++) {
|
|
297
|
-
edgeIndicesBuffer.push(edgeIndices[i]);
|
|
298
|
-
}
|
|
302
|
+
edgeIndicesBuffer.push(edgeIndices);
|
|
299
303
|
}
|
|
300
304
|
|
|
301
305
|
this._state.numVertices += numVertices;
|
|
@@ -466,7 +470,6 @@ export class TrianglesDataTextureLayer {
|
|
|
466
470
|
const buffer = this._buffer;
|
|
467
471
|
|
|
468
472
|
state.gl = gl;
|
|
469
|
-
|
|
470
473
|
textureState.texturePerObjectIdColorsAndFlags = this._dataTextureGenerator.generateTextureForColorsAndFlags(
|
|
471
474
|
gl,
|
|
472
475
|
buffer.perObjectColors,
|
|
@@ -484,9 +487,17 @@ export class TrianglesDataTextureLayer {
|
|
|
484
487
|
buffer.perObjectPositionsDecodeMatrices,
|
|
485
488
|
buffer.perObjectInstancePositioningMatrices);
|
|
486
489
|
|
|
490
|
+
// const positionsCompressed = new Uint16Array(buffer.lenPositionsCompressed);
|
|
491
|
+
// for (let i = 0, j = 0, len = buffer.positionsCompressed.length; i < len; i++) {
|
|
492
|
+
// const pc = buffer.positionsCompressed[i];
|
|
493
|
+
// positionsCompressed.set(pc, j);
|
|
494
|
+
// j += pc.length;
|
|
495
|
+
// }
|
|
496
|
+
|
|
487
497
|
textureState.texturePerVertexIdCoordinates = this._dataTextureGenerator.generateTextureForPositions(
|
|
488
498
|
gl,
|
|
489
|
-
buffer.positionsCompressed
|
|
499
|
+
buffer.positionsCompressed,
|
|
500
|
+
buffer.lenPositionsCompressed );
|
|
490
501
|
|
|
491
502
|
textureState.texturePerPolygonIdPortionIds8Bits = this._dataTextureGenerator.generateTextureForPackedPortionIds(
|
|
492
503
|
gl,
|
|
@@ -512,47 +523,46 @@ export class TrianglesDataTextureLayer {
|
|
|
512
523
|
buffer.perEdgeNumberPortionId16Bits);
|
|
513
524
|
}
|
|
514
525
|
|
|
515
|
-
|
|
516
526
|
if (buffer.perEdgeNumberPortionId32Bits.length > 0) {
|
|
517
527
|
textureState.texturePerEdgeIdPortionIds32Bits = this._dataTextureGenerator.generateTextureForPackedPortionIds(
|
|
518
528
|
gl,
|
|
519
529
|
buffer.perEdgeNumberPortionId32Bits);
|
|
520
530
|
}
|
|
521
531
|
|
|
522
|
-
if (buffer.
|
|
532
|
+
if (buffer.lenIndices8Bits > 0) {
|
|
523
533
|
textureState.texturePerPolygonIdIndices8Bits = this._dataTextureGenerator.generateTextureFor8BitIndices(
|
|
524
534
|
gl,
|
|
525
|
-
buffer.indices8Bits);
|
|
535
|
+
buffer.indices8Bits, buffer.lenIndices8Bits);
|
|
526
536
|
}
|
|
527
537
|
|
|
528
|
-
if (buffer.
|
|
538
|
+
if (buffer.lenIndices16Bits > 0) {
|
|
529
539
|
textureState.texturePerPolygonIdIndices16Bits = this._dataTextureGenerator.generateTextureFor16BitIndices(
|
|
530
540
|
gl,
|
|
531
|
-
buffer.indices16Bits);
|
|
541
|
+
buffer.indices16Bits, buffer.lenIndices16Bits);
|
|
532
542
|
}
|
|
533
543
|
|
|
534
|
-
if (buffer.
|
|
544
|
+
if (buffer.lenIndices32Bits > 0) {
|
|
535
545
|
textureState.texturePerPolygonIdIndices32Bits = this._dataTextureGenerator.generateTextureFor32BitIndices(
|
|
536
546
|
gl,
|
|
537
|
-
buffer.indices32Bits);
|
|
547
|
+
buffer.indices32Bits, buffer.lenIndices32Bits);
|
|
538
548
|
}
|
|
539
549
|
|
|
540
|
-
if (buffer.
|
|
550
|
+
if (buffer.lenEdgeIndices8Bits > 0) {
|
|
541
551
|
textureState.texturePerPolygonIdEdgeIndices8Bits = this._dataTextureGenerator.generateTextureFor8BitsEdgeIndices(
|
|
542
552
|
gl,
|
|
543
|
-
buffer.edgeIndices8Bits);
|
|
553
|
+
buffer.edgeIndices8Bits, buffer.lenEdgeIndices8Bits);
|
|
544
554
|
}
|
|
545
555
|
|
|
546
|
-
if (buffer.
|
|
556
|
+
if (buffer.lenEdgeIndices16Bits > 0) {
|
|
547
557
|
textureState.texturePerPolygonIdEdgeIndices16Bits = this._dataTextureGenerator.generateTextureFor16BitsEdgeIndices(
|
|
548
558
|
gl,
|
|
549
|
-
buffer.edgeIndices16Bits);
|
|
559
|
+
buffer.edgeIndices16Bits, buffer.lenEdgeIndices16Bits);
|
|
550
560
|
}
|
|
551
561
|
|
|
552
|
-
if (buffer.
|
|
562
|
+
if (buffer.lenEdgeIndices32Bits > 0) {
|
|
553
563
|
textureState.texturePerPolygonIdEdgeIndices32Bits = this._dataTextureGenerator.generateTextureFor32BitsEdgeIndices(
|
|
554
564
|
gl,
|
|
555
|
-
buffer.edgeIndices32Bits);
|
|
565
|
+
buffer.edgeIndices32Bits, buffer.lenEdgeIndices32Bits);
|
|
556
566
|
}
|
|
557
567
|
|
|
558
568
|
textureState.finalize();
|
|
@@ -976,9 +976,19 @@ class TrianglesInstancingLayer {
|
|
|
976
976
|
return;
|
|
977
977
|
}
|
|
978
978
|
this._updateBackfaceCull(renderFlags, frameCtx);
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
979
|
+
|
|
980
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
981
|
+
// TODO
|
|
982
|
+
// if (this._state.normalsBuf) {
|
|
983
|
+
// if (this._instancingRenderers.pickNormalsRenderer) {
|
|
984
|
+
// this._instancingRenderers.pickNormalsRenderer.drawLayer(frameCtx, this, RENDER_PASSES.PICK);
|
|
985
|
+
// }
|
|
986
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
987
|
+
// } else {
|
|
988
|
+
if (this._instancingRenderers.pickNormalsFlatRenderer) {
|
|
989
|
+
this._instancingRenderers.pickNormalsFlatRenderer.drawLayer(frameCtx, this, RENDER_PASSES.PICK);
|
|
990
|
+
}
|
|
991
|
+
// }
|
|
982
992
|
}
|
|
983
993
|
|
|
984
994
|
drawSnapInitDepthBuf(renderFlags, frameCtx) {
|