@xeokit/xeokit-sdk 2.6.29 → 2.6.30
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 +510 -429
- package/dist/xeokit-sdk.es.js +510 -429
- package/dist/xeokit-sdk.es5.js +315 -328
- package/dist/xeokit-sdk.min.cjs.js +4 -4
- package/dist/xeokit-sdk.min.es.js +4 -4
- package/dist/xeokit-sdk.min.es5.js +3 -3
- package/package.json +1 -1
- package/src/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.js +2 -110
- package/src/plugins/GLTFLoaderPlugin/GLTFSceneModelLoader.js +252 -222
- package/src/viewer/metadata/MetaScene.js +0 -2
- package/src/viewer/scene/model/SceneModel.js +9 -0
- package/src/viewer/scene/model/SceneModelTextureSet.js +5 -0
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesSnapInitRenderer.js +8 -0
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesSnapRenderer.js +8 -0
- package/src/viewer/scene/model/vbo/VBORenderer.js +10 -1
- package/src/viewer/scene/model/vbo/batching/lines/renderers/VBOBatchingLinesSnapRenderer.js +1 -1
- package/src/viewer/scene/model/vbo/batching/triangles/VBOBatchingTrianglesLayer.js +26 -6
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/Renderers.js +40 -12
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesBatchingRenderer.js +2 -3
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesColorTextureRenderer.js +25 -7
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesSnapRenderer.js +1 -1
- package/src/viewer/scene/model/vbo/instancing/lines/renderers/VBOInstancingLinesSnapRenderer.js +1 -1
- package/src/viewer/scene/model/vbo/instancing/triangles/VBOInstancingTrianglesLayer.js +17 -4
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/Renderers.js +74 -47
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesColorTextureRenderer.js +29 -14
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesInstancingRenderer.js +5 -4
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesSnapRenderer.js +1 -1
- package/src/viewer/scene/webgl/occlusion/OcclusionLayer.js +1 -1
- package/src/viewer/scene/webgl/occlusion/OcclusionTester.js +1 -4
package/dist/xeokit-sdk.es.js
CHANGED
|
@@ -17467,7 +17467,7 @@ class OcclusionLayer {
|
|
|
17467
17467
|
for (let i = 0; i < this.numMarkers; i++) {
|
|
17468
17468
|
if (this.markerList[i]) {
|
|
17469
17469
|
const marker = this.markerList[i];
|
|
17470
|
-
const worldPos = marker.
|
|
17470
|
+
const worldPos = marker.rtcPos;
|
|
17471
17471
|
this.positions[j++] = worldPos[0];
|
|
17472
17472
|
this.positions[j++] = worldPos[1];
|
|
17473
17473
|
this.positions[j++] = worldPos[2];
|
|
@@ -17909,10 +17909,7 @@ class OcclusionTester {
|
|
|
17909
17909
|
continue;
|
|
17910
17910
|
}
|
|
17911
17911
|
|
|
17912
|
-
|
|
17913
|
-
// because OcclusionLayer markers' transformation is being applied through the
|
|
17914
|
-
// OcclusionLayer::positions array. See XEOK-33
|
|
17915
|
-
const origin = [ 0, 0, 0 ];
|
|
17912
|
+
const origin = occlusionLayer.origin;
|
|
17916
17913
|
|
|
17917
17914
|
gl.uniformMatrix4fv(this._uViewMatrix, false, createRTCViewMat(camera.viewMatrix, origin));
|
|
17918
17915
|
|
|
@@ -51502,11 +51499,12 @@ const tempMat4a$r = math.mat4();
|
|
|
51502
51499
|
* @private
|
|
51503
51500
|
*/
|
|
51504
51501
|
class VBORenderer {
|
|
51505
|
-
constructor(scene, withSAO = false, {instancing = false, edges = false} = {}) {
|
|
51502
|
+
constructor(scene, withSAO = false, {instancing = false, edges = false, useAlphaCutoff = false} = {}) {
|
|
51506
51503
|
this._scene = scene;
|
|
51507
51504
|
this._withSAO = withSAO;
|
|
51508
51505
|
this._instancing = instancing;
|
|
51509
51506
|
this._edges = edges;
|
|
51507
|
+
this._useAlphaCutoff = useAlphaCutoff;
|
|
51510
51508
|
this._hash = this._getHash();
|
|
51511
51509
|
|
|
51512
51510
|
/**
|
|
@@ -51757,6 +51755,10 @@ class VBORenderer {
|
|
|
51757
51755
|
this._uSAOParams = program.getLocation("uSAOParams");
|
|
51758
51756
|
}
|
|
51759
51757
|
|
|
51758
|
+
if (this._useAlphaCutoff) {
|
|
51759
|
+
this._alphaCutoffLocation = program.getLocation("materialAlphaCutoff");
|
|
51760
|
+
}
|
|
51761
|
+
|
|
51760
51762
|
if (scene.logarithmicDepthBufferEnabled) {
|
|
51761
51763
|
this._uLogDepthBufFC = program.getLocation("logDepthBufFC");
|
|
51762
51764
|
}
|
|
@@ -52094,6 +52096,10 @@ class VBORenderer {
|
|
|
52094
52096
|
}
|
|
52095
52097
|
}
|
|
52096
52098
|
|
|
52099
|
+
if (this._useAlphaCutoff) {
|
|
52100
|
+
gl.uniform1f(this._alphaCutoffLocation, textureSet.alphaCutoff);
|
|
52101
|
+
}
|
|
52102
|
+
|
|
52097
52103
|
if (colorUniform) {
|
|
52098
52104
|
const colorKey = this._edges ? "edgeColor" : "fillColor";
|
|
52099
52105
|
const alphaKey = this._edges ? "edgeAlpha" : "fillAlpha";
|
|
@@ -52144,8 +52150,8 @@ class VBORenderer {
|
|
|
52144
52150
|
*/
|
|
52145
52151
|
class TrianglesBatchingRenderer extends VBORenderer {
|
|
52146
52152
|
|
|
52147
|
-
constructor(scene, withSAO, {edges = false} = {}) {
|
|
52148
|
-
super(scene, withSAO, {instancing: false, edges});
|
|
52153
|
+
constructor(scene, withSAO, {edges = false, useAlphaCutoff = false} = {}) {
|
|
52154
|
+
super(scene, withSAO, {instancing: false, edges, useAlphaCutoff});
|
|
52149
52155
|
}
|
|
52150
52156
|
|
|
52151
52157
|
_draw(drawCfg) {
|
|
@@ -52162,7 +52168,6 @@ class TrianglesBatchingRenderer extends VBORenderer {
|
|
|
52162
52168
|
} else {
|
|
52163
52169
|
const count = frameCtx.pickElementsCount || state.indicesBuf.numItems;
|
|
52164
52170
|
const offset = frameCtx.pickElementsOffset ? frameCtx.pickElementsOffset * state.indicesBuf.itemByteSize : 0;
|
|
52165
|
-
|
|
52166
52171
|
gl.drawElements(gl.TRIANGLES, count, state.indicesBuf.itemType, offset);
|
|
52167
52172
|
|
|
52168
52173
|
if (incrementDrawState) {
|
|
@@ -54615,6 +54620,7 @@ class TrianglesPickNormalsFlatRenderer$1 extends TrianglesBatchingRenderer {
|
|
|
54615
54620
|
/**
|
|
54616
54621
|
* @private
|
|
54617
54622
|
*/
|
|
54623
|
+
|
|
54618
54624
|
class TrianglesColorTextureRenderer$1 extends TrianglesBatchingRenderer {
|
|
54619
54625
|
_getHash() {
|
|
54620
54626
|
const scene = this._scene;
|
|
@@ -54622,11 +54628,10 @@ class TrianglesColorTextureRenderer$1 extends TrianglesBatchingRenderer {
|
|
|
54622
54628
|
}
|
|
54623
54629
|
|
|
54624
54630
|
drawLayer(frameCtx, layer, renderPass) {
|
|
54625
|
-
super.drawLayer(frameCtx, layer, renderPass, {incrementDrawState: true});
|
|
54631
|
+
super.drawLayer(frameCtx, layer, renderPass, { incrementDrawState: true });
|
|
54626
54632
|
}
|
|
54627
54633
|
|
|
54628
54634
|
_buildVertexShader() {
|
|
54629
|
-
|
|
54630
54635
|
const scene = this._scene;
|
|
54631
54636
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
54632
54637
|
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
@@ -54681,6 +54686,7 @@ class TrianglesColorTextureRenderer$1 extends TrianglesBatchingRenderer {
|
|
|
54681
54686
|
if (scene.entityOffsetsEnabled) {
|
|
54682
54687
|
src.push("worldPosition.xyz = worldPosition.xyz + offset;");
|
|
54683
54688
|
}
|
|
54689
|
+
|
|
54684
54690
|
src.push("vec4 viewPosition = viewMatrix * worldPosition; ");
|
|
54685
54691
|
src.push("vViewPosition = viewPosition;");
|
|
54686
54692
|
src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");
|
|
@@ -54691,10 +54697,12 @@ class TrianglesColorTextureRenderer$1 extends TrianglesBatchingRenderer {
|
|
|
54691
54697
|
src.push("vFragDepth = 1.0 + clipPos.w;");
|
|
54692
54698
|
src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
|
|
54693
54699
|
}
|
|
54700
|
+
|
|
54694
54701
|
if (clipping) {
|
|
54695
54702
|
src.push("vWorldPosition = worldPosition;");
|
|
54696
54703
|
src.push("vFlags = flags;");
|
|
54697
54704
|
}
|
|
54705
|
+
|
|
54698
54706
|
src.push("gl_Position = clipPos;");
|
|
54699
54707
|
src.push("}");
|
|
54700
54708
|
src.push("}");
|
|
@@ -54707,6 +54715,7 @@ class TrianglesColorTextureRenderer$1 extends TrianglesBatchingRenderer {
|
|
|
54707
54715
|
const lightsState = scene._lightsState;
|
|
54708
54716
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
54709
54717
|
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
54718
|
+
const useAlphaCutoff = this._useAlphaCutoff;
|
|
54710
54719
|
const src = [];
|
|
54711
54720
|
src.push("#version 300 es");
|
|
54712
54721
|
src.push("// Triangles batching color texture fragment shader");
|
|
@@ -54765,6 +54774,7 @@ class TrianglesColorTextureRenderer$1 extends TrianglesBatchingRenderer {
|
|
|
54765
54774
|
src.push("uniform vec4 sliceColor;");
|
|
54766
54775
|
}
|
|
54767
54776
|
this._addMatricesUniformBlockLines(src);
|
|
54777
|
+
|
|
54768
54778
|
src.push("uniform vec4 lightAmbient;");
|
|
54769
54779
|
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
54770
54780
|
const light = lightsState.lights[i];
|
|
@@ -54784,6 +54794,10 @@ class TrianglesColorTextureRenderer$1 extends TrianglesBatchingRenderer {
|
|
|
54784
54794
|
}
|
|
54785
54795
|
}
|
|
54786
54796
|
|
|
54797
|
+
if (useAlphaCutoff) {
|
|
54798
|
+
src.push("uniform float materialAlphaCutoff;");
|
|
54799
|
+
}
|
|
54800
|
+
|
|
54787
54801
|
src.push("in vec4 vViewPosition;");
|
|
54788
54802
|
src.push("in vec4 vColor;");
|
|
54789
54803
|
src.push("in vec2 vUV;");
|
|
@@ -54851,11 +54865,21 @@ class TrianglesColorTextureRenderer$1 extends TrianglesBatchingRenderer {
|
|
|
54851
54865
|
}
|
|
54852
54866
|
|
|
54853
54867
|
src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * newColor.rgb) + (reflectedColor * newColor.rgb), newColor.a);");
|
|
54868
|
+
|
|
54869
|
+
src.push("vec4 sampleColor = texture(uColorMap, vUV);");
|
|
54870
|
+
|
|
54871
|
+
if (useAlphaCutoff) {
|
|
54872
|
+
src.push("if (sampleColor.a < materialAlphaCutoff) {");
|
|
54873
|
+
src.push(" discard;");
|
|
54874
|
+
src.push("}");
|
|
54875
|
+
}
|
|
54876
|
+
|
|
54854
54877
|
if (gammaOutput) {
|
|
54855
|
-
src.push("
|
|
54856
|
-
} else {
|
|
54857
|
-
src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");
|
|
54878
|
+
src.push("sampleColor = sRGBToLinear(sampleColor);");
|
|
54858
54879
|
}
|
|
54880
|
+
|
|
54881
|
+
src.push("vec4 colorTexel = color * sampleColor;");
|
|
54882
|
+
|
|
54859
54883
|
src.push("float opacity = color.a;");
|
|
54860
54884
|
|
|
54861
54885
|
if (this._withSAO) {
|
|
@@ -55402,7 +55426,7 @@ class TrianglesSnapRenderer$1 extends VBORenderer{
|
|
|
55402
55426
|
|
|
55403
55427
|
src.push(`int pickFlag = int(flags) >> 12 & 0xF;`);
|
|
55404
55428
|
src.push(`if (pickFlag != renderPass) {`);
|
|
55405
|
-
src.push(" gl_Position = vec4(
|
|
55429
|
+
src.push(" gl_Position = vec4(2.0, 0.0, 0.0, 0.0);"); // Cull vertex
|
|
55406
55430
|
src.push(" } else {");
|
|
55407
55431
|
src.push(" vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");
|
|
55408
55432
|
if (scene.entityOffsetsEnabled) {
|
|
@@ -55529,6 +55553,14 @@ class Renderers$1 {
|
|
|
55529
55553
|
this._colorTextureRendererWithSAO.destroy();
|
|
55530
55554
|
this._colorTextureRendererWithSAO = null;
|
|
55531
55555
|
}
|
|
55556
|
+
if (this._colorTextureRendererAlphaCutoff && (!this._colorTextureRendererAlphaCutoff.getValid())) {
|
|
55557
|
+
this._colorTextureRendererAlphaCutoff.destroy();
|
|
55558
|
+
this._colorTextureRendererAlphaCutoff = null;
|
|
55559
|
+
}
|
|
55560
|
+
if (this._colorTextureRendererWithSAOAlphaCutoff && (!this._colorTextureRendererWithSAOAlphaCutoff.getValid())) {
|
|
55561
|
+
this._colorTextureRendererWithSAOAlphaCutoff.destroy();
|
|
55562
|
+
this._colorTextureRendererWithSAOAlphaCutoff = null;
|
|
55563
|
+
}
|
|
55532
55564
|
if (this._pbrRenderer && (!this._pbrRenderer.getValid())) {
|
|
55533
55565
|
this._pbrRenderer.destroy();
|
|
55534
55566
|
this._pbrRenderer = null;
|
|
@@ -55656,6 +55688,20 @@ class Renderers$1 {
|
|
|
55656
55688
|
return this._colorTextureRendererWithSAO;
|
|
55657
55689
|
}
|
|
55658
55690
|
|
|
55691
|
+
get colorTextureRendererAlphaCutoff() {
|
|
55692
|
+
if (!this._colorTextureRendererAlphaCutoff) {
|
|
55693
|
+
this._colorTextureRendererAlphaCutoff = new TrianglesColorTextureRenderer$1(this._scene, false, { useAlphaCutoff: true });
|
|
55694
|
+
}
|
|
55695
|
+
return this._colorTextureRendererAlphaCutoff;
|
|
55696
|
+
}
|
|
55697
|
+
|
|
55698
|
+
get colorTextureRendererWithSAOAlphaCutoff() {
|
|
55699
|
+
if (!this._colorTextureRendererWithSAOAlphaCutoff) {
|
|
55700
|
+
this._colorTextureRendererWithSAOAlphaCutoff = new TrianglesColorTextureRenderer$1(this._scene, true, { useAlphaCutoff: true });
|
|
55701
|
+
}
|
|
55702
|
+
return this._colorTextureRendererWithSAOAlphaCutoff;
|
|
55703
|
+
}
|
|
55704
|
+
|
|
55659
55705
|
get pbrRenderer() {
|
|
55660
55706
|
if (!this._pbrRenderer) {
|
|
55661
55707
|
this._pbrRenderer = new TrianglesPBRRenderer$1(this._scene, false);
|
|
@@ -55780,6 +55826,12 @@ class Renderers$1 {
|
|
|
55780
55826
|
if (this._colorTextureRendererWithSAO) {
|
|
55781
55827
|
this._colorTextureRendererWithSAO.destroy();
|
|
55782
55828
|
}
|
|
55829
|
+
if (this._colorTextureRendererAlphaCutoff) {
|
|
55830
|
+
this._colorTextureRendererAlphaCutoff.destroy();
|
|
55831
|
+
}
|
|
55832
|
+
if (this._colorTextureRendererWithSAOAlphaCutoff) {
|
|
55833
|
+
this._colorTextureRendererWithSAOAlphaCutoff.destroy();
|
|
55834
|
+
}
|
|
55783
55835
|
if (this._pbrRenderer) {
|
|
55784
55836
|
this._pbrRenderer.destroy();
|
|
55785
55837
|
}
|
|
@@ -55828,29 +55880,29 @@ class Renderers$1 {
|
|
|
55828
55880
|
}
|
|
55829
55881
|
}
|
|
55830
55882
|
|
|
55831
|
-
const
|
|
55883
|
+
const cachedRenderers$6 = {};
|
|
55832
55884
|
|
|
55833
55885
|
/**
|
|
55834
55886
|
* @private
|
|
55835
55887
|
*/
|
|
55836
55888
|
function getRenderers$7(scene) {
|
|
55837
55889
|
const sceneId = scene.id;
|
|
55838
|
-
let
|
|
55839
|
-
if (!
|
|
55840
|
-
|
|
55841
|
-
|
|
55842
|
-
|
|
55843
|
-
|
|
55890
|
+
let renderers = cachedRenderers$6[sceneId];
|
|
55891
|
+
if (!renderers) {
|
|
55892
|
+
renderers = new Renderers$1(scene);
|
|
55893
|
+
cachedRenderers$6[sceneId] = renderers;
|
|
55894
|
+
renderers._compile();
|
|
55895
|
+
renderers.eagerCreateRenders();
|
|
55844
55896
|
scene.on("compile", () => {
|
|
55845
|
-
|
|
55846
|
-
|
|
55897
|
+
renderers._compile();
|
|
55898
|
+
renderers.eagerCreateRenders();
|
|
55847
55899
|
});
|
|
55848
55900
|
scene.on("destroyed", () => {
|
|
55849
|
-
delete
|
|
55850
|
-
|
|
55901
|
+
delete cachedRenderers$6[sceneId];
|
|
55902
|
+
renderers._destroy();
|
|
55851
55903
|
});
|
|
55852
55904
|
}
|
|
55853
|
-
return
|
|
55905
|
+
return renderers;
|
|
55854
55906
|
}
|
|
55855
55907
|
|
|
55856
55908
|
let maxDataTextureHeight = 1 << 16;
|
|
@@ -57014,14 +57066,21 @@ class VBOBatchingTrianglesLayer {
|
|
|
57014
57066
|
return;
|
|
57015
57067
|
}
|
|
57016
57068
|
this._updateBackfaceCull(renderFlags, frameCtx);
|
|
57069
|
+
const useAlphaCutoff = this._state.textureSet && (typeof(this._state.textureSet.alphaCutoff) === "number");
|
|
57017
57070
|
if (frameCtx.withSAO && this.model.saoEnabled) {
|
|
57018
57071
|
if (frameCtx.pbrEnabled && this.model.pbrEnabled && this._state.pbrSupported) {
|
|
57019
57072
|
if (this._renderers.pbrRendererWithSAO) {
|
|
57020
57073
|
this._renderers.pbrRendererWithSAO.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
|
|
57021
57074
|
}
|
|
57022
57075
|
} else if (frameCtx.colorTextureEnabled && this.model.colorTextureEnabled && this._state.colorTextureSupported) {
|
|
57023
|
-
if (
|
|
57024
|
-
this._renderers.
|
|
57076
|
+
if (useAlphaCutoff) {
|
|
57077
|
+
if (this._renderers.colorTextureRendererWithSAOAlphaCutoff) {
|
|
57078
|
+
this._renderers.colorTextureRendererWithSAOAlphaCutoff.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
|
|
57079
|
+
}
|
|
57080
|
+
} else {
|
|
57081
|
+
if (this._renderers.colorTextureRendererWithSAO) {
|
|
57082
|
+
this._renderers.colorTextureRendererWithSAO.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
|
|
57083
|
+
}
|
|
57025
57084
|
}
|
|
57026
57085
|
} else if (this._state.normalsBuf) {
|
|
57027
57086
|
if (this._renderers.colorRendererWithSAO) {
|
|
@@ -57038,8 +57097,14 @@ class VBOBatchingTrianglesLayer {
|
|
|
57038
57097
|
this._renderers.pbrRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
|
|
57039
57098
|
}
|
|
57040
57099
|
} else if (frameCtx.colorTextureEnabled && this.model.colorTextureEnabled && this._state.colorTextureSupported) {
|
|
57041
|
-
if (
|
|
57042
|
-
this._renderers.
|
|
57100
|
+
if (useAlphaCutoff) {
|
|
57101
|
+
if (this._renderers.colorTextureRendererAlphaCutoff) {
|
|
57102
|
+
this._renderers.colorTextureRendererAlphaCutoff.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
|
|
57103
|
+
}
|
|
57104
|
+
} else {
|
|
57105
|
+
if (this._renderers.colorTextureRenderer) {
|
|
57106
|
+
this._renderers.colorTextureRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
|
|
57107
|
+
}
|
|
57043
57108
|
}
|
|
57044
57109
|
} else if (this._state.normalsBuf) {
|
|
57045
57110
|
if (this._renderers.colorRenderer) {
|
|
@@ -57076,8 +57141,15 @@ class VBOBatchingTrianglesLayer {
|
|
|
57076
57141
|
this._renderers.pbrRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_TRANSPARENT);
|
|
57077
57142
|
}
|
|
57078
57143
|
} else if (frameCtx.colorTextureEnabled && this.model.colorTextureEnabled && this._state.colorTextureSupported) {
|
|
57079
|
-
|
|
57080
|
-
|
|
57144
|
+
const useAlphaCutoff = this._state.textureSet && (typeof(this._state.textureSet.alphaCutoff) === "number");
|
|
57145
|
+
if (useAlphaCutoff) {
|
|
57146
|
+
if (this._renderers.colorTextureRendererAlphaCutoff) {
|
|
57147
|
+
this._renderers.colorTextureRendererAlphaCutoff.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_TRANSPARENT);
|
|
57148
|
+
}
|
|
57149
|
+
} else {
|
|
57150
|
+
if (this._renderers.colorTextureRenderer) {
|
|
57151
|
+
this._renderers.colorTextureRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_TRANSPARENT);
|
|
57152
|
+
}
|
|
57081
57153
|
}
|
|
57082
57154
|
} else if (this._state.normalsBuf) {
|
|
57083
57155
|
if (this._renderers.colorRenderer) {
|
|
@@ -57421,8 +57493,8 @@ class VBOBatchingTrianglesLayer {
|
|
|
57421
57493
|
* @private
|
|
57422
57494
|
*/
|
|
57423
57495
|
class TrianglesInstancingRenderer extends VBORenderer {
|
|
57424
|
-
constructor(scene, withSAO, {edges = false} = {}) {
|
|
57425
|
-
super(scene, withSAO, {instancing: true, edges});
|
|
57496
|
+
constructor(scene, withSAO, {edges = false, useAlphaCutoff = false} = {}) {
|
|
57497
|
+
super(scene, withSAO, {instancing: true, edges, useAlphaCutoff});
|
|
57426
57498
|
}
|
|
57427
57499
|
|
|
57428
57500
|
_draw(drawCfg) {
|
|
@@ -57431,13 +57503,14 @@ class TrianglesInstancingRenderer extends VBORenderer {
|
|
|
57431
57503
|
const {
|
|
57432
57504
|
state,
|
|
57433
57505
|
frameCtx,
|
|
57434
|
-
incrementDrawState
|
|
57506
|
+
incrementDrawState
|
|
57435
57507
|
} = drawCfg;
|
|
57436
57508
|
|
|
57437
57509
|
if (this._edges) {
|
|
57438
57510
|
gl.drawElementsInstanced(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0, state.numInstances);
|
|
57439
57511
|
} else {
|
|
57440
57512
|
gl.drawElementsInstanced(gl.TRIANGLES, state.indicesBuf.numItems, state.indicesBuf.itemType, 0, state.numInstances);
|
|
57513
|
+
|
|
57441
57514
|
if (incrementDrawState) {
|
|
57442
57515
|
frameCtx.drawElements++;
|
|
57443
57516
|
}
|
|
@@ -59966,7 +60039,6 @@ class TrianglesPickNormalsFlatRenderer extends TrianglesInstancingRenderer {
|
|
|
59966
60039
|
* @private
|
|
59967
60040
|
*/
|
|
59968
60041
|
|
|
59969
|
-
|
|
59970
60042
|
class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
|
|
59971
60043
|
_getHash() {
|
|
59972
60044
|
const scene = this._scene;
|
|
@@ -60035,7 +60107,7 @@ class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
|
|
|
60035
60107
|
src.push("vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");
|
|
60036
60108
|
src.push("worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");
|
|
60037
60109
|
if (scene.entityOffsetsEnabled) {
|
|
60038
|
-
src.push("
|
|
60110
|
+
src.push("worldPosition.xyz = worldPosition.xyz + offset;");
|
|
60039
60111
|
}
|
|
60040
60112
|
|
|
60041
60113
|
src.push("vec4 viewPosition = viewMatrix * worldPosition; ");
|
|
@@ -60063,11 +60135,10 @@ class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
|
|
|
60063
60135
|
_buildFragmentShader() {
|
|
60064
60136
|
const scene = this._scene;
|
|
60065
60137
|
const gammaOutput = scene.gammaOutput; // If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is false.
|
|
60066
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
60067
60138
|
const lightsState = scene._lightsState;
|
|
60068
|
-
|
|
60069
|
-
let len;
|
|
60139
|
+
const sectionPlanesState = scene._sectionPlanesState;
|
|
60070
60140
|
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
60141
|
+
const useAlphaCutoff = this._useAlphaCutoff;
|
|
60071
60142
|
const src = [];
|
|
60072
60143
|
src.push("#version 300 es");
|
|
60073
60144
|
src.push("// Instancing geometry drawing fragment shader");
|
|
@@ -60079,6 +60150,7 @@ class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
|
|
|
60079
60150
|
src.push("precision mediump float;");
|
|
60080
60151
|
src.push("precision mediump int;");
|
|
60081
60152
|
src.push("#endif");
|
|
60153
|
+
|
|
60082
60154
|
if (scene.logarithmicDepthBufferEnabled) {
|
|
60083
60155
|
src.push("in float isPerspective;");
|
|
60084
60156
|
src.push("uniform float logDepthBufFC;");
|
|
@@ -60127,7 +60199,7 @@ class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
|
|
|
60127
60199
|
this._addMatricesUniformBlockLines(src);
|
|
60128
60200
|
|
|
60129
60201
|
src.push("uniform vec4 lightAmbient;");
|
|
60130
|
-
for (i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
60202
|
+
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
60131
60203
|
const light = lightsState.lights[i];
|
|
60132
60204
|
if (light.type === "ambient") {
|
|
60133
60205
|
continue;
|
|
@@ -60145,6 +60217,10 @@ class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
|
|
|
60145
60217
|
}
|
|
60146
60218
|
}
|
|
60147
60219
|
|
|
60220
|
+
if (useAlphaCutoff) {
|
|
60221
|
+
src.push("uniform float materialAlphaCutoff;");
|
|
60222
|
+
}
|
|
60223
|
+
|
|
60148
60224
|
src.push("in vec4 vViewPosition;");
|
|
60149
60225
|
src.push("in vec4 vColor;");
|
|
60150
60226
|
src.push("in vec2 vUV;");
|
|
@@ -60180,7 +60256,7 @@ class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
|
|
|
60180
60256
|
src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");
|
|
60181
60257
|
src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");
|
|
60182
60258
|
|
|
60183
|
-
for (i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
60259
|
+
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
60184
60260
|
const light = lightsState.lights[i];
|
|
60185
60261
|
if (light.type === "ambient") {
|
|
60186
60262
|
continue;
|
|
@@ -60206,16 +60282,27 @@ class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
|
|
|
60206
60282
|
} else {
|
|
60207
60283
|
continue;
|
|
60208
60284
|
}
|
|
60285
|
+
|
|
60209
60286
|
src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");
|
|
60210
60287
|
src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
|
|
60211
60288
|
}
|
|
60212
60289
|
|
|
60213
60290
|
src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * newColor.rgb) + (reflectedColor * newColor.rgb), newColor.a);");
|
|
60291
|
+
|
|
60292
|
+
src.push("vec4 sampleColor = texture(uColorMap, vUV);");
|
|
60293
|
+
|
|
60294
|
+
if (useAlphaCutoff) {
|
|
60295
|
+
src.push("if (sampleColor.a < materialAlphaCutoff) {");
|
|
60296
|
+
src.push(" discard;");
|
|
60297
|
+
src.push("}");
|
|
60298
|
+
}
|
|
60299
|
+
|
|
60214
60300
|
if (gammaOutput) {
|
|
60215
|
-
src.push("
|
|
60216
|
-
} else {
|
|
60217
|
-
src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");
|
|
60301
|
+
src.push("sampleColor = sRGBToLinear(sampleColor);");
|
|
60218
60302
|
}
|
|
60303
|
+
|
|
60304
|
+
src.push("vec4 colorTexel = color * sampleColor;");
|
|
60305
|
+
|
|
60219
60306
|
src.push("float opacity = color.a;");
|
|
60220
60307
|
|
|
60221
60308
|
if (this._withSAO) {
|
|
@@ -60227,9 +60314,10 @@ class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
|
|
|
60227
60314
|
src.push(" float blendFactor = uSAOParams[3];");
|
|
60228
60315
|
src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");
|
|
60229
60316
|
src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");
|
|
60230
|
-
|
|
60317
|
+
|
|
60318
|
+
src.push(" outColor = vec4(colorTexel.rgb * ambient, opacity);");
|
|
60231
60319
|
} else {
|
|
60232
|
-
src.push(" outColor = vec4(
|
|
60320
|
+
src.push(" outColor = vec4(colorTexel.rgb, opacity);");
|
|
60233
60321
|
}
|
|
60234
60322
|
|
|
60235
60323
|
if (gammaOutput) {
|
|
@@ -60237,7 +60325,7 @@ class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
|
|
|
60237
60325
|
}
|
|
60238
60326
|
|
|
60239
60327
|
if (scene.logarithmicDepthBufferEnabled) {
|
|
60240
|
-
src.push("
|
|
60328
|
+
src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
60241
60329
|
}
|
|
60242
60330
|
|
|
60243
60331
|
src.push("}");
|
|
@@ -60807,7 +60895,7 @@ class TrianglesSnapRenderer extends VBORenderer {
|
|
|
60807
60895
|
// renderPass = PICK
|
|
60808
60896
|
src.push(`int pickFlag = int(flags) >> 12 & 0xF;`);
|
|
60809
60897
|
src.push(`if (pickFlag != renderPass) {`);
|
|
60810
|
-
src.push(" gl_Position = vec4(
|
|
60898
|
+
src.push(" gl_Position = vec4(2.0, 0.0, 0.0, 0.0);"); // Cull vertex
|
|
60811
60899
|
src.push("} else {");
|
|
60812
60900
|
src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");
|
|
60813
60901
|
src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");
|
|
@@ -60927,14 +61015,6 @@ class Renderers {
|
|
|
60927
61015
|
this._flatColorRendererWithSAO.destroy();
|
|
60928
61016
|
this._flatColorRendererWithSAO = null;
|
|
60929
61017
|
}
|
|
60930
|
-
if (this._pbrRenderer && (!this._pbrRenderer.getValid())) {
|
|
60931
|
-
this._pbrRenderer.destroy();
|
|
60932
|
-
this._pbrRenderer = null;
|
|
60933
|
-
}
|
|
60934
|
-
if (this._pbrRendererWithSAO && (!this._pbrRendererWithSAO.getValid())) {
|
|
60935
|
-
this._pbrRendererWithSAO.destroy();
|
|
60936
|
-
this._pbrRendererWithSAO = null;
|
|
60937
|
-
}
|
|
60938
61018
|
if (this._colorTextureRenderer && (!this._colorTextureRenderer.getValid())) {
|
|
60939
61019
|
this._colorTextureRenderer.destroy();
|
|
60940
61020
|
this._colorTextureRenderer = null;
|
|
@@ -60943,6 +61023,22 @@ class Renderers {
|
|
|
60943
61023
|
this._colorTextureRendererWithSAO.destroy();
|
|
60944
61024
|
this._colorTextureRendererWithSAO = null;
|
|
60945
61025
|
}
|
|
61026
|
+
if (this._colorTextureRendererAlphaCutoff && (!this._colorTextureRendererAlphaCutoff.getValid())) {
|
|
61027
|
+
this._colorTextureRendererAlphaCutoff.destroy();
|
|
61028
|
+
this._colorTextureRendererAlphaCutoff = null;
|
|
61029
|
+
}
|
|
61030
|
+
if (this._colorTextureRendererWithSAOAlphaCutoff && (!this._colorTextureRendererWithSAOAlphaCutoff.getValid())) {
|
|
61031
|
+
this._colorTextureRendererWithSAOAlphaCutoff.destroy();
|
|
61032
|
+
this._colorTextureRendererWithSAOAlphaCutoff = null;
|
|
61033
|
+
}
|
|
61034
|
+
if (this._pbrRenderer && (!this._pbrRenderer.getValid())) {
|
|
61035
|
+
this._pbrRenderer.destroy();
|
|
61036
|
+
this._pbrRenderer = null;
|
|
61037
|
+
}
|
|
61038
|
+
if (this._pbrRendererWithSAO && (!this._pbrRendererWithSAO.getValid())) {
|
|
61039
|
+
this._pbrRendererWithSAO.destroy();
|
|
61040
|
+
this._pbrRendererWithSAO = null;
|
|
61041
|
+
}
|
|
60946
61042
|
if (this._depthRenderer && (!this._depthRenderer.getValid())) {
|
|
60947
61043
|
this._depthRenderer.destroy();
|
|
60948
61044
|
this._depthRenderer = null;
|
|
@@ -60975,7 +61071,7 @@ class Renderers {
|
|
|
60975
61071
|
this._pickNormalsRenderer.destroy();
|
|
60976
61072
|
this._pickNormalsRenderer = null;
|
|
60977
61073
|
}
|
|
60978
|
-
if (this._pickNormalsFlatRenderer &&
|
|
61074
|
+
if (this._pickNormalsFlatRenderer && this._pickNormalsFlatRenderer.getValid() === false) {
|
|
60979
61075
|
this._pickNormalsFlatRenderer.destroy();
|
|
60980
61076
|
this._pickNormalsFlatRenderer = null;
|
|
60981
61077
|
}
|
|
@@ -61048,20 +61144,6 @@ class Renderers {
|
|
|
61048
61144
|
return this._flatColorRendererWithSAO;
|
|
61049
61145
|
}
|
|
61050
61146
|
|
|
61051
|
-
get pbrRenderer() {
|
|
61052
|
-
if (!this._pbrRenderer) {
|
|
61053
|
-
this._pbrRenderer = new TrianglesPBRRenderer(this._scene, false);
|
|
61054
|
-
}
|
|
61055
|
-
return this._pbrRenderer;
|
|
61056
|
-
}
|
|
61057
|
-
|
|
61058
|
-
get pbrRendererWithSAO() {
|
|
61059
|
-
if (!this._pbrRendererWithSAO) {
|
|
61060
|
-
this._pbrRendererWithSAO = new TrianglesPBRRenderer(this._scene, true);
|
|
61061
|
-
}
|
|
61062
|
-
return this._pbrRendererWithSAO;
|
|
61063
|
-
}
|
|
61064
|
-
|
|
61065
61147
|
get colorTextureRenderer() {
|
|
61066
61148
|
if (!this._colorTextureRenderer) {
|
|
61067
61149
|
this._colorTextureRenderer = new TrianglesColorTextureRenderer(this._scene, false);
|
|
@@ -61076,6 +61158,34 @@ class Renderers {
|
|
|
61076
61158
|
return this._colorTextureRendererWithSAO;
|
|
61077
61159
|
}
|
|
61078
61160
|
|
|
61161
|
+
get colorTextureRendererAlphaCutoff() {
|
|
61162
|
+
if (!this._colorTextureRendererAlphaCutoff) {
|
|
61163
|
+
this._colorTextureRendererAlphaCutoff = new TrianglesColorTextureRenderer(this._scene, false, { useAlphaCutoff: true });
|
|
61164
|
+
}
|
|
61165
|
+
return this._colorTextureRendererAlphaCutoff;
|
|
61166
|
+
}
|
|
61167
|
+
|
|
61168
|
+
get colorTextureRendererWithSAOAlphaCutoff() {
|
|
61169
|
+
if (!this._colorTextureRendererWithSAOAlphaCutoff) {
|
|
61170
|
+
this._colorTextureRendererWithSAOAlphaCutoff = new TrianglesColorTextureRenderer(this._scene, true, { useAlphaCutoff: true });
|
|
61171
|
+
}
|
|
61172
|
+
return this._colorTextureRendererWithSAOAlphaCutoff;
|
|
61173
|
+
}
|
|
61174
|
+
|
|
61175
|
+
get pbrRenderer() {
|
|
61176
|
+
if (!this._pbrRenderer) {
|
|
61177
|
+
this._pbrRenderer = new TrianglesPBRRenderer(this._scene, false);
|
|
61178
|
+
}
|
|
61179
|
+
return this._pbrRenderer;
|
|
61180
|
+
}
|
|
61181
|
+
|
|
61182
|
+
get pbrRendererWithSAO() {
|
|
61183
|
+
if (!this._pbrRendererWithSAO) {
|
|
61184
|
+
this._pbrRendererWithSAO = new TrianglesPBRRenderer(this._scene, true);
|
|
61185
|
+
}
|
|
61186
|
+
return this._pbrRendererWithSAO;
|
|
61187
|
+
}
|
|
61188
|
+
|
|
61079
61189
|
get silhouetteRenderer() {
|
|
61080
61190
|
if (!this._silhouetteRenderer) {
|
|
61081
61191
|
this._silhouetteRenderer = new TrianglesSilhouetteRenderer(this._scene);
|
|
@@ -61153,13 +61263,6 @@ class Renderers {
|
|
|
61153
61263
|
return this._shadowRenderer;
|
|
61154
61264
|
}
|
|
61155
61265
|
|
|
61156
|
-
get snapInitRenderer() {
|
|
61157
|
-
if (!this._snapInitRenderer) {
|
|
61158
|
-
this._snapInitRenderer = new TrianglesSnapInitRenderer(this._scene, false);
|
|
61159
|
-
}
|
|
61160
|
-
return this._snapInitRenderer;
|
|
61161
|
-
}
|
|
61162
|
-
|
|
61163
61266
|
get snapRenderer() {
|
|
61164
61267
|
if (!this._snapRenderer) {
|
|
61165
61268
|
this._snapRenderer = new TrianglesSnapRenderer(this._scene);
|
|
@@ -61167,6 +61270,13 @@ class Renderers {
|
|
|
61167
61270
|
return this._snapRenderer;
|
|
61168
61271
|
}
|
|
61169
61272
|
|
|
61273
|
+
get snapInitRenderer() {
|
|
61274
|
+
if (!this._snapInitRenderer) {
|
|
61275
|
+
this._snapInitRenderer = new TrianglesSnapInitRenderer(this._scene);
|
|
61276
|
+
}
|
|
61277
|
+
return this._snapInitRenderer;
|
|
61278
|
+
}
|
|
61279
|
+
|
|
61170
61280
|
_destroy() {
|
|
61171
61281
|
if (this._colorRenderer) {
|
|
61172
61282
|
this._colorRenderer.destroy();
|
|
@@ -61180,18 +61290,24 @@ class Renderers {
|
|
|
61180
61290
|
if (this._flatColorRendererWithSAO) {
|
|
61181
61291
|
this._flatColorRendererWithSAO.destroy();
|
|
61182
61292
|
}
|
|
61183
|
-
if (this._pbrRenderer) {
|
|
61184
|
-
this._pbrRenderer.destroy();
|
|
61185
|
-
}
|
|
61186
|
-
if (this._pbrRendererWithSAO) {
|
|
61187
|
-
this._pbrRendererWithSAO.destroy();
|
|
61188
|
-
}
|
|
61189
61293
|
if (this._colorTextureRenderer) {
|
|
61190
61294
|
this._colorTextureRenderer.destroy();
|
|
61191
61295
|
}
|
|
61192
61296
|
if (this._colorTextureRendererWithSAO) {
|
|
61193
61297
|
this._colorTextureRendererWithSAO.destroy();
|
|
61194
61298
|
}
|
|
61299
|
+
if (this._colorTextureRendererAlphaCutoff) {
|
|
61300
|
+
this._colorTextureRendererAlphaCutoff.destroy();
|
|
61301
|
+
}
|
|
61302
|
+
if (this._colorTextureRendererWithSAOAlphaCutoff) {
|
|
61303
|
+
this._colorTextureRendererWithSAOAlphaCutoff.destroy();
|
|
61304
|
+
}
|
|
61305
|
+
if (this._pbrRenderer) {
|
|
61306
|
+
this._pbrRenderer.destroy();
|
|
61307
|
+
}
|
|
61308
|
+
if (this._pbrRendererWithSAO) {
|
|
61309
|
+
this._pbrRendererWithSAO.destroy();
|
|
61310
|
+
}
|
|
61195
61311
|
if (this._depthRenderer) {
|
|
61196
61312
|
this._depthRenderer.destroy();
|
|
61197
61313
|
}
|
|
@@ -61241,22 +61357,22 @@ const cachedRenderers$5 = {};
|
|
|
61241
61357
|
*/
|
|
61242
61358
|
function getRenderers$6(scene) {
|
|
61243
61359
|
const sceneId = scene.id;
|
|
61244
|
-
let
|
|
61245
|
-
if (!
|
|
61246
|
-
|
|
61247
|
-
cachedRenderers$5[sceneId] =
|
|
61248
|
-
|
|
61249
|
-
|
|
61360
|
+
let renderers = cachedRenderers$5[sceneId];
|
|
61361
|
+
if (!renderers) {
|
|
61362
|
+
renderers = new Renderers(scene);
|
|
61363
|
+
cachedRenderers$5[sceneId] = renderers;
|
|
61364
|
+
renderers._compile();
|
|
61365
|
+
renderers.eagerCreateRenders();
|
|
61250
61366
|
scene.on("compile", () => {
|
|
61251
|
-
|
|
61252
|
-
|
|
61367
|
+
renderers._compile();
|
|
61368
|
+
renderers.eagerCreateRenders();
|
|
61253
61369
|
});
|
|
61254
61370
|
scene.on("destroyed", () => {
|
|
61255
61371
|
delete cachedRenderers$5[sceneId];
|
|
61256
|
-
|
|
61372
|
+
renderers._destroy();
|
|
61257
61373
|
});
|
|
61258
61374
|
}
|
|
61259
|
-
return
|
|
61375
|
+
return renderers;
|
|
61260
61376
|
}
|
|
61261
61377
|
|
|
61262
61378
|
const tempUint8Vec4$2 = new Uint8Array(4);
|
|
@@ -62038,14 +62154,21 @@ class VBOInstancingTrianglesLayer {
|
|
|
62038
62154
|
return;
|
|
62039
62155
|
}
|
|
62040
62156
|
this._updateBackfaceCull(renderFlags, frameCtx);
|
|
62157
|
+
const useAlphaCutoff = this._state.textureSet && (typeof(this._state.textureSet.alphaCutoff) === "number");
|
|
62041
62158
|
if (frameCtx.withSAO && this.model.saoEnabled) {
|
|
62042
62159
|
if (frameCtx.pbrEnabled && this.model.pbrEnabled && this._state.pbrSupported) {
|
|
62043
62160
|
if (this._renderers.pbrRendererWithSAO) {
|
|
62044
62161
|
this._renderers.pbrRendererWithSAO.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
|
|
62045
62162
|
}
|
|
62046
62163
|
} else if (frameCtx.colorTextureEnabled && this.model.colorTextureEnabled && this._state.colorTextureSupported) {
|
|
62047
|
-
if (
|
|
62048
|
-
this._renderers.
|
|
62164
|
+
if (useAlphaCutoff) {
|
|
62165
|
+
if (this._renderers.colorTextureRendererWithSAOAlphaCutoff) {
|
|
62166
|
+
this._renderers.colorTextureRendererWithSAOAlphaCutoff.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
|
|
62167
|
+
}
|
|
62168
|
+
} else {
|
|
62169
|
+
if (this._renderers.colorTextureRendererWithSAO) {
|
|
62170
|
+
this._renderers.colorTextureRendererWithSAO.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
|
|
62171
|
+
}
|
|
62049
62172
|
}
|
|
62050
62173
|
} else if (this._state.normalsBuf) {
|
|
62051
62174
|
if (this._renderers.colorRendererWithSAO) {
|
|
@@ -62061,8 +62184,14 @@ class VBOInstancingTrianglesLayer {
|
|
|
62061
62184
|
this._renderers.pbrRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
|
|
62062
62185
|
}
|
|
62063
62186
|
} else if (frameCtx.colorTextureEnabled && this.model.colorTextureEnabled && this._state.colorTextureSupported) {
|
|
62064
|
-
if (
|
|
62065
|
-
this._renderers.
|
|
62187
|
+
if (useAlphaCutoff) {
|
|
62188
|
+
if (this._renderers.colorTextureRendererAlphaCutoff) {
|
|
62189
|
+
this._renderers.colorTextureRendererAlphaCutoff.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
|
|
62190
|
+
}
|
|
62191
|
+
} else {
|
|
62192
|
+
if (this._renderers.colorTextureRenderer) {
|
|
62193
|
+
this._renderers.colorTextureRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
|
|
62194
|
+
}
|
|
62066
62195
|
}
|
|
62067
62196
|
} else if (this._state.normalsBuf) {
|
|
62068
62197
|
if (this._renderers.colorRenderer) {
|
|
@@ -63237,7 +63366,7 @@ class VBOBatchingLinesSnapRenderer extends VBORenderer{
|
|
|
63237
63366
|
|
|
63238
63367
|
src.push(`int pickFlag = int(flags) >> 12 & 0xF;`);
|
|
63239
63368
|
src.push(`if (pickFlag != renderPass) {`);
|
|
63240
|
-
src.push(" gl_Position = vec4(
|
|
63369
|
+
src.push(" gl_Position = vec4(2.0, 0.0, 0.0, 0.0);"); // Cull vertex
|
|
63241
63370
|
src.push(" } else {");
|
|
63242
63371
|
src.push(" vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");
|
|
63243
63372
|
if (scene.entityOffsetsEnabled) {
|
|
@@ -64979,7 +65108,7 @@ class VBOInstancingLinesSnapRenderer extends VBORenderer {
|
|
|
64979
65108
|
// renderPass = PICK
|
|
64980
65109
|
src.push(`int pickFlag = int(flags) >> 12 & 0xF;`);
|
|
64981
65110
|
src.push(`if (pickFlag != renderPass) {`);
|
|
64982
|
-
src.push(" gl_Position = vec4(
|
|
65111
|
+
src.push(" gl_Position = vec4(2.0, 0.0, 0.0, 0.0);"); // Cull vertex
|
|
64983
65112
|
src.push("} else {");
|
|
64984
65113
|
src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");
|
|
64985
65114
|
src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");
|
|
@@ -75746,6 +75875,14 @@ class DTXTrianglesSnapRenderer {
|
|
|
75746
75875
|
src.push("uvec4 flags = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");
|
|
75747
75876
|
src.push("uvec4 flags2 = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");
|
|
75748
75877
|
|
|
75878
|
+
// flags.w = NOT_RENDERED | PICK
|
|
75879
|
+
// renderPass = PICK
|
|
75880
|
+
|
|
75881
|
+
src.push(`if (int(flags.w) != renderPass) {`);
|
|
75882
|
+
src.push(" gl_Position = vec4(3.0, 3.0, 3.0, 1.0);"); // Cull vertex
|
|
75883
|
+
src.push(" return;"); // Cull vertex
|
|
75884
|
+
src.push("}");
|
|
75885
|
+
|
|
75749
75886
|
src.push("{");
|
|
75750
75887
|
|
|
75751
75888
|
// get vertex base
|
|
@@ -76161,6 +76298,14 @@ class DTXTrianglesSnapInitRenderer {
|
|
|
76161
76298
|
src.push("uvec4 flags = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");
|
|
76162
76299
|
src.push("uvec4 flags2 = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");
|
|
76163
76300
|
|
|
76301
|
+
// flags.w = NOT_RENDERED | PICK
|
|
76302
|
+
// renderPass = PICK
|
|
76303
|
+
|
|
76304
|
+
src.push(`if (int(flags.w) != renderPass) {`);
|
|
76305
|
+
src.push(" gl_Position = vec4(3.0, 3.0, 3.0, 1.0);"); // Cull vertex
|
|
76306
|
+
src.push(" return;"); // Cull vertex
|
|
76307
|
+
src.push("}");
|
|
76308
|
+
|
|
76164
76309
|
src.push("{");
|
|
76165
76310
|
|
|
76166
76311
|
// get color
|
|
@@ -80553,6 +80698,11 @@ class SceneModelTextureSet {
|
|
|
80553
80698
|
*/
|
|
80554
80699
|
this.colorTexture = cfg.colorTexture;
|
|
80555
80700
|
|
|
80701
|
+
/**
|
|
80702
|
+
* The alpha cutoff [float]
|
|
80703
|
+
*/
|
|
80704
|
+
this.alphaCutoff = cfg.alphaCutoff;
|
|
80705
|
+
|
|
80556
80706
|
/**
|
|
80557
80707
|
* The metallic-roughness texture.
|
|
80558
80708
|
* @type {SceneModelTexture|*}
|
|
@@ -85109,6 +85259,7 @@ class SceneModel extends Component {
|
|
|
85109
85259
|
id: textureSetId,
|
|
85110
85260
|
model: this,
|
|
85111
85261
|
colorTexture,
|
|
85262
|
+
alphaCutoff: cfg.alphaCutoff,
|
|
85112
85263
|
metallicRoughnessTexture,
|
|
85113
85264
|
normalsTexture,
|
|
85114
85265
|
emissiveTexture,
|
|
@@ -85542,6 +85693,14 @@ class SceneModel extends Component {
|
|
|
85542
85693
|
return this._createMesh(cfg);
|
|
85543
85694
|
}
|
|
85544
85695
|
|
|
85696
|
+
_createDefaultIndices(numIndices) {
|
|
85697
|
+
const indices = [];
|
|
85698
|
+
for (let i = 0; i < numIndices; i++) {
|
|
85699
|
+
indices.push(i);
|
|
85700
|
+
}
|
|
85701
|
+
return indices;
|
|
85702
|
+
}
|
|
85703
|
+
|
|
85545
85704
|
_createMesh(cfg) {
|
|
85546
85705
|
const mesh = new SceneModelMesh(this, cfg.id, cfg.color, cfg.opacity, cfg.transform, cfg.textureSet);
|
|
85547
85706
|
mesh.pickId = this.scene._renderer.getPickID(mesh);
|
|
@@ -101591,8 +101750,6 @@ class MetaScene {
|
|
|
101591
101750
|
* @param {String} modelId ID for the new {@link MetaModel}, which will have {@link MetaModel#id} set to this value.
|
|
101592
101751
|
* @param {Object} metaModelData Data for the {@link MetaModel}.
|
|
101593
101752
|
* @param {Object} [options] Options for creating the {@link MetaModel}.
|
|
101594
|
-
* @param {Object} [options.includeTypes] When provided, only create {@link MetaObject}s with types in this list.
|
|
101595
|
-
* @param {Object} [options.excludeTypes] When provided, never create {@link MetaObject}s with types in this list.
|
|
101596
101753
|
* @param {Boolean} [options.globalizeObjectIds=false] Whether to globalize each {@link MetaObject#id}. Set this ````true```` when you need to load multiple instances of the same meta model, to avoid ID clashes between the meta objects in the different instances.
|
|
101597
101754
|
* @returns {MetaModel} The new MetaModel.
|
|
101598
101755
|
*/
|
|
@@ -117578,40 +117735,6 @@ class GLTFSceneModelLoader {
|
|
|
117578
117735
|
}
|
|
117579
117736
|
}
|
|
117580
117737
|
|
|
117581
|
-
function getMetaModelCorrections(metaModelJSON) {
|
|
117582
|
-
const eachRootStats = {};
|
|
117583
|
-
const eachChildRoot = {};
|
|
117584
|
-
const metaObjects = metaModelJSON.metaObjects || [];
|
|
117585
|
-
const metaObjectsMap = {};
|
|
117586
|
-
for (let i = 0, len = metaObjects.length; i < len; i++) {
|
|
117587
|
-
const metaObject = metaObjects[i];
|
|
117588
|
-
metaObjectsMap[metaObject.id] = metaObject;
|
|
117589
|
-
}
|
|
117590
|
-
for (let i = 0, len = metaObjects.length; i < len; i++) {
|
|
117591
|
-
const metaObject = metaObjects[i];
|
|
117592
|
-
if (metaObject.parent !== undefined && metaObject.parent !== null) {
|
|
117593
|
-
const metaObjectParent = metaObjectsMap[metaObject.parent];
|
|
117594
|
-
if (metaObject.type === metaObjectParent.type) {
|
|
117595
|
-
let rootMetaObject = metaObjectParent;
|
|
117596
|
-
while (rootMetaObject.parent && metaObjectsMap[rootMetaObject.parent].type === rootMetaObject.type) {
|
|
117597
|
-
rootMetaObject = metaObjectsMap[rootMetaObject.parent];
|
|
117598
|
-
}
|
|
117599
|
-
const rootStats = eachRootStats[rootMetaObject.id] || (eachRootStats[rootMetaObject.id] = {
|
|
117600
|
-
numChildren: 0,
|
|
117601
|
-
countChildren: 0
|
|
117602
|
-
});
|
|
117603
|
-
rootStats.numChildren++;
|
|
117604
|
-
eachChildRoot[metaObject.id] = rootMetaObject;
|
|
117605
|
-
}
|
|
117606
|
-
}
|
|
117607
|
-
}
|
|
117608
|
-
return {
|
|
117609
|
-
metaObjectsMap,
|
|
117610
|
-
eachRootStats,
|
|
117611
|
-
eachChildRoot
|
|
117612
|
-
};
|
|
117613
|
-
}
|
|
117614
|
-
|
|
117615
117738
|
function loadGLTF(plugin, src, metaModelJSON, options, sceneModel, ok, error) {
|
|
117616
117739
|
const spinner = plugin.viewer.scene.canvas.spinner;
|
|
117617
117740
|
spinner.processes++;
|
|
@@ -117653,7 +117776,9 @@ function parseGLTF(plugin, src, gltf, metaModelJSON, options, sceneModel, ok) {
|
|
|
117653
117776
|
const ctx = {
|
|
117654
117777
|
src: src,
|
|
117655
117778
|
entityId: options.entityId,
|
|
117656
|
-
|
|
117779
|
+
metaModelJSON,
|
|
117780
|
+
autoMetaModel: options.autoMetaModel,
|
|
117781
|
+
metaObjects: [],
|
|
117657
117782
|
loadBuffer: options.loadBuffer,
|
|
117658
117783
|
basePath: options.basePath,
|
|
117659
117784
|
handlenode: options.handlenode,
|
|
@@ -117672,8 +117797,20 @@ function parseGLTF(plugin, src, gltf, metaModelJSON, options, sceneModel, ok) {
|
|
|
117672
117797
|
};
|
|
117673
117798
|
loadTextures(ctx);
|
|
117674
117799
|
loadMaterials(ctx);
|
|
117800
|
+
if (options.autoMetaModel) {
|
|
117801
|
+
ctx.metaObjects.push({
|
|
117802
|
+
id: sceneModel.id,
|
|
117803
|
+
type: "Default",
|
|
117804
|
+
name: sceneModel.id
|
|
117805
|
+
});
|
|
117806
|
+
}
|
|
117675
117807
|
loadDefaultScene(ctx);
|
|
117676
117808
|
sceneModel.finalize();
|
|
117809
|
+
if (options.autoMetaModel) {
|
|
117810
|
+
plugin.viewer.metaScene.createMetaModel(sceneModel.id, {
|
|
117811
|
+
metaObjects: ctx.metaObjects
|
|
117812
|
+
});
|
|
117813
|
+
}
|
|
117677
117814
|
spinner.processes--;
|
|
117678
117815
|
ok();
|
|
117679
117816
|
});
|
|
@@ -117802,23 +117939,17 @@ function loadTextureSet(ctx, material) {
|
|
|
117802
117939
|
if (material.emissiveTexture) {
|
|
117803
117940
|
textureSetCfg.emissiveTextureId = material.emissiveTexture.texture._textureId;
|
|
117804
117941
|
}
|
|
117805
|
-
|
|
117806
|
-
|
|
117807
|
-
|
|
117808
|
-
|
|
117809
|
-
|
|
117810
|
-
|
|
117811
|
-
|
|
117812
|
-
|
|
117813
|
-
|
|
117814
|
-
|
|
117815
|
-
|
|
117816
|
-
// default:
|
|
117817
|
-
// }
|
|
117818
|
-
// const alphaCutoff = material.alphaCutoff;
|
|
117819
|
-
// if (alphaCutoff !== undefined) {
|
|
117820
|
-
// materialCfg.alphaCutoff = alphaCutoff;
|
|
117821
|
-
// }
|
|
117942
|
+
|
|
117943
|
+
switch (material.alphaMode) {
|
|
117944
|
+
case "OPAQUE":
|
|
117945
|
+
break;
|
|
117946
|
+
case "MASK":
|
|
117947
|
+
const alphaCutoff = material.alphaCutoff;
|
|
117948
|
+
// Default from the spec https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#reference-material
|
|
117949
|
+
textureSetCfg.alphaCutoff = (alphaCutoff !== undefined) ? alphaCutoff : 0.5;
|
|
117950
|
+
break;
|
|
117951
|
+
}
|
|
117952
|
+
|
|
117822
117953
|
const metallicPBR = material.pbrMetallicRoughness;
|
|
117823
117954
|
if (material.pbrMetallicRoughness) {
|
|
117824
117955
|
const pbrMetallicRoughness = material.pbrMetallicRoughness;
|
|
@@ -117864,7 +117995,7 @@ function loadMaterialAttributes(ctx, material) { // Substitute RGBA for material
|
|
|
117864
117995
|
opacity: 1,
|
|
117865
117996
|
metallic: 0,
|
|
117866
117997
|
roughness: 1,
|
|
117867
|
-
doubleSided
|
|
117998
|
+
doubleSided: true
|
|
117868
117999
|
};
|
|
117869
118000
|
if (extensions) {
|
|
117870
118001
|
const specularPBR = extensions["KHR_materials_pbrSpecularGlossiness"];
|
|
@@ -117938,9 +118069,22 @@ function loadScene(ctx, scene) {
|
|
|
117938
118069
|
const node = nodes[i];
|
|
117939
118070
|
countMeshUsage(ctx, node);
|
|
117940
118071
|
}
|
|
117941
|
-
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
118072
|
+
for (let i = 0, len = nodes.length; i < len && !ctx.nodesHaveNames; i++) {
|
|
117942
118073
|
const node = nodes[i];
|
|
117943
|
-
|
|
118074
|
+
if (testIfNodesHaveNames(node)) {
|
|
118075
|
+
ctx.nodesHaveNames = true;
|
|
118076
|
+
}
|
|
118077
|
+
}
|
|
118078
|
+
if (!ctx.nodesHaveNames) {
|
|
118079
|
+
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
118080
|
+
const node = nodes[i];
|
|
118081
|
+
parseNodesWithoutNames(ctx, node, 0, null);
|
|
118082
|
+
}
|
|
118083
|
+
} else {
|
|
118084
|
+
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
118085
|
+
const node = nodes[i];
|
|
118086
|
+
parseNodesWithNames(ctx, node, 0, null);
|
|
118087
|
+
}
|
|
117944
118088
|
}
|
|
117945
118089
|
}
|
|
117946
118090
|
|
|
@@ -117962,10 +118106,131 @@ function countMeshUsage(ctx, node) {
|
|
|
117962
118106
|
}
|
|
117963
118107
|
}
|
|
117964
118108
|
|
|
117965
|
-
|
|
118109
|
+
function testIfNodesHaveNames(node) {
|
|
118110
|
+
if (node.name) {
|
|
118111
|
+
return true;
|
|
118112
|
+
}
|
|
118113
|
+
if (node.children) {
|
|
118114
|
+
const children = node.children;
|
|
118115
|
+
for (let i = 0, len = children.length; i < len; i++) {
|
|
118116
|
+
const childNode = children[i];
|
|
118117
|
+
if (testIfNodesHaveNames(childNode)) {
|
|
118118
|
+
return true;
|
|
118119
|
+
}
|
|
118120
|
+
}
|
|
118121
|
+
}
|
|
118122
|
+
return false;
|
|
118123
|
+
}
|
|
118124
|
+
|
|
118125
|
+
/**
|
|
118126
|
+
* Parses a glTF node hierarchy that is known to NOT contain "name" attributes on the nodes.
|
|
118127
|
+
* Create a SceneMesh for each mesh primitive, and a single SceneObject.
|
|
118128
|
+
*/
|
|
118129
|
+
const parseNodesWithoutNames = (function () {
|
|
118130
|
+
const meshIds = [];
|
|
118131
|
+
return function (ctx, node, depth, matrix, parentNode) {
|
|
118132
|
+
matrix = parseNodeMatrix(node, matrix);
|
|
118133
|
+
if (node.mesh) {
|
|
118134
|
+
parseNodeMesh(node, ctx, matrix, meshIds);
|
|
118135
|
+
}
|
|
118136
|
+
if (node.children) {
|
|
118137
|
+
const children = node.children;
|
|
118138
|
+
for (let i = 0, len = children.length; i < len; i++) {
|
|
118139
|
+
const childNode = children[i];
|
|
118140
|
+
parseNodesWithoutNames(ctx, childNode, depth + 1, matrix, node);
|
|
118141
|
+
}
|
|
118142
|
+
}
|
|
118143
|
+
if (depth === 0) {
|
|
118144
|
+
let entityId = "entity-" + ctx.nextId++;
|
|
118145
|
+
if (meshIds && meshIds.length > 0) {
|
|
118146
|
+
ctx.sceneModel.createEntity({
|
|
118147
|
+
id: entityId,
|
|
118148
|
+
meshIds,
|
|
118149
|
+
isObject: true
|
|
118150
|
+
});
|
|
118151
|
+
if (ctx.autoMetaModel) {
|
|
118152
|
+
ctx.metaObjects.push({
|
|
118153
|
+
id: entityId,
|
|
118154
|
+
type: "Default",
|
|
118155
|
+
name: entityId,
|
|
118156
|
+
parent: ctx.sceneModel.id
|
|
118157
|
+
});
|
|
118158
|
+
}
|
|
118159
|
+
meshIds.length = 0;
|
|
118160
|
+
}
|
|
118161
|
+
}
|
|
118162
|
+
}
|
|
118163
|
+
})();
|
|
118164
|
+
|
|
118165
|
+
const parseNodesWithNames = (function () {
|
|
118166
|
+
|
|
118167
|
+
const objectIdStack = [];
|
|
118168
|
+
const meshIdsStack = [];
|
|
118169
|
+
let meshIds = null;
|
|
118170
|
+
|
|
118171
|
+
return function (ctx, node, depth, matrix) {
|
|
118172
|
+
matrix = parseNodeMatrix(node, matrix);
|
|
118173
|
+
if (meshIds && node.mesh) {
|
|
118174
|
+
parseNodeMesh(node, ctx, matrix, meshIds);
|
|
118175
|
+
}
|
|
118176
|
+
|
|
118177
|
+
if (node.name) {
|
|
118178
|
+
meshIds = [];
|
|
118179
|
+
let entityId = node.name;
|
|
118180
|
+
if (!!entityId && ctx.sceneModel.objects[entityId]) ;
|
|
118181
|
+
while (!entityId || ctx.sceneModel.objects[entityId]) {
|
|
118182
|
+
entityId = "entity-" + ctx.nextId++;
|
|
118183
|
+
}
|
|
118184
|
+
objectIdStack.push(entityId);
|
|
118185
|
+
meshIdsStack.push(meshIds);
|
|
118186
|
+
}
|
|
118187
|
+
|
|
118188
|
+
if (node.children) {
|
|
118189
|
+
const children = node.children;
|
|
118190
|
+
for (let i = 0, len = children.length; i < len; i++) {
|
|
118191
|
+
const childNode = children[i];
|
|
118192
|
+
parseNodesWithNames(ctx, childNode, depth + 1, matrix);
|
|
118193
|
+
}
|
|
118194
|
+
}
|
|
118195
|
+
|
|
118196
|
+
// Post-order visit scene node
|
|
117966
118197
|
|
|
117967
|
-
|
|
117968
|
-
|
|
118198
|
+
const nodeName = node.name;
|
|
118199
|
+
if ((nodeName !== undefined && nodeName !== null) || depth === 0) {
|
|
118200
|
+
let entityId = objectIdStack.pop();
|
|
118201
|
+
if (!entityId) { // For when there are no nodes with names
|
|
118202
|
+
entityId = "entity-" + ctx.nextId++;
|
|
118203
|
+
}
|
|
118204
|
+
let entityMeshIds = meshIdsStack.pop();
|
|
118205
|
+
if (meshIds && meshIds.length > 0) {
|
|
118206
|
+
ctx.sceneModel.createEntity({
|
|
118207
|
+
id: entityId,
|
|
118208
|
+
meshIds: entityMeshIds,
|
|
118209
|
+
isObject: true
|
|
118210
|
+
});
|
|
118211
|
+
if (ctx.autoMetaModel) {
|
|
118212
|
+
ctx.metaObjects.push({
|
|
118213
|
+
id: entityId,
|
|
118214
|
+
type: "Default",
|
|
118215
|
+
name: entityId,
|
|
118216
|
+
parent: ctx.sceneModel.id
|
|
118217
|
+
});
|
|
118218
|
+
}
|
|
118219
|
+
}
|
|
118220
|
+
meshIds = meshIdsStack.length > 0 ? meshIdsStack[meshIdsStack.length - 1] : null;
|
|
118221
|
+
}
|
|
118222
|
+
};
|
|
118223
|
+
})();
|
|
118224
|
+
|
|
118225
|
+
|
|
118226
|
+
/**
|
|
118227
|
+
* Parses transform at the given glTF node.
|
|
118228
|
+
*
|
|
118229
|
+
* @param node the glTF node
|
|
118230
|
+
* @param matrix Transfor matrix from parent nodes
|
|
118231
|
+
* @returns {*} Transform matrix for the node
|
|
118232
|
+
*/
|
|
118233
|
+
function parseNodeMatrix(node, matrix) {
|
|
117969
118234
|
let localMatrix;
|
|
117970
118235
|
if (node.matrix) {
|
|
117971
118236
|
localMatrix = node.matrix;
|
|
@@ -117999,171 +118264,92 @@ function loadNode(ctx, node, depth, matrix) {
|
|
|
117999
118264
|
matrix = localMatrix;
|
|
118000
118265
|
}
|
|
118001
118266
|
}
|
|
118267
|
+
return matrix;
|
|
118268
|
+
}
|
|
118002
118269
|
|
|
118003
|
-
|
|
118004
|
-
|
|
118005
|
-
|
|
118006
|
-
|
|
118007
|
-
|
|
118008
|
-
|
|
118009
|
-
|
|
118010
|
-
|
|
118011
|
-
|
|
118012
|
-
|
|
118013
|
-
|
|
118014
|
-
|
|
118015
|
-
|
|
118016
|
-
if (numPrimitives > 0) {
|
|
118017
|
-
|
|
118018
|
-
for (let i = 0; i < numPrimitives; i++) {
|
|
118019
|
-
|
|
118020
|
-
const primitive = mesh.primitives[i];
|
|
118021
|
-
if (primitive.mode < 4) {
|
|
118022
|
-
continue;
|
|
118023
|
-
}
|
|
118024
|
-
|
|
118025
|
-
const meshCfg = {
|
|
118026
|
-
id: sceneModel.id + "." + ctx.numObjects++
|
|
118027
|
-
};
|
|
118028
|
-
|
|
118029
|
-
const material = primitive.material;
|
|
118030
|
-
if (material) {
|
|
118031
|
-
meshCfg.textureSetId = material._textureSetId;
|
|
118032
|
-
meshCfg.color = material._attributes.color;
|
|
118033
|
-
meshCfg.opacity = material._attributes.opacity;
|
|
118034
|
-
meshCfg.metallic = material._attributes.metallic;
|
|
118035
|
-
meshCfg.roughness = material._attributes.roughness;
|
|
118036
|
-
} else {
|
|
118037
|
-
meshCfg.color = new Float32Array([1.0, 1.0, 1.0]);
|
|
118038
|
-
meshCfg.opacity = 1.0;
|
|
118039
|
-
}
|
|
118040
|
-
|
|
118041
|
-
const backfaces = ((ctx.backfaces !== false) || (material && material.doubleSided !== false));
|
|
118042
|
-
|
|
118043
|
-
switch (primitive.mode) {
|
|
118044
|
-
case 0: // POINTS
|
|
118045
|
-
meshCfg.primitive = "points";
|
|
118046
|
-
break;
|
|
118047
|
-
case 1: // LINES
|
|
118048
|
-
meshCfg.primitive = "lines";
|
|
118049
|
-
break;
|
|
118050
|
-
case 2: // LINE_LOOP
|
|
118051
|
-
meshCfg.primitive = "lines";
|
|
118052
|
-
break;
|
|
118053
|
-
case 3: // LINE_STRIP
|
|
118054
|
-
meshCfg.primitive = "lines";
|
|
118055
|
-
break;
|
|
118056
|
-
case 4: // TRIANGLES
|
|
118057
|
-
meshCfg.primitive = backfaces ? "triangles" : "solid";
|
|
118058
|
-
break;
|
|
118059
|
-
case 5: // TRIANGLE_STRIP
|
|
118060
|
-
meshCfg.primitive = backfaces ? "triangles" : "solid";
|
|
118061
|
-
break;
|
|
118062
|
-
case 6: // TRIANGLE_FAN
|
|
118063
|
-
meshCfg.primitive = backfaces ? "triangles" : "solid";
|
|
118064
|
-
break;
|
|
118065
|
-
default:
|
|
118066
|
-
meshCfg.primitive = backfaces ? "triangles" : "solid";
|
|
118067
|
-
}
|
|
118068
|
-
|
|
118069
|
-
const POSITION = primitive.attributes.POSITION;
|
|
118070
|
-
if (!POSITION) {
|
|
118071
|
-
continue;
|
|
118072
|
-
}
|
|
118073
|
-
meshCfg.localPositions = POSITION.value;
|
|
118074
|
-
meshCfg.positions = new Float64Array(meshCfg.localPositions.length);
|
|
118075
|
-
|
|
118076
|
-
if (primitive.attributes.NORMAL) {
|
|
118077
|
-
meshCfg.normals = primitive.attributes.NORMAL.value;
|
|
118078
|
-
}
|
|
118079
|
-
|
|
118080
|
-
if (primitive.attributes.TEXCOORD_0) {
|
|
118081
|
-
meshCfg.uv = primitive.attributes.TEXCOORD_0.value;
|
|
118082
|
-
}
|
|
118083
|
-
|
|
118084
|
-
if (primitive.indices) {
|
|
118085
|
-
meshCfg.indices = primitive.indices.value;
|
|
118086
|
-
}
|
|
118087
|
-
|
|
118088
|
-
math.transformPositions3(worldMatrix, meshCfg.localPositions, meshCfg.positions);
|
|
118089
|
-
const origin = math.vec3();
|
|
118090
|
-
const rtcNeeded = worldToRTCPositions(meshCfg.positions, meshCfg.positions, origin); // Small cellsize guarantees better accuracy
|
|
118091
|
-
if (rtcNeeded) {
|
|
118092
|
-
meshCfg.origin = origin;
|
|
118093
|
-
}
|
|
118094
|
-
|
|
118095
|
-
sceneModel.createMesh(meshCfg);
|
|
118096
|
-
deferredMeshIds.push(meshCfg.id);
|
|
118097
|
-
}
|
|
118098
|
-
}
|
|
118099
|
-
}
|
|
118100
|
-
|
|
118101
|
-
if (node.children) {
|
|
118102
|
-
const children = node.children;
|
|
118103
|
-
for (let i = 0, len = children.length; i < len; i++) {
|
|
118104
|
-
const childNode = children[i];
|
|
118105
|
-
loadNode(ctx, childNode, depth + 1, matrix);
|
|
118106
|
-
}
|
|
118270
|
+
/**
|
|
118271
|
+
* Parses primitives referenced by the mesh belonging to the given node, creating XKTMeshes in the XKTModel.
|
|
118272
|
+
*
|
|
118273
|
+
* @param node glTF node
|
|
118274
|
+
* @param ctx Parsing context
|
|
118275
|
+
* @param matrix Matrix for the XKTMeshes
|
|
118276
|
+
* @param meshIds returns IDs of the new XKTMeshes
|
|
118277
|
+
*/
|
|
118278
|
+
function parseNodeMesh(node, ctx, matrix, meshIds) {
|
|
118279
|
+
const mesh = node.mesh;
|
|
118280
|
+
if (!mesh) {
|
|
118281
|
+
return;
|
|
118107
118282
|
}
|
|
118108
|
-
|
|
118109
|
-
|
|
118110
|
-
|
|
118111
|
-
|
|
118112
|
-
|
|
118113
|
-
|
|
118114
|
-
id: ctx.entityId,
|
|
118115
|
-
meshIds: deferredMeshIds,
|
|
118116
|
-
isObject: true
|
|
118117
|
-
});
|
|
118118
|
-
deferredMeshIds.length = 0;
|
|
118119
|
-
}
|
|
118120
|
-
} else {
|
|
118121
|
-
const nodeName = node.name;
|
|
118122
|
-
if (((nodeName !== undefined && nodeName !== null) || depth === 0) && deferredMeshIds.length > 0) {
|
|
118123
|
-
if (nodeName === undefined || nodeName === null) {
|
|
118124
|
-
ctx.log(`Warning: 'name' properties not found on glTF scene nodes - will randomly-generate object IDs in XKT`);
|
|
118283
|
+
const numPrimitives = mesh.primitives.length;
|
|
118284
|
+
if (numPrimitives > 0) {
|
|
118285
|
+
for (let i = 0; i < numPrimitives; i++) {
|
|
118286
|
+
const primitive = mesh.primitives[i];
|
|
118287
|
+
if (primitive.mode < 4) {
|
|
118288
|
+
continue;
|
|
118125
118289
|
}
|
|
118126
|
-
|
|
118127
|
-
|
|
118128
|
-
|
|
118129
|
-
|
|
118130
|
-
|
|
118131
|
-
|
|
118132
|
-
|
|
118133
|
-
|
|
118134
|
-
|
|
118135
|
-
|
|
118136
|
-
if (rootMetaObject) {
|
|
118137
|
-
const rootMetaObjectStats = ctx.metaModelCorrections.eachRootStats[rootMetaObject.id];
|
|
118138
|
-
rootMetaObjectStats.countChildren++;
|
|
118139
|
-
if (rootMetaObjectStats.countChildren >= rootMetaObjectStats.numChildren) {
|
|
118140
|
-
sceneModel.createEntity({
|
|
118141
|
-
id: rootMetaObject.id,
|
|
118142
|
-
meshIds: deferredMeshIds,
|
|
118143
|
-
isObject: true
|
|
118144
|
-
});
|
|
118145
|
-
deferredMeshIds.length = 0;
|
|
118146
|
-
}
|
|
118147
|
-
} else {
|
|
118148
|
-
const metaObject = ctx.metaModelCorrections.metaObjectsMap[entityId];
|
|
118149
|
-
if (metaObject) {
|
|
118150
|
-
sceneModel.createEntity({
|
|
118151
|
-
id: entityId,
|
|
118152
|
-
meshIds: deferredMeshIds,
|
|
118153
|
-
isObject: true
|
|
118154
|
-
});
|
|
118155
|
-
deferredMeshIds.length = 0;
|
|
118156
|
-
}
|
|
118157
|
-
}
|
|
118290
|
+
const meshCfg = {
|
|
118291
|
+
id: ctx.sceneModel.id + "." + ctx.numObjects++
|
|
118292
|
+
};
|
|
118293
|
+
const material = primitive.material;
|
|
118294
|
+
if (material) {
|
|
118295
|
+
meshCfg.textureSetId = material._textureSetId;
|
|
118296
|
+
meshCfg.color = material._attributes.color;
|
|
118297
|
+
meshCfg.opacity = material._attributes.opacity;
|
|
118298
|
+
meshCfg.metallic = material._attributes.metallic;
|
|
118299
|
+
meshCfg.roughness = material._attributes.roughness;
|
|
118158
118300
|
} else {
|
|
118159
|
-
|
|
118160
|
-
|
|
118161
|
-
|
|
118162
|
-
|
|
118163
|
-
|
|
118164
|
-
|
|
118165
|
-
|
|
118301
|
+
meshCfg.color = new Float32Array([1.0, 1.0, 1.0]);
|
|
118302
|
+
meshCfg.opacity = 1.0;
|
|
118303
|
+
}
|
|
118304
|
+
const backfaces = ((ctx.backfaces !== false) || (material && material.doubleSided !== false));
|
|
118305
|
+
switch (primitive.mode) {
|
|
118306
|
+
case 0: // POINTS
|
|
118307
|
+
meshCfg.primitive = "points";
|
|
118308
|
+
break;
|
|
118309
|
+
case 1: // LINES
|
|
118310
|
+
meshCfg.primitive = "lines";
|
|
118311
|
+
break;
|
|
118312
|
+
case 2: // LINE_LOOP
|
|
118313
|
+
meshCfg.primitive = "lines";
|
|
118314
|
+
break;
|
|
118315
|
+
case 3: // LINE_STRIP
|
|
118316
|
+
meshCfg.primitive = "lines";
|
|
118317
|
+
break;
|
|
118318
|
+
case 4: // TRIANGLES
|
|
118319
|
+
meshCfg.primitive = backfaces ? "triangles" : "solid";
|
|
118320
|
+
break;
|
|
118321
|
+
case 5: // TRIANGLE_STRIP
|
|
118322
|
+
meshCfg.primitive = backfaces ? "triangles" : "solid";
|
|
118323
|
+
break;
|
|
118324
|
+
case 6: // TRIANGLE_FAN
|
|
118325
|
+
meshCfg.primitive = backfaces ? "triangles" : "solid";
|
|
118326
|
+
break;
|
|
118327
|
+
default:
|
|
118328
|
+
meshCfg.primitive = backfaces ? "triangles" : "solid";
|
|
118329
|
+
}
|
|
118330
|
+
const POSITION = primitive.attributes.POSITION;
|
|
118331
|
+
if (!POSITION) {
|
|
118332
|
+
continue;
|
|
118333
|
+
}
|
|
118334
|
+
meshCfg.localPositions = POSITION.value;
|
|
118335
|
+
meshCfg.positions = new Float64Array(meshCfg.localPositions.length);
|
|
118336
|
+
if (primitive.attributes.NORMAL) {
|
|
118337
|
+
meshCfg.normals = primitive.attributes.NORMAL.value;
|
|
118338
|
+
}
|
|
118339
|
+
if (primitive.attributes.TEXCOORD_0) {
|
|
118340
|
+
meshCfg.uv = primitive.attributes.TEXCOORD_0.value;
|
|
118341
|
+
}
|
|
118342
|
+
if (primitive.indices) {
|
|
118343
|
+
meshCfg.indices = primitive.indices.value;
|
|
118344
|
+
}
|
|
118345
|
+
math.transformPositions3(matrix, meshCfg.localPositions, meshCfg.positions);
|
|
118346
|
+
const origin = math.vec3();
|
|
118347
|
+
const rtcNeeded = worldToRTCPositions(meshCfg.positions, meshCfg.positions, origin); // Small cellsize guarantees better accuracy
|
|
118348
|
+
if (rtcNeeded) {
|
|
118349
|
+
meshCfg.origin = origin;
|
|
118166
118350
|
}
|
|
118351
|
+
ctx.sceneModel.createMesh(meshCfg);
|
|
118352
|
+
meshIds.push(meshCfg.id);
|
|
118167
118353
|
}
|
|
118168
118354
|
}
|
|
118169
118355
|
}
|
|
@@ -118490,8 +118676,6 @@ class GLTFLoaderPlugin extends Plugin {
|
|
|
118490
118676
|
* @param {String} [params.metaModelSrc] Path to an optional metadata file, as an alternative to the ````metaModelJSON```` parameter.
|
|
118491
118677
|
* @param {*} [params.metaModelJSON] JSON model metadata, as an alternative to the ````metaModelSrc```` parameter.
|
|
118492
118678
|
* @param {{String:Object}} [params.objectDefaults] Map of initial default states for each loaded {@link Entity} that represents an object. Default value is {@link IFCObjectDefaults}.
|
|
118493
|
-
* @param {String[]} [params.includeTypes] When loading metadata, only loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
|
|
118494
|
-
* @param {String[]} [params.excludeTypes] When loading metadata, never loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
|
|
118495
118679
|
* @param {Boolean} [params.edges=false] Whether or not xeokit renders the model with edges emphasized.
|
|
118496
118680
|
* @param {Number[]} [params.origin=[0,0,0]] The double-precision World-space origin of the model's coordinates.
|
|
118497
118681
|
* @param {Number[]} [params.position=[0,0,0]] The single-precision position, relative to ````origin````.
|
|
@@ -118507,150 +118691,47 @@ class GLTFLoaderPlugin extends Plugin {
|
|
|
118507
118691
|
* represent the returned model. Set false to always use vertex buffer objects (VBOs). Note that DTX is only applicable
|
|
118508
118692
|
* to non-textured triangle meshes, and that VBOs are always used for meshes that have textures, line segments, or point
|
|
118509
118693
|
* primitives. Only works while {@link DTX#enabled} is also ````true````.
|
|
118510
|
-
* @param {
|
|
118694
|
+
* @param {Boolean} [params.autoMetaModel] When supplied, creates a default MetaModel with a single MetaObject.
|
|
118511
118695
|
* @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}
|
|
118512
118696
|
*/
|
|
118513
118697
|
load(params = {}) {
|
|
118514
|
-
|
|
118515
118698
|
if (params.id && this.viewer.scene.components[params.id]) {
|
|
118516
118699
|
this.error("Component with this ID already exists in viewer: " + params.id + " - will autogenerate this ID");
|
|
118517
118700
|
delete params.id;
|
|
118518
118701
|
}
|
|
118519
|
-
|
|
118520
118702
|
const sceneModel = new SceneModel(this.viewer.scene, utils.apply(params, {
|
|
118521
118703
|
isModel: true,
|
|
118522
118704
|
dtxEnabled: params.dtxEnabled
|
|
118523
118705
|
}));
|
|
118524
|
-
|
|
118525
118706
|
const modelId = sceneModel.id; // In case ID was auto-generated
|
|
118526
|
-
|
|
118527
118707
|
if (!params.src && !params.gltf) {
|
|
118528
118708
|
this.error("load() param expected: src or gltf");
|
|
118529
118709
|
return sceneModel; // Return new empty model
|
|
118530
118710
|
}
|
|
118531
|
-
|
|
118532
118711
|
if (params.metaModelSrc || params.metaModelJSON) {
|
|
118533
|
-
|
|
118534
|
-
const objectDefaults = params.objectDefaults || this._objectDefaults || IFCObjectDefaults;
|
|
118535
|
-
|
|
118536
118712
|
const processMetaModelJSON = (metaModelJSON) => {
|
|
118537
|
-
|
|
118538
|
-
this.viewer.metaScene.createMetaModel(modelId, metaModelJSON, {
|
|
118539
|
-
includeTypes: params.includeTypes,
|
|
118540
|
-
excludeTypes: params.excludeTypes
|
|
118541
|
-
});
|
|
118542
|
-
|
|
118713
|
+
this.viewer.metaScene.createMetaModel(modelId, metaModelJSON, {});
|
|
118543
118714
|
this.viewer.scene.canvas.spinner.processes--;
|
|
118544
|
-
|
|
118545
|
-
let includeTypes;
|
|
118546
|
-
if (params.includeTypes) {
|
|
118547
|
-
includeTypes = {};
|
|
118548
|
-
for (let i = 0, len = params.includeTypes.length; i < len; i++) {
|
|
118549
|
-
includeTypes[params.includeTypes[i]] = true;
|
|
118550
|
-
}
|
|
118551
|
-
}
|
|
118552
|
-
if (params.excludeTypes) {
|
|
118553
|
-
if (!includeTypes) {
|
|
118554
|
-
includeTypes = {};
|
|
118555
|
-
}
|
|
118556
|
-
for (let i = 0, len = params.excludeTypes.length; i < len; i++) {
|
|
118557
|
-
includeTypes[params.excludeTypes[i]] = true;
|
|
118558
|
-
}
|
|
118559
|
-
}
|
|
118560
|
-
|
|
118561
|
-
params.readableGeometry = false;
|
|
118562
|
-
|
|
118563
|
-
params.handleGLTFNode = (modelId, glTFNode, actions) => {
|
|
118564
|
-
|
|
118565
|
-
const name = glTFNode.name;
|
|
118566
|
-
|
|
118567
|
-
if (!name) {
|
|
118568
|
-
return true; // Continue descending this node subtree
|
|
118569
|
-
}
|
|
118570
|
-
|
|
118571
|
-
const nodeId = name;
|
|
118572
|
-
const metaObject = this.viewer.metaScene.metaObjects[nodeId];
|
|
118573
|
-
const type = (metaObject ? metaObject.type : "DEFAULT") || "DEFAULT";
|
|
118574
|
-
|
|
118575
|
-
actions.createEntity = {
|
|
118576
|
-
id: nodeId,
|
|
118577
|
-
isObject: true // Registers the Entity in Scene#objects
|
|
118578
|
-
};
|
|
118579
|
-
|
|
118580
|
-
const props = objectDefaults[type];
|
|
118581
|
-
|
|
118582
|
-
if (props) { // Set Entity's initial rendering state for recognized type
|
|
118583
|
-
|
|
118584
|
-
if (props.visible === false) {
|
|
118585
|
-
actions.createEntity.visible = false;
|
|
118586
|
-
}
|
|
118587
|
-
|
|
118588
|
-
if (props.colorize) {
|
|
118589
|
-
actions.createEntity.colorize = props.colorize;
|
|
118590
|
-
}
|
|
118591
|
-
|
|
118592
|
-
if (props.pickable === false) {
|
|
118593
|
-
actions.createEntity.pickable = false;
|
|
118594
|
-
}
|
|
118595
|
-
|
|
118596
|
-
if (props.opacity !== undefined && props.opacity !== null) {
|
|
118597
|
-
actions.createEntity.opacity = props.opacity;
|
|
118598
|
-
}
|
|
118599
|
-
}
|
|
118600
|
-
|
|
118601
|
-
return true; // Continue descending this glTF node subtree
|
|
118602
|
-
};
|
|
118603
|
-
|
|
118604
118715
|
if (params.src) {
|
|
118605
118716
|
this._sceneModelLoader.load(this, params.src, metaModelJSON, params, sceneModel);
|
|
118606
118717
|
} else {
|
|
118607
118718
|
this._sceneModelLoader.parse(this, params.gltf, metaModelJSON, params, sceneModel);
|
|
118608
118719
|
}
|
|
118609
118720
|
};
|
|
118610
|
-
|
|
118611
118721
|
if (params.metaModelSrc) {
|
|
118612
|
-
|
|
118613
118722
|
const metaModelSrc = params.metaModelSrc;
|
|
118614
|
-
|
|
118615
118723
|
this.viewer.scene.canvas.spinner.processes++;
|
|
118616
|
-
|
|
118617
118724
|
this._dataSource.getMetaModel(metaModelSrc, (metaModelJSON) => {
|
|
118618
|
-
|
|
118619
118725
|
this.viewer.scene.canvas.spinner.processes--;
|
|
118620
|
-
|
|
118621
118726
|
processMetaModelJSON(metaModelJSON);
|
|
118622
|
-
|
|
118623
118727
|
}, (errMsg) => {
|
|
118624
118728
|
this.error(`load(): Failed to load model metadata for model '${modelId} from '${metaModelSrc}' - ${errMsg}`);
|
|
118625
118729
|
this.viewer.scene.canvas.spinner.processes--;
|
|
118626
118730
|
});
|
|
118627
|
-
|
|
118628
118731
|
} else if (params.metaModelJSON) {
|
|
118629
|
-
|
|
118630
118732
|
processMetaModelJSON(params.metaModelJSON);
|
|
118631
118733
|
}
|
|
118632
|
-
|
|
118633
118734
|
} else {
|
|
118634
|
-
|
|
118635
|
-
params.handleGLTFNode = (modelId, glTFNode, actions) => {
|
|
118636
|
-
|
|
118637
|
-
const name = glTFNode.name;
|
|
118638
|
-
|
|
118639
|
-
if (!name) {
|
|
118640
|
-
return true; // Continue descending this node subtree
|
|
118641
|
-
}
|
|
118642
|
-
|
|
118643
|
-
const id = name;
|
|
118644
|
-
|
|
118645
|
-
actions.createEntity = { // Create an Entity for this glTF scene node
|
|
118646
|
-
id: id,
|
|
118647
|
-
isObject: true // Registers the Entity in Scene#objects
|
|
118648
|
-
};
|
|
118649
|
-
|
|
118650
|
-
return true; // Continue descending this glTF node subtree
|
|
118651
|
-
};
|
|
118652
|
-
|
|
118653
|
-
|
|
118654
118735
|
if (params.src) {
|
|
118655
118736
|
this._sceneModelLoader.load(this, params.src, null, params, sceneModel);
|
|
118656
118737
|
} else {
|