@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.cjs.js
CHANGED
|
@@ -14609,7 +14609,8 @@ class SAODepthLimitedBlurRenderer {
|
|
|
14609
14609
|
}
|
|
14610
14610
|
|
|
14611
14611
|
outColor = packFloatToRGBA(occlusionSum / weightSum);
|
|
14612
|
-
}`
|
|
14612
|
+
}`
|
|
14613
|
+
]
|
|
14613
14614
|
});
|
|
14614
14615
|
|
|
14615
14616
|
if (this._program.errors) {
|
|
@@ -14699,7 +14700,7 @@ class SAODepthLimitedBlurRenderer {
|
|
|
14699
14700
|
|
|
14700
14701
|
gl.uniform1fv(this._uSampleWeights, sampleWeights);
|
|
14701
14702
|
|
|
14702
|
-
const depthTexture =
|
|
14703
|
+
const depthTexture = depthRenderBuffer.getDepthTexture();
|
|
14703
14704
|
const occlusionTexture = occlusionRenderBuffer.getTexture();
|
|
14704
14705
|
|
|
14705
14706
|
program.bindTexture(this._uDepthTexture, depthTexture, 0); // TODO: use FrameCtx.textureUnit
|
|
@@ -45608,10 +45609,7 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45608
45609
|
gl.uniform1i(this._uRenderPass, renderPass);
|
|
45609
45610
|
|
|
45610
45611
|
gl.uniformMatrix4fv(this._uViewMatrix, false, (origin) ? createRTCViewMat(camera.viewMatrix, origin) : camera.viewMatrix);
|
|
45611
|
-
gl.uniformMatrix4fv(this._uViewNormalMatrix, false, camera.viewNormalMatrix);
|
|
45612
|
-
|
|
45613
45612
|
gl.uniformMatrix4fv(this._uWorldMatrix, false, model.worldMatrix);
|
|
45614
|
-
gl.uniformMatrix4fv(this._uWorldNormalMatrix, false, model.worldNormalMatrix);
|
|
45615
45613
|
|
|
45616
45614
|
const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
|
|
45617
45615
|
if (numSectionPlanes > 0) {
|
|
@@ -45645,10 +45643,6 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45645
45643
|
|
|
45646
45644
|
this._aPosition.bindArrayBuffer(state.positionsBuf);
|
|
45647
45645
|
|
|
45648
|
-
if (this._aNormal) {
|
|
45649
|
-
this._aNormal.bindArrayBuffer(state.normalsBuf);
|
|
45650
|
-
}
|
|
45651
|
-
|
|
45652
45646
|
if (this._aUV) {
|
|
45653
45647
|
this._aUV.bindArrayBuffer(state.uvBuf);
|
|
45654
45648
|
}
|
|
@@ -45719,9 +45713,7 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45719
45713
|
this._uPositionsDecodeMatrix = program.getLocation("positionsDecodeMatrix");
|
|
45720
45714
|
this._uUVDecodeMatrix = program.getLocation("uvDecodeMatrix");
|
|
45721
45715
|
this._uWorldMatrix = program.getLocation("worldMatrix");
|
|
45722
|
-
this._uWorldNormalMatrix = program.getLocation("worldNormalMatrix");
|
|
45723
45716
|
this._uViewMatrix = program.getLocation("viewMatrix");
|
|
45724
|
-
this._uViewNormalMatrix = program.getLocation("viewNormalMatrix");
|
|
45725
45717
|
this._uProjMatrix = program.getLocation("projMatrix");
|
|
45726
45718
|
|
|
45727
45719
|
this._uLightAmbient = program.getLocation("lightAmbient");
|
|
@@ -45768,7 +45760,6 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45768
45760
|
|
|
45769
45761
|
this._aPosition = program.getAttribute("position");
|
|
45770
45762
|
this._aOffset = program.getAttribute("offset");
|
|
45771
|
-
this._aNormal = program.getAttribute("normal");
|
|
45772
45763
|
this._aUV = program.getAttribute("uv");
|
|
45773
45764
|
this._aColor = program.getAttribute("color");
|
|
45774
45765
|
this._aFlags = program.getAttribute("flags");
|
|
@@ -45835,9 +45826,7 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45835
45826
|
|
|
45836
45827
|
const scene = this._scene;
|
|
45837
45828
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
45838
|
-
const lightsState = scene._lightsState;
|
|
45839
45829
|
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
45840
|
-
let light;
|
|
45841
45830
|
const src = [];
|
|
45842
45831
|
src.push("#version 300 es");
|
|
45843
45832
|
src.push("// Triangles batching color texture vertex shader");
|
|
@@ -45845,7 +45834,6 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45845
45834
|
src.push("uniform int renderPass;");
|
|
45846
45835
|
|
|
45847
45836
|
src.push("in vec3 position;");
|
|
45848
|
-
src.push("in vec3 normal;");
|
|
45849
45837
|
src.push("in vec4 color;");
|
|
45850
45838
|
src.push("in vec2 uv;");
|
|
45851
45839
|
src.push("in vec4 flags;");
|
|
@@ -45856,11 +45844,9 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45856
45844
|
}
|
|
45857
45845
|
|
|
45858
45846
|
src.push("uniform mat4 worldMatrix;");
|
|
45859
|
-
src.push("uniform mat4 worldNormalMatrix;");
|
|
45860
45847
|
|
|
45861
45848
|
src.push("uniform mat4 viewMatrix;");
|
|
45862
45849
|
src.push("uniform mat4 projMatrix;");
|
|
45863
|
-
src.push("uniform mat4 viewNormalMatrix;");
|
|
45864
45850
|
src.push("uniform mat4 positionsDecodeMatrix;");
|
|
45865
45851
|
src.push("uniform mat3 uvDecodeMatrix;");
|
|
45866
45852
|
|
|
@@ -45873,38 +45859,11 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45873
45859
|
src.push("out float isPerspective;");
|
|
45874
45860
|
}
|
|
45875
45861
|
|
|
45876
|
-
src.push("uniform vec4 lightAmbient;");
|
|
45877
|
-
|
|
45878
|
-
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
45879
|
-
light = lightsState.lights[i];
|
|
45880
|
-
if (light.type === "ambient") {
|
|
45881
|
-
continue;
|
|
45882
|
-
}
|
|
45883
|
-
src.push("uniform vec4 lightColor" + i + ";");
|
|
45884
|
-
if (light.type === "dir") {
|
|
45885
|
-
src.push("uniform vec3 lightDir" + i + ";");
|
|
45886
|
-
}
|
|
45887
|
-
if (light.type === "point") {
|
|
45888
|
-
src.push("uniform vec3 lightPos" + i + ";");
|
|
45889
|
-
}
|
|
45890
|
-
if (light.type === "spot") {
|
|
45891
|
-
src.push("uniform vec3 lightPos" + i + ";");
|
|
45892
|
-
src.push("uniform vec3 lightDir" + i + ";");
|
|
45893
|
-
}
|
|
45894
|
-
}
|
|
45895
|
-
|
|
45896
|
-
src.push("vec3 octDecode(vec2 oct) {");
|
|
45897
|
-
src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
|
|
45898
|
-
src.push(" if (v.z < 0.0) {");
|
|
45899
|
-
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);");
|
|
45900
|
-
src.push(" }");
|
|
45901
|
-
src.push(" return normalize(v);");
|
|
45902
|
-
src.push("}");
|
|
45903
|
-
|
|
45904
45862
|
if (clipping) {
|
|
45905
45863
|
src.push("out vec4 vWorldPosition;");
|
|
45906
45864
|
src.push("out vec4 vFlags2;");
|
|
45907
45865
|
}
|
|
45866
|
+
src.push("out vec4 vViewPosition;");
|
|
45908
45867
|
src.push("out vec4 vColor;");
|
|
45909
45868
|
src.push("out vec2 vUV;");
|
|
45910
45869
|
|
|
@@ -45923,45 +45882,8 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45923
45882
|
src.push("worldPosition.xyz = worldPosition.xyz + offset;");
|
|
45924
45883
|
}
|
|
45925
45884
|
src.push("vec4 viewPosition = viewMatrix * worldPosition; ");
|
|
45926
|
-
src.push("
|
|
45927
|
-
src.push("
|
|
45928
|
-
|
|
45929
|
-
src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");
|
|
45930
|
-
src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");
|
|
45931
|
-
|
|
45932
|
-
src.push("float lambertian = 1.0;");
|
|
45933
|
-
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
45934
|
-
light = lightsState.lights[i];
|
|
45935
|
-
if (light.type === "ambient") {
|
|
45936
|
-
continue;
|
|
45937
|
-
}
|
|
45938
|
-
if (light.type === "dir") {
|
|
45939
|
-
if (light.space === "view") {
|
|
45940
|
-
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
45941
|
-
} else {
|
|
45942
|
-
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
45943
|
-
}
|
|
45944
|
-
} else if (light.type === "point") {
|
|
45945
|
-
if (light.space === "view") {
|
|
45946
|
-
src.push("viewLightDir = -normalize(lightPos" + i + " - viewPosition.xyz);");
|
|
45947
|
-
} else {
|
|
45948
|
-
src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos" + i + ", 0.0)).xyz);");
|
|
45949
|
-
}
|
|
45950
|
-
} else if (light.type === "spot") {
|
|
45951
|
-
if (light.space === "view") {
|
|
45952
|
-
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
45953
|
-
} else {
|
|
45954
|
-
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
45955
|
-
}
|
|
45956
|
-
} else {
|
|
45957
|
-
continue;
|
|
45958
|
-
}
|
|
45959
|
-
src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");
|
|
45960
|
-
src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
|
|
45961
|
-
}
|
|
45962
|
-
|
|
45963
|
-
src.push("vec3 rgb = (vec3(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0));");
|
|
45964
|
-
src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * rgb) + (reflectedColor * rgb), float(color.a) / 255.0);");
|
|
45885
|
+
src.push("vViewPosition = viewPosition;");
|
|
45886
|
+
src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");
|
|
45965
45887
|
src.push("vUV = (uvDecodeMatrix * vec3(uv, 1.0)).xy;");
|
|
45966
45888
|
|
|
45967
45889
|
src.push("vec4 clipPos = projMatrix * viewPosition;");
|
|
@@ -45981,6 +45903,7 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45981
45903
|
|
|
45982
45904
|
_buildFragmentShader() {
|
|
45983
45905
|
const scene = this._scene;
|
|
45906
|
+
const lightsState = scene._lightsState;
|
|
45984
45907
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
45985
45908
|
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
45986
45909
|
const src = [];
|
|
@@ -46000,9 +45923,7 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
46000
45923
|
src.push("uniform float logDepthBufFC;");
|
|
46001
45924
|
src.push("in float vFragDepth;");
|
|
46002
45925
|
}
|
|
46003
|
-
|
|
46004
45926
|
src.push("uniform sampler2D uColorMap;");
|
|
46005
|
-
|
|
46006
45927
|
if (this._withSAO) {
|
|
46007
45928
|
src.push("uniform sampler2D uOcclusionTexture;");
|
|
46008
45929
|
src.push("uniform vec4 uSAOParams;");
|
|
@@ -46016,7 +45937,6 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
46016
45937
|
src.push(" return dot( v, unPackFactors );");
|
|
46017
45938
|
src.push("}");
|
|
46018
45939
|
}
|
|
46019
|
-
|
|
46020
45940
|
if (clipping) {
|
|
46021
45941
|
src.push("in vec4 vWorldPosition;");
|
|
46022
45942
|
src.push("in vec4 vFlags2;");
|
|
@@ -46026,7 +45946,27 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
46026
45946
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
46027
45947
|
}
|
|
46028
45948
|
}
|
|
45949
|
+
src.push("uniform mat4 viewMatrix;");
|
|
45950
|
+
src.push("uniform vec4 lightAmbient;");
|
|
45951
|
+
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
45952
|
+
const light = lightsState.lights[i];
|
|
45953
|
+
if (light.type === "ambient") {
|
|
45954
|
+
continue;
|
|
45955
|
+
}
|
|
45956
|
+
src.push("uniform vec4 lightColor" + i + ";");
|
|
45957
|
+
if (light.type === "dir") {
|
|
45958
|
+
src.push("uniform vec3 lightDir" + i + ";");
|
|
45959
|
+
}
|
|
45960
|
+
if (light.type === "point") {
|
|
45961
|
+
src.push("uniform vec3 lightPos" + i + ";");
|
|
45962
|
+
}
|
|
45963
|
+
if (light.type === "spot") {
|
|
45964
|
+
src.push("uniform vec3 lightPos" + i + ";");
|
|
45965
|
+
src.push("uniform vec3 lightDir" + i + ";");
|
|
45966
|
+
}
|
|
45967
|
+
}
|
|
46029
45968
|
|
|
45969
|
+
src.push("in vec4 vViewPosition;");
|
|
46030
45970
|
src.push("in vec4 vColor;");
|
|
46031
45971
|
src.push("in vec2 vUV;");
|
|
46032
45972
|
src.push("out vec4 outColor;");
|
|
@@ -46048,12 +45988,49 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
46048
45988
|
src.push("}");
|
|
46049
45989
|
}
|
|
46050
45990
|
|
|
46051
|
-
|
|
46052
|
-
|
|
45991
|
+
src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");
|
|
45992
|
+
src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");
|
|
45993
|
+
|
|
45994
|
+
src.push("float lambertian = 1.0;");
|
|
45995
|
+
|
|
45996
|
+
src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");
|
|
45997
|
+
src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");
|
|
45998
|
+
src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");
|
|
45999
|
+
|
|
46000
|
+
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
46001
|
+
const light = lightsState.lights[i];
|
|
46002
|
+
if (light.type === "ambient") {
|
|
46003
|
+
continue;
|
|
46004
|
+
}
|
|
46005
|
+
if (light.type === "dir") {
|
|
46006
|
+
if (light.space === "view") {
|
|
46007
|
+
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
46008
|
+
} else {
|
|
46009
|
+
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
46010
|
+
}
|
|
46011
|
+
} else if (light.type === "point") {
|
|
46012
|
+
if (light.space === "view") {
|
|
46013
|
+
src.push("viewLightDir = -normalize(lightPos" + i + " - viewPosition.xyz);");
|
|
46014
|
+
} else {
|
|
46015
|
+
src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos" + i + ", 0.0)).xyz);");
|
|
46016
|
+
}
|
|
46017
|
+
} else if (light.type === "spot") {
|
|
46018
|
+
if (light.space === "view") {
|
|
46019
|
+
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
46020
|
+
} else {
|
|
46021
|
+
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
46022
|
+
}
|
|
46023
|
+
} else {
|
|
46024
|
+
continue;
|
|
46025
|
+
}
|
|
46026
|
+
|
|
46027
|
+
src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");
|
|
46028
|
+
src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
|
|
46053
46029
|
}
|
|
46054
46030
|
|
|
46055
|
-
src.push("vec4
|
|
46056
|
-
src.push("
|
|
46031
|
+
src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
|
|
46032
|
+
src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");
|
|
46033
|
+
src.push("float opacity = color.a;");
|
|
46057
46034
|
|
|
46058
46035
|
if (this._withSAO) {
|
|
46059
46036
|
// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
|
|
@@ -46070,6 +46047,10 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
46070
46047
|
src.push(" outColor = vec4(colorTexel.rgb, opacity);");
|
|
46071
46048
|
}
|
|
46072
46049
|
|
|
46050
|
+
if (scene.logarithmicDepthBufferEnabled) {
|
|
46051
|
+
src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
46052
|
+
}
|
|
46053
|
+
|
|
46073
46054
|
src.push("}");
|
|
46074
46055
|
return src;
|
|
46075
46056
|
}
|
|
@@ -46456,6 +46437,11 @@ function quantizePositions(positions, aabb, positionsDecodeMatrix) { // http://c
|
|
|
46456
46437
|
*/
|
|
46457
46438
|
function transformAndOctEncodeNormals(worldNormalMatrix, normals, lenNormals, compressedNormals, lenCompressedNormals) {
|
|
46458
46439
|
// http://jcgt.org/published/0003/02/01/
|
|
46440
|
+
|
|
46441
|
+
function dot(array, vec3) {
|
|
46442
|
+
return array[0] * vec3[0] + array[1] * vec3[1] + array[2] * vec3[2];
|
|
46443
|
+
}
|
|
46444
|
+
|
|
46459
46445
|
let oct, dec, best, currentCos, bestCos;
|
|
46460
46446
|
let i;
|
|
46461
46447
|
let localNormal = new Float32Array([0, 0, 0, 0]);
|
|
@@ -47133,7 +47119,6 @@ class TrianglesBatchingLayer {
|
|
|
47133
47119
|
|
|
47134
47120
|
this._state.colorTextureSupported
|
|
47135
47121
|
= !!state.uvBuf
|
|
47136
|
-
&& !!state.normalsBuf
|
|
47137
47122
|
&& !!state.textureSet
|
|
47138
47123
|
&& !!state.textureSet.colorTexture;
|
|
47139
47124
|
|
|
@@ -48876,8 +48861,8 @@ class TrianglesInstancingFlatColorRenderer {
|
|
|
48876
48861
|
|
|
48877
48862
|
src.push("in vec4 vViewPosition;");
|
|
48878
48863
|
src.push("in vec4 vColor;");
|
|
48879
|
-
|
|
48880
48864
|
src.push("out vec4 outColor;");
|
|
48865
|
+
|
|
48881
48866
|
src.push("void main(void) {");
|
|
48882
48867
|
|
|
48883
48868
|
if (clipping) {
|
|
@@ -53550,10 +53535,7 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53550
53535
|
gl.uniform1i(this._uRenderPass, renderPass);
|
|
53551
53536
|
|
|
53552
53537
|
gl.uniformMatrix4fv(this._uViewMatrix, false, (origin) ? createRTCViewMat(camera.viewMatrix, origin) : camera.viewMatrix);
|
|
53553
|
-
gl.uniformMatrix4fv(this._uViewNormalMatrix, false, camera.viewNormalMatrix);
|
|
53554
|
-
|
|
53555
53538
|
gl.uniformMatrix4fv(this._uWorldMatrix, false, model.worldMatrix);
|
|
53556
|
-
gl.uniformMatrix4fv(this._uWorldNormalMatrix, false, model.worldNormalMatrix);
|
|
53557
53539
|
|
|
53558
53540
|
const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
|
|
53559
53541
|
if (numSectionPlanes > 0) {
|
|
@@ -53593,16 +53575,7 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53593
53575
|
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 1);
|
|
53594
53576
|
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 1);
|
|
53595
53577
|
|
|
53596
|
-
this._aModelNormalMatrixCol0.bindArrayBuffer(state.modelNormalMatrixCol0Buf);
|
|
53597
|
-
this._aModelNormalMatrixCol1.bindArrayBuffer(state.modelNormalMatrixCol1Buf);
|
|
53598
|
-
this._aModelNormalMatrixCol2.bindArrayBuffer(state.modelNormalMatrixCol2Buf);
|
|
53599
|
-
|
|
53600
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol0.location, 1);
|
|
53601
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol1.location, 1);
|
|
53602
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol2.location, 1);
|
|
53603
|
-
|
|
53604
53578
|
this._aPosition.bindArrayBuffer(geometry.positionsBuf);
|
|
53605
|
-
this._aNormal.bindArrayBuffer(geometry.normalsBuf);
|
|
53606
53579
|
this._aUV.bindArrayBuffer(geometry.uvBuf);
|
|
53607
53580
|
|
|
53608
53581
|
this._aColor.bindArrayBuffer(state.colorsBuf);
|
|
@@ -53630,9 +53603,6 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53630
53603
|
gl.vertexAttribDivisor(this._aModelMatrixCol0.location, 0);
|
|
53631
53604
|
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 0);
|
|
53632
53605
|
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 0);
|
|
53633
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol0.location, 0);
|
|
53634
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol1.location, 0);
|
|
53635
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol2.location, 0);
|
|
53636
53606
|
gl.vertexAttribDivisor(this._aColor.location, 0);
|
|
53637
53607
|
gl.vertexAttribDivisor(this._aFlags.location, 0);
|
|
53638
53608
|
|
|
@@ -53688,10 +53658,8 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53688
53658
|
this._uUVDecodeMatrix = program.getLocation("uvDecodeMatrix");
|
|
53689
53659
|
|
|
53690
53660
|
this._uWorldMatrix = program.getLocation("worldMatrix");
|
|
53691
|
-
this._uWorldNormalMatrix = program.getLocation("worldNormalMatrix");
|
|
53692
53661
|
|
|
53693
53662
|
this._uViewMatrix = program.getLocation("viewMatrix");
|
|
53694
|
-
this._uViewNormalMatrix = program.getLocation("viewNormalMatrix");
|
|
53695
53663
|
this._uProjMatrix = program.getLocation("projMatrix");
|
|
53696
53664
|
|
|
53697
53665
|
this._uLightAmbient = program.getLocation("lightAmbient");
|
|
@@ -53737,7 +53705,6 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53737
53705
|
}
|
|
53738
53706
|
|
|
53739
53707
|
this._aPosition = program.getAttribute("position");
|
|
53740
|
-
this._aNormal = program.getAttribute("normal");
|
|
53741
53708
|
this._aColor = program.getAttribute("color");
|
|
53742
53709
|
this._aUV = program.getAttribute("uv");
|
|
53743
53710
|
this._aFlags = program.getAttribute("flags");
|
|
@@ -53748,10 +53715,6 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53748
53715
|
this._aModelMatrixCol1 = program.getAttribute("modelMatrixCol1");
|
|
53749
53716
|
this._aModelMatrixCol2 = program.getAttribute("modelMatrixCol2");
|
|
53750
53717
|
|
|
53751
|
-
this._aModelNormalMatrixCol0 = program.getAttribute("modelNormalMatrixCol0");
|
|
53752
|
-
this._aModelNormalMatrixCol1 = program.getAttribute("modelNormalMatrixCol1");
|
|
53753
|
-
this._aModelNormalMatrixCol2 = program.getAttribute("modelNormalMatrixCol2");
|
|
53754
|
-
|
|
53755
53718
|
this._uColorMap = "uColorMap";
|
|
53756
53719
|
|
|
53757
53720
|
this._uOcclusionTexture = "uOcclusionTexture";
|
|
@@ -53810,11 +53773,7 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53810
53773
|
_buildVertexShader() {
|
|
53811
53774
|
const scene = this._scene;
|
|
53812
53775
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
53813
|
-
const lightsState = scene._lightsState;
|
|
53814
53776
|
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
53815
|
-
let i;
|
|
53816
|
-
let len;
|
|
53817
|
-
let light;
|
|
53818
53777
|
const src = [];
|
|
53819
53778
|
src.push("#version 300 es");
|
|
53820
53779
|
src.push("// Instancing geometry drawing vertex shader");
|
|
@@ -53822,7 +53781,6 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53822
53781
|
src.push("uniform int renderPass;");
|
|
53823
53782
|
|
|
53824
53783
|
src.push("in vec3 position;");
|
|
53825
|
-
src.push("in vec3 normal;");
|
|
53826
53784
|
src.push("in vec4 color;");
|
|
53827
53785
|
src.push("in vec2 uv;");
|
|
53828
53786
|
src.push("in vec4 flags;");
|
|
@@ -53836,14 +53794,8 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53836
53794
|
src.push("in vec4 modelMatrixCol1;");
|
|
53837
53795
|
src.push("in vec4 modelMatrixCol2;");
|
|
53838
53796
|
|
|
53839
|
-
src.push("in vec4 modelNormalMatrixCol0;");
|
|
53840
|
-
src.push("in vec4 modelNormalMatrixCol1;");
|
|
53841
|
-
src.push("in vec4 modelNormalMatrixCol2;");
|
|
53842
|
-
|
|
53843
53797
|
src.push("uniform mat4 worldMatrix;");
|
|
53844
|
-
src.push("uniform mat4 worldNormalMatrix;");
|
|
53845
53798
|
src.push("uniform mat4 viewMatrix;");
|
|
53846
|
-
src.push("uniform mat4 viewNormalMatrix;");
|
|
53847
53799
|
src.push("uniform mat4 projMatrix;");
|
|
53848
53800
|
src.push("uniform mat4 positionsDecodeMatrix;");
|
|
53849
53801
|
src.push("uniform mat3 uvDecodeMatrix;");
|
|
@@ -53857,38 +53809,11 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53857
53809
|
src.push("out float isPerspective;");
|
|
53858
53810
|
}
|
|
53859
53811
|
|
|
53860
|
-
src.push("uniform vec4 lightAmbient;");
|
|
53861
|
-
|
|
53862
|
-
for (i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
53863
|
-
light = lightsState.lights[i];
|
|
53864
|
-
if (light.type === "ambient") {
|
|
53865
|
-
continue;
|
|
53866
|
-
}
|
|
53867
|
-
src.push("uniform vec4 lightColor" + i + ";");
|
|
53868
|
-
if (light.type === "dir") {
|
|
53869
|
-
src.push("uniform vec3 lightDir" + i + ";");
|
|
53870
|
-
}
|
|
53871
|
-
if (light.type === "point") {
|
|
53872
|
-
src.push("uniform vec3 lightPos" + i + ";");
|
|
53873
|
-
}
|
|
53874
|
-
if (light.type === "spot") {
|
|
53875
|
-
src.push("uniform vec3 lightPos" + i + ";");
|
|
53876
|
-
src.push("uniform vec3 lightDir" + i + ";");
|
|
53877
|
-
}
|
|
53878
|
-
}
|
|
53879
|
-
|
|
53880
|
-
src.push("vec3 octDecode(vec2 oct) {");
|
|
53881
|
-
src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
|
|
53882
|
-
src.push(" if (v.z < 0.0) {");
|
|
53883
|
-
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);");
|
|
53884
|
-
src.push(" }");
|
|
53885
|
-
src.push(" return normalize(v);");
|
|
53886
|
-
src.push("}");
|
|
53887
|
-
|
|
53888
53812
|
if (clipping) {
|
|
53889
53813
|
src.push("out vec4 vWorldPosition;");
|
|
53890
53814
|
src.push("out vec4 vFlags2;");
|
|
53891
53815
|
}
|
|
53816
|
+
src.push("out vec4 vViewPosition;");
|
|
53892
53817
|
src.push("out vec4 vColor;");
|
|
53893
53818
|
src.push("out vec2 vUV;");
|
|
53894
53819
|
|
|
@@ -53909,47 +53834,8 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53909
53834
|
}
|
|
53910
53835
|
|
|
53911
53836
|
src.push("vec4 viewPosition = viewMatrix * worldPosition; ");
|
|
53912
|
-
|
|
53913
|
-
src.push("
|
|
53914
|
-
src.push("vec4 worldNormal = worldNormalMatrix * vec4(dot(modelNormal, modelNormalMatrixCol0), dot(modelNormal, modelNormalMatrixCol1), dot(modelNormal, modelNormalMatrixCol2), 0.0);");
|
|
53915
|
-
src.push("vec3 viewNormal = normalize(vec4(viewNormalMatrix * worldNormal).xyz);");
|
|
53916
|
-
|
|
53917
|
-
src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");
|
|
53918
|
-
src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");
|
|
53919
|
-
|
|
53920
|
-
src.push("float lambertian = 1.0;");
|
|
53921
|
-
for (i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
53922
|
-
light = lightsState.lights[i];
|
|
53923
|
-
if (light.type === "ambient") {
|
|
53924
|
-
continue;
|
|
53925
|
-
}
|
|
53926
|
-
if (light.type === "dir") {
|
|
53927
|
-
if (light.space === "view") {
|
|
53928
|
-
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
53929
|
-
} else {
|
|
53930
|
-
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
53931
|
-
}
|
|
53932
|
-
} else if (light.type === "point") {
|
|
53933
|
-
if (light.space === "view") {
|
|
53934
|
-
src.push("viewLightDir = -normalize(lightPos" + i + " - viewPosition.xyz);");
|
|
53935
|
-
} else {
|
|
53936
|
-
src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos" + i + ", 0.0)).xyz);");
|
|
53937
|
-
}
|
|
53938
|
-
} else if (light.type === "spot") {
|
|
53939
|
-
if (light.space === "view") {
|
|
53940
|
-
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
53941
|
-
} else {
|
|
53942
|
-
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
53943
|
-
}
|
|
53944
|
-
} else {
|
|
53945
|
-
continue;
|
|
53946
|
-
}
|
|
53947
|
-
src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");
|
|
53948
|
-
src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
|
|
53949
|
-
}
|
|
53950
|
-
|
|
53951
|
-
src.push("vec3 rgb = (vec3(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0));");
|
|
53952
|
-
src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * rgb) + (reflectedColor * rgb), float(color.a) / 255.0);");
|
|
53837
|
+
src.push("vViewPosition = viewPosition;");
|
|
53838
|
+
src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");
|
|
53953
53839
|
src.push("vUV = (uvDecodeMatrix * vec3(uv, 1.0)).xy;");
|
|
53954
53840
|
|
|
53955
53841
|
src.push("vec4 clipPos = projMatrix * viewPosition;");
|
|
@@ -53972,6 +53858,9 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53972
53858
|
_buildFragmentShader() {
|
|
53973
53859
|
const scene = this._scene;
|
|
53974
53860
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
53861
|
+
const lightsState = scene._lightsState;
|
|
53862
|
+
let i;
|
|
53863
|
+
let len;
|
|
53975
53864
|
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
53976
53865
|
const src = [];
|
|
53977
53866
|
src.push("#version 300 es");
|
|
@@ -54013,9 +53902,31 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
54013
53902
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
54014
53903
|
}
|
|
54015
53904
|
}
|
|
53905
|
+
src.push("uniform mat4 viewMatrix;");
|
|
53906
|
+
src.push("uniform vec4 lightAmbient;");
|
|
53907
|
+
for (i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
53908
|
+
const light = lightsState.lights[i];
|
|
53909
|
+
if (light.type === "ambient") {
|
|
53910
|
+
continue;
|
|
53911
|
+
}
|
|
53912
|
+
src.push("uniform vec4 lightColor" + i + ";");
|
|
53913
|
+
if (light.type === "dir") {
|
|
53914
|
+
src.push("uniform vec3 lightDir" + i + ";");
|
|
53915
|
+
}
|
|
53916
|
+
if (light.type === "point") {
|
|
53917
|
+
src.push("uniform vec3 lightPos" + i + ";");
|
|
53918
|
+
}
|
|
53919
|
+
if (light.type === "spot") {
|
|
53920
|
+
src.push("uniform vec3 lightPos" + i + ";");
|
|
53921
|
+
src.push("uniform vec3 lightDir" + i + ";");
|
|
53922
|
+
}
|
|
53923
|
+
}
|
|
53924
|
+
|
|
53925
|
+
src.push("in vec4 vViewPosition;");
|
|
54016
53926
|
src.push("in vec4 vColor;");
|
|
54017
53927
|
src.push("in vec2 vUV;");
|
|
54018
53928
|
src.push("out vec4 outColor;");
|
|
53929
|
+
|
|
54019
53930
|
src.push("void main(void) {");
|
|
54020
53931
|
|
|
54021
53932
|
if (clipping) {
|
|
@@ -54033,17 +53944,52 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
54033
53944
|
src.push("}");
|
|
54034
53945
|
}
|
|
54035
53946
|
|
|
54036
|
-
|
|
54037
|
-
|
|
54038
|
-
}
|
|
53947
|
+
src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");
|
|
53948
|
+
src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");
|
|
54039
53949
|
|
|
54040
|
-
src.push("
|
|
54041
|
-
src.push("float opacity = vColor.a;");
|
|
53950
|
+
src.push("float lambertian = 1.0;");
|
|
54042
53951
|
|
|
54043
|
-
|
|
54044
|
-
|
|
53952
|
+
src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");
|
|
53953
|
+
src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");
|
|
53954
|
+
src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");
|
|
53955
|
+
|
|
53956
|
+
for (i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
53957
|
+
const light = lightsState.lights[i];
|
|
53958
|
+
if (light.type === "ambient") {
|
|
53959
|
+
continue;
|
|
53960
|
+
}
|
|
53961
|
+
if (light.type === "dir") {
|
|
53962
|
+
if (light.space === "view") {
|
|
53963
|
+
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
53964
|
+
} else {
|
|
53965
|
+
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
53966
|
+
}
|
|
53967
|
+
} else if (light.type === "point") {
|
|
53968
|
+
if (light.space === "view") {
|
|
53969
|
+
src.push("viewLightDir = -normalize(lightPos" + i + " - viewPosition.xyz);");
|
|
53970
|
+
} else {
|
|
53971
|
+
src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos" + i + ", 0.0)).xyz);");
|
|
53972
|
+
}
|
|
53973
|
+
} else if (light.type === "spot") {
|
|
53974
|
+
if (light.space === "view") {
|
|
53975
|
+
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
53976
|
+
} else {
|
|
53977
|
+
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
53978
|
+
}
|
|
53979
|
+
} else {
|
|
53980
|
+
continue;
|
|
53981
|
+
}
|
|
53982
|
+
src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");
|
|
53983
|
+
src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
|
|
53984
|
+
}
|
|
53985
|
+
|
|
53986
|
+
src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
|
|
53987
|
+
src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");
|
|
53988
|
+
src.push("float opacity = color.a;");
|
|
54045
53989
|
|
|
54046
53990
|
if (this._withSAO) {
|
|
53991
|
+
// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
|
|
53992
|
+
// Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
|
|
54047
53993
|
src.push(" float viewportWidth = uSAOParams[0];");
|
|
54048
53994
|
src.push(" float viewportHeight = uSAOParams[1];");
|
|
54049
53995
|
src.push(" float blendCutoff = uSAOParams[2];");
|
|
@@ -54054,6 +54000,11 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
54054
54000
|
} else {
|
|
54055
54001
|
src.push(" outColor = vec4(vColor.rgb * colorTexel.rgb, opacity);");
|
|
54056
54002
|
}
|
|
54003
|
+
|
|
54004
|
+
if (scene.logarithmicDepthBufferEnabled) {
|
|
54005
|
+
src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
54006
|
+
}
|
|
54007
|
+
|
|
54057
54008
|
src.push("}");
|
|
54058
54009
|
return src;
|
|
54059
54010
|
}
|
|
@@ -54709,7 +54660,6 @@ class TrianglesInstancingLayer {
|
|
|
54709
54660
|
|
|
54710
54661
|
this._state.colorTextureSupported
|
|
54711
54662
|
= !!geometry.uvBuf
|
|
54712
|
-
&& !!geometry.normalsBuf
|
|
54713
54663
|
&& !!textureSet
|
|
54714
54664
|
&& !!textureSet.colorTexture;
|
|
54715
54665
|
|