@xeokit/xeokit-sdk 2.5.2-beta-11 → 2.5.2-beta-13

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.
Files changed (52) hide show
  1. package/dist/xeokit-sdk.cjs.js +146 -132
  2. package/dist/xeokit-sdk.es.js +146 -132
  3. package/dist/xeokit-sdk.es5.js +84 -84
  4. package/dist/xeokit-sdk.min.cjs.js +1 -1
  5. package/dist/xeokit-sdk.min.es.js +1 -1
  6. package/dist/xeokit-sdk.min.es5.js +1 -1
  7. package/package.json +1 -1
  8. package/src/viewer/scene/model/SceneModel.js +1 -1
  9. package/src/viewer/scene/model/vbo/batching/triangles/VBOBatchingTrianglesLayer.js +1 -1
  10. package/src/viewer/scene/model/vbo/instancing/triangles/VBOInstancingTrianglesLayer.js +1 -1
  11. package/src/viewer/scene/webgl/Renderer.js +20 -19
  12. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesColorRenderer.js +0 -238
  13. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesColorTextureRenderer.js +0 -270
  14. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesDepthRenderer.js +0 -126
  15. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesEdgesColorRenderer.js +0 -127
  16. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesEdgesRenderer.js +0 -133
  17. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesFlatColorRenderer.js +0 -235
  18. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesNormalsRenderer.js +0 -139
  19. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesOcclusionRenderer.js +0 -125
  20. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPBRRenderer.js +0 -561
  21. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickDepthRenderer.js +0 -144
  22. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickMeshRenderer.js +0 -130
  23. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickNormalsFlatRenderer.js +0 -121
  24. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickNormalsRenderer.js +0 -131
  25. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesRenderer.js +0 -33
  26. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesRenderers.js +0 -375
  27. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesShadowRenderer.js +0 -107
  28. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesSilhouetteRenderer.js +0 -136
  29. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesSnapInitRenderer.js +0 -311
  30. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesSnapRenderer.js +0 -308
  31. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOSceneModelTriangleBatchingEdgesRenderer.js +0 -12
  32. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesColorRenderer.js +0 -253
  33. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesColorTextureRenderer.js +0 -278
  34. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesDepthRenderer.js +0 -126
  35. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesEdgesColorRenderer.js +0 -132
  36. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesEdgesRenderer.js +0 -134
  37. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesFlatColorRenderer.js +0 -244
  38. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesFlatNormalsRenderer.js +0 -130
  39. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesNormalsRenderer.js +0 -138
  40. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesOcclusionRenderer.js +0 -128
  41. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPBRRenderer.js +0 -561
  42. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickDepthRenderer.js +0 -149
  43. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickMeshRenderer.js +0 -136
  44. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickNormalsFlatRenderer.js +0 -130
  45. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickNormalsRenderer.js +0 -145
  46. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesRenderers.js +0 -376
  47. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesShadowRenderer.js +0 -113
  48. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesSilhouetteRenderer.js +0 -139
  49. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesSnapInitRenderer.js +0 -342
  50. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesSnapRenderer.js +0 -325
  51. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOSceneModelTriangleInstancingEdgesRenderer.js +0 -12
  52. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOSceneModelTriangleInstancingRenderer.js +0 -29
