@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.
- package/dist/xeokit-sdk.cjs.js +146 -132
- package/dist/xeokit-sdk.es.js +146 -132
- package/dist/xeokit-sdk.es5.js +84 -84
- package/dist/xeokit-sdk.min.cjs.js +1 -1
- package/dist/xeokit-sdk.min.es.js +1 -1
- package/dist/xeokit-sdk.min.es5.js +1 -1
- package/package.json +1 -1
- package/src/viewer/scene/model/SceneModel.js +1 -1
- package/src/viewer/scene/model/vbo/batching/triangles/VBOBatchingTrianglesLayer.js +1 -1
- package/src/viewer/scene/model/vbo/instancing/triangles/VBOInstancingTrianglesLayer.js +1 -1
- package/src/viewer/scene/webgl/Renderer.js +20 -19
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesColorRenderer.js +0 -238
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesColorTextureRenderer.js +0 -270
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesDepthRenderer.js +0 -126
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesEdgesColorRenderer.js +0 -127
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesEdgesRenderer.js +0 -133
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesFlatColorRenderer.js +0 -235
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesNormalsRenderer.js +0 -139
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesOcclusionRenderer.js +0 -125
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPBRRenderer.js +0 -561
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickDepthRenderer.js +0 -144
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickMeshRenderer.js +0 -130
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickNormalsFlatRenderer.js +0 -121
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickNormalsRenderer.js +0 -131
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesRenderer.js +0 -33
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesRenderers.js +0 -375
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesShadowRenderer.js +0 -107
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesSilhouetteRenderer.js +0 -136
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesSnapInitRenderer.js +0 -311
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesSnapRenderer.js +0 -308
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOSceneModelTriangleBatchingEdgesRenderer.js +0 -12
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesColorRenderer.js +0 -253
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesColorTextureRenderer.js +0 -278
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesDepthRenderer.js +0 -126
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesEdgesColorRenderer.js +0 -132
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesEdgesRenderer.js +0 -134
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesFlatColorRenderer.js +0 -244
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesFlatNormalsRenderer.js +0 -130
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesNormalsRenderer.js +0 -138
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesOcclusionRenderer.js +0 -128
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPBRRenderer.js +0 -561
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickDepthRenderer.js +0 -149
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickMeshRenderer.js +0 -136
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickNormalsFlatRenderer.js +0 -130
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickNormalsRenderer.js +0 -145
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesRenderers.js +0 -376
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesShadowRenderer.js +0 -113
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesSilhouetteRenderer.js +0 -139
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesSnapInitRenderer.js +0 -342
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesSnapRenderer.js +0 -325
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOSceneModelTriangleInstancingEdgesRenderer.js +0 -12
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOSceneModelTriangleInstancingRenderer.js +0 -29
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import {VBOSceneModelTriangleInstancingRenderer} from "./VBOSceneModelTriangleInstancingRenderer.js";
|
|
2
|
-
/**
|
|
3
|
-
* @private
|
|
4
|
-
*/
|
|
5
|
-
export class VBOInstancingTrianglesPickDepthRenderer extends VBOSceneModelTriangleInstancingRenderer {
|
|
6
|
-
|
|
7
|
-
_buildVertexShader() {
|
|
8
|
-
const scene = this._scene;
|
|
9
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
10
|
-
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
11
|
-
const src = [];
|
|
12
|
-
src.push("#version 300 es");
|
|
13
|
-
src.push("// Instancing geometry depth vertex shader");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
src.push("uniform int renderPass;");
|
|
17
|
-
|
|
18
|
-
src.push("in vec3 position;");
|
|
19
|
-
|
|
20
|
-
if (scene.entityOffsetsEnabled) {
|
|
21
|
-
src.push("in vec3 offset;");
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
src.push("in float flags;");
|
|
25
|
-
src.push("in vec4 modelMatrixCol0;"); // Modeling matrix
|
|
26
|
-
src.push("in vec4 modelMatrixCol1;");
|
|
27
|
-
src.push("in vec4 modelMatrixCol2;");
|
|
28
|
-
|
|
29
|
-
src.push("uniform bool pickInvisible;");
|
|
30
|
-
|
|
31
|
-
this._addMatricesUniformBlockLines(src);
|
|
32
|
-
|
|
33
|
-
this._addRemapClipPosLines(src);
|
|
34
|
-
|
|
35
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
36
|
-
src.push("uniform float logDepthBufFC;");
|
|
37
|
-
src.push("out float vFragDepth;");
|
|
38
|
-
src.push("bool isPerspectiveMatrix(mat4 m) {");
|
|
39
|
-
src.push(" return (m[2][3] == - 1.0);");
|
|
40
|
-
src.push("}");
|
|
41
|
-
src.push("out float isPerspective;");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (clipping) {
|
|
45
|
-
src.push("out vec4 vWorldPosition;");
|
|
46
|
-
src.push("out float vFlags;");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
src.push("out vec4 vViewPosition;");
|
|
50
|
-
src.push("void main(void) {");
|
|
51
|
-
|
|
52
|
-
// pickFlag = NOT_RENDERED | PICK
|
|
53
|
-
// renderPass = PICK
|
|
54
|
-
|
|
55
|
-
src.push(`int pickFlag = int(flags) >> 12 & 0xF;`);
|
|
56
|
-
src.push(`if (pickFlag != renderPass) {`);
|
|
57
|
-
src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"); // Cull vertex
|
|
58
|
-
|
|
59
|
-
src.push("} else {");
|
|
60
|
-
src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");
|
|
61
|
-
src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");
|
|
62
|
-
|
|
63
|
-
if (scene.entityOffsetsEnabled) {
|
|
64
|
-
src.push(" worldPosition.xyz = worldPosition.xyz + offset;");
|
|
65
|
-
}
|
|
66
|
-
src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");
|
|
67
|
-
if (clipping) {
|
|
68
|
-
src.push(" vWorldPosition = worldPosition;");
|
|
69
|
-
src.push(" vFlags = flags;");
|
|
70
|
-
}
|
|
71
|
-
src.push(" vViewPosition = viewPosition;");
|
|
72
|
-
src.push("vec4 clipPos = projMatrix * viewPosition;");
|
|
73
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
74
|
-
src.push("vFragDepth = 1.0 + clipPos.w;");
|
|
75
|
-
src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
|
|
76
|
-
}
|
|
77
|
-
src.push("gl_Position = remapClipPos(clipPos);");
|
|
78
|
-
src.push("}");
|
|
79
|
-
src.push("}");
|
|
80
|
-
return src;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
_buildFragmentShader() {
|
|
84
|
-
const scene = this._scene;
|
|
85
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
86
|
-
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
87
|
-
const src = [];
|
|
88
|
-
src.push("#version 300 es");
|
|
89
|
-
src.push("// Batched geometry depth fragment shader");
|
|
90
|
-
|
|
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
|
-
src.push("uniform float pickZNear;");
|
|
107
|
-
src.push("uniform float pickZFar;");
|
|
108
|
-
|
|
109
|
-
if (clipping) {
|
|
110
|
-
src.push("in vec4 vWorldPosition;");
|
|
111
|
-
src.push("in float vFlags;");
|
|
112
|
-
for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
113
|
-
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
114
|
-
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
115
|
-
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
src.push("in vec4 vViewPosition;");
|
|
119
|
-
src.push("vec4 packDepth(const in float depth) {");
|
|
120
|
-
src.push(" const vec4 bitShift = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);");
|
|
121
|
-
src.push(" const vec4 bitMask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);");
|
|
122
|
-
src.push(" vec4 res = fract(depth * bitShift);");
|
|
123
|
-
src.push(" res -= res.xxyz * bitMask;");
|
|
124
|
-
src.push(" return res;");
|
|
125
|
-
src.push("}");
|
|
126
|
-
src.push("out vec4 outColor;");
|
|
127
|
-
src.push("void main(void) {");
|
|
128
|
-
if (clipping) {
|
|
129
|
-
src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
|
|
130
|
-
src.push(" if (clippable) {");
|
|
131
|
-
src.push(" float dist = 0.0;");
|
|
132
|
-
for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
133
|
-
src.push("if (sectionPlaneActive" + i + ") {");
|
|
134
|
-
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
135
|
-
src.push("}");
|
|
136
|
-
}
|
|
137
|
-
src.push("if (dist > 0.0) { discard; }");
|
|
138
|
-
src.push("}");
|
|
139
|
-
}
|
|
140
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
141
|
-
src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
142
|
-
}
|
|
143
|
-
src.push(" float zNormalizedDepth = abs((pickZNear + vViewPosition.z) / (pickZFar - pickZNear));");
|
|
144
|
-
src.push(" outColor = packDepth(zNormalizedDepth); "); // Must be linear depth
|
|
145
|
-
src.push("}");
|
|
146
|
-
return src;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import {VBOSceneModelTriangleInstancingRenderer} from "./VBOSceneModelTriangleInstancingRenderer.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @private
|
|
5
|
-
*/
|
|
6
|
-
export class VBOInstancingTrianglesPickMeshRenderer extends VBOSceneModelTriangleInstancingRenderer {
|
|
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("// Instancing geometry picking 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
|
-
src.push("in vec4 pickColor;");
|
|
23
|
-
|
|
24
|
-
src.push("in vec4 modelMatrixCol0;"); // Modeling matrix
|
|
25
|
-
src.push("in vec4 modelMatrixCol1;");
|
|
26
|
-
src.push("in vec4 modelMatrixCol2;");
|
|
27
|
-
|
|
28
|
-
src.push("uniform bool pickInvisible;");
|
|
29
|
-
|
|
30
|
-
this._addMatricesUniformBlockLines(src);
|
|
31
|
-
|
|
32
|
-
this._addRemapClipPosLines(src);
|
|
33
|
-
|
|
34
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
35
|
-
src.push("uniform float logDepthBufFC;");
|
|
36
|
-
src.push("out float vFragDepth;");
|
|
37
|
-
src.push("bool isPerspectiveMatrix(mat4 m) {");
|
|
38
|
-
src.push(" return (m[2][3] == - 1.0);");
|
|
39
|
-
src.push("}");
|
|
40
|
-
src.push("out float isPerspective;");
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (clipping) {
|
|
44
|
-
src.push("out vec4 vWorldPosition;");
|
|
45
|
-
src.push("out float vFlags;");
|
|
46
|
-
}
|
|
47
|
-
src.push("out vec4 vPickColor;");
|
|
48
|
-
src.push("void main(void) {");
|
|
49
|
-
|
|
50
|
-
// pickFlag = NOT_RENDERED | PICK
|
|
51
|
-
// renderPass = PICK
|
|
52
|
-
|
|
53
|
-
src.push(`int pickFlag = int(flags) >> 12 & 0xF;`);
|
|
54
|
-
src.push(`if (pickFlag != renderPass) {`);
|
|
55
|
-
src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"); // Cull vertex
|
|
56
|
-
|
|
57
|
-
src.push("} else {");
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");
|
|
61
|
-
src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");
|
|
62
|
-
if (scene.entityOffsetsEnabled) {
|
|
63
|
-
src.push(" worldPosition.xyz = worldPosition.xyz + offset;");
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");
|
|
67
|
-
|
|
68
|
-
src.push(" vPickColor = vec4(float(pickColor.r) / 255.0, float(pickColor.g) / 255.0, float(pickColor.b) / 255.0, float(pickColor.a) / 255.0);");
|
|
69
|
-
if (clipping) {
|
|
70
|
-
src.push(" vWorldPosition = worldPosition;");
|
|
71
|
-
src.push(" vFlags = flags;");
|
|
72
|
-
}
|
|
73
|
-
src.push("vec4 clipPos = projMatrix * viewPosition;");
|
|
74
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
75
|
-
src.push("vFragDepth = 1.0 + clipPos.w;");
|
|
76
|
-
src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
|
|
77
|
-
}
|
|
78
|
-
src.push("gl_Position = remapClipPos(clipPos);");
|
|
79
|
-
src.push("}");
|
|
80
|
-
src.push("}");
|
|
81
|
-
return src;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
_buildFragmentShader() {
|
|
85
|
-
const scene = this._scene;
|
|
86
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
87
|
-
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
88
|
-
const src = [];
|
|
89
|
-
src.push("#version 300 es");
|
|
90
|
-
src.push("// Batched geometry picking 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
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
100
|
-
src.push("in float isPerspective;");
|
|
101
|
-
src.push("uniform float logDepthBufFC;");
|
|
102
|
-
src.push("in float vFragDepth;");
|
|
103
|
-
}
|
|
104
|
-
if (clipping) {
|
|
105
|
-
src.push("in vec4 vWorldPosition;");
|
|
106
|
-
src.push("in float vFlags;");
|
|
107
|
-
for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
108
|
-
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
109
|
-
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
110
|
-
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
src.push("in vec4 vPickColor;");
|
|
114
|
-
src.push("out vec4 outColor;");
|
|
115
|
-
src.push("void main(void) {");
|
|
116
|
-
if (clipping) {
|
|
117
|
-
src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
|
|
118
|
-
src.push(" if (clippable) {");
|
|
119
|
-
src.push(" float dist = 0.0;");
|
|
120
|
-
for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
121
|
-
src.push("if (sectionPlaneActive" + i + ") {");
|
|
122
|
-
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
123
|
-
src.push("}");
|
|
124
|
-
}
|
|
125
|
-
src.push("if (dist > 0.0) { discard; }");
|
|
126
|
-
src.push("}");
|
|
127
|
-
}
|
|
128
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
129
|
-
src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
130
|
-
}
|
|
131
|
-
src.push("outColor = vPickColor; ");
|
|
132
|
-
src.push("}");
|
|
133
|
-
return src;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { math } from "../../../../../math/math.js";
|
|
2
|
-
import {VBOSceneModelTriangleInstancingRenderer} from "./VBOSceneModelTriangleInstancingRenderer.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @private
|
|
6
|
-
*/
|
|
7
|
-
export class VBOInstancingTrianglesPickNormalsFlatRenderer extends VBOSceneModelTriangleInstancingRenderer {
|
|
8
|
-
|
|
9
|
-
_buildVertexShader() {
|
|
10
|
-
const scene = this._scene;
|
|
11
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
12
|
-
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
13
|
-
const src = [];
|
|
14
|
-
src.push("#version 300 es");
|
|
15
|
-
src.push("// Instancing geometry normals vertex shader");
|
|
16
|
-
|
|
17
|
-
src.push("uniform int renderPass;");
|
|
18
|
-
src.push("in vec3 position;");
|
|
19
|
-
if (scene.entityOffsetsEnabled) {
|
|
20
|
-
src.push("in vec3 offset;");
|
|
21
|
-
}
|
|
22
|
-
src.push("in float flags;");
|
|
23
|
-
src.push("in vec4 modelMatrixCol0;"); // Modeling matrix
|
|
24
|
-
src.push("in vec4 modelMatrixCol1;");
|
|
25
|
-
src.push("in vec4 modelMatrixCol2;");
|
|
26
|
-
src.push("uniform bool pickInvisible;");
|
|
27
|
-
|
|
28
|
-
this._addMatricesUniformBlockLines(src);
|
|
29
|
-
|
|
30
|
-
this._addRemapClipPosLines(src, 3);
|
|
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
|
-
if (clipping) {
|
|
41
|
-
src.push("out float vFlags;");
|
|
42
|
-
}
|
|
43
|
-
src.push("out vec4 vWorldPosition;");
|
|
44
|
-
src.push("void main(void) {");
|
|
45
|
-
|
|
46
|
-
// pickFlag = NOT_RENDERED | PICK
|
|
47
|
-
// renderPass = PICK
|
|
48
|
-
|
|
49
|
-
src.push(`int pickFlag = int(flags) >> 12 & 0xF;`);
|
|
50
|
-
src.push(`if (pickFlag != renderPass) {`);
|
|
51
|
-
src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"); // Cull vertex
|
|
52
|
-
src.push("} else {");
|
|
53
|
-
src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");
|
|
54
|
-
src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");
|
|
55
|
-
if (scene.entityOffsetsEnabled) {
|
|
56
|
-
src.push(" worldPosition.xyz = worldPosition.xyz + offset;");
|
|
57
|
-
}
|
|
58
|
-
src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");
|
|
59
|
-
src.push(" vWorldPosition = worldPosition;");
|
|
60
|
-
src.push("vec4 clipPos = projMatrix * viewPosition;");
|
|
61
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
62
|
-
src.push("vFragDepth = 1.0 + clipPos.w;");
|
|
63
|
-
src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (clipping) {
|
|
67
|
-
src.push("vFlags = flags;");
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
src.push("gl_Position = remapClipPos(clipPos);");
|
|
71
|
-
src.push("}");
|
|
72
|
-
src.push("}");
|
|
73
|
-
return src;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
_buildFragmentShader() {
|
|
77
|
-
const scene = this._scene;
|
|
78
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
79
|
-
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
80
|
-
const src = [];
|
|
81
|
-
src.push("#version 300 es");
|
|
82
|
-
src.push("// Batched geometry normals fragment shader");
|
|
83
|
-
|
|
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
|
-
|
|
92
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
93
|
-
src.push("in float isPerspective;");
|
|
94
|
-
src.push("uniform float logDepthBufFC;");
|
|
95
|
-
src.push("in float vFragDepth;");
|
|
96
|
-
}
|
|
97
|
-
src.push("in vec4 vWorldPosition;");
|
|
98
|
-
if (clipping) {
|
|
99
|
-
src.push("in float vFlags;");
|
|
100
|
-
for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
101
|
-
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
102
|
-
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
103
|
-
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
src.push("out highp ivec4 outNormal;");
|
|
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 (var i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); 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(" vec3 xTangent = dFdx( vWorldPosition.xyz );");
|
|
124
|
-
src.push(" vec3 yTangent = dFdy( vWorldPosition.xyz );");
|
|
125
|
-
src.push(" vec3 worldNormal = normalize( cross( xTangent, yTangent ) );");
|
|
126
|
-
src.push(` outNormal = ivec4(worldNormal * float(${math.MAX_INT}), 1.0);`);
|
|
127
|
-
src.push("}");
|
|
128
|
-
return src;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { math } from "../../../../../math/math.js";
|
|
2
|
-
import {VBOSceneModelTriangleInstancingRenderer} from "./VBOSceneModelTriangleInstancingRenderer.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @private
|
|
6
|
-
*/
|
|
7
|
-
export class VBOInstancingTrianglesPickNormalsRenderer extends VBOSceneModelTriangleInstancingRenderer {
|
|
8
|
-
|
|
9
|
-
_buildVertexShader() {
|
|
10
|
-
const scene = this._scene;
|
|
11
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
12
|
-
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
13
|
-
const src = [];
|
|
14
|
-
src.push("#version 300 es");
|
|
15
|
-
src.push("// Instancing geometry normals vertex shader");
|
|
16
|
-
|
|
17
|
-
src.push("uniform int renderPass;");
|
|
18
|
-
src.push("in vec3 position;");
|
|
19
|
-
if (scene.entityOffsetsEnabled) {
|
|
20
|
-
src.push("in vec3 offset;");
|
|
21
|
-
}
|
|
22
|
-
src.push("in vec2 normal;");
|
|
23
|
-
src.push("in float flags;");
|
|
24
|
-
src.push("in vec4 modelMatrixCol0;"); // Modeling matrix
|
|
25
|
-
src.push("in vec4 modelMatrixCol1;");
|
|
26
|
-
src.push("in vec4 modelMatrixCol2;");
|
|
27
|
-
src.push("in vec4 modelNormalMatrixCol0;");
|
|
28
|
-
src.push("in vec4 modelNormalMatrixCol1;");
|
|
29
|
-
src.push("in vec4 modelNormalMatrixCol2;");
|
|
30
|
-
src.push("uniform bool pickInvisible;");
|
|
31
|
-
|
|
32
|
-
this._addMatricesUniformBlockLines(src);
|
|
33
|
-
|
|
34
|
-
this._addRemapClipPosLines(src, 3);
|
|
35
|
-
|
|
36
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
37
|
-
src.push("uniform float logDepthBufFC;");
|
|
38
|
-
src.push("out float vFragDepth;");
|
|
39
|
-
src.push("bool isPerspectiveMatrix(mat4 m) {");
|
|
40
|
-
src.push(" return (m[2][3] == - 1.0);");
|
|
41
|
-
src.push("}");
|
|
42
|
-
src.push("out float isPerspective;");
|
|
43
|
-
}
|
|
44
|
-
src.push("vec3 octDecode(vec2 oct) {");
|
|
45
|
-
src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
|
|
46
|
-
src.push(" if (v.z < 0.0) {");
|
|
47
|
-
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);");
|
|
48
|
-
src.push(" }");
|
|
49
|
-
src.push(" return normalize(v);");
|
|
50
|
-
src.push("}");
|
|
51
|
-
if (clipping) {
|
|
52
|
-
src.push("out vec4 vWorldPosition;");
|
|
53
|
-
src.push("out float vFlags;");
|
|
54
|
-
}
|
|
55
|
-
src.push("out vec3 vWorldNormal;");
|
|
56
|
-
src.push("void main(void) {");
|
|
57
|
-
|
|
58
|
-
// pickFlag = NOT_RENDERED | PICK
|
|
59
|
-
// renderPass = PICK
|
|
60
|
-
|
|
61
|
-
src.push(`int pickFlag = int(flags) >> 12 & 0xF;`);
|
|
62
|
-
src.push(`if (pickFlag != renderPass) {`);
|
|
63
|
-
src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"); // Cull vertex
|
|
64
|
-
|
|
65
|
-
src.push("} else {");
|
|
66
|
-
src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");
|
|
67
|
-
src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");
|
|
68
|
-
if (scene.entityOffsetsEnabled) {
|
|
69
|
-
src.push(" worldPosition.xyz = worldPosition.xyz + offset;");
|
|
70
|
-
}
|
|
71
|
-
src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");
|
|
72
|
-
src.push(" vec4 modelNormal = vec4(octDecode(normal.xy), 0.0); ");
|
|
73
|
-
src.push(" vec3 worldNormal = vec3(dot(modelNormal, modelNormalMatrixCol0), dot(modelNormal, modelNormalMatrixCol1), dot(modelNormal, modelNormalMatrixCol2));");
|
|
74
|
-
src.push(" vWorldNormal = worldNormal;");
|
|
75
|
-
if (clipping) {
|
|
76
|
-
src.push(" vWorldPosition = worldPosition;");
|
|
77
|
-
src.push("vFlags = flags;");
|
|
78
|
-
}
|
|
79
|
-
src.push("vec4 clipPos = projMatrix * viewPosition;");
|
|
80
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
81
|
-
src.push("vFragDepth = 1.0 + clipPos.w;");
|
|
82
|
-
src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
|
|
83
|
-
}
|
|
84
|
-
src.push("gl_Position = remapClipPos(clipPos);");
|
|
85
|
-
src.push("}");
|
|
86
|
-
src.push("}");
|
|
87
|
-
return src;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
_buildFragmentShader() {
|
|
91
|
-
const scene = this._scene;
|
|
92
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
93
|
-
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
94
|
-
const src = [];
|
|
95
|
-
src.push("#version 300 es");
|
|
96
|
-
src.push("// Batched geometry normals fragment shader");
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
|
|
101
|
-
src.push("precision highp float;");
|
|
102
|
-
src.push("precision highp int;");
|
|
103
|
-
src.push("#else");
|
|
104
|
-
src.push("precision mediump float;");
|
|
105
|
-
src.push("precision mediump int;");
|
|
106
|
-
src.push("#endif");
|
|
107
|
-
|
|
108
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
109
|
-
src.push("in float isPerspective;");
|
|
110
|
-
src.push("uniform float logDepthBufFC;");
|
|
111
|
-
src.push("in float vFragDepth;");
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (clipping) {
|
|
115
|
-
src.push("in vec4 vWorldPosition;");
|
|
116
|
-
src.push("in float vFlags;");
|
|
117
|
-
for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
118
|
-
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
119
|
-
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
120
|
-
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
src.push("in vec3 vWorldNormal;");
|
|
124
|
-
src.push("out highp ivec4 outNormal;");
|
|
125
|
-
src.push("void main(void) {");
|
|
126
|
-
if (clipping) {
|
|
127
|
-
src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
|
|
128
|
-
src.push(" if (clippable) {");
|
|
129
|
-
src.push(" float dist = 0.0;");
|
|
130
|
-
for (var i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
131
|
-
src.push("if (sectionPlaneActive" + i + ") {");
|
|
132
|
-
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
133
|
-
src.push("}");
|
|
134
|
-
}
|
|
135
|
-
src.push("if (dist > 0.0) { discard; }");
|
|
136
|
-
src.push("}");
|
|
137
|
-
}
|
|
138
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
139
|
-
src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
140
|
-
}
|
|
141
|
-
src.push(` outNormal = ivec4(vWorldNormal * float(${math.MAX_INT}), 1.0);`);
|
|
142
|
-
src.push("}");
|
|
143
|
-
return src;
|
|
144
|
-
}
|
|
145
|
-
}
|