@xeokit/xeokit-sdk 2.3.0-beta-16 → 2.3.0-beta-17
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 +153 -203
- package/dist/xeokit-sdk.es.js +153 -203
- package/dist/xeokit-sdk.min.cjs.js +1 -1
- package/dist/xeokit-sdk.min.es.js +1 -1
- package/package.json +1 -1
package/dist/xeokit-sdk.es.js
CHANGED
|
@@ -14605,7 +14605,8 @@ class SAODepthLimitedBlurRenderer {
|
|
|
14605
14605
|
}
|
|
14606
14606
|
|
|
14607
14607
|
outColor = packFloatToRGBA(occlusionSum / weightSum);
|
|
14608
|
-
}`
|
|
14608
|
+
}`
|
|
14609
|
+
]
|
|
14609
14610
|
});
|
|
14610
14611
|
|
|
14611
14612
|
if (this._program.errors) {
|
|
@@ -14695,7 +14696,7 @@ class SAODepthLimitedBlurRenderer {
|
|
|
14695
14696
|
|
|
14696
14697
|
gl.uniform1fv(this._uSampleWeights, sampleWeights);
|
|
14697
14698
|
|
|
14698
|
-
const depthTexture =
|
|
14699
|
+
const depthTexture = depthRenderBuffer.getDepthTexture();
|
|
14699
14700
|
const occlusionTexture = occlusionRenderBuffer.getTexture();
|
|
14700
14701
|
|
|
14701
14702
|
program.bindTexture(this._uDepthTexture, depthTexture, 0); // TODO: use FrameCtx.textureUnit
|
|
@@ -45604,10 +45605,7 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45604
45605
|
gl.uniform1i(this._uRenderPass, renderPass);
|
|
45605
45606
|
|
|
45606
45607
|
gl.uniformMatrix4fv(this._uViewMatrix, false, (origin) ? createRTCViewMat(camera.viewMatrix, origin) : camera.viewMatrix);
|
|
45607
|
-
gl.uniformMatrix4fv(this._uViewNormalMatrix, false, camera.viewNormalMatrix);
|
|
45608
|
-
|
|
45609
45608
|
gl.uniformMatrix4fv(this._uWorldMatrix, false, model.worldMatrix);
|
|
45610
|
-
gl.uniformMatrix4fv(this._uWorldNormalMatrix, false, model.worldNormalMatrix);
|
|
45611
45609
|
|
|
45612
45610
|
const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
|
|
45613
45611
|
if (numSectionPlanes > 0) {
|
|
@@ -45641,10 +45639,6 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45641
45639
|
|
|
45642
45640
|
this._aPosition.bindArrayBuffer(state.positionsBuf);
|
|
45643
45641
|
|
|
45644
|
-
if (this._aNormal) {
|
|
45645
|
-
this._aNormal.bindArrayBuffer(state.normalsBuf);
|
|
45646
|
-
}
|
|
45647
|
-
|
|
45648
45642
|
if (this._aUV) {
|
|
45649
45643
|
this._aUV.bindArrayBuffer(state.uvBuf);
|
|
45650
45644
|
}
|
|
@@ -45715,9 +45709,7 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45715
45709
|
this._uPositionsDecodeMatrix = program.getLocation("positionsDecodeMatrix");
|
|
45716
45710
|
this._uUVDecodeMatrix = program.getLocation("uvDecodeMatrix");
|
|
45717
45711
|
this._uWorldMatrix = program.getLocation("worldMatrix");
|
|
45718
|
-
this._uWorldNormalMatrix = program.getLocation("worldNormalMatrix");
|
|
45719
45712
|
this._uViewMatrix = program.getLocation("viewMatrix");
|
|
45720
|
-
this._uViewNormalMatrix = program.getLocation("viewNormalMatrix");
|
|
45721
45713
|
this._uProjMatrix = program.getLocation("projMatrix");
|
|
45722
45714
|
|
|
45723
45715
|
this._uLightAmbient = program.getLocation("lightAmbient");
|
|
@@ -45764,7 +45756,6 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45764
45756
|
|
|
45765
45757
|
this._aPosition = program.getAttribute("position");
|
|
45766
45758
|
this._aOffset = program.getAttribute("offset");
|
|
45767
|
-
this._aNormal = program.getAttribute("normal");
|
|
45768
45759
|
this._aUV = program.getAttribute("uv");
|
|
45769
45760
|
this._aColor = program.getAttribute("color");
|
|
45770
45761
|
this._aFlags = program.getAttribute("flags");
|
|
@@ -45831,9 +45822,7 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45831
45822
|
|
|
45832
45823
|
const scene = this._scene;
|
|
45833
45824
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
45834
|
-
const lightsState = scene._lightsState;
|
|
45835
45825
|
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
45836
|
-
let light;
|
|
45837
45826
|
const src = [];
|
|
45838
45827
|
src.push("#version 300 es");
|
|
45839
45828
|
src.push("// Triangles batching color texture vertex shader");
|
|
@@ -45841,7 +45830,6 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45841
45830
|
src.push("uniform int renderPass;");
|
|
45842
45831
|
|
|
45843
45832
|
src.push("in vec3 position;");
|
|
45844
|
-
src.push("in vec3 normal;");
|
|
45845
45833
|
src.push("in vec4 color;");
|
|
45846
45834
|
src.push("in vec2 uv;");
|
|
45847
45835
|
src.push("in vec4 flags;");
|
|
@@ -45852,11 +45840,9 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45852
45840
|
}
|
|
45853
45841
|
|
|
45854
45842
|
src.push("uniform mat4 worldMatrix;");
|
|
45855
|
-
src.push("uniform mat4 worldNormalMatrix;");
|
|
45856
45843
|
|
|
45857
45844
|
src.push("uniform mat4 viewMatrix;");
|
|
45858
45845
|
src.push("uniform mat4 projMatrix;");
|
|
45859
|
-
src.push("uniform mat4 viewNormalMatrix;");
|
|
45860
45846
|
src.push("uniform mat4 positionsDecodeMatrix;");
|
|
45861
45847
|
src.push("uniform mat3 uvDecodeMatrix;");
|
|
45862
45848
|
|
|
@@ -45869,38 +45855,11 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45869
45855
|
src.push("out float isPerspective;");
|
|
45870
45856
|
}
|
|
45871
45857
|
|
|
45872
|
-
src.push("uniform vec4 lightAmbient;");
|
|
45873
|
-
|
|
45874
|
-
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
45875
|
-
light = lightsState.lights[i];
|
|
45876
|
-
if (light.type === "ambient") {
|
|
45877
|
-
continue;
|
|
45878
|
-
}
|
|
45879
|
-
src.push("uniform vec4 lightColor" + i + ";");
|
|
45880
|
-
if (light.type === "dir") {
|
|
45881
|
-
src.push("uniform vec3 lightDir" + i + ";");
|
|
45882
|
-
}
|
|
45883
|
-
if (light.type === "point") {
|
|
45884
|
-
src.push("uniform vec3 lightPos" + i + ";");
|
|
45885
|
-
}
|
|
45886
|
-
if (light.type === "spot") {
|
|
45887
|
-
src.push("uniform vec3 lightPos" + i + ";");
|
|
45888
|
-
src.push("uniform vec3 lightDir" + i + ";");
|
|
45889
|
-
}
|
|
45890
|
-
}
|
|
45891
|
-
|
|
45892
|
-
src.push("vec3 octDecode(vec2 oct) {");
|
|
45893
|
-
src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
|
|
45894
|
-
src.push(" if (v.z < 0.0) {");
|
|
45895
|
-
src.push(" v.xy = (1.0 - abs(v.yx)) * vec2(v.x >= 0.0 ? 1.0 : -1.0, v.y >= 0.0 ? 1.0 : -1.0);");
|
|
45896
|
-
src.push(" }");
|
|
45897
|
-
src.push(" return normalize(v);");
|
|
45898
|
-
src.push("}");
|
|
45899
|
-
|
|
45900
45858
|
if (clipping) {
|
|
45901
45859
|
src.push("out vec4 vWorldPosition;");
|
|
45902
45860
|
src.push("out vec4 vFlags2;");
|
|
45903
45861
|
}
|
|
45862
|
+
src.push("out vec4 vViewPosition;");
|
|
45904
45863
|
src.push("out vec4 vColor;");
|
|
45905
45864
|
src.push("out vec2 vUV;");
|
|
45906
45865
|
|
|
@@ -45919,45 +45878,8 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45919
45878
|
src.push("worldPosition.xyz = worldPosition.xyz + offset;");
|
|
45920
45879
|
}
|
|
45921
45880
|
src.push("vec4 viewPosition = viewMatrix * worldPosition; ");
|
|
45922
|
-
src.push("
|
|
45923
|
-
src.push("
|
|
45924
|
-
|
|
45925
|
-
src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");
|
|
45926
|
-
src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");
|
|
45927
|
-
|
|
45928
|
-
src.push("float lambertian = 1.0;");
|
|
45929
|
-
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
45930
|
-
light = lightsState.lights[i];
|
|
45931
|
-
if (light.type === "ambient") {
|
|
45932
|
-
continue;
|
|
45933
|
-
}
|
|
45934
|
-
if (light.type === "dir") {
|
|
45935
|
-
if (light.space === "view") {
|
|
45936
|
-
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
45937
|
-
} else {
|
|
45938
|
-
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
45939
|
-
}
|
|
45940
|
-
} else if (light.type === "point") {
|
|
45941
|
-
if (light.space === "view") {
|
|
45942
|
-
src.push("viewLightDir = -normalize(lightPos" + i + " - viewPosition.xyz);");
|
|
45943
|
-
} else {
|
|
45944
|
-
src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos" + i + ", 0.0)).xyz);");
|
|
45945
|
-
}
|
|
45946
|
-
} else if (light.type === "spot") {
|
|
45947
|
-
if (light.space === "view") {
|
|
45948
|
-
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
45949
|
-
} else {
|
|
45950
|
-
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
45951
|
-
}
|
|
45952
|
-
} else {
|
|
45953
|
-
continue;
|
|
45954
|
-
}
|
|
45955
|
-
src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");
|
|
45956
|
-
src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
|
|
45957
|
-
}
|
|
45958
|
-
|
|
45959
|
-
src.push("vec3 rgb = (vec3(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0));");
|
|
45960
|
-
src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * rgb) + (reflectedColor * rgb), float(color.a) / 255.0);");
|
|
45881
|
+
src.push("vViewPosition = viewPosition;");
|
|
45882
|
+
src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");
|
|
45961
45883
|
src.push("vUV = (uvDecodeMatrix * vec3(uv, 1.0)).xy;");
|
|
45962
45884
|
|
|
45963
45885
|
src.push("vec4 clipPos = projMatrix * viewPosition;");
|
|
@@ -45977,6 +45899,7 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45977
45899
|
|
|
45978
45900
|
_buildFragmentShader() {
|
|
45979
45901
|
const scene = this._scene;
|
|
45902
|
+
const lightsState = scene._lightsState;
|
|
45980
45903
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
45981
45904
|
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
45982
45905
|
const src = [];
|
|
@@ -45996,9 +45919,7 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45996
45919
|
src.push("uniform float logDepthBufFC;");
|
|
45997
45920
|
src.push("in float vFragDepth;");
|
|
45998
45921
|
}
|
|
45999
|
-
|
|
46000
45922
|
src.push("uniform sampler2D uColorMap;");
|
|
46001
|
-
|
|
46002
45923
|
if (this._withSAO) {
|
|
46003
45924
|
src.push("uniform sampler2D uOcclusionTexture;");
|
|
46004
45925
|
src.push("uniform vec4 uSAOParams;");
|
|
@@ -46012,7 +45933,6 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
46012
45933
|
src.push(" return dot( v, unPackFactors );");
|
|
46013
45934
|
src.push("}");
|
|
46014
45935
|
}
|
|
46015
|
-
|
|
46016
45936
|
if (clipping) {
|
|
46017
45937
|
src.push("in vec4 vWorldPosition;");
|
|
46018
45938
|
src.push("in vec4 vFlags2;");
|
|
@@ -46022,7 +45942,27 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
46022
45942
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
46023
45943
|
}
|
|
46024
45944
|
}
|
|
45945
|
+
src.push("uniform mat4 viewMatrix;");
|
|
45946
|
+
src.push("uniform vec4 lightAmbient;");
|
|
45947
|
+
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
45948
|
+
const light = lightsState.lights[i];
|
|
45949
|
+
if (light.type === "ambient") {
|
|
45950
|
+
continue;
|
|
45951
|
+
}
|
|
45952
|
+
src.push("uniform vec4 lightColor" + i + ";");
|
|
45953
|
+
if (light.type === "dir") {
|
|
45954
|
+
src.push("uniform vec3 lightDir" + i + ";");
|
|
45955
|
+
}
|
|
45956
|
+
if (light.type === "point") {
|
|
45957
|
+
src.push("uniform vec3 lightPos" + i + ";");
|
|
45958
|
+
}
|
|
45959
|
+
if (light.type === "spot") {
|
|
45960
|
+
src.push("uniform vec3 lightPos" + i + ";");
|
|
45961
|
+
src.push("uniform vec3 lightDir" + i + ";");
|
|
45962
|
+
}
|
|
45963
|
+
}
|
|
46025
45964
|
|
|
45965
|
+
src.push("in vec4 vViewPosition;");
|
|
46026
45966
|
src.push("in vec4 vColor;");
|
|
46027
45967
|
src.push("in vec2 vUV;");
|
|
46028
45968
|
src.push("out vec4 outColor;");
|
|
@@ -46044,12 +45984,49 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
46044
45984
|
src.push("}");
|
|
46045
45985
|
}
|
|
46046
45986
|
|
|
46047
|
-
|
|
46048
|
-
|
|
45987
|
+
src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");
|
|
45988
|
+
src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");
|
|
45989
|
+
|
|
45990
|
+
src.push("float lambertian = 1.0;");
|
|
45991
|
+
|
|
45992
|
+
src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");
|
|
45993
|
+
src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");
|
|
45994
|
+
src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");
|
|
45995
|
+
|
|
45996
|
+
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
45997
|
+
const light = lightsState.lights[i];
|
|
45998
|
+
if (light.type === "ambient") {
|
|
45999
|
+
continue;
|
|
46000
|
+
}
|
|
46001
|
+
if (light.type === "dir") {
|
|
46002
|
+
if (light.space === "view") {
|
|
46003
|
+
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
46004
|
+
} else {
|
|
46005
|
+
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
46006
|
+
}
|
|
46007
|
+
} else if (light.type === "point") {
|
|
46008
|
+
if (light.space === "view") {
|
|
46009
|
+
src.push("viewLightDir = -normalize(lightPos" + i + " - viewPosition.xyz);");
|
|
46010
|
+
} else {
|
|
46011
|
+
src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos" + i + ", 0.0)).xyz);");
|
|
46012
|
+
}
|
|
46013
|
+
} else if (light.type === "spot") {
|
|
46014
|
+
if (light.space === "view") {
|
|
46015
|
+
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
46016
|
+
} else {
|
|
46017
|
+
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
46018
|
+
}
|
|
46019
|
+
} else {
|
|
46020
|
+
continue;
|
|
46021
|
+
}
|
|
46022
|
+
|
|
46023
|
+
src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");
|
|
46024
|
+
src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
|
|
46049
46025
|
}
|
|
46050
46026
|
|
|
46051
|
-
src.push("vec4
|
|
46052
|
-
src.push("
|
|
46027
|
+
src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
|
|
46028
|
+
src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");
|
|
46029
|
+
src.push("float opacity = color.a;");
|
|
46053
46030
|
|
|
46054
46031
|
if (this._withSAO) {
|
|
46055
46032
|
// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
|
|
@@ -46066,6 +46043,10 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
46066
46043
|
src.push(" outColor = vec4(colorTexel.rgb, opacity);");
|
|
46067
46044
|
}
|
|
46068
46045
|
|
|
46046
|
+
if (scene.logarithmicDepthBufferEnabled) {
|
|
46047
|
+
src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
46048
|
+
}
|
|
46049
|
+
|
|
46069
46050
|
src.push("}");
|
|
46070
46051
|
return src;
|
|
46071
46052
|
}
|
|
@@ -46452,6 +46433,11 @@ function quantizePositions(positions, aabb, positionsDecodeMatrix) { // http://c
|
|
|
46452
46433
|
*/
|
|
46453
46434
|
function transformAndOctEncodeNormals(worldNormalMatrix, normals, lenNormals, compressedNormals, lenCompressedNormals) {
|
|
46454
46435
|
// http://jcgt.org/published/0003/02/01/
|
|
46436
|
+
|
|
46437
|
+
function dot(array, vec3) {
|
|
46438
|
+
return array[0] * vec3[0] + array[1] * vec3[1] + array[2] * vec3[2];
|
|
46439
|
+
}
|
|
46440
|
+
|
|
46455
46441
|
let oct, dec, best, currentCos, bestCos;
|
|
46456
46442
|
let i;
|
|
46457
46443
|
let localNormal = new Float32Array([0, 0, 0, 0]);
|
|
@@ -47129,7 +47115,6 @@ class TrianglesBatchingLayer {
|
|
|
47129
47115
|
|
|
47130
47116
|
this._state.colorTextureSupported
|
|
47131
47117
|
= !!state.uvBuf
|
|
47132
|
-
&& !!state.normalsBuf
|
|
47133
47118
|
&& !!state.textureSet
|
|
47134
47119
|
&& !!state.textureSet.colorTexture;
|
|
47135
47120
|
|
|
@@ -48872,8 +48857,8 @@ class TrianglesInstancingFlatColorRenderer {
|
|
|
48872
48857
|
|
|
48873
48858
|
src.push("in vec4 vViewPosition;");
|
|
48874
48859
|
src.push("in vec4 vColor;");
|
|
48875
|
-
|
|
48876
48860
|
src.push("out vec4 outColor;");
|
|
48861
|
+
|
|
48877
48862
|
src.push("void main(void) {");
|
|
48878
48863
|
|
|
48879
48864
|
if (clipping) {
|
|
@@ -53546,10 +53531,7 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53546
53531
|
gl.uniform1i(this._uRenderPass, renderPass);
|
|
53547
53532
|
|
|
53548
53533
|
gl.uniformMatrix4fv(this._uViewMatrix, false, (origin) ? createRTCViewMat(camera.viewMatrix, origin) : camera.viewMatrix);
|
|
53549
|
-
gl.uniformMatrix4fv(this._uViewNormalMatrix, false, camera.viewNormalMatrix);
|
|
53550
|
-
|
|
53551
53534
|
gl.uniformMatrix4fv(this._uWorldMatrix, false, model.worldMatrix);
|
|
53552
|
-
gl.uniformMatrix4fv(this._uWorldNormalMatrix, false, model.worldNormalMatrix);
|
|
53553
53535
|
|
|
53554
53536
|
const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
|
|
53555
53537
|
if (numSectionPlanes > 0) {
|
|
@@ -53589,16 +53571,7 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53589
53571
|
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 1);
|
|
53590
53572
|
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 1);
|
|
53591
53573
|
|
|
53592
|
-
this._aModelNormalMatrixCol0.bindArrayBuffer(state.modelNormalMatrixCol0Buf);
|
|
53593
|
-
this._aModelNormalMatrixCol1.bindArrayBuffer(state.modelNormalMatrixCol1Buf);
|
|
53594
|
-
this._aModelNormalMatrixCol2.bindArrayBuffer(state.modelNormalMatrixCol2Buf);
|
|
53595
|
-
|
|
53596
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol0.location, 1);
|
|
53597
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol1.location, 1);
|
|
53598
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol2.location, 1);
|
|
53599
|
-
|
|
53600
53574
|
this._aPosition.bindArrayBuffer(geometry.positionsBuf);
|
|
53601
|
-
this._aNormal.bindArrayBuffer(geometry.normalsBuf);
|
|
53602
53575
|
this._aUV.bindArrayBuffer(geometry.uvBuf);
|
|
53603
53576
|
|
|
53604
53577
|
this._aColor.bindArrayBuffer(state.colorsBuf);
|
|
@@ -53626,9 +53599,6 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53626
53599
|
gl.vertexAttribDivisor(this._aModelMatrixCol0.location, 0);
|
|
53627
53600
|
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 0);
|
|
53628
53601
|
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 0);
|
|
53629
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol0.location, 0);
|
|
53630
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol1.location, 0);
|
|
53631
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol2.location, 0);
|
|
53632
53602
|
gl.vertexAttribDivisor(this._aColor.location, 0);
|
|
53633
53603
|
gl.vertexAttribDivisor(this._aFlags.location, 0);
|
|
53634
53604
|
|
|
@@ -53684,10 +53654,8 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53684
53654
|
this._uUVDecodeMatrix = program.getLocation("uvDecodeMatrix");
|
|
53685
53655
|
|
|
53686
53656
|
this._uWorldMatrix = program.getLocation("worldMatrix");
|
|
53687
|
-
this._uWorldNormalMatrix = program.getLocation("worldNormalMatrix");
|
|
53688
53657
|
|
|
53689
53658
|
this._uViewMatrix = program.getLocation("viewMatrix");
|
|
53690
|
-
this._uViewNormalMatrix = program.getLocation("viewNormalMatrix");
|
|
53691
53659
|
this._uProjMatrix = program.getLocation("projMatrix");
|
|
53692
53660
|
|
|
53693
53661
|
this._uLightAmbient = program.getLocation("lightAmbient");
|
|
@@ -53733,7 +53701,6 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53733
53701
|
}
|
|
53734
53702
|
|
|
53735
53703
|
this._aPosition = program.getAttribute("position");
|
|
53736
|
-
this._aNormal = program.getAttribute("normal");
|
|
53737
53704
|
this._aColor = program.getAttribute("color");
|
|
53738
53705
|
this._aUV = program.getAttribute("uv");
|
|
53739
53706
|
this._aFlags = program.getAttribute("flags");
|
|
@@ -53744,10 +53711,6 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53744
53711
|
this._aModelMatrixCol1 = program.getAttribute("modelMatrixCol1");
|
|
53745
53712
|
this._aModelMatrixCol2 = program.getAttribute("modelMatrixCol2");
|
|
53746
53713
|
|
|
53747
|
-
this._aModelNormalMatrixCol0 = program.getAttribute("modelNormalMatrixCol0");
|
|
53748
|
-
this._aModelNormalMatrixCol1 = program.getAttribute("modelNormalMatrixCol1");
|
|
53749
|
-
this._aModelNormalMatrixCol2 = program.getAttribute("modelNormalMatrixCol2");
|
|
53750
|
-
|
|
53751
53714
|
this._uColorMap = "uColorMap";
|
|
53752
53715
|
|
|
53753
53716
|
this._uOcclusionTexture = "uOcclusionTexture";
|
|
@@ -53806,11 +53769,7 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53806
53769
|
_buildVertexShader() {
|
|
53807
53770
|
const scene = this._scene;
|
|
53808
53771
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
53809
|
-
const lightsState = scene._lightsState;
|
|
53810
53772
|
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
53811
|
-
let i;
|
|
53812
|
-
let len;
|
|
53813
|
-
let light;
|
|
53814
53773
|
const src = [];
|
|
53815
53774
|
src.push("#version 300 es");
|
|
53816
53775
|
src.push("// Instancing geometry drawing vertex shader");
|
|
@@ -53818,7 +53777,6 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53818
53777
|
src.push("uniform int renderPass;");
|
|
53819
53778
|
|
|
53820
53779
|
src.push("in vec3 position;");
|
|
53821
|
-
src.push("in vec3 normal;");
|
|
53822
53780
|
src.push("in vec4 color;");
|
|
53823
53781
|
src.push("in vec2 uv;");
|
|
53824
53782
|
src.push("in vec4 flags;");
|
|
@@ -53832,14 +53790,8 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53832
53790
|
src.push("in vec4 modelMatrixCol1;");
|
|
53833
53791
|
src.push("in vec4 modelMatrixCol2;");
|
|
53834
53792
|
|
|
53835
|
-
src.push("in vec4 modelNormalMatrixCol0;");
|
|
53836
|
-
src.push("in vec4 modelNormalMatrixCol1;");
|
|
53837
|
-
src.push("in vec4 modelNormalMatrixCol2;");
|
|
53838
|
-
|
|
53839
53793
|
src.push("uniform mat4 worldMatrix;");
|
|
53840
|
-
src.push("uniform mat4 worldNormalMatrix;");
|
|
53841
53794
|
src.push("uniform mat4 viewMatrix;");
|
|
53842
|
-
src.push("uniform mat4 viewNormalMatrix;");
|
|
53843
53795
|
src.push("uniform mat4 projMatrix;");
|
|
53844
53796
|
src.push("uniform mat4 positionsDecodeMatrix;");
|
|
53845
53797
|
src.push("uniform mat3 uvDecodeMatrix;");
|
|
@@ -53853,38 +53805,11 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53853
53805
|
src.push("out float isPerspective;");
|
|
53854
53806
|
}
|
|
53855
53807
|
|
|
53856
|
-
src.push("uniform vec4 lightAmbient;");
|
|
53857
|
-
|
|
53858
|
-
for (i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
53859
|
-
light = lightsState.lights[i];
|
|
53860
|
-
if (light.type === "ambient") {
|
|
53861
|
-
continue;
|
|
53862
|
-
}
|
|
53863
|
-
src.push("uniform vec4 lightColor" + i + ";");
|
|
53864
|
-
if (light.type === "dir") {
|
|
53865
|
-
src.push("uniform vec3 lightDir" + i + ";");
|
|
53866
|
-
}
|
|
53867
|
-
if (light.type === "point") {
|
|
53868
|
-
src.push("uniform vec3 lightPos" + i + ";");
|
|
53869
|
-
}
|
|
53870
|
-
if (light.type === "spot") {
|
|
53871
|
-
src.push("uniform vec3 lightPos" + i + ";");
|
|
53872
|
-
src.push("uniform vec3 lightDir" + i + ";");
|
|
53873
|
-
}
|
|
53874
|
-
}
|
|
53875
|
-
|
|
53876
|
-
src.push("vec3 octDecode(vec2 oct) {");
|
|
53877
|
-
src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
|
|
53878
|
-
src.push(" if (v.z < 0.0) {");
|
|
53879
|
-
src.push(" v.xy = (1.0 - abs(v.yx)) * vec2(v.x >= 0.0 ? 1.0 : -1.0, v.y >= 0.0 ? 1.0 : -1.0);");
|
|
53880
|
-
src.push(" }");
|
|
53881
|
-
src.push(" return normalize(v);");
|
|
53882
|
-
src.push("}");
|
|
53883
|
-
|
|
53884
53808
|
if (clipping) {
|
|
53885
53809
|
src.push("out vec4 vWorldPosition;");
|
|
53886
53810
|
src.push("out vec4 vFlags2;");
|
|
53887
53811
|
}
|
|
53812
|
+
src.push("out vec4 vViewPosition;");
|
|
53888
53813
|
src.push("out vec4 vColor;");
|
|
53889
53814
|
src.push("out vec2 vUV;");
|
|
53890
53815
|
|
|
@@ -53905,47 +53830,8 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53905
53830
|
}
|
|
53906
53831
|
|
|
53907
53832
|
src.push("vec4 viewPosition = viewMatrix * worldPosition; ");
|
|
53908
|
-
|
|
53909
|
-
src.push("
|
|
53910
|
-
src.push("vec4 worldNormal = worldNormalMatrix * vec4(dot(modelNormal, modelNormalMatrixCol0), dot(modelNormal, modelNormalMatrixCol1), dot(modelNormal, modelNormalMatrixCol2), 0.0);");
|
|
53911
|
-
src.push("vec3 viewNormal = normalize(vec4(viewNormalMatrix * worldNormal).xyz);");
|
|
53912
|
-
|
|
53913
|
-
src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");
|
|
53914
|
-
src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");
|
|
53915
|
-
|
|
53916
|
-
src.push("float lambertian = 1.0;");
|
|
53917
|
-
for (i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
53918
|
-
light = lightsState.lights[i];
|
|
53919
|
-
if (light.type === "ambient") {
|
|
53920
|
-
continue;
|
|
53921
|
-
}
|
|
53922
|
-
if (light.type === "dir") {
|
|
53923
|
-
if (light.space === "view") {
|
|
53924
|
-
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
53925
|
-
} else {
|
|
53926
|
-
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
53927
|
-
}
|
|
53928
|
-
} else if (light.type === "point") {
|
|
53929
|
-
if (light.space === "view") {
|
|
53930
|
-
src.push("viewLightDir = -normalize(lightPos" + i + " - viewPosition.xyz);");
|
|
53931
|
-
} else {
|
|
53932
|
-
src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos" + i + ", 0.0)).xyz);");
|
|
53933
|
-
}
|
|
53934
|
-
} else if (light.type === "spot") {
|
|
53935
|
-
if (light.space === "view") {
|
|
53936
|
-
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
53937
|
-
} else {
|
|
53938
|
-
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
53939
|
-
}
|
|
53940
|
-
} else {
|
|
53941
|
-
continue;
|
|
53942
|
-
}
|
|
53943
|
-
src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");
|
|
53944
|
-
src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
|
|
53945
|
-
}
|
|
53946
|
-
|
|
53947
|
-
src.push("vec3 rgb = (vec3(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0));");
|
|
53948
|
-
src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * rgb) + (reflectedColor * rgb), float(color.a) / 255.0);");
|
|
53833
|
+
src.push("vViewPosition = viewPosition;");
|
|
53834
|
+
src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");
|
|
53949
53835
|
src.push("vUV = (uvDecodeMatrix * vec3(uv, 1.0)).xy;");
|
|
53950
53836
|
|
|
53951
53837
|
src.push("vec4 clipPos = projMatrix * viewPosition;");
|
|
@@ -53968,6 +53854,9 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53968
53854
|
_buildFragmentShader() {
|
|
53969
53855
|
const scene = this._scene;
|
|
53970
53856
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
53857
|
+
const lightsState = scene._lightsState;
|
|
53858
|
+
let i;
|
|
53859
|
+
let len;
|
|
53971
53860
|
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
53972
53861
|
const src = [];
|
|
53973
53862
|
src.push("#version 300 es");
|
|
@@ -54009,9 +53898,31 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
54009
53898
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
54010
53899
|
}
|
|
54011
53900
|
}
|
|
53901
|
+
src.push("uniform mat4 viewMatrix;");
|
|
53902
|
+
src.push("uniform vec4 lightAmbient;");
|
|
53903
|
+
for (i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
53904
|
+
const light = lightsState.lights[i];
|
|
53905
|
+
if (light.type === "ambient") {
|
|
53906
|
+
continue;
|
|
53907
|
+
}
|
|
53908
|
+
src.push("uniform vec4 lightColor" + i + ";");
|
|
53909
|
+
if (light.type === "dir") {
|
|
53910
|
+
src.push("uniform vec3 lightDir" + i + ";");
|
|
53911
|
+
}
|
|
53912
|
+
if (light.type === "point") {
|
|
53913
|
+
src.push("uniform vec3 lightPos" + i + ";");
|
|
53914
|
+
}
|
|
53915
|
+
if (light.type === "spot") {
|
|
53916
|
+
src.push("uniform vec3 lightPos" + i + ";");
|
|
53917
|
+
src.push("uniform vec3 lightDir" + i + ";");
|
|
53918
|
+
}
|
|
53919
|
+
}
|
|
53920
|
+
|
|
53921
|
+
src.push("in vec4 vViewPosition;");
|
|
54012
53922
|
src.push("in vec4 vColor;");
|
|
54013
53923
|
src.push("in vec2 vUV;");
|
|
54014
53924
|
src.push("out vec4 outColor;");
|
|
53925
|
+
|
|
54015
53926
|
src.push("void main(void) {");
|
|
54016
53927
|
|
|
54017
53928
|
if (clipping) {
|
|
@@ -54029,17 +53940,52 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
54029
53940
|
src.push("}");
|
|
54030
53941
|
}
|
|
54031
53942
|
|
|
54032
|
-
|
|
54033
|
-
|
|
54034
|
-
}
|
|
53943
|
+
src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");
|
|
53944
|
+
src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");
|
|
54035
53945
|
|
|
54036
|
-
src.push("
|
|
54037
|
-
src.push("float opacity = vColor.a;");
|
|
53946
|
+
src.push("float lambertian = 1.0;");
|
|
54038
53947
|
|
|
54039
|
-
|
|
54040
|
-
|
|
53948
|
+
src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");
|
|
53949
|
+
src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");
|
|
53950
|
+
src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");
|
|
53951
|
+
|
|
53952
|
+
for (i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
53953
|
+
const light = lightsState.lights[i];
|
|
53954
|
+
if (light.type === "ambient") {
|
|
53955
|
+
continue;
|
|
53956
|
+
}
|
|
53957
|
+
if (light.type === "dir") {
|
|
53958
|
+
if (light.space === "view") {
|
|
53959
|
+
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
53960
|
+
} else {
|
|
53961
|
+
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
53962
|
+
}
|
|
53963
|
+
} else if (light.type === "point") {
|
|
53964
|
+
if (light.space === "view") {
|
|
53965
|
+
src.push("viewLightDir = -normalize(lightPos" + i + " - viewPosition.xyz);");
|
|
53966
|
+
} else {
|
|
53967
|
+
src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos" + i + ", 0.0)).xyz);");
|
|
53968
|
+
}
|
|
53969
|
+
} else if (light.type === "spot") {
|
|
53970
|
+
if (light.space === "view") {
|
|
53971
|
+
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
53972
|
+
} else {
|
|
53973
|
+
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
53974
|
+
}
|
|
53975
|
+
} else {
|
|
53976
|
+
continue;
|
|
53977
|
+
}
|
|
53978
|
+
src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");
|
|
53979
|
+
src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
|
|
53980
|
+
}
|
|
53981
|
+
|
|
53982
|
+
src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
|
|
53983
|
+
src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");
|
|
53984
|
+
src.push("float opacity = color.a;");
|
|
54041
53985
|
|
|
54042
53986
|
if (this._withSAO) {
|
|
53987
|
+
// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
|
|
53988
|
+
// Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
|
|
54043
53989
|
src.push(" float viewportWidth = uSAOParams[0];");
|
|
54044
53990
|
src.push(" float viewportHeight = uSAOParams[1];");
|
|
54045
53991
|
src.push(" float blendCutoff = uSAOParams[2];");
|
|
@@ -54050,6 +53996,11 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
54050
53996
|
} else {
|
|
54051
53997
|
src.push(" outColor = vec4(vColor.rgb * colorTexel.rgb, opacity);");
|
|
54052
53998
|
}
|
|
53999
|
+
|
|
54000
|
+
if (scene.logarithmicDepthBufferEnabled) {
|
|
54001
|
+
src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
54002
|
+
}
|
|
54003
|
+
|
|
54053
54004
|
src.push("}");
|
|
54054
54005
|
return src;
|
|
54055
54006
|
}
|
|
@@ -54705,7 +54656,6 @@ class TrianglesInstancingLayer {
|
|
|
54705
54656
|
|
|
54706
54657
|
this._state.colorTextureSupported
|
|
54707
54658
|
= !!geometry.uvBuf
|
|
54708
|
-
&& !!geometry.normalsBuf
|
|
54709
54659
|
&& !!textureSet
|
|
54710
54660
|
&& !!textureSet.colorTexture;
|
|
54711
54661
|
|