@@ -1,126 +0,0 @@
1
- import {VBOBatchingTrianglesRenderer} from "./VBOBatchingTrianglesRenderer.js";
2
-
3
-
4
- /**
5
- * @private
6
- */
7
- export class VBOBatchingTrianglesDepthRenderer extends VBOBatchingTrianglesRenderer {
8
-
9
- _buildVertexShader() {
10
- const scene = this._scene;
11
- const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
12
- const src = [];
13
- src.push("#version 300 es");
14
- src.push("// Triangles batching depth vertex shader");
15
-
16
- src.push("uniform int renderPass;");
17
- src.push("in vec3 position;");
18
- if (scene.entityOffsetsEnabled) {
19
- src.push("in vec3 offset;");
20
- }
21
- src.push("in float flags;");
22
-
23
- this._addMatricesUniformBlockLines(src);
24
-
25
- if (scene.logarithmicDepthBufferEnabled) {
26
- src.push("uniform float logDepthBufFC;");
27
- src.push("out float vFragDepth;");
28
- src.push("bool isPerspectiveMatrix(mat4 m) {");
29
- src.push(" return (m[2][3] == - 1.0);");
30
- src.push("}");
31
- src.push("out float isPerspective;");
32
- }
33
- if (clipping) {
34
- src.push("out vec4 vWorldPosition;");
35
- src.push("out float vFlags;");
36
- }
37
- src.push("out vec2 vHighPrecisionZW;");
38
- src.push("void main(void) {");
39
-
40
- // colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
41
- // renderPass = COLOR_OPAQUE
42
-
43
- src.push(`int colorFlag = int(flags) & 0xF;`);
44
- src.push(`if (colorFlag != renderPass) {`);
45
- src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"); // Cull vertex
46
- src.push(" } else {");
47
- src.push(" vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");
48
- if (scene.entityOffsetsEnabled) {
49
- src.push(" worldPosition.xyz = worldPosition.xyz + offset;");
50
- }
51
- src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");
52
- if (clipping) {
53
- src.push(" vWorldPosition = worldPosition;");
54
- src.push(" vFlags = flags;");
55
- }
56
- src.push("vec4 clipPos = projMatrix * viewPosition;");
57
- if (scene.logarithmicDepthBufferEnabled) {
58
- src.push("vFragDepth = 1.0 + clipPos.w;");
59
- src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
60
- }
61
- src.push("gl_Position = clipPos;");
62
- src.push("vHighPrecisionZW = gl_Position.zw;");
63
- src.push(" }");
64
- src.push("}");
65
- return src;
66
- }
67
-
68
- _buildFragmentShader() {
69
- const scene = this._scene;
70
- const sectionPlanesState = scene._sectionPlanesState;
71
- const clipping = (sectionPlanesState.getNumAllocatedSectionPlanes() > 0);
72
- const src = [];
73
- src.push("#version 300 es");
74
- src.push("// Triangles batching depth fragment shader");
75
-
76
- src.push("precision highp float;");
77
- src.push("precision highp int;");
78
- if (scene.logarithmicDepthBufferEnabled) {
79
- src.push("in float isPerspective;");
80
- src.push("uniform float logDepthBufFC;");
81
- src.push("in float vFragDepth;");
82
- }
83
- if (clipping) {
84
- src.push("in vec4 vWorldPosition;");
85
- src.push("in float vFlags;");
86
- for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
87
- src.push("uniform bool sectionPlaneActive" + i + ";");
88
- src.push("uniform vec3 sectionPlanePos" + i + ";");
89
- src.push("uniform vec3 sectionPlaneDir" + i + ";");
90
- }
91
- }
92
- src.push("const float packUpScale = 256. / 255.;");
93
- src.push("const float unpackDownscale = 255. / 256.;");
94
- src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");
95
- src.push("const vec4 unpackFactors = unpackDownscale / vec4( packFactors, 1. );");
96
- src.push("const float shiftRight8 = 1.0 / 256.;");
97
-
98
- src.push("vec4 packDepthToRGBA( const in float v ) {");
99
- src.push(" vec4 r = vec4( fract( v * packFactors ), v );");
100
- src.push(" r.yzw -= r.xyz * shiftRight8;");
101
- src.push(" return r * packUpScale;");
102
- src.push("}");
103
- src.push("in vec2 vHighPrecisionZW;");
104
- src.push("out vec4 outColor;");
105
- src.push("void main(void) {");
106
- if (clipping) {
107
- src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
108
- src.push(" if (clippable) {");
109
- src.push(" float dist = 0.0;");
110
- for (var i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
111
- src.push(" if (sectionPlaneActive" + i + ") {");
112
- src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
113
- src.push(" }");
114
- }
115
- src.push(" if (dist > 0.0) { discard; }");
116
- src.push(" }");
117
- }
118
- if (scene.logarithmicDepthBufferEnabled) {
119
- src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
120
- }
121
- src.push("float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;");
122
- src.push(" outColor = vec4(vec3(1.0 - fragCoordZ), 1.0); ");
123
- src.push("}");
124
- return src;
125
- }
126
- }
@@ -1,127 +0,0 @@
1
- import {VBOSceneModelTriangleBatchingEdgesRenderer} from "./VBOSceneModelTriangleBatchingEdgesRenderer.js";
2
-
3
- /**
4
- * @private
5
- */
6
- export class VBOBatchingTrianglesEdgesColorRenderer extends VBOSceneModelTriangleBatchingEdgesRenderer {
7
-
8
- _buildVertexShader() {
9
- const scene = this._scene;
10
- const sectionPlanesState = scene._sectionPlanesState;
11
- const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
12
- const src = [];
13
- src.push("#version 300 es");
14
- src.push("// Batched geometry edges drawing vertex shader");
15
-
16
- src.push("uniform int renderPass;");
17
-
18
- src.push("in vec3 position;");
19
- src.push("in vec4 color;");
20
- if (scene.entityOffsetsEnabled) {
21
- src.push("in vec3 offset;");
22
- }
23
- src.push("in float flags;");
24
-
25
- this._addMatricesUniformBlockLines(src);
26
-
27
- if (scene.logarithmicDepthBufferEnabled) {
28
- src.push("uniform float logDepthBufFC;");
29
- src.push("out float vFragDepth;");
30
- src.push("bool isPerspectiveMatrix(mat4 m) {");
31
- src.push(" return (m[2][3] == - 1.0);");
32
- src.push("}");
33
- src.push("out float isPerspective;");
34
- }
35
-
36
- if (clipping) {
37
- src.push("out vec4 vWorldPosition;");
38
- src.push("out float vFlags;");
39
- }
40
-
41
- src.push("out vec4 vColor;");
42
- src.push("void main(void) {");
43
-
44
- // edgeFlag = NOT_RENDERED | EDGES_COLOR_OPAQUE | EDGES_COLOR_TRANSPARENT | EDGES_HIGHLIGHTED | EDGES_XRAYED | EDGES_SELECTED
45
- // renderPass = EDGES_COLOR_OPAQUE | EDGES_COLOR_TRANSPARENT
46
-
47
- src.push(`int edgeFlag = int(flags) >> 8 & 0xF;`);
48
- src.push(`if (edgeFlag != renderPass) {`);
49
- src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"); // Cull vertex
50
-
51
- src.push("} else {");
52
-
53
- src.push(" vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");
54
- if (scene.entityOffsetsEnabled) {
55
- src.push(" worldPosition.xyz = worldPosition.xyz + offset;");
56
- }
57
- src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");
58
-
59
- if (clipping) {
60
- src.push(" vWorldPosition = worldPosition;");
61
- src.push(" vFlags = flags;");
62
- }
63
-
64
- src.push("vec4 clipPos = projMatrix * viewPosition;");
65
- if (scene.logarithmicDepthBufferEnabled) {
66
- src.push("vFragDepth = 1.0 + clipPos.w;");
67
- src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
68
- }
69
- src.push("gl_Position = clipPos;");
70
- //src.push("vColor = vec4(float(color.r-100.0) / 255.0, float(color.g-100.0) / 255.0, float(color.b-100.0) / 255.0, float(color.a) / 255.0);");
71
- src.push("vColor = vec4(float(color.r*0.5) / 255.0, float(color.g*0.5) / 255.0, float(color.b*0.5) / 255.0, float(color.a) / 255.0);");
72
- src.push("}");
73
- src.push("}");
74
- return src;
75
- }
76
-
77
- _buildFragmentShader() {
78
- const scene = this._scene;
79
- const sectionPlanesState = scene._sectionPlanesState;
80
- const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
81
- const src = [];
82
- src.push("#version 300 es");
83
- src.push("// Batched geometry edges drawing fragment shader");
84
- src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
85
- src.push("precision highp float;");
86
- src.push("precision highp int;");
87
- src.push("#else");
88
- src.push("precision mediump float;");
89
- src.push("precision mediump int;");
90
- src.push("#endif");
91
- if (scene.logarithmicDepthBufferEnabled) {
92
- src.push("in float isPerspective;");
93
- src.push("uniform float logDepthBufFC;");
94
- src.push("in float vFragDepth;");
95
- }
96
- if (clipping) {
97
- src.push("in vec4 vWorldPosition;");
98
- src.push("in float vFlags;");
99
- for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
100
- src.push("uniform bool sectionPlaneActive" + i + ";");
101
- src.push("uniform vec3 sectionPlanePos" + i + ";");
102
- src.push("uniform vec3 sectionPlaneDir" + i + ";");
103
- }
104
- }
105
- src.push("in vec4 vColor;");
106
- src.push("out vec4 outColor;");
107
- src.push("void main(void) {");
108
- if (clipping) {
109
- src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
110
- src.push(" if (clippable) {");
111
- src.push(" float dist = 0.0;");
112
- for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
113
- src.push("if (sectionPlaneActive" + i + ") {");
114
- src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
115
- src.push("}");
116
- }
117
- src.push(" if (dist > 0.0) { discard; }");
118
- src.push("}");
119
- }
120
- if (scene.logarithmicDepthBufferEnabled) {
121
- src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
122
- }
123
- src.push("outColor = vColor;");
124
- src.push("}");
125
- return src;
126
- }
127
- }
@@ -1,133 +0,0 @@
1
- import {VBOBatchingTrianglesRenderer} from "./VBOBatchingTrianglesRenderer.js";
2
-
3
-
4
- /**
5
- * @private
6
- */
7
- export class VBOBatchingTrianglesEdgesRenderer extends VBOBatchingTrianglesRenderer {
8
-
9
- drawLayer(frameCtx, batchingLayer, renderPass) {
10
- super.drawLayer(frameCtx, batchingLayer, renderPass, { colorUniform: true });
11
- }
12
-
13
- _buildVertexShader() {
14
- const scene = this._scene;
15
- const sectionPlanesState = scene._sectionPlanesState;
16
- const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
17
- const src = [];
18
-
19
- src.push("#version 300 es");
20
- src.push("// VBOBatchingTrianglesEdgesRenderer vertex shader");
21
-
22
- src.push("uniform int renderPass;");
23
- src.push("uniform vec4 color;");
24
-
25
- src.push("in vec3 position;");
26
- if (scene.entityOffsetsEnabled) {
27
- src.push("in vec3 offset;");
28
- }
29
- src.push("in float flags;");
30
-
31
- this._addMatricesUniformBlockLines(src);
32
-
33
- if (scene.logarithmicDepthBufferEnabled) {
34
- src.push("uniform float logDepthBufFC;");
35
- src.push("out float vFragDepth;");
36
- src.push("bool isPerspectiveMatrix(mat4 m) {");
37
- src.push(" return (m[2][3] == - 1.0);");
38
- src.push("}");
39
- src.push("out float isPerspective;");
40
- }
41
-
42
- if (clipping) {
43
- src.push("out vec4 vWorldPosition;");
44
- src.push("out float vFlags;");
45
- }
46
-
47
- src.push("out vec4 vColor;");
48
- src.push("void main(void) {");
49
-
50
- // edgeFlag = NOT_RENDERED | EDGES_COLOR_OPAQUE | EDGES_COLOR_TRANSPARENT | EDGES_HIGHLIGHTED | EDGES_XRAYED | EDGES_SELECTED
51
- // renderPass = EDGES_COLOR_OPAQUE | EDGES_COLOR_TRANSPARENT | EDGES_HIGHLIGHTED | EDGES_XRAYED | EDGES_SELECTED
52
-
53
- src.push(`int edgeFlag = int(flags) >> 8 & 0xF;`);
54
- src.push(`if (edgeFlag != renderPass) {`);
55
- src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"); // Cull vertex
56
-
57
- src.push("} else {");
58
-
59
- src.push(" vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");
60
- if (scene.entityOffsetsEnabled) {
61
- src.push(" worldPosition.xyz = worldPosition.xyz + offset;");
62
- }
63
- src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");
64
-
65
- if (clipping) {
66
- src.push(" vWorldPosition = worldPosition;");
67
- src.push(" vFlags = flags;");
68
- }
69
-
70
- src.push("vec4 clipPos = projMatrix * viewPosition;");
71
- if (scene.logarithmicDepthBufferEnabled) {
72
- src.push("vFragDepth = 1.0 + clipPos.w;");
73
- src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
74
- }
75
- src.push("gl_Position = clipPos;");
76
- src.push("vColor = vec4(color.r, color.g, color.b, color.a);");
77
- src.push("}");
78
- src.push("}");
79
- return src;
80
- }
81
-
82
- _buildFragmentShader() {
83
- const scene = this._scene;
84
- const sectionPlanesState = scene._sectionPlanesState;
85
- const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
86
- const src = [];
87
- src.push("#version 300 es");
88
- src.push("// VBOBatchingTrianglesEdgesRenderer fragment shader");
89
-
90
- src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
91
- src.push("precision highp float;");
92
- src.push("precision highp int;");
93
- src.push("#else");
94
- src.push("precision mediump float;");
95
- src.push("precision mediump int;");
96
- src.push("#endif");
97
- if (scene.logarithmicDepthBufferEnabled) {
98
- src.push("in float isPerspective;");
99
- src.push("uniform float logDepthBufFC;");
100
- src.push("in float vFragDepth;");
101
- }
102
- if (clipping) {
103
- src.push("in vec4 vWorldPosition;");
104
- src.push("in float vFlags;");
105
- for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
106
- src.push("uniform bool sectionPlaneActive" + i + ";");
107
- src.push("uniform vec3 sectionPlanePos" + i + ";");
108
- src.push("uniform vec3 sectionPlaneDir" + i + ";");
109
- }
110
- }
111
- src.push("in vec4 vColor;");
112
- src.push("out vec4 outColor;");
113
- src.push("void main(void) {");
114
- if (clipping) {
115
- src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
116
- src.push(" if (clippable) {");
117
- src.push(" float dist = 0.0;");
118
- for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
119
- src.push("if (sectionPlaneActive" + i + ") {");
120
- src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
121
- src.push("}");
122
- }
123
- src.push(" if (dist > 0.0) { discard; }");
124
- src.push("}");
125
- }
126
- if (scene.logarithmicDepthBufferEnabled) {
127
- src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
128
- }
129
- src.push("outColor = vColor;");
130
- src.push("}");
131
- return src;
132
- }
133
- }
@@ -1,235 +0,0 @@
1
- import {VBOBatchingTrianglesRenderer} from "./VBOBatchingTrianglesRenderer.js";
2
-
3
- /**
4
- * @private
5
- */
6
- export class VBOBatchingTrianglesFlatColorRenderer extends VBOBatchingTrianglesRenderer {
7
- _getHash() {
8
- const scene = this._scene;
9
- return [scene._lightsState.getHash(), scene._sectionPlanesState.getHash(), (this._withSAO ? "sao" : "nosao")].join(";");
10
- }
11
-
12
- _buildVertexShader() {
13
- const scene = this._scene;
14
- const sectionPlanesState = scene._sectionPlanesState;
15
- const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
16
- const src = [];
17
- src.push("#version 300 es");
18
- src.push("// Triangles batching flat-shading draw vertex shader");
19
-
20
- src.push("uniform int renderPass;");
21
-
22
- src.push("in vec3 position;");
23
- src.push("in vec4 color;");
24
- src.push("in float flags;");
25
-
26
- if (scene.entityOffsetsEnabled) {
27
- src.push("in vec3 offset;");
28
- }
29
-
30
- this._addMatricesUniformBlockLines(src);
31
-
32
- if (scene.logarithmicDepthBufferEnabled) {
33
- src.push("uniform float logDepthBufFC;");
34
- src.push("out float vFragDepth;");
35
- src.push("bool isPerspectiveMatrix(mat4 m) {");
36
- src.push(" return (m[2][3] == - 1.0);");
37
- src.push("}");
38
- src.push("out float isPerspective;");
39
- }
40
-
41
- if (clipping) {
42
- src.push("out vec4 vWorldPosition;");
43
- src.push("out float vFlags;");
44
- }
45
- src.push("out vec4 vViewPosition;");
46
- src.push("out vec4 vColor;");
47
-
48
- src.push("void main(void) {");
49
-
50
- // colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
51
- // renderPass = COLOR_OPAQUE
52
-
53
- src.push(`int colorFlag = int(flags) & 0xF;`);
54
- src.push(`if (colorFlag != renderPass) {`);
55
- src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"); // Cull vertex
56
-
57
- src.push("} else {");
58
-
59
- src.push("vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");
60
- if (scene.entityOffsetsEnabled) {
61
- src.push("worldPosition.xyz = worldPosition.xyz + offset;");
62
- }
63
- src.push("vec4 viewPosition = viewMatrix * worldPosition; ");
64
- src.push("vViewPosition = viewPosition;");
65
- src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");
66
-
67
- src.push("vec4 clipPos = projMatrix * viewPosition;");
68
- if (scene.logarithmicDepthBufferEnabled) {
69
- src.push("vFragDepth = 1.0 + clipPos.w;");
70
- src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
71
- }
72
- if (clipping) {
73
- src.push("vWorldPosition = worldPosition;");
74
- src.push("vFlags = flags;");
75
- }
76
- src.push("gl_Position = clipPos;");
77
- src.push("}");
78
-
79
- src.push("}");
80
- return src;
81
- }
82
-
83
- _buildFragmentShader() {
84
- const scene = this._scene;
85
- const lightsState = scene._lightsState;
86
- const sectionPlanesState = scene._sectionPlanesState;
87
- const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
88
- const src = [];
89
- src.push("#version 300 es");
90
- src.push("// Triangles batching flat-shading draw fragment shader");
91
-
92
- src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
93
- src.push("precision highp float;");
94
- src.push("precision highp int;");
95
- src.push("#else");
96
- src.push("precision mediump float;");
97
- src.push("precision mediump int;");
98
- src.push("#endif");
99
-
100
- if (scene.logarithmicDepthBufferEnabled) {
101
- src.push("in float isPerspective;");
102
- src.push("uniform float logDepthBufFC;");
103
- src.push("in float vFragDepth;");
104
- }
105
-
106
- if (this._withSAO) {
107
- src.push("uniform sampler2D uOcclusionTexture;");
108
- src.push("uniform vec4 uSAOParams;");
109
-
110
- src.push("const float packUpscale = 256. / 255.;");
111
- src.push("const float unpackDownScale = 255. / 256.;");
112
- src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");
113
- src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");
114
-
115
- src.push("float unpackRGBToFloat( const in vec4 v ) {");
116
- src.push(" return dot( v, unPackFactors );");
117
- src.push("}");
118
- }
119
-
120
- if (clipping) {
121
- src.push("in vec4 vWorldPosition;");
122
- src.push("in float vFlags;");
123
- for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
124
- src.push("uniform bool sectionPlaneActive" + i + ";");
125
- src.push("uniform vec3 sectionPlanePos" + i + ";");
126
- src.push("uniform vec3 sectionPlaneDir" + i + ";");
127
- }
128
- }
129
-
130
- this._addMatricesUniformBlockLines(src);
131
-
132
- src.push("uniform vec4 lightAmbient;");
133
- for (let i = 0, len = lightsState.lights.length; i < len; i++) {
134
- const light = lightsState.lights[i];
135
- if (light.type === "ambient") {
136
- continue;
137
- }
138
- src.push("uniform vec4 lightColor" + i + ";");
139
- if (light.type === "dir") {
140
- src.push("uniform vec3 lightDir" + i + ";");
141
- }
142
- if (light.type === "point") {
143
- src.push("uniform vec3 lightPos" + i + ";");
144
- }
145
- if (light.type === "spot") {
146
- src.push("uniform vec3 lightPos" + i + ";");
147
- src.push("uniform vec3 lightDir" + i + ";");
148
- }
149
- }
150
-
151
- src.push("in vec4 vViewPosition;");
152
- src.push("in vec4 vColor;");
153
- src.push("out vec4 outColor;");
154
-
155
- src.push("void main(void) {");
156
-
157
- if (clipping) {
158
- src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
159
- src.push(" if (clippable) {");
160
- src.push(" float dist = 0.0;");
161
- for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
162
- src.push("if (sectionPlaneActive" + i + ") {");
163
- src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
164
- src.push("}");
165
- }
166
- src.push(" if (dist > 0.0) { ");
167
- src.push(" discard;")
168
- src.push(" }");
169
- src.push("}");
170
- }
171
-
172
- src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");
173
- src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");
174
-
175
- src.push("float lambertian = 1.0;");
176
-
177
- src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");
178
- src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");
179
- src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");
180
-
181
- for (let i = 0, len = lightsState.lights.length; i < len; i++) {
182
- const light = lightsState.lights[i];
183
- if (light.type === "ambient") {
184
- continue;
185
- }
186
- if (light.type === "dir") {
187
- if (light.space === "view") {
188
- src.push("viewLightDir = normalize(lightDir" + i + ");");
189
- } else {
190
- src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
191
- }
192
- } else if (light.type === "point") {
193
- if (light.space === "view") {
194
- src.push("viewLightDir = -normalize(lightPos" + i + " - viewPosition.xyz);");
195
- } else {
196
- src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos" + i + ", 0.0)).xyz);");
197
- }
198
- } else if (light.type === "spot") {
199
- if (light.space === "view") {
200
- src.push("viewLightDir = normalize(lightDir" + i + ");");
201
- } else {
202
- src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
203
- }
204
- } else {
205
- continue;
206
- }
207
-
208
- src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");
209
- src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
210
- }
211
-
212
- src.push("vec4 fragColor = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
213
-
214
- if (this._withSAO) {
215
- // Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
216
- // Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
217
- src.push(" float viewportWidth = uSAOParams[0];");
218
- src.push(" float viewportHeight = uSAOParams[1];");
219
- src.push(" float blendCutoff = uSAOParams[2];");
220
- src.push(" float blendFactor = uSAOParams[3];");
221
- src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");
222
- src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");
223
- src.push(" outColor = vec4(fragColor.rgb * ambient, 1.0);");
224
- } else {
225
- src.push(" outColor = fragColor;");
226
- }
227
-
228
- if (scene.logarithmicDepthBufferEnabled) {
229
- src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
230
- }
231
-
232
- src.push("}");
233
- return src;
234
- }
235
- }