@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
|
@@ -1,664 +0,0 @@
|
|
|
1
|
-
import {createRTCViewMat, getPlaneRTCPos} from "../../math/rtcCoords.js";
|
|
2
|
-
import {math} from "../../math/math.js";
|
|
3
|
-
import {Program} from "../../webgl/Program.js";
|
|
4
|
-
import {stats} from "../../stats.js"
|
|
5
|
-
import {WEBGL_INFO} from "../../webglInfo.js";
|
|
6
|
-
import {RENDER_PASSES} from "./../RENDER_PASSES.js";
|
|
7
|
-
|
|
8
|
-
const defaultColor = new Float32Array([1, 1, 1, 1]);
|
|
9
|
-
const edgesDefaultColor = new Float32Array([0, 0, 0, 1]);
|
|
10
|
-
|
|
11
|
-
const tempVec4 = math.vec4();
|
|
12
|
-
const tempVec3a = math.vec3();
|
|
13
|
-
const tempVec3c = math.vec3();
|
|
14
|
-
const tempMat4a = math.mat4();
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @private
|
|
18
|
-
*/
|
|
19
|
-
export class VBORenderer {
|
|
20
|
-
constructor(scene, withSAO = false, {instancing = false, edges = false, useAlphaCutoff = false} = {}) {
|
|
21
|
-
this._scene = scene;
|
|
22
|
-
this._withSAO = withSAO;
|
|
23
|
-
this._instancing = instancing;
|
|
24
|
-
this._edges = edges;
|
|
25
|
-
this._useAlphaCutoff = useAlphaCutoff;
|
|
26
|
-
this._hash = this._getHash();
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Matrices Uniform Block Buffer
|
|
30
|
-
*
|
|
31
|
-
* In shaders, matrices in the Matrices Uniform Block MUST be set in this order:
|
|
32
|
-
* - worldMatrix
|
|
33
|
-
* - viewMatrix
|
|
34
|
-
* - projMatrix
|
|
35
|
-
* - positionsDecodeMatrix
|
|
36
|
-
* - worldNormalMatrix
|
|
37
|
-
* - viewNormalMatrix
|
|
38
|
-
*/
|
|
39
|
-
this._matricesUniformBlockBufferBindingPoint = 0;
|
|
40
|
-
|
|
41
|
-
this._matricesUniformBlockBuffer = this._scene.canvas.gl.createBuffer();
|
|
42
|
-
this._matricesUniformBlockBufferData = new Float32Array(4 * 4 * 6); // there is 6 mat4
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* A Vertex Array Object by Layer
|
|
46
|
-
*/
|
|
47
|
-
this._vaoCache = new WeakMap();
|
|
48
|
-
|
|
49
|
-
this._allocate();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Should be overrided by subclasses if it does not only "depend" on section planes state.
|
|
54
|
-
* @returns { string }
|
|
55
|
-
*/
|
|
56
|
-
_getHash() {
|
|
57
|
-
return this._scene._sectionPlanesState.getHash();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
_buildShader() {
|
|
61
|
-
return {
|
|
62
|
-
vertex: this._buildVertexShader(),
|
|
63
|
-
fragment: this._buildFragmentShader()
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
_buildVertexShader() {
|
|
68
|
-
return [""];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
_buildFragmentShader() {
|
|
72
|
-
return [""];
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
_addMatricesUniformBlockLines(src, normals = false) {
|
|
76
|
-
src.push("uniform Matrices {");
|
|
77
|
-
src.push(" mat4 worldMatrix;");
|
|
78
|
-
src.push(" mat4 viewMatrix;");
|
|
79
|
-
src.push(" mat4 projMatrix;");
|
|
80
|
-
src.push(" mat4 positionsDecodeMatrix;");
|
|
81
|
-
if (normals) {
|
|
82
|
-
src.push(" mat4 worldNormalMatrix;");
|
|
83
|
-
src.push(" mat4 viewNormalMatrix;");
|
|
84
|
-
}
|
|
85
|
-
src.push("};");
|
|
86
|
-
return src;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
_addRemapClipPosLines(src, viewportSize = 1) {
|
|
90
|
-
src.push("uniform vec2 drawingBufferSize;");
|
|
91
|
-
src.push("uniform vec2 pickClipPos;");
|
|
92
|
-
|
|
93
|
-
src.push("vec4 remapClipPos(vec4 clipPos) {");
|
|
94
|
-
src.push(" clipPos.xy /= clipPos.w;");
|
|
95
|
-
if (viewportSize === 1) {
|
|
96
|
-
src.push(" clipPos.xy = (clipPos.xy - pickClipPos) * drawingBufferSize;");
|
|
97
|
-
} else {
|
|
98
|
-
src.push(` clipPos.xy = (clipPos.xy - pickClipPos) * (drawingBufferSize / float(${viewportSize}));`);
|
|
99
|
-
}
|
|
100
|
-
src.push(" clipPos.xy *= clipPos.w;")
|
|
101
|
-
src.push(" return clipPos;")
|
|
102
|
-
src.push("}");
|
|
103
|
-
return src;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
getValid() {
|
|
107
|
-
return this._hash === this._getHash();
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
setSectionPlanesStateUniforms(layer) {
|
|
111
|
-
const scene = this._scene;
|
|
112
|
-
const {gl} = scene.canvas;
|
|
113
|
-
const {model, layerIndex} = layer;
|
|
114
|
-
|
|
115
|
-
const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
|
|
116
|
-
const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
|
|
117
|
-
if (numAllocatedSectionPlanes > 0) {
|
|
118
|
-
const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
|
|
119
|
-
const baseIndex = layerIndex * numSectionPlanes;
|
|
120
|
-
const renderFlags = model.renderFlags;
|
|
121
|
-
if (scene.crossSections) {
|
|
122
|
-
gl.uniform4fv(this._uSliceColor, scene.crossSections.sliceColor);
|
|
123
|
-
gl.uniform1f(this._uSliceThickness, scene.crossSections.sliceThickness);
|
|
124
|
-
}
|
|
125
|
-
for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
|
|
126
|
-
const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
|
|
127
|
-
if (sectionPlaneUniforms) {
|
|
128
|
-
if (sectionPlaneIndex < numSectionPlanes) {
|
|
129
|
-
const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
|
|
130
|
-
gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
|
|
131
|
-
if (active) {
|
|
132
|
-
const sectionPlane = sectionPlanes[sectionPlaneIndex];
|
|
133
|
-
const origin = layer._state.origin;
|
|
134
|
-
if (origin) {
|
|
135
|
-
const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a, model.matrix);
|
|
136
|
-
gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
|
|
137
|
-
} else {
|
|
138
|
-
gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
|
|
139
|
-
}
|
|
140
|
-
gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
|
|
141
|
-
}
|
|
142
|
-
} else {
|
|
143
|
-
gl.uniform1i(sectionPlaneUniforms.active, 0);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
_allocate() {
|
|
152
|
-
const scene = this._scene;
|
|
153
|
-
const gl = scene.canvas.gl;
|
|
154
|
-
const lightsState = scene._lightsState;
|
|
155
|
-
|
|
156
|
-
this._program = new Program(gl, this._buildShader());
|
|
157
|
-
|
|
158
|
-
if (this._program.errors) {
|
|
159
|
-
this.errors = this._program.errors;
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const program = this._program;
|
|
164
|
-
|
|
165
|
-
this._uRenderPass = program.getLocation("renderPass");
|
|
166
|
-
|
|
167
|
-
this._uColor = program.getLocation("color");
|
|
168
|
-
if (!this._uColor) {
|
|
169
|
-
// some shader may have color as attribute, in this case the uniform must be renamed silhouetteColor
|
|
170
|
-
this._uColor = program.getLocation("silhouetteColor");
|
|
171
|
-
}
|
|
172
|
-
this._uUVDecodeMatrix = program.getLocation("uvDecodeMatrix");
|
|
173
|
-
this._uPickInvisible = program.getLocation("pickInvisible");
|
|
174
|
-
this._uGammaFactor = program.getLocation("gammaFactor");
|
|
175
|
-
|
|
176
|
-
gl.uniformBlockBinding(
|
|
177
|
-
program.handle,
|
|
178
|
-
gl.getUniformBlockIndex(program.handle, "Matrices"),
|
|
179
|
-
this._matricesUniformBlockBufferBindingPoint
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
this._uShadowViewMatrix = program.getLocation("shadowViewMatrix");
|
|
183
|
-
this._uShadowProjMatrix = program.getLocation("shadowProjMatrix");
|
|
184
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
185
|
-
this._uZFar = program.getLocation("zFar");
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
this._uLightAmbient = program.getLocation("lightAmbient");
|
|
189
|
-
this._uLightColor = [];
|
|
190
|
-
this._uLightDir = [];
|
|
191
|
-
this._uLightPos = [];
|
|
192
|
-
this._uLightAttenuation = [];
|
|
193
|
-
|
|
194
|
-
// TODO add a gard to prevent light params if not affected by light ?
|
|
195
|
-
const lights = lightsState.lights;
|
|
196
|
-
let light;
|
|
197
|
-
|
|
198
|
-
for (let i = 0, len = lights.length; i < len; i++) {
|
|
199
|
-
light = lights[i];
|
|
200
|
-
switch (light.type) {
|
|
201
|
-
case "dir":
|
|
202
|
-
this._uLightColor[i] = program.getLocation("lightColor" + i);
|
|
203
|
-
this._uLightPos[i] = null;
|
|
204
|
-
this._uLightDir[i] = program.getLocation("lightDir" + i);
|
|
205
|
-
break;
|
|
206
|
-
case "point":
|
|
207
|
-
this._uLightColor[i] = program.getLocation("lightColor" + i);
|
|
208
|
-
this._uLightPos[i] = program.getLocation("lightPos" + i);
|
|
209
|
-
this._uLightDir[i] = null;
|
|
210
|
-
this._uLightAttenuation[i] = program.getLocation("lightAttenuation" + i);
|
|
211
|
-
break;
|
|
212
|
-
case "spot":
|
|
213
|
-
this._uLightColor[i] = program.getLocation("lightColor" + i);
|
|
214
|
-
this._uLightPos[i] = program.getLocation("lightPos" + i);
|
|
215
|
-
this._uLightDir[i] = program.getLocation("lightDir" + i);
|
|
216
|
-
this._uLightAttenuation[i] = program.getLocation("lightAttenuation" + i);
|
|
217
|
-
break;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
if (lightsState.reflectionMaps.length > 0) {
|
|
222
|
-
this._uReflectionMap = "reflectionMap";
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (lightsState.lightMaps.length > 0) {
|
|
226
|
-
this._uLightMap = "lightMap";
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
this._uSectionPlanes = [];
|
|
230
|
-
|
|
231
|
-
for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
|
|
232
|
-
this._uSectionPlanes.push({
|
|
233
|
-
active: program.getLocation("sectionPlaneActive" + i),
|
|
234
|
-
pos: program.getLocation("sectionPlanePos" + i),
|
|
235
|
-
dir: program.getLocation("sectionPlaneDir" + i)
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
this._aPosition = program.getAttribute("position");
|
|
240
|
-
this._aOffset = program.getAttribute("offset");
|
|
241
|
-
this._aNormal = program.getAttribute("normal");
|
|
242
|
-
this._aUV = program.getAttribute("uv");
|
|
243
|
-
this._aColor = program.getAttribute("color");
|
|
244
|
-
this._aMetallicRoughness = program.getAttribute("metallicRoughness");
|
|
245
|
-
this._aFlags = program.getAttribute("flags");
|
|
246
|
-
this._aPickColor = program.getAttribute("pickColor");
|
|
247
|
-
this._uPickZNear = program.getLocation("pickZNear");
|
|
248
|
-
this._uPickZFar = program.getLocation("pickZFar");
|
|
249
|
-
this._uPickClipPos = program.getLocation("pickClipPos");
|
|
250
|
-
this._uDrawingBufferSize = program.getLocation("drawingBufferSize");
|
|
251
|
-
|
|
252
|
-
this._uColorMap = "uColorMap";
|
|
253
|
-
this._uMetallicRoughMap = "uMetallicRoughMap";
|
|
254
|
-
this._uEmissiveMap = "uEmissiveMap";
|
|
255
|
-
this._uNormalMap = "uNormalMap";
|
|
256
|
-
this._uAOMap = "uAOMap";
|
|
257
|
-
|
|
258
|
-
if (this._instancing) {
|
|
259
|
-
|
|
260
|
-
this._aModelMatrix = program.getAttribute("modelMatrix");
|
|
261
|
-
|
|
262
|
-
this._aModelMatrixCol0 = program.getAttribute("modelMatrixCol0");
|
|
263
|
-
this._aModelMatrixCol1 = program.getAttribute("modelMatrixCol1");
|
|
264
|
-
this._aModelMatrixCol2 = program.getAttribute("modelMatrixCol2");
|
|
265
|
-
|
|
266
|
-
this._aModelNormalMatrixCol0 = program.getAttribute("modelNormalMatrixCol0");
|
|
267
|
-
this._aModelNormalMatrixCol1 = program.getAttribute("modelNormalMatrixCol1");
|
|
268
|
-
this._aModelNormalMatrixCol2 = program.getAttribute("modelNormalMatrixCol2");
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
if (this._withSAO) {
|
|
272
|
-
this._uOcclusionTexture = "uOcclusionTexture";
|
|
273
|
-
this._uSAOParams = program.getLocation("uSAOParams");
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
if (this._useAlphaCutoff) {
|
|
277
|
-
this._alphaCutoffLocation = program.getLocation("materialAlphaCutoff");
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
281
|
-
this._uLogDepthBufFC = program.getLocation("logDepthBufFC");
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
if (scene.pointsMaterial._state.filterIntensity) {
|
|
285
|
-
this._uIntensityRange = program.getLocation("intensityRange");
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
this._uPointSize = program.getLocation("pointSize");
|
|
289
|
-
this._uNearPlaneHeight = program.getLocation("nearPlaneHeight");
|
|
290
|
-
|
|
291
|
-
if (scene.crossSections) {
|
|
292
|
-
this._uSliceColor = program.getLocation("sliceColor");
|
|
293
|
-
this._uSliceThickness = program.getLocation("sliceThickness");
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
_bindProgram(frameCtx) {
|
|
298
|
-
const scene = this._scene;
|
|
299
|
-
const gl = scene.canvas.gl;
|
|
300
|
-
const program = this._program;
|
|
301
|
-
const lightsState = scene._lightsState;
|
|
302
|
-
const lights = lightsState.lights;
|
|
303
|
-
|
|
304
|
-
program.bind();
|
|
305
|
-
|
|
306
|
-
frameCtx.textureUnit = 0;
|
|
307
|
-
|
|
308
|
-
if (this._uLightAmbient) {
|
|
309
|
-
gl.uniform4fv(this._uLightAmbient, lightsState.getAmbientColorAndIntensity());
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
if (this._uGammaFactor) {
|
|
313
|
-
gl.uniform1f(this._uGammaFactor, scene.gammaFactor);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
for (let i = 0, len = lights.length; i < len; i++) {
|
|
317
|
-
|
|
318
|
-
const light = lights[i];
|
|
319
|
-
|
|
320
|
-
if (this._uLightColor[i]) {
|
|
321
|
-
gl.uniform4f(this._uLightColor[i], light.color[0], light.color[1], light.color[2], light.intensity);
|
|
322
|
-
}
|
|
323
|
-
if (this._uLightPos[i]) {
|
|
324
|
-
gl.uniform3fv(this._uLightPos[i], light.pos);
|
|
325
|
-
if (this._uLightAttenuation[i]) {
|
|
326
|
-
gl.uniform1f(this._uLightAttenuation[i], light.attenuation);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
if (this._uLightDir[i]) {
|
|
330
|
-
gl.uniform3fv(this._uLightDir[i], light.dir);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
_makeVAO(state) {
|
|
336
|
-
const gl = this._scene.canvas.gl;
|
|
337
|
-
const vao = gl.createVertexArray();
|
|
338
|
-
gl.bindVertexArray(vao);
|
|
339
|
-
|
|
340
|
-
if (this._instancing) {
|
|
341
|
-
this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);
|
|
342
|
-
this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);
|
|
343
|
-
this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);
|
|
344
|
-
|
|
345
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol0.location, 1);
|
|
346
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 1);
|
|
347
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 1);
|
|
348
|
-
|
|
349
|
-
if (this._aModelNormalMatrixCol0) {
|
|
350
|
-
this._aModelNormalMatrixCol0.bindArrayBuffer(state.modelNormalMatrixCol0Buf);
|
|
351
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol0.location, 1);
|
|
352
|
-
}
|
|
353
|
-
if (this._aModelNormalMatrixCol1) {
|
|
354
|
-
this._aModelNormalMatrixCol1.bindArrayBuffer(state.modelNormalMatrixCol1Buf);
|
|
355
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol1.location, 1);
|
|
356
|
-
}
|
|
357
|
-
if (this._aModelNormalMatrixCol2) {
|
|
358
|
-
this._aModelNormalMatrixCol2.bindArrayBuffer(state.modelNormalMatrixCol2Buf);
|
|
359
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol2.location, 1);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
this._aPosition.bindArrayBuffer(state.positionsBuf);
|
|
365
|
-
|
|
366
|
-
if (this._aUV) {
|
|
367
|
-
this._aUV.bindArrayBuffer(state.uvBuf);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
if (this._aNormal) {
|
|
371
|
-
this._aNormal.bindArrayBuffer(state.normalsBuf);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
if (this._aMetallicRoughness) {
|
|
375
|
-
this._aMetallicRoughness.bindArrayBuffer(state.metallicRoughnessBuf);
|
|
376
|
-
if (this._instancing) {
|
|
377
|
-
gl.vertexAttribDivisor(this._aMetallicRoughness.location, 1);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
if (this._aColor) {
|
|
382
|
-
this._aColor.bindArrayBuffer(state.colorsBuf);
|
|
383
|
-
if (this._instancing && state.colorsBuf) {
|
|
384
|
-
gl.vertexAttribDivisor(this._aColor.location, 1);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
if (this._aFlags) {
|
|
389
|
-
this._aFlags.bindArrayBuffer(state.flagsBuf);
|
|
390
|
-
if (this._instancing) {
|
|
391
|
-
gl.vertexAttribDivisor(this._aFlags.location, 1);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
if (this._aOffset) {
|
|
396
|
-
this._aOffset.bindArrayBuffer(state.offsetsBuf);
|
|
397
|
-
if (this._instancing) {
|
|
398
|
-
gl.vertexAttribDivisor(this._aOffset.location, 1);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
if (this._aPickColor) {
|
|
403
|
-
this._aPickColor.bindArrayBuffer(state.pickColorsBuf);
|
|
404
|
-
if (this._instancing) {
|
|
405
|
-
gl.vertexAttribDivisor(this._aPickColor.location, 1);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
if (this._instancing) {
|
|
410
|
-
if (this._edges && state.edgeIndicesBuf) {
|
|
411
|
-
state.edgeIndicesBuf.bind();
|
|
412
|
-
} else {
|
|
413
|
-
if (state.indicesBuf) {
|
|
414
|
-
state.indicesBuf.bind();
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
} else {
|
|
418
|
-
if (this._edges && state.edgeIndicesBuf) {
|
|
419
|
-
state.edgeIndicesBuf.bind();
|
|
420
|
-
} else {
|
|
421
|
-
if (state.indicesBuf) {
|
|
422
|
-
state.indicesBuf.bind();
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
return vao;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
drawLayer(frameCtx, layer, renderPass, {colorUniform = false, incrementDrawState = false} = {}) {
|
|
431
|
-
const maxTextureUnits = WEBGL_INFO.MAX_TEXTURE_IMAGE_UNITS;
|
|
432
|
-
|
|
433
|
-
const scene = this._scene;
|
|
434
|
-
const gl = scene.canvas.gl;
|
|
435
|
-
const {_state: state, model} = layer;
|
|
436
|
-
const {textureSet, origin, positionsDecodeMatrix} = state;
|
|
437
|
-
const lightsState = scene._lightsState;
|
|
438
|
-
const pointsMaterial = scene.pointsMaterial;
|
|
439
|
-
const {camera} = model.scene;
|
|
440
|
-
const {viewNormalMatrix, project} = camera;
|
|
441
|
-
const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix
|
|
442
|
-
const {position, rotationMatrix, worldNormalMatrix} = model;
|
|
443
|
-
|
|
444
|
-
if (!this._program) {
|
|
445
|
-
this._allocate();
|
|
446
|
-
if (this.errors) {
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
if (frameCtx.lastProgramId !== this._program.id) {
|
|
452
|
-
frameCtx.lastProgramId = this._program.id;
|
|
453
|
-
this._bindProgram(frameCtx);
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
if (this._vaoCache.has(layer)) {
|
|
457
|
-
gl.bindVertexArray(this._vaoCache.get(layer));
|
|
458
|
-
} else {
|
|
459
|
-
this._vaoCache.set(layer, this._makeVAO(state))
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
let offset = 0;
|
|
463
|
-
const mat4Size = 4 * 4;
|
|
464
|
-
|
|
465
|
-
this._matricesUniformBlockBufferData.set(rotationMatrix, 0);
|
|
466
|
-
|
|
467
|
-
const gotOrigin = (origin[0] !== 0 || origin[1] !== 0 || origin[2] !== 0);
|
|
468
|
-
const gotPosition = (position[0] !== 0 || position[1] !== 0 || position[2] !== 0);
|
|
469
|
-
if (gotOrigin || gotPosition) {
|
|
470
|
-
const rtcOrigin = tempVec3a;
|
|
471
|
-
if (gotOrigin) {
|
|
472
|
-
const rotatedOrigin = math.transformPoint3(rotationMatrix, origin, tempVec3c);
|
|
473
|
-
rtcOrigin[0] = rotatedOrigin[0];
|
|
474
|
-
rtcOrigin[1] = rotatedOrigin[1];
|
|
475
|
-
rtcOrigin[2] = rotatedOrigin[2];
|
|
476
|
-
} else {
|
|
477
|
-
rtcOrigin[0] = 0;
|
|
478
|
-
rtcOrigin[1] = 0;
|
|
479
|
-
rtcOrigin[2] = 0;
|
|
480
|
-
}
|
|
481
|
-
rtcOrigin[0] += position[0];
|
|
482
|
-
rtcOrigin[1] += position[1];
|
|
483
|
-
rtcOrigin[2] += position[2];
|
|
484
|
-
this._matricesUniformBlockBufferData.set(createRTCViewMat(viewMatrix, rtcOrigin, tempMat4a), offset += mat4Size);
|
|
485
|
-
} else {
|
|
486
|
-
this._matricesUniformBlockBufferData.set(viewMatrix, offset += mat4Size);
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
this._matricesUniformBlockBufferData.set(frameCtx.pickProjMatrix || project.matrix, offset += mat4Size);
|
|
490
|
-
this._matricesUniformBlockBufferData.set(positionsDecodeMatrix, offset += mat4Size);
|
|
491
|
-
this._matricesUniformBlockBufferData.set(worldNormalMatrix, offset += mat4Size);
|
|
492
|
-
this._matricesUniformBlockBufferData.set(viewNormalMatrix, offset += mat4Size);
|
|
493
|
-
|
|
494
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, this._matricesUniformBlockBuffer);
|
|
495
|
-
gl.bufferData(gl.UNIFORM_BUFFER, this._matricesUniformBlockBufferData, gl.DYNAMIC_DRAW);
|
|
496
|
-
|
|
497
|
-
gl.bindBufferBase(
|
|
498
|
-
gl.UNIFORM_BUFFER,
|
|
499
|
-
this._matricesUniformBlockBufferBindingPoint,
|
|
500
|
-
this._matricesUniformBlockBuffer);
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
gl.uniform1i(this._uRenderPass, renderPass);
|
|
504
|
-
|
|
505
|
-
this.setSectionPlanesStateUniforms(layer);
|
|
506
|
-
|
|
507
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
508
|
-
if (this._uLogDepthBufFC) {
|
|
509
|
-
const logDepthBufFC = 2.0 / (Math.log(frameCtx.pickZFar + 1.0) / Math.LN2); // TODO: Far from pick project matrix?
|
|
510
|
-
gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
|
|
511
|
-
}
|
|
512
|
-
if (this._uZFar) {
|
|
513
|
-
gl.uniform1f(this._uZFar, scene.camera.project.far)
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
if (this._uPickInvisible) {
|
|
518
|
-
gl.uniform1i(this._uPickInvisible, frameCtx.pickInvisible);
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
if (this._uPickZNear) {
|
|
522
|
-
gl.uniform1f(this._uPickZNear, frameCtx.pickZNear);
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
if (this._uPickZFar) {
|
|
526
|
-
gl.uniform1f(this._uPickZFar, frameCtx.pickZFar);
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
if (this._uPickClipPos) {
|
|
530
|
-
gl.uniform2fv(this._uPickClipPos, frameCtx.pickClipPos);
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
if (this._uDrawingBufferSize) {
|
|
534
|
-
gl.uniform2f(this._uDrawingBufferSize, gl.drawingBufferWidth, gl.drawingBufferHeight);
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
if (this._uUVDecodeMatrix) {
|
|
538
|
-
gl.uniformMatrix3fv(this._uUVDecodeMatrix, false, state.uvDecodeMatrix);
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
if (this._uIntensityRange && pointsMaterial.filterIntensity) {
|
|
542
|
-
gl.uniform2f(this._uIntensityRange, pointsMaterial.minIntensity, pointsMaterial.maxIntensity);
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
if (this._uPointSize) {
|
|
546
|
-
gl.uniform1f(this._uPointSize, pointsMaterial.pointSize);
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
if (this._uNearPlaneHeight) {
|
|
550
|
-
const nearPlaneHeight = (scene.camera.projection === "ortho") ?
|
|
551
|
-
1.0
|
|
552
|
-
: (gl.drawingBufferHeight / (2 * Math.tan(0.5 * scene.camera.perspective.fov * Math.PI / 180.0)));
|
|
553
|
-
gl.uniform1f(this._uNearPlaneHeight, nearPlaneHeight);
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
if (textureSet) {
|
|
557
|
-
const {
|
|
558
|
-
colorTexture,
|
|
559
|
-
metallicRoughnessTexture,
|
|
560
|
-
emissiveTexture,
|
|
561
|
-
normalsTexture,
|
|
562
|
-
occlusionTexture,
|
|
563
|
-
} = textureSet;
|
|
564
|
-
|
|
565
|
-
if (this._uColorMap && colorTexture) {
|
|
566
|
-
this._program.bindTexture(this._uColorMap, colorTexture.texture, frameCtx.textureUnit);
|
|
567
|
-
frameCtx.textureUnit = (frameCtx.textureUnit + 1) % maxTextureUnits;
|
|
568
|
-
}
|
|
569
|
-
if (this._uMetallicRoughMap && metallicRoughnessTexture) {
|
|
570
|
-
this._program.bindTexture(this._uMetallicRoughMap, metallicRoughnessTexture.texture, frameCtx.textureUnit);
|
|
571
|
-
frameCtx.textureUnit = (frameCtx.textureUnit + 1) % maxTextureUnits;
|
|
572
|
-
}
|
|
573
|
-
if (this._uEmissiveMap && emissiveTexture) {
|
|
574
|
-
this._program.bindTexture(this._uEmissiveMap, emissiveTexture.texture, frameCtx.textureUnit);
|
|
575
|
-
frameCtx.textureUnit = (frameCtx.textureUnit + 1) % maxTextureUnits;
|
|
576
|
-
}
|
|
577
|
-
if (this._uNormalMap && normalsTexture) {
|
|
578
|
-
this._program.bindTexture(this._uNormalMap, normalsTexture.texture, frameCtx.textureUnit);
|
|
579
|
-
frameCtx.textureUnit = (frameCtx.textureUnit + 1) % maxTextureUnits;
|
|
580
|
-
}
|
|
581
|
-
if (this._uAOMap && occlusionTexture) {
|
|
582
|
-
this._program.bindTexture(this._uAOMap, occlusionTexture.texture, frameCtx.textureUnit);
|
|
583
|
-
frameCtx.textureUnit = (frameCtx.textureUnit + 1) % maxTextureUnits;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
if (lightsState.reflectionMaps.length > 0 && lightsState.reflectionMaps[0].texture && this._uReflectionMap) {
|
|
589
|
-
this._program.bindTexture(this._uReflectionMap, lightsState.reflectionMaps[0].texture, frameCtx.textureUnit);
|
|
590
|
-
frameCtx.textureUnit = (frameCtx.textureUnit + 1) % maxTextureUnits;
|
|
591
|
-
frameCtx.bindTexture++;
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
if (lightsState.lightMaps.length > 0 && lightsState.lightMaps[0].texture && this._uLightMap) {
|
|
595
|
-
this._program.bindTexture(this._uLightMap, lightsState.lightMaps[0].texture, frameCtx.textureUnit);
|
|
596
|
-
frameCtx.textureUnit = (frameCtx.textureUnit + 1) % maxTextureUnits;
|
|
597
|
-
frameCtx.bindTexture++;
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
if (this._withSAO) {
|
|
601
|
-
const sao = scene.sao;
|
|
602
|
-
const saoEnabled = sao.possible;
|
|
603
|
-
if (saoEnabled) {
|
|
604
|
-
const viewportWidth = gl.drawingBufferWidth;
|
|
605
|
-
const viewportHeight = gl.drawingBufferHeight;
|
|
606
|
-
tempVec4[0] = viewportWidth;
|
|
607
|
-
tempVec4[1] = viewportHeight;
|
|
608
|
-
tempVec4[2] = sao.blendCutoff;
|
|
609
|
-
tempVec4[3] = sao.blendFactor;
|
|
610
|
-
gl.uniform4fv(this._uSAOParams, tempVec4);
|
|
611
|
-
this._program.bindTexture(this._uOcclusionTexture, frameCtx.occlusionTexture, frameCtx.textureUnit);
|
|
612
|
-
frameCtx.textureUnit = (frameCtx.textureUnit + 1) % maxTextureUnits;
|
|
613
|
-
frameCtx.bindTexture++;
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
if (this._useAlphaCutoff) {
|
|
618
|
-
gl.uniform1f(this._alphaCutoffLocation, textureSet.alphaCutoff);
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
if (colorUniform) {
|
|
622
|
-
const colorKey = this._edges ? "edgeColor" : "fillColor";
|
|
623
|
-
const alphaKey = this._edges ? "edgeAlpha" : "fillAlpha";
|
|
624
|
-
|
|
625
|
-
if (renderPass === RENDER_PASSES[`${this._edges ? "EDGES" : "SILHOUETTE"}_XRAYED`]) {
|
|
626
|
-
const material = scene.xrayMaterial._state;
|
|
627
|
-
const color = material[colorKey];
|
|
628
|
-
const alpha = material[alphaKey];
|
|
629
|
-
gl.uniform4f(this._uColor, color[0], color[1], color[2], alpha);
|
|
630
|
-
|
|
631
|
-
} else if (renderPass === RENDER_PASSES[`${this._edges ? "EDGES" : "SILHOUETTE"}_HIGHLIGHTED`]) {
|
|
632
|
-
const material = scene.highlightMaterial._state;
|
|
633
|
-
const color = material[colorKey];
|
|
634
|
-
const alpha = material[alphaKey];
|
|
635
|
-
gl.uniform4f(this._uColor, color[0], color[1], color[2], alpha);
|
|
636
|
-
|
|
637
|
-
} else if (renderPass === RENDER_PASSES[`${this._edges ? "EDGES" : "SILHOUETTE"}_SELECTED`]) {
|
|
638
|
-
const material = scene.selectedMaterial._state;
|
|
639
|
-
const color = material[colorKey];
|
|
640
|
-
const alpha = material[alphaKey];
|
|
641
|
-
gl.uniform4f(this._uColor, color[0], color[1], color[2], alpha);
|
|
642
|
-
|
|
643
|
-
} else {
|
|
644
|
-
gl.uniform4fv(this._uColor, this._edges ? edgesDefaultColor : defaultColor);
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
this._draw({state, frameCtx, incrementDrawState});
|
|
649
|
-
|
|
650
|
-
gl.bindVertexArray(null);
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
webglContextRestored() {
|
|
654
|
-
this._program = null;
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
destroy() {
|
|
658
|
-
if (this._program) {
|
|
659
|
-
this._program.destroy();
|
|
660
|
-
}
|
|
661
|
-
this._program = null;
|
|
662
|
-
stats.memory.programs--;
|
|
663
|
-
}
|
|
664
|
-
}
|