@xeokit/xeokit-sdk 2.6.92 → 2.6.94
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 +13076 -44663
- package/dist/xeokit-sdk.es.js +13077 -44662
- package/dist/xeokit-sdk.es5.js +1404 -3502
- package/dist/xeokit-sdk.min.cjs.js +8 -8
- package/dist/xeokit-sdk.min.es.js +8 -8
- package/dist/xeokit-sdk.min.es5.js +7 -7
- package/package.json +1 -1
- package/src/viewer/Viewer.js +55 -103
- package/src/viewer/scene/canvas/Canvas.js +3 -43
- package/src/viewer/scene/geometry/ReadableGeometry.js +0 -25
- package/src/viewer/scene/lights/CubeTexture.js +0 -13
- package/src/viewer/scene/lights/DirLight.js +3 -2
- package/src/viewer/scene/lights/PointLight.js +2 -1
- package/src/viewer/scene/materials/Texture.js +0 -9
- package/src/viewer/scene/math/rtcCoords.js +1 -38
- package/src/viewer/scene/mesh/Mesh.js +454 -212
- package/src/viewer/scene/mesh/draw/DrawShaderSource.js +305 -1504
- package/src/viewer/scene/mesh/draw/LambertShaderSource.js +35 -0
- package/src/viewer/scene/mesh/emphasis/EmphasisShaderSource.js +34 -0
- package/src/viewer/scene/mesh/occlusion/OcclusionShaderSource.js +9 -158
- package/src/viewer/scene/mesh/pick/PickMeshShaderSource.js +21 -151
- package/src/viewer/scene/mesh/pick/PickTriangleShaderSource.js +12 -124
- package/src/viewer/scene/mesh/shadow/ShadowShaderSource.js +22 -97
- package/src/viewer/scene/model/SceneModel.js +248 -852
- package/src/viewer/scene/model/SceneModelEntity.js +4 -4
- package/src/viewer/scene/model/SceneModelMesh.js +3 -3
- package/src/viewer/scene/model/layer/DTXLayer.js +940 -0
- package/src/viewer/scene/model/layer/Layer.js +788 -0
- package/src/viewer/scene/model/layer/VBOLayer.js +1019 -0
- package/src/viewer/scene/model/layer/programs/ColorProgram.js +35 -0
- package/src/viewer/scene/model/layer/programs/ColorTextureProgram.js +46 -0
- package/src/viewer/scene/model/layer/programs/DepthProgram.js +11 -0
- package/src/viewer/scene/model/layer/programs/EdgesProgram.js +12 -0
- package/src/viewer/scene/model/layer/programs/FlatColorProgram.js +24 -0
- package/src/viewer/scene/model/layer/programs/OcclusionProgram.js +12 -0
- package/src/viewer/scene/model/layer/programs/PBRProgram.js +180 -0
- package/src/viewer/scene/model/layer/programs/PickDepthProgram.js +30 -0
- package/src/viewer/scene/model/layer/programs/PickMeshProgram.js +12 -0
- package/src/viewer/scene/model/layer/programs/PickNormalsProgram.js +18 -0
- package/src/viewer/scene/model/layer/programs/ShadowProgram.js +23 -0
- package/src/viewer/scene/model/layer/programs/SilhouetteProgram.js +15 -0
- package/src/viewer/scene/model/layer/programs/SnapProgram.js +29 -0
- package/src/viewer/scene/scene/Scene.js +22 -39
- package/src/viewer/scene/webgl/ArrayBuf.js +5 -20
- package/src/viewer/scene/webgl/FrameContext.js +14 -86
- package/src/viewer/scene/webgl/RenderBuffer.js +62 -262
- package/src/viewer/scene/webgl/Renderer.js +880 -843
- package/src/viewer/scene/webgl/WebGLRenderer.js +612 -0
- package/src/viewer/scene/webgl/occlusion/OcclusionLayer.js +60 -132
- package/src/viewer/scene/webgl/occlusion/OcclusionTester.js +167 -328
- package/src/viewer/scene/mesh/draw/DrawRenderer.js +0 -998
- package/src/viewer/scene/mesh/emphasis/EmphasisEdgesRenderer.js +0 -259
- package/src/viewer/scene/mesh/emphasis/EmphasisEdgesShaderSource.js +0 -160
- package/src/viewer/scene/mesh/emphasis/EmphasisFillRenderer.js +0 -286
- package/src/viewer/scene/mesh/emphasis/EmphasisFillShaderSource.js +0 -263
- package/src/viewer/scene/mesh/occlusion/OcclusionRenderer.js +0 -221
- package/src/viewer/scene/mesh/pick/PickMeshRenderer.js +0 -223
- package/src/viewer/scene/mesh/pick/PickTriangleRenderer.js +0 -200
- package/src/viewer/scene/mesh/shadow/ShadowRenderer.js +0 -214
- package/src/viewer/scene/model/RENDER_PASSES.js +0 -34
- package/src/viewer/scene/model/dtx/BindableDataTexture.js +0 -31
- package/src/viewer/scene/model/dtx/lines/DTXLinesBuffer.js +0 -27
- package/src/viewer/scene/model/dtx/lines/DTXLinesLayer.js +0 -897
- package/src/viewer/scene/model/dtx/lines/DTXLinesState.js +0 -46
- package/src/viewer/scene/model/dtx/lines/DTXLinesTextureFactory.js +0 -411
- package/src/viewer/scene/model/dtx/lines/dataTextureRamStats.js +0 -49
- package/src/viewer/scene/model/dtx/lines/rebucketPositions.js +0 -208
- package/src/viewer/scene/model/dtx/lines/renderers/DTXLinesColorRenderer.js +0 -389
- package/src/viewer/scene/model/dtx/lines/renderers/DTXLinesRenderers.js +0 -65
- package/src/viewer/scene/model/dtx/triangles/DTXTrianglesLayer.js +0 -1399
- package/src/viewer/scene/model/dtx/triangles/lib/DTXTrianglesBuffer.js +0 -46
- package/src/viewer/scene/model/dtx/triangles/lib/DTXTrianglesState.js +0 -250
- package/src/viewer/scene/model/dtx/triangles/lib/DTXTrianglesTextureFactory.js +0 -518
- package/src/viewer/scene/model/dtx/triangles/lib/dataTextureRamStats.js +0 -54
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesColorRenderer.js +0 -639
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesDepthRenderer.js +0 -464
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesEdgesColorRenderer.js +0 -423
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesEdgesRenderer.js +0 -431
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesNormalsRenderer.js +0 -345
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesOcclusionRenderer.js +0 -436
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesPickDepthRenderer.js +0 -466
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesPickMeshRenderer.js +0 -437
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesPickNormalsFlatRenderer.js +0 -460
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesPickNormalsRenderer.js +0 -437
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesRenderers.js +0 -307
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesSilhouetteRenderer.js +0 -472
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesSnapInitRenderer.js +0 -474
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesSnapRenderer.js +0 -435
- package/src/viewer/scene/model/vbo/ScratchMemory.js +0 -63
- package/src/viewer/scene/model/vbo/VBORenderer.js +0 -664
- package/src/viewer/scene/model/vbo/batching/lines/VBOBatchingLinesLayer.js +0 -704
- package/src/viewer/scene/model/vbo/batching/lines/lib/VBOBatchingLinesBuffer.js +0 -19
- package/src/viewer/scene/model/vbo/batching/lines/renderers/VBOBatchingLineSnapInitRenderer.js +0 -318
- package/src/viewer/scene/model/vbo/batching/lines/renderers/VBOBatchingLinesColorRenderer.js +0 -114
- package/src/viewer/scene/model/vbo/batching/lines/renderers/VBOBatchingLinesRenderers.js +0 -99
- package/src/viewer/scene/model/vbo/batching/lines/renderers/VBOBatchingLinesSilhouetteRenderer.js +0 -124
- package/src/viewer/scene/model/vbo/batching/lines/renderers/VBOBatchingLinesSnapInitRenderer.js +0 -313
- package/src/viewer/scene/model/vbo/batching/lines/renderers/VBOBatchingLinesSnapRenderer.js +0 -311
- package/src/viewer/scene/model/vbo/batching/lines/renderers/VBOSceneModelLineBatchingRenderer.js +0 -24
- package/src/viewer/scene/model/vbo/batching/points/VBOBatchingPointsLayer.js +0 -688
- package/src/viewer/scene/model/vbo/batching/points/VBOBatchingPointsRenderer.js +0 -24
- package/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsColorRenderer.js +0 -168
- package/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsOcclusionRenderer.js +0 -136
- package/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsPickDepthRenderer.js +0 -156
- package/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsPickMeshRenderer.js +0 -148
- package/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsRenderers.js +0 -144
- package/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsShadowRenderer.js +0 -107
- package/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsSilhouetteRenderer.js +0 -146
- package/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsSnapInitRenderer.js +0 -315
- package/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsSnapRenderer.js +0 -305
- package/src/viewer/scene/model/vbo/batching/triangles/VBOBatchingTrianglesBuffer.js +0 -24
- package/src/viewer/scene/model/vbo/batching/triangles/VBOBatchingTrianglesLayer.js +0 -1346
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/EdgesColorRenderer.js +0 -131
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/EdgesEmphasisRenderer.js +0 -135
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/EdgesRenderer.js +0 -12
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/Renderers.js +0 -403
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesBatchingRenderer.js +0 -35
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesColorRenderer.js +0 -252
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesColorTextureRenderer.js +0 -294
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesDepthRenderer.js +0 -115
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesFlatColorRenderer.js +0 -246
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesNormalsRenderer.js +0 -139
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesOcclusionRenderer.js +0 -125
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesPBRRenderer.js +0 -561
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesPickDepthRenderer.js +0 -144
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesPickMeshRenderer.js +0 -130
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesPickNormalsFlatRenderer.js +0 -121
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesPickNormalsRenderer.js +0 -131
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesShadowRenderer.js +0 -107
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesSilhouetteRenderer.js +0 -144
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesSnapInitRenderer.js +0 -313
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesSnapRenderer.js +0 -312
- package/src/viewer/scene/model/vbo/float16.js +0 -760
- package/src/viewer/scene/model/vbo/instancing/lines/VBOInstancingLinesLayer.js +0 -711
- package/src/viewer/scene/model/vbo/instancing/lines/renderers/VBOInstancingLinesColorRenderer.js +0 -148
- package/src/viewer/scene/model/vbo/instancing/lines/renderers/VBOInstancingLinesRenderer.js +0 -26
- package/src/viewer/scene/model/vbo/instancing/lines/renderers/VBOInstancingLinesRenderers.js +0 -139
- package/src/viewer/scene/model/vbo/instancing/lines/renderers/VBOInstancingLinesSilhouetteRenderer.js +0 -127
- package/src/viewer/scene/model/vbo/instancing/lines/renderers/VBOInstancingLinesSnapInitRenderer.js +0 -308
- package/src/viewer/scene/model/vbo/instancing/lines/renderers/VBOInstancingLinesSnapRenderer.js +0 -299
- package/src/viewer/scene/model/vbo/instancing/points/VBOInstancingPointsLayer.js +0 -733
- package/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsColorRenderer.js +0 -174
- package/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsDepthRenderer.js +0 -156
- package/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsOcclusionRenderer.js +0 -149
- package/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsPickDepthRenderer.js +0 -170
- package/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsPickMeshRenderer.js +0 -152
- package/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsRenderer.js +0 -26
- package/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsRenderers.js +0 -174
- package/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsShadowRenderer.js +0 -119
- package/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsSilhouetteRenderer.js +0 -154
- package/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsSnapInitRenderer.js +0 -307
- package/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsSnapRenderer.js +0 -293
- package/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingTrianglesRenderer.js +0 -150
- package/src/viewer/scene/model/vbo/instancing/triangles/VBOInstancingTrianglesLayer.js +0 -1289
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/EdgesColorRenderer.js +0 -135
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/EdgesEmphasisRenderer.js +0 -137
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/EdgesRenderer.js +0 -12
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/Renderers.js +0 -403
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesColorRenderer.js +0 -267
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesColorTextureRenderer.js +0 -299
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesDepthRenderer.js +0 -126
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesFlatColorRenderer.js +0 -255
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesFlatNormalsRenderer.js +0 -130
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesInstancingRenderer.js +0 -32
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesNormalsRenderer.js +0 -138
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesOcclusionRenderer.js +0 -128
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesPBRRenderer.js +0 -561
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesPickDepthRenderer.js +0 -149
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesPickMeshRenderer.js +0 -136
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesPickNormalsFlatRenderer.js +0 -130
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesPickNormalsRenderer.js +0 -145
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesShadowRenderer.js +0 -113
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesSilhouetteRenderer.js +0 -148
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesSnapInitRenderer.js +0 -319
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesSnapRenderer.js +0 -310
- package/src/viewer/scene/webgl/Attribute.js +0 -23
- package/src/viewer/scene/webgl/Program.js +0 -181
- package/src/viewer/scene/webgl/RenderBufferManager.js +0 -34
- package/src/viewer/scene/webgl/Sampler.js +0 -18
- package/src/viewer/scene/webgl/Shader.js +0 -49
- package/src/viewer/scene/webgl/sao/SAODepthLimitedBlurRenderer.js +0 -324
- package/src/viewer/scene/webgl/sao/SAOOcclusionRenderer.js +0 -384
package/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsColorRenderer.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import {VBOInstancingPointsRenderer} from "./VBOInstancingPointsRenderer.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @private
|
|
5
|
-
*/
|
|
6
|
-
class VBOInstancingPointsColorRenderer extends VBOInstancingPointsRenderer {
|
|
7
|
-
_getHash() {
|
|
8
|
-
return this._scene._sectionPlanesState.getHash() + this._scene.pointsMaterial.hash;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
drawLayer(frameCtx, layer, renderPass) {
|
|
12
|
-
super.drawLayer(frameCtx, layer, renderPass, { incrementDrawState: true });
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
_buildVertexShader() {
|
|
16
|
-
const scene = this._scene;
|
|
17
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
18
|
-
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
19
|
-
const pointsMaterial = scene.pointsMaterial._state;
|
|
20
|
-
const src = [];
|
|
21
|
-
src.push('#version 300 es');
|
|
22
|
-
src.push("// Points instancing color vertex shader");
|
|
23
|
-
|
|
24
|
-
src.push("uniform int renderPass;");
|
|
25
|
-
|
|
26
|
-
src.push("in vec3 position;");
|
|
27
|
-
src.push("in vec4 color;");
|
|
28
|
-
src.push("in float flags;");
|
|
29
|
-
|
|
30
|
-
if (scene.entityOffsetsEnabled) {
|
|
31
|
-
src.push("in vec3 offset;");
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
src.push("in vec4 modelMatrixCol0;"); // Modeling matrix
|
|
35
|
-
src.push("in vec4 modelMatrixCol1;");
|
|
36
|
-
src.push("in vec4 modelMatrixCol2;");
|
|
37
|
-
|
|
38
|
-
this._addMatricesUniformBlockLines(src);
|
|
39
|
-
|
|
40
|
-
src.push("uniform float pointSize;");
|
|
41
|
-
if (pointsMaterial.perspectivePoints) {
|
|
42
|
-
src.push("uniform float nearPlaneHeight;");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (pointsMaterial.filterIntensity) {
|
|
46
|
-
src.push("uniform vec2 intensityRange;");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
50
|
-
src.push("uniform float logDepthBufFC;");
|
|
51
|
-
src.push("out float vFragDepth;");
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (clipping) {
|
|
55
|
-
src.push("out vec4 vWorldPosition;");
|
|
56
|
-
src.push("out float vFlags;");
|
|
57
|
-
}
|
|
58
|
-
src.push("out vec4 vColor;");
|
|
59
|
-
|
|
60
|
-
src.push("void main(void) {");
|
|
61
|
-
|
|
62
|
-
// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
|
|
63
|
-
// renderPass = COLOR_OPAQUE
|
|
64
|
-
|
|
65
|
-
src.push(`int colorFlag = int(flags) & 0xF;`);
|
|
66
|
-
src.push(`if (colorFlag != renderPass) {`);
|
|
67
|
-
src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"); // Cull vertex
|
|
68
|
-
|
|
69
|
-
src.push("} else {");
|
|
70
|
-
|
|
71
|
-
if (pointsMaterial.filterIntensity) {
|
|
72
|
-
src.push("float intensity = float(color.a) / 255.0;")
|
|
73
|
-
src.push("if (intensity < intensityRange[0] || intensity > intensityRange[1]) {");
|
|
74
|
-
src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"); // Cull vertex
|
|
75
|
-
src.push("} else {");
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
src.push("vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");
|
|
79
|
-
src.push("worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");
|
|
80
|
-
if (scene.entityOffsetsEnabled) {
|
|
81
|
-
src.push(" worldPosition.xyz = worldPosition.xyz + offset;");
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
src.push("vec4 viewPosition = viewMatrix * worldPosition; ");
|
|
85
|
-
|
|
86
|
-
src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, 1.0);");
|
|
87
|
-
|
|
88
|
-
if (clipping) {
|
|
89
|
-
src.push("vWorldPosition = worldPosition;");
|
|
90
|
-
src.push("vFlags = flags;");
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
src.push("vec4 clipPos = projMatrix * viewPosition;");
|
|
94
|
-
|
|
95
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
96
|
-
src.push("vFragDepth = 1.0 + clipPos.w;");
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
src.push("gl_Position = clipPos;");
|
|
100
|
-
if (pointsMaterial.perspectivePoints) {
|
|
101
|
-
src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");
|
|
102
|
-
src.push("gl_PointSize = max(gl_PointSize, " + Math.floor(pointsMaterial.minPerspectivePointSize) + ".0);");
|
|
103
|
-
src.push("gl_PointSize = min(gl_PointSize, " + Math.floor(pointsMaterial.maxPerspectivePointSize) + ".0);");
|
|
104
|
-
} else {
|
|
105
|
-
src.push("gl_PointSize = pointSize;");
|
|
106
|
-
}
|
|
107
|
-
src.push("}");
|
|
108
|
-
if (pointsMaterial.filterIntensity) {
|
|
109
|
-
src.push("}");
|
|
110
|
-
}
|
|
111
|
-
src.push("}");
|
|
112
|
-
return src;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
_buildFragmentShader() {
|
|
116
|
-
const scene = this._scene;
|
|
117
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
118
|
-
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
119
|
-
const src = [];
|
|
120
|
-
src.push('#version 300 es');
|
|
121
|
-
src.push("// Points instancing color fragment shader");
|
|
122
|
-
|
|
123
|
-
src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
|
|
124
|
-
src.push("precision highp float;");
|
|
125
|
-
src.push("precision highp int;");
|
|
126
|
-
src.push("#else");
|
|
127
|
-
src.push("precision mediump float;");
|
|
128
|
-
src.push("precision mediump int;");
|
|
129
|
-
src.push("#endif");
|
|
130
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
131
|
-
src.push("uniform float logDepthBufFC;");
|
|
132
|
-
src.push("in float vFragDepth;");
|
|
133
|
-
}
|
|
134
|
-
if (clipping) {
|
|
135
|
-
src.push("in vec4 vWorldPosition;");
|
|
136
|
-
src.push("in float vFlags;");
|
|
137
|
-
for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
|
|
138
|
-
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
139
|
-
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
140
|
-
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
src.push("in vec4 vColor;");
|
|
144
|
-
src.push("out vec4 outColor;");
|
|
145
|
-
src.push("void main(void) {");
|
|
146
|
-
if (scene.pointsMaterial.roundPoints) {
|
|
147
|
-
src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");
|
|
148
|
-
src.push(" float r = dot(cxy, cxy);");
|
|
149
|
-
src.push(" if (r > 1.0) {");
|
|
150
|
-
src.push(" discard;");
|
|
151
|
-
src.push(" }");
|
|
152
|
-
}
|
|
153
|
-
if (clipping) {
|
|
154
|
-
src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
|
|
155
|
-
src.push(" if (clippable) {");
|
|
156
|
-
src.push(" float dist = 0.0;");
|
|
157
|
-
for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
|
|
158
|
-
src.push("if (sectionPlaneActive" + i + ") {");
|
|
159
|
-
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
160
|
-
src.push("}");
|
|
161
|
-
}
|
|
162
|
-
src.push("if (dist > 0.0) { discard; }");
|
|
163
|
-
src.push("}");
|
|
164
|
-
}
|
|
165
|
-
src.push(" outColor = vColor;");
|
|
166
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
167
|
-
src.push("gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
168
|
-
}
|
|
169
|
-
src.push("}");
|
|
170
|
-
return src;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export {VBOInstancingPointsColorRenderer};
|
package/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsDepthRenderer.js
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import {VBOInstancingPointsRenderer} from "./VBOInstancingPointsRenderer.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @private
|
|
5
|
-
*/
|
|
6
|
-
class VBOInstancingPointsDepthRenderer extends VBOInstancingPointsRenderer {
|
|
7
|
-
_getHash() {
|
|
8
|
-
return this._scene._sectionPlanesState.getHash() + this._scene.pointsMaterial.hash;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
_buildVertexShader() {
|
|
12
|
-
const scene = this._scene;
|
|
13
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
14
|
-
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
15
|
-
const pointsMaterial = scene.pointsMaterial._state;
|
|
16
|
-
const src = [];
|
|
17
|
-
src.push('#version 300 es');
|
|
18
|
-
src.push("// Points instancing depth vertex shader");
|
|
19
|
-
src.push("uniform int renderPass;");
|
|
20
|
-
src.push("in vec3 position;");
|
|
21
|
-
if (scene.entityOffsetsEnabled) {
|
|
22
|
-
src.push("in vec3 offset;");
|
|
23
|
-
}
|
|
24
|
-
src.push("in float flags;");
|
|
25
|
-
src.push("in vec4 modelMatrixCol0;");
|
|
26
|
-
src.push("in vec4 modelMatrixCol1;");
|
|
27
|
-
src.push("in vec4 modelMatrixCol2;");
|
|
28
|
-
|
|
29
|
-
this._addMatricesUniformBlockLines(src);
|
|
30
|
-
|
|
31
|
-
src.push("uniform float pointSize;");
|
|
32
|
-
if (pointsMaterial.perspectivePoints) {
|
|
33
|
-
src.push("uniform float nearPlaneHeight;");
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
37
|
-
src.push("uniform float logDepthBufFC;");
|
|
38
|
-
src.push("out float vFragDepth;");
|
|
39
|
-
}
|
|
40
|
-
if (clipping) {
|
|
41
|
-
src.push("out vec4 vWorldPosition;");
|
|
42
|
-
src.push("out float vFlags;");
|
|
43
|
-
}
|
|
44
|
-
src.push("void main(void) {");
|
|
45
|
-
|
|
46
|
-
// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
|
|
47
|
-
// renderPass = COLOR_OPAQUE
|
|
48
|
-
|
|
49
|
-
src.push(`int colorFlag = int(flags) & 0xF;`);
|
|
50
|
-
src.push(`if (colorFlag != renderPass) {`);
|
|
51
|
-
src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"); // Cull vertex
|
|
52
|
-
|
|
53
|
-
src.push("} else {");
|
|
54
|
-
src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");
|
|
55
|
-
src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");
|
|
56
|
-
if (scene.entityOffsetsEnabled) {
|
|
57
|
-
src.push(" worldPosition.xyz = worldPosition.xyz + offset;");
|
|
58
|
-
}
|
|
59
|
-
src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");
|
|
60
|
-
|
|
61
|
-
if (clipping) {
|
|
62
|
-
src.push("vWorldPosition = worldPosition;");
|
|
63
|
-
src.push("vFlags = flags;");
|
|
64
|
-
}
|
|
65
|
-
src.push("vec4 clipPos = projMatrix * viewPosition;");
|
|
66
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
67
|
-
src.push("vFragDepth = 1.0 + clipPos.w;");
|
|
68
|
-
}
|
|
69
|
-
src.push("gl_Position = clipPos;");
|
|
70
|
-
if (pointsMaterial.perspectivePoints) {
|
|
71
|
-
src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");
|
|
72
|
-
src.push("gl_PointSize = max(gl_PointSize, " + Math.floor(pointsMaterial.minPerspectivePointSize) + ".0);");
|
|
73
|
-
src.push("gl_PointSize = min(gl_PointSize, " + Math.floor(pointsMaterial.maxPerspectivePointSize) + ".0);");
|
|
74
|
-
} else {
|
|
75
|
-
src.push("gl_PointSize = pointSize;");
|
|
76
|
-
}
|
|
77
|
-
src.push("}");
|
|
78
|
-
src.push("}");
|
|
79
|
-
return src;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
_buildFragmentShader() {
|
|
83
|
-
const scene = this._scene;
|
|
84
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
85
|
-
let i;
|
|
86
|
-
let len;
|
|
87
|
-
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
88
|
-
const src = [];
|
|
89
|
-
src.push('#version 300 es');
|
|
90
|
-
src.push("// Points instancing depth vertex shader");
|
|
91
|
-
src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
|
|
92
|
-
src.push("precision highp float;");
|
|
93
|
-
src.push("precision highp int;");
|
|
94
|
-
src.push("#else");
|
|
95
|
-
src.push("precision mediump float;");
|
|
96
|
-
src.push("precision mediump int;");
|
|
97
|
-
src.push("#endif");
|
|
98
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
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 (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
|
-
|
|
112
|
-
src.push("const float packUpScale = 256. / 255.;");
|
|
113
|
-
src.push("const float unpackDownscale = 255. / 256.;");
|
|
114
|
-
src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");
|
|
115
|
-
src.push("const vec4 unpackFactors = unpackDownscale / vec4( packFactors, 1. );");
|
|
116
|
-
src.push("const float shiftRight8 = 1.0 / 256.;");
|
|
117
|
-
|
|
118
|
-
src.push("vec4 packDepthToRGBA( const in float v ) {");
|
|
119
|
-
src.push(" vec4 r = vec4( fract( v * packFactors ), v );");
|
|
120
|
-
src.push(" r.yzw -= r.xyz * shiftRight8;");
|
|
121
|
-
src.push(" return r * packUpScale;");
|
|
122
|
-
src.push("}");
|
|
123
|
-
|
|
124
|
-
src.push("out vec4 outColor;");
|
|
125
|
-
src.push("void main(void) {");
|
|
126
|
-
|
|
127
|
-
if (scene.pointsMaterial.roundPoints) {
|
|
128
|
-
src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");
|
|
129
|
-
src.push(" float r = dot(cxy, cxy);");
|
|
130
|
-
src.push(" if (r > 1.0) {");
|
|
131
|
-
src.push(" discard;");
|
|
132
|
-
src.push(" }");
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (clipping) {
|
|
136
|
-
src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
|
|
137
|
-
src.push(" if (clippable) {");
|
|
138
|
-
src.push(" float dist = 0.0;");
|
|
139
|
-
for (i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
|
|
140
|
-
src.push("if (sectionPlaneActive" + i + ") {");
|
|
141
|
-
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
142
|
-
src.push("}");
|
|
143
|
-
}
|
|
144
|
-
src.push("if (dist > 0.0) { discard; }");
|
|
145
|
-
src.push("}");
|
|
146
|
-
}
|
|
147
|
-
src.push(" outColor = packDepthToRGBA( gl_FragCoord.z); "); // Must be linear depth
|
|
148
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
149
|
-
src.push("gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
150
|
-
}
|
|
151
|
-
src.push("}");
|
|
152
|
-
return src;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export {VBOInstancingPointsDepthRenderer};
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import {VBOInstancingPointsRenderer} from "./VBOInstancingPointsRenderer.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @private
|
|
5
|
-
*/
|
|
6
|
-
export class VBOInstancingPointsOcclusionRenderer extends VBOInstancingPointsRenderer {
|
|
7
|
-
_getHash() {
|
|
8
|
-
return this._scene._sectionPlanesState.getHash() + this._scene.pointsMaterial.hash;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
_buildVertexShader() {
|
|
12
|
-
|
|
13
|
-
const scene = this._scene;
|
|
14
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
15
|
-
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
16
|
-
const pointsMaterial = scene.pointsMaterial._state;
|
|
17
|
-
const src = [];
|
|
18
|
-
|
|
19
|
-
src.push ('#version 300 es');
|
|
20
|
-
src.push("// Points instancing occlusion vertex shader");
|
|
21
|
-
|
|
22
|
-
src.push("uniform int renderPass;");
|
|
23
|
-
src.push("in vec3 position;");
|
|
24
|
-
|
|
25
|
-
if (scene.entityOffsetsEnabled) {
|
|
26
|
-
src.push("in vec3 offset;");
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
src.push("in vec4 color;");
|
|
30
|
-
src.push("in float flags;");
|
|
31
|
-
|
|
32
|
-
src.push("in vec4 modelMatrixCol0;"); // Modeling matrix
|
|
33
|
-
src.push("in vec4 modelMatrixCol1;");
|
|
34
|
-
src.push("in vec4 modelMatrixCol2;");
|
|
35
|
-
|
|
36
|
-
this._addMatricesUniformBlockLines(src);
|
|
37
|
-
|
|
38
|
-
src.push("uniform float pointSize;");
|
|
39
|
-
if (pointsMaterial.perspectivePoints) {
|
|
40
|
-
src.push("uniform float nearPlaneHeight;");
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
44
|
-
src.push("uniform float logDepthBufFC;");
|
|
45
|
-
src.push("out float vFragDepth;");
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (clipping) {
|
|
49
|
-
src.push("out vec4 vWorldPosition;");
|
|
50
|
-
src.push("out float vFlags;");
|
|
51
|
-
}
|
|
52
|
-
src.push("void main(void) {");
|
|
53
|
-
|
|
54
|
-
// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
|
|
55
|
-
// renderPass = COLOR_OPAQUE
|
|
56
|
-
|
|
57
|
-
src.push(`int colorFlag = int(flags) & 0xF;`);
|
|
58
|
-
src.push(`if (colorFlag != renderPass) {`);
|
|
59
|
-
src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");
|
|
60
|
-
|
|
61
|
-
src.push("} else {");
|
|
62
|
-
src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");
|
|
63
|
-
src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");
|
|
64
|
-
if (scene.entityOffsetsEnabled) {
|
|
65
|
-
src.push(" worldPosition.xyz = worldPosition.xyz + offset;");
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");
|
|
69
|
-
|
|
70
|
-
if (clipping) {
|
|
71
|
-
src.push(" vWorldPosition = worldPosition;");
|
|
72
|
-
src.push("vFlags = flags;");
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
src.push("vec4 clipPos = projMatrix * viewPosition;");
|
|
76
|
-
|
|
77
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
78
|
-
src.push("vFragDepth = 1.0 + clipPos.w;");
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
src.push("gl_Position = clipPos;");
|
|
82
|
-
if (pointsMaterial.perspectivePoints) {
|
|
83
|
-
src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");
|
|
84
|
-
src.push("gl_PointSize = max(gl_PointSize, " + Math.floor(pointsMaterial.minPerspectivePointSize) + ".0);");
|
|
85
|
-
src.push("gl_PointSize = min(gl_PointSize, " + Math.floor(pointsMaterial.maxPerspectivePointSize) + ".0);");
|
|
86
|
-
} else {
|
|
87
|
-
src.push("gl_PointSize = pointSize;");
|
|
88
|
-
}
|
|
89
|
-
src.push("}");
|
|
90
|
-
src.push("}");
|
|
91
|
-
return src;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
_buildFragmentShader() {
|
|
95
|
-
const scene = this._scene;
|
|
96
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
97
|
-
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
98
|
-
const src = [];
|
|
99
|
-
src.push ('#version 300 es');
|
|
100
|
-
src.push("// Points instancing occlusion vertex shader");
|
|
101
|
-
src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
|
|
102
|
-
src.push("precision highp float;");
|
|
103
|
-
src.push("precision highp int;");
|
|
104
|
-
src.push("#else");
|
|
105
|
-
src.push("precision mediump float;");
|
|
106
|
-
src.push("precision mediump int;");
|
|
107
|
-
src.push("#endif");
|
|
108
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
109
|
-
src.push("uniform float logDepthBufFC;");
|
|
110
|
-
src.push("in float vFragDepth;");
|
|
111
|
-
}
|
|
112
|
-
if (clipping) {
|
|
113
|
-
src.push("in vec4 vWorldPosition;");
|
|
114
|
-
src.push("in float vFlags;");
|
|
115
|
-
for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
116
|
-
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
117
|
-
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
118
|
-
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
src.push("out vec4 outColor;");
|
|
122
|
-
src.push("void main(void) {");
|
|
123
|
-
if (scene.pointsMaterial.roundPoints) {
|
|
124
|
-
src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");
|
|
125
|
-
src.push(" float r = dot(cxy, cxy);");
|
|
126
|
-
src.push(" if (r > 1.0) {");
|
|
127
|
-
src.push(" discard;");
|
|
128
|
-
src.push(" }");
|
|
129
|
-
}
|
|
130
|
-
if (clipping) {
|
|
131
|
-
src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
|
|
132
|
-
src.push(" if (clippable) {");
|
|
133
|
-
src.push(" float dist = 0.0;");
|
|
134
|
-
for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
135
|
-
src.push("if (sectionPlaneActive" + i + ") {");
|
|
136
|
-
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
137
|
-
src.push("}");
|
|
138
|
-
}
|
|
139
|
-
src.push("if (dist > 0.0) { discard; }");
|
|
140
|
-
src.push("}");
|
|
141
|
-
}
|
|
142
|
-
src.push(" outColor = vec4(0.0, 0.0, 1.0, 1.0); "); // Occluders are blue
|
|
143
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
144
|
-
src.push("gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
145
|
-
}
|
|
146
|
-
src.push("}");
|
|
147
|
-
return src;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import {VBOInstancingPointsRenderer} from "./VBOInstancingPointsRenderer.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @private
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export class VBOInstancingPointsPickDepthRenderer extends VBOInstancingPointsRenderer {
|
|
9
|
-
_getHash() {
|
|
10
|
-
return this._scene._sectionPlanesState.getHash() + this._scene.pointsMaterial.hash;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
_buildVertexShader() {
|
|
14
|
-
const scene = this._scene;
|
|
15
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
16
|
-
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
17
|
-
const pointsMaterial = scene.pointsMaterial._state;
|
|
18
|
-
const src = [];
|
|
19
|
-
|
|
20
|
-
src.push('#version 300 es');
|
|
21
|
-
src.push("// Points instancing pick depth vertex shader");
|
|
22
|
-
|
|
23
|
-
src.push("uniform int renderPass;");
|
|
24
|
-
|
|
25
|
-
src.push("in vec3 position;");
|
|
26
|
-
|
|
27
|
-
if (scene.entityOffsetsEnabled) {
|
|
28
|
-
src.push("in vec3 offset;");
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
src.push("in float flags;");
|
|
32
|
-
src.push("in vec4 modelMatrixCol0;"); // Modeling matrix
|
|
33
|
-
src.push("in vec4 modelMatrixCol1;");
|
|
34
|
-
src.push("in vec4 modelMatrixCol2;");
|
|
35
|
-
|
|
36
|
-
src.push("uniform bool pickInvisible;");
|
|
37
|
-
|
|
38
|
-
this._addMatricesUniformBlockLines(src);
|
|
39
|
-
|
|
40
|
-
this._addRemapClipPosLines(src);
|
|
41
|
-
|
|
42
|
-
src.push("uniform float pointSize;");
|
|
43
|
-
if (pointsMaterial.perspectivePoints) {
|
|
44
|
-
src.push("uniform float nearPlaneHeight;");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
48
|
-
src.push("uniform float logDepthBufFC;");
|
|
49
|
-
src.push("out float vFragDepth;");
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (clipping) {
|
|
53
|
-
src.push("out vec4 vWorldPosition;");
|
|
54
|
-
src.push("out float vFlags;");
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
src.push("out vec4 vViewPosition;");
|
|
58
|
-
src.push("void main(void) {");
|
|
59
|
-
|
|
60
|
-
// pickFlag = NOT_RENDERED | PICK
|
|
61
|
-
// renderPass = PICK
|
|
62
|
-
|
|
63
|
-
src.push(`int pickFlag = int(flags) >> 12 & 0xF;`);
|
|
64
|
-
src.push(`if (pickFlag != renderPass) {`);
|
|
65
|
-
src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"); // Cull vertex
|
|
66
|
-
|
|
67
|
-
src.push("} else {");
|
|
68
|
-
src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");
|
|
69
|
-
src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");
|
|
70
|
-
|
|
71
|
-
if (scene.entityOffsetsEnabled) {
|
|
72
|
-
src.push(" worldPosition.xyz = worldPosition.xyz + offset;");
|
|
73
|
-
}
|
|
74
|
-
src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");
|
|
75
|
-
if (clipping) {
|
|
76
|
-
src.push(" vWorldPosition = worldPosition;");
|
|
77
|
-
src.push(" vFlags = flags;");
|
|
78
|
-
}
|
|
79
|
-
src.push(" vViewPosition = viewPosition;");
|
|
80
|
-
src.push("vec4 clipPos = projMatrix * viewPosition;");
|
|
81
|
-
src.push("gl_Position = remapClipPos(clipPos);");
|
|
82
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
83
|
-
src.push("vFragDepth = 1.0 + clipPos.w;");
|
|
84
|
-
}
|
|
85
|
-
src.push("gl_Position = remapClipPos(clipPos);");
|
|
86
|
-
if (pointsMaterial.perspectivePoints) {
|
|
87
|
-
src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");
|
|
88
|
-
src.push("gl_PointSize = max(gl_PointSize, " + Math.floor(pointsMaterial.minPerspectivePointSize) + ".0);");
|
|
89
|
-
src.push("gl_PointSize = min(gl_PointSize, " + Math.floor(pointsMaterial.maxPerspectivePointSize) + ".0);");
|
|
90
|
-
} else {
|
|
91
|
-
src.push("gl_PointSize = pointSize;");
|
|
92
|
-
}
|
|
93
|
-
src.push("}");
|
|
94
|
-
src.push("}");
|
|
95
|
-
return src;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
_buildFragmentShader() {
|
|
99
|
-
const scene = this._scene;
|
|
100
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
101
|
-
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
102
|
-
const src = [];
|
|
103
|
-
src.push('#version 300 es');
|
|
104
|
-
src.push("// Points instancing pick depth fragment shader");
|
|
105
|
-
|
|
106
|
-
src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
|
|
107
|
-
src.push("precision highp float;");
|
|
108
|
-
src.push("precision highp int;");
|
|
109
|
-
src.push("#else");
|
|
110
|
-
src.push("precision mediump float;");
|
|
111
|
-
src.push("precision mediump int;");
|
|
112
|
-
src.push("#endif");
|
|
113
|
-
|
|
114
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
115
|
-
src.push("uniform float logDepthBufFC;");
|
|
116
|
-
src.push("in float vFragDepth;");
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
src.push("uniform float pickZNear;");
|
|
120
|
-
src.push("uniform float pickZFar;");
|
|
121
|
-
|
|
122
|
-
if (clipping) {
|
|
123
|
-
src.push("in vec4 vWorldPosition;");
|
|
124
|
-
src.push("in float vFlags;");
|
|
125
|
-
for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
126
|
-
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
127
|
-
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
128
|
-
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
src.push("in vec4 vViewPosition;");
|
|
132
|
-
src.push("vec4 packDepth(const in float depth) {");
|
|
133
|
-
src.push(" const vec4 bitShift = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);");
|
|
134
|
-
src.push(" const vec4 bitMask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);");
|
|
135
|
-
src.push(" vec4 res = fract(depth * bitShift);");
|
|
136
|
-
src.push(" res -= res.xxyz * bitMask;");
|
|
137
|
-
src.push(" return res;");
|
|
138
|
-
src.push("}");
|
|
139
|
-
src.push("out vec4 outColor;");
|
|
140
|
-
src.push("void main(void) {");
|
|
141
|
-
|
|
142
|
-
if (scene.pointsMaterial.roundPoints) {
|
|
143
|
-
src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");
|
|
144
|
-
src.push(" float r = dot(cxy, cxy);");
|
|
145
|
-
src.push(" if (r > 1.0) {");
|
|
146
|
-
src.push(" discard;");
|
|
147
|
-
src.push(" }");
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (clipping) {
|
|
151
|
-
src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
|
|
152
|
-
src.push(" if (clippable) {");
|
|
153
|
-
src.push(" float dist = 0.0;");
|
|
154
|
-
for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
155
|
-
src.push("if (sectionPlaneActive" + i + ") {");
|
|
156
|
-
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
157
|
-
src.push("}");
|
|
158
|
-
}
|
|
159
|
-
src.push("if (dist > 0.0) { discard; }");
|
|
160
|
-
src.push("}");
|
|
161
|
-
}
|
|
162
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
163
|
-
src.push("gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
164
|
-
}
|
|
165
|
-
src.push(" float zNormalizedDepth = abs((pickZNear + vViewPosition.z) / (pickZFar - pickZNear));");
|
|
166
|
-
src.push(" outColor = packDepth(zNormalizedDepth); "); // Must be linear depth
|
|
167
|
-
src.push("}");
|
|
168
|
-
return src;
|
|
169
|
-
}
|
|
170
|
-
}
|