@xeokit/xeokit-sdk 2.4.2-beta-21 → 2.4.2-beta-23
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 +750 -598
- package/dist/xeokit-sdk.es.js +750 -598
- package/dist/xeokit-sdk.es5.js +227 -198
- package/dist/xeokit-sdk.min.cjs.js +4 -4
- package/dist/xeokit-sdk.min.es.js +4 -4
- package/dist/xeokit-sdk.min.es5.js +3 -3
- package/package.json +1 -1
- package/src/viewer/Viewer.js +7 -1
- package/src/viewer/scene/mesh/draw/DrawRenderer.js +18 -8
- package/src/viewer/scene/mesh/draw/DrawShaderSource.js +8 -8
- package/src/viewer/scene/mesh/emphasis/EmphasisEdgesRenderer.js +19 -9
- package/src/viewer/scene/mesh/emphasis/EmphasisEdgesShaderSource.js +3 -3
- package/src/viewer/scene/mesh/emphasis/EmphasisFillRenderer.js +19 -9
- package/src/viewer/scene/mesh/emphasis/EmphasisFillShaderSource.js +3 -3
- package/src/viewer/scene/mesh/occlusion/OcclusionRenderer.js +18 -8
- package/src/viewer/scene/mesh/occlusion/OcclusionShaderSource.js +3 -3
- package/src/viewer/scene/mesh/pick/PickMeshRenderer.js +18 -8
- package/src/viewer/scene/mesh/pick/PickMeshShaderSource.js +3 -3
- package/src/viewer/scene/mesh/pick/PickTriangleRenderer.js +18 -8
- package/src/viewer/scene/mesh/pick/PickTriangleShaderSource.js +3 -3
- package/src/viewer/scene/mesh/shadow/ShadowRenderer.js +1 -1
- package/src/viewer/scene/mesh/shadow/ShadowShaderSource.js +3 -3
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureColorRenderer.js +22 -17
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureDepthRenderer.js +22 -21
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureEdgesColorRenderer.js +7 -10
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureEdgesRenderer.js +22 -19
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureNormalsRenderer.js +22 -18
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureOcclusionRenderer.js +22 -17
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickDepthRenderer.js +22 -18
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickMeshRenderer.js +59 -55
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickNormalsFlatRenderer.js +22 -20
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickNormalsRenderer.js +22 -18
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSilhouetteRenderer.js +22 -19
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSnapDepthBufInitRenderer.js +22 -19
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSnapDepthRenderer.js +22 -19
- package/src/viewer/scene/model/vbo/VBOSceneModelRenderers.js +21 -16
- package/src/viewer/scene/model/vbo/linesBatching/renderers/LinesBatchingColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/linesBatching/renderers/LinesBatchingSilhouetteRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/linesInstancing/renderers/LinesInstancingColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/linesInstancing/renderers/LinesInstancingSilhouetteRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingOcclusionRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingPickDepthRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingPickMeshRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingShadowRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingSilhouetteRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingDepthRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingOcclusionRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingPickDepthRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingPickMeshRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingShadowRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingSilhouetteRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/snapBatching/SnapBatchingDepthBufInitRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/snapBatching/SnapBatchingDepthRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/snapInstancing/SnapInstancingDepthBufInitRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/snapInstancing/SnapInstancingDepthRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingColorTextureRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingDepthRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingEdgesColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingEdgesRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingFlatColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingNormalsRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingOcclusionRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPBRRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickDepthRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickMeshRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickNormalsFlatRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickNormalsRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingShadowRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingSilhouetteRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingColorTextureRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingDepthRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingEdgesColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingEdgesRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingFlatColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingFlatNormalsRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingNormalsRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingOcclusionRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPBRRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickDepthRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickMeshRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickNormalsFlatRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickNormalsRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingShadowRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingSilhouetteRenderer.js +4 -4
- package/src/viewer/scene/scene/Scene.js +57 -11
- package/src/viewer/scene/sectionPlane/SectionPlaneCache.js +101 -0
package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickMeshRenderer.js
CHANGED
|
@@ -91,25 +91,30 @@ export class TrianglesDataTexturePickMeshRenderer {
|
|
|
91
91
|
const logDepthBufFC = 2.0 / (Math.log(camera.project.far + 1.0) / Math.LN2); // TODO: Far from pick project matrix?
|
|
92
92
|
gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
|
|
93
93
|
}
|
|
94
|
+
const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
|
|
94
95
|
const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
|
|
95
|
-
if (
|
|
96
|
+
if (numAllocatedSectionPlanes > 0) {
|
|
96
97
|
const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
|
|
97
98
|
const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes;
|
|
98
99
|
const renderFlags = model.renderFlags;
|
|
99
|
-
for (let sectionPlaneIndex = 0; sectionPlaneIndex <
|
|
100
|
+
for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
|
|
100
101
|
const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
|
|
101
102
|
if (sectionPlaneUniforms) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
103
|
+
if (sectionPlaneIndex < numSectionPlanes) {
|
|
104
|
+
const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
|
|
105
|
+
gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
|
|
106
|
+
if (active) {
|
|
107
|
+
const sectionPlane = sectionPlanes[sectionPlaneIndex];
|
|
108
|
+
if (origin) {
|
|
109
|
+
const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
|
|
110
|
+
gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
|
|
111
|
+
} else {
|
|
112
|
+
gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
|
|
113
|
+
}
|
|
114
|
+
gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
|
|
111
115
|
}
|
|
112
|
-
|
|
116
|
+
} else {
|
|
117
|
+
gl.uniform1i(sectionPlaneUniforms.active, 0);
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
120
|
}
|
|
@@ -117,8 +122,8 @@ export class TrianglesDataTexturePickMeshRenderer {
|
|
|
117
122
|
if (state.numIndices8Bits > 0) {
|
|
118
123
|
textureState.bindTriangleIndicesTextures(
|
|
119
124
|
this._program,
|
|
120
|
-
this._uTexturePerPolygonIdPortionIds,
|
|
121
|
-
this._uTexturePerPolygonIdIndices,
|
|
125
|
+
this._uTexturePerPolygonIdPortionIds,
|
|
126
|
+
this._uTexturePerPolygonIdIndices,
|
|
122
127
|
8 // 8 bits indices
|
|
123
128
|
);
|
|
124
129
|
gl.drawArrays(gl.TRIANGLES, 0, state.numIndices8Bits);
|
|
@@ -126,8 +131,8 @@ export class TrianglesDataTexturePickMeshRenderer {
|
|
|
126
131
|
if (state.numIndices16Bits > 0) {
|
|
127
132
|
textureState.bindTriangleIndicesTextures(
|
|
128
133
|
this._program,
|
|
129
|
-
this._uTexturePerPolygonIdPortionIds,
|
|
130
|
-
this._uTexturePerPolygonIdIndices,
|
|
134
|
+
this._uTexturePerPolygonIdPortionIds,
|
|
135
|
+
this._uTexturePerPolygonIdIndices,
|
|
131
136
|
16 // 16 bits indices
|
|
132
137
|
);
|
|
133
138
|
gl.drawArrays(gl.TRIANGLES, 0, state.numIndices16Bits);
|
|
@@ -135,8 +140,8 @@ export class TrianglesDataTexturePickMeshRenderer {
|
|
|
135
140
|
if (state.numIndices32Bits > 0) {
|
|
136
141
|
textureState.bindTriangleIndicesTextures(
|
|
137
142
|
this._program,
|
|
138
|
-
this._uTexturePerPolygonIdPortionIds,
|
|
139
|
-
this._uTexturePerPolygonIdIndices,
|
|
143
|
+
this._uTexturePerPolygonIdPortionIds,
|
|
144
|
+
this._uTexturePerPolygonIdIndices,
|
|
140
145
|
32 // 32 bits indices
|
|
141
146
|
);
|
|
142
147
|
gl.drawArrays(gl.TRIANGLES, 0, state.numIndices32Bits);
|
|
@@ -161,7 +166,7 @@ export class TrianglesDataTexturePickMeshRenderer {
|
|
|
161
166
|
this._uViewMatrix = program.getLocation("viewMatrix");
|
|
162
167
|
this._uProjMatrix = program.getLocation("projMatrix");
|
|
163
168
|
this._uSectionPlanes = [];
|
|
164
|
-
for (let i = 0, len = scene.
|
|
169
|
+
for (let i = 0, len = scene.getMaxSectionPlanes(); i < len; i++) {
|
|
165
170
|
this._uSectionPlanes.push({
|
|
166
171
|
active: program.getLocation("sectionPlaneActive" + i),
|
|
167
172
|
pos: program.getLocation("sectionPlanePos" + i),
|
|
@@ -171,14 +176,14 @@ export class TrianglesDataTexturePickMeshRenderer {
|
|
|
171
176
|
if (scene.logarithmicDepthBufferEnabled) {
|
|
172
177
|
this._uLogDepthBufFC = program.getLocation("logDepthBufFC");
|
|
173
178
|
}
|
|
174
|
-
this.uTexturePerObjectPositionsDecodeMatrix = "uObjectPerObjectPositionsDecodeMatrix";
|
|
175
|
-
this.uTexturePerObjectColorsAndFlags = "uObjectPerObjectColorsAndFlags";
|
|
176
|
-
this._uTexturePerVertexIdCoordinates = "uTexturePerVertexIdCoordinates";
|
|
177
|
-
this._uTexturePerPolygonIdNormals = "uTexturePerPolygonIdNormals";
|
|
178
|
-
this._uTexturePerPolygonIdIndices = "uTexturePerPolygonIdIndices";
|
|
179
|
+
this.uTexturePerObjectPositionsDecodeMatrix = "uObjectPerObjectPositionsDecodeMatrix";
|
|
180
|
+
this.uTexturePerObjectColorsAndFlags = "uObjectPerObjectColorsAndFlags";
|
|
181
|
+
this._uTexturePerVertexIdCoordinates = "uTexturePerVertexIdCoordinates";
|
|
182
|
+
this._uTexturePerPolygonIdNormals = "uTexturePerPolygonIdNormals";
|
|
183
|
+
this._uTexturePerPolygonIdIndices = "uTexturePerPolygonIdIndices";
|
|
179
184
|
this._uTexturePerPolygonIdPortionIds = "uTexturePerPolygonIdPortionIds";
|
|
180
|
-
this._uTexturePerObjectMatrix= "uTexturePerObjectMatrix";
|
|
181
|
-
this._uCameraEyeRtc = program.getLocation("uCameraEyeRtc");
|
|
185
|
+
this._uTexturePerObjectMatrix = "uTexturePerObjectMatrix";
|
|
186
|
+
this._uCameraEyeRtc = program.getLocation("uCameraEyeRtc");
|
|
182
187
|
}
|
|
183
188
|
|
|
184
189
|
_bindProgram(frameCtx) {
|
|
@@ -197,7 +202,7 @@ export class TrianglesDataTexturePickMeshRenderer {
|
|
|
197
202
|
|
|
198
203
|
_buildVertexShader() {
|
|
199
204
|
const scene = this._scene;
|
|
200
|
-
const clipping = scene._sectionPlanesState.
|
|
205
|
+
const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
201
206
|
const src = [];
|
|
202
207
|
src.push("#version 300 es");
|
|
203
208
|
src.push("// Batched geometry picking vertex shader");
|
|
@@ -232,10 +237,10 @@ export class TrianglesDataTexturePickMeshRenderer {
|
|
|
232
237
|
src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");
|
|
233
238
|
src.push("uniform highp sampler2D uTexturePerObjectMatrix;");
|
|
234
239
|
src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");
|
|
235
|
-
src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");
|
|
236
|
-
src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");
|
|
240
|
+
src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");
|
|
241
|
+
src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");
|
|
237
242
|
src.push("uniform mediump usampler2D uTexturePerPolygonIdPortionIds;");
|
|
238
|
-
src.push("uniform vec3 uCameraEyeRtc;");
|
|
243
|
+
src.push("uniform vec3 uCameraEyeRtc;");
|
|
239
244
|
|
|
240
245
|
src.push("vec3 positions[3];")
|
|
241
246
|
|
|
@@ -278,9 +283,9 @@ export class TrianglesDataTexturePickMeshRenderer {
|
|
|
278
283
|
src.push("ivec2 objectIndexCoords = ivec2(objectIndex % 512, objectIndex / 512);");
|
|
279
284
|
|
|
280
285
|
// get flags & flags2
|
|
281
|
-
src.push("uvec4 flags = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");
|
|
282
|
-
src.push("uvec4 flags2 = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");
|
|
283
|
-
|
|
286
|
+
src.push("uvec4 flags = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");
|
|
287
|
+
src.push("uvec4 flags2 = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");
|
|
288
|
+
|
|
284
289
|
// flags.w = NOT_RENDERED | PICK
|
|
285
290
|
// renderPass = PICK
|
|
286
291
|
|
|
@@ -290,9 +295,9 @@ export class TrianglesDataTexturePickMeshRenderer {
|
|
|
290
295
|
src.push("} else {");
|
|
291
296
|
|
|
292
297
|
// get vertex base
|
|
293
|
-
src.push("ivec4 packedVertexBase = ivec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+4, objectIndexCoords.y), 0));");
|
|
298
|
+
src.push("ivec4 packedVertexBase = ivec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+4, objectIndexCoords.y), 0));");
|
|
294
299
|
|
|
295
|
-
src.push("ivec4 packedIndexBaseOffset = ivec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+5, objectIndexCoords.y), 0));");
|
|
300
|
+
src.push("ivec4 packedIndexBaseOffset = ivec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+5, objectIndexCoords.y), 0));");
|
|
296
301
|
|
|
297
302
|
src.push("int indexBaseOffset = (packedIndexBaseOffset.r << 24) + (packedIndexBaseOffset.g << 16) + (packedIndexBaseOffset.b << 8) + packedIndexBaseOffset.a;");
|
|
298
303
|
|
|
@@ -301,7 +306,7 @@ export class TrianglesDataTexturePickMeshRenderer {
|
|
|
301
306
|
|
|
302
307
|
src.push("ivec3 vertexIndices = ivec3(texelFetch(uTexturePerPolygonIdIndices, ivec2(h_index, v_index), 0));");
|
|
303
308
|
src.push("ivec3 uniqueVertexIndexes = vertexIndices + (packedVertexBase.r << 24) + (packedVertexBase.g << 16) + (packedVertexBase.b << 8) + packedVertexBase.a;")
|
|
304
|
-
|
|
309
|
+
|
|
305
310
|
src.push("ivec3 indexPositionH = uniqueVertexIndexes & 4095;")
|
|
306
311
|
src.push("ivec3 indexPositionV = uniqueVertexIndexes >> 12;")
|
|
307
312
|
|
|
@@ -309,7 +314,7 @@ export class TrianglesDataTexturePickMeshRenderer {
|
|
|
309
314
|
|
|
310
315
|
src.push("mat4 objectDecodeAndInstanceMatrix = objectInstanceMatrix * mat4 (texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+0, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+1, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+2, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+3, objectIndexCoords.y), 0));")
|
|
311
316
|
|
|
312
|
-
src.push("uint solid = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+7, objectIndexCoords.y), 0).r;");
|
|
317
|
+
src.push("uint solid = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+7, objectIndexCoords.y), 0).r;");
|
|
313
318
|
|
|
314
319
|
// get position
|
|
315
320
|
src.push("positions[0] = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(indexPositionH.r, indexPositionV.r), 0));")
|
|
@@ -317,7 +322,7 @@ export class TrianglesDataTexturePickMeshRenderer {
|
|
|
317
322
|
src.push("positions[2] = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(indexPositionH.b, indexPositionV.b), 0));")
|
|
318
323
|
|
|
319
324
|
// get color
|
|
320
|
-
src.push("uvec4 color = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+0, objectIndexCoords.y), 0);");
|
|
325
|
+
src.push("uvec4 color = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+0, objectIndexCoords.y), 0);");
|
|
321
326
|
|
|
322
327
|
src.push(`if (color.a == 0u) {`);
|
|
323
328
|
src.push(" gl_Position = vec4(3.0, 3.0, 3.0, 1.0);"); // Cull vertex
|
|
@@ -335,17 +340,17 @@ export class TrianglesDataTexturePickMeshRenderer {
|
|
|
335
340
|
|
|
336
341
|
// when the geometry is not solid, if needed, flip the triangle winding
|
|
337
342
|
src.push("if (solid != 1u) {");
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
343
|
+
src.push("if (isPerspectiveMatrix(projMatrix)) {");
|
|
344
|
+
src.push("vec3 uCameraEyeRtcInQuantizedSpace = (inverse(sceneModelMatrix * objectDecodeAndInstanceMatrix) * vec4(uCameraEyeRtc, 1)).xyz;")
|
|
345
|
+
src.push("if (dot(position.xyz - uCameraEyeRtcInQuantizedSpace, normal) < 0.0) {");
|
|
346
|
+
src.push("position = positions[2 - (gl_VertexID % 3)];");
|
|
347
|
+
src.push("}");
|
|
348
|
+
src.push("} else {");
|
|
349
|
+
src.push("vec3 viewNormal = -normalize((transpose(inverse(viewMatrix*objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);");
|
|
350
|
+
src.push("if (viewNormal.z < 0.0) {");
|
|
351
|
+
src.push("position = positions[2 - (gl_VertexID % 3)];");
|
|
352
|
+
src.push("}");
|
|
353
|
+
src.push("}");
|
|
349
354
|
src.push("}");
|
|
350
355
|
|
|
351
356
|
src.push("vec4 worldPosition = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");
|
|
@@ -369,10 +374,9 @@ export class TrianglesDataTexturePickMeshRenderer {
|
|
|
369
374
|
|
|
370
375
|
_buildFragmentShader() {
|
|
371
376
|
const scene = this._scene;
|
|
372
|
-
const
|
|
373
|
-
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
377
|
+
const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
374
378
|
const src = [];
|
|
375
|
-
src.push
|
|
379
|
+
src.push('#version 300 es');
|
|
376
380
|
src.push("// Batched geometry picking fragment shader");
|
|
377
381
|
src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
|
|
378
382
|
src.push("precision highp float;");
|
|
@@ -389,7 +393,7 @@ export class TrianglesDataTexturePickMeshRenderer {
|
|
|
389
393
|
if (clipping) {
|
|
390
394
|
src.push("in vec4 vWorldPosition;");
|
|
391
395
|
src.push("flat in uvec4 vFlags2;");
|
|
392
|
-
for (var i = 0; i <
|
|
396
|
+
for (var i = 0; i < scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
393
397
|
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
394
398
|
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
395
399
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
@@ -402,7 +406,7 @@ export class TrianglesDataTexturePickMeshRenderer {
|
|
|
402
406
|
src.push(" bool clippable = (float(vFlags2.x) > 0.0);");
|
|
403
407
|
src.push(" if (clippable) {");
|
|
404
408
|
src.push(" float dist = 0.0;");
|
|
405
|
-
for (var i = 0; i <
|
|
409
|
+
for (var i = 0; i < scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
406
410
|
src.push(" if (sectionPlaneActive" + i + ") {");
|
|
407
411
|
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
408
412
|
src.push(" }");
|
|
@@ -411,7 +415,7 @@ export class TrianglesDataTexturePickMeshRenderer {
|
|
|
411
415
|
src.push(" }");
|
|
412
416
|
}
|
|
413
417
|
if (scene.logarithmicDepthBufferEnabled) {
|
|
414
|
-
|
|
418
|
+
src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
415
419
|
//src.push(" gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
416
420
|
}
|
|
417
421
|
src.push(" outPickColor = vPickColor; ");
|
|
@@ -103,25 +103,30 @@ export class TrianglesDataTexturePickNormalsFlatRenderer {
|
|
|
103
103
|
const logDepthBufFC = 2.0 / (Math.log(frameCtx.pickZFar + 1.0) / Math.LN2);
|
|
104
104
|
gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
|
|
105
105
|
}
|
|
106
|
+
const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
|
|
106
107
|
const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
|
|
107
|
-
if (
|
|
108
|
+
if (numAllocatedSectionPlanes > 0) {
|
|
108
109
|
const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
|
|
109
110
|
const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes;
|
|
110
111
|
const renderFlags = model.renderFlags;
|
|
111
|
-
for (let sectionPlaneIndex = 0; sectionPlaneIndex <
|
|
112
|
+
for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
|
|
112
113
|
const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
|
|
113
114
|
if (sectionPlaneUniforms) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
115
|
+
if (sectionPlaneIndex < numSectionPlanes) {
|
|
116
|
+
const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
|
|
117
|
+
gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
|
|
118
|
+
if (active) {
|
|
119
|
+
const sectionPlane = sectionPlanes[sectionPlaneIndex];
|
|
120
|
+
if (origin) {
|
|
121
|
+
const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
|
|
122
|
+
gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
|
|
123
|
+
} else {
|
|
124
|
+
gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
|
|
125
|
+
}
|
|
126
|
+
gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
|
|
123
127
|
}
|
|
124
|
-
|
|
128
|
+
} else {
|
|
129
|
+
gl.uniform1i(sectionPlaneUniforms.active, 0);
|
|
125
130
|
}
|
|
126
131
|
}
|
|
127
132
|
}
|
|
@@ -177,7 +182,7 @@ export class TrianglesDataTexturePickNormalsFlatRenderer {
|
|
|
177
182
|
this._uViewMatrix = program.getLocation("viewMatrix");
|
|
178
183
|
this._uProjMatrix = program.getLocation("projMatrix");
|
|
179
184
|
this._uSectionPlanes = [];
|
|
180
|
-
for (let i = 0, len = scene.
|
|
185
|
+
for (let i = 0, len = scene.getMaxSectionPlanes(); i < len; i++) {
|
|
181
186
|
this._uSectionPlanes.push({
|
|
182
187
|
active: program.getLocation("sectionPlaneActive" + i),
|
|
183
188
|
pos: program.getLocation("sectionPlanePos" + i),
|
|
@@ -218,9 +223,7 @@ export class TrianglesDataTexturePickNormalsFlatRenderer {
|
|
|
218
223
|
|
|
219
224
|
_buildVertexShader() {
|
|
220
225
|
const scene = this._scene;
|
|
221
|
-
const
|
|
222
|
-
const lightsState = scene._lightsState;
|
|
223
|
-
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
226
|
+
const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
224
227
|
let light;
|
|
225
228
|
const src = [];
|
|
226
229
|
src.push("#version 300 es");
|
|
@@ -387,8 +390,7 @@ export class TrianglesDataTexturePickNormalsFlatRenderer {
|
|
|
387
390
|
|
|
388
391
|
_buildFragmentShader() {
|
|
389
392
|
const scene = this._scene;
|
|
390
|
-
const
|
|
391
|
-
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
393
|
+
const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
392
394
|
const src = [];
|
|
393
395
|
src.push('#version 300 es');
|
|
394
396
|
src.push("// TrianglesDataTexturePickNormalsRenderer fragment shader");
|
|
@@ -407,7 +409,7 @@ export class TrianglesDataTexturePickNormalsFlatRenderer {
|
|
|
407
409
|
src.push("in vec4 vWorldPosition;");
|
|
408
410
|
if (clipping) {
|
|
409
411
|
src.push("flat in uint vFlags2;");
|
|
410
|
-
for (let i = 0, len =
|
|
412
|
+
for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
|
|
411
413
|
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
412
414
|
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
413
415
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
@@ -419,7 +421,7 @@ export class TrianglesDataTexturePickNormalsFlatRenderer {
|
|
|
419
421
|
src.push(" bool clippable = vFlags2 > 0u;");
|
|
420
422
|
src.push(" if (clippable) {");
|
|
421
423
|
src.push(" float dist = 0.0;");
|
|
422
|
-
for (let i = 0, len =
|
|
424
|
+
for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
|
|
423
425
|
src.push("if (sectionPlaneActive" + i + ") {");
|
|
424
426
|
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
425
427
|
src.push("}");
|
package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickNormalsRenderer.js
CHANGED
|
@@ -81,25 +81,30 @@ export class TrianglesDataTexturePickNormalsRenderer {
|
|
|
81
81
|
gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
|
|
84
85
|
const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
|
|
85
|
-
if (
|
|
86
|
+
if (numAllocatedSectionPlanes > 0) {
|
|
86
87
|
const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
|
|
87
88
|
const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes;
|
|
88
89
|
const renderFlags = model.renderFlags;
|
|
89
|
-
for (let sectionPlaneIndex = 0; sectionPlaneIndex <
|
|
90
|
+
for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
|
|
90
91
|
const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
|
|
91
92
|
if (sectionPlaneUniforms) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
93
|
+
if (sectionPlaneIndex < numSectionPlanes) {
|
|
94
|
+
const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
|
|
95
|
+
gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
|
|
96
|
+
if (active) {
|
|
97
|
+
const sectionPlane = sectionPlanes[sectionPlaneIndex];
|
|
98
|
+
if (origin) {
|
|
99
|
+
const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
|
|
100
|
+
gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
|
|
101
|
+
} else {
|
|
102
|
+
gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
|
|
103
|
+
}
|
|
104
|
+
gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
|
|
101
105
|
}
|
|
102
|
-
|
|
106
|
+
} else {
|
|
107
|
+
gl.uniform1i(sectionPlaneUniforms.active, 0);
|
|
103
108
|
}
|
|
104
109
|
}
|
|
105
110
|
}
|
|
@@ -162,7 +167,7 @@ export class TrianglesDataTexturePickNormalsRenderer {
|
|
|
162
167
|
|
|
163
168
|
this._uSectionPlanes = [];
|
|
164
169
|
|
|
165
|
-
for (let i = 0, len = scene._sectionPlanesState.
|
|
170
|
+
for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
|
|
166
171
|
this._uSectionPlanes.push({
|
|
167
172
|
active: program.getLocation("sectionPlaneActive" + i),
|
|
168
173
|
pos: program.getLocation("sectionPlanePos" + i),
|
|
@@ -197,7 +202,7 @@ export class TrianglesDataTexturePickNormalsRenderer {
|
|
|
197
202
|
|
|
198
203
|
_buildVertexShader() {
|
|
199
204
|
const scene = this._scene;
|
|
200
|
-
const clipping = scene._sectionPlanesState.
|
|
205
|
+
const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
201
206
|
const src = [];
|
|
202
207
|
src.push("#version 300 es");
|
|
203
208
|
src.push("// Triangles dataTexture pick normals vertex shader");
|
|
@@ -371,8 +376,7 @@ export class TrianglesDataTexturePickNormalsRenderer {
|
|
|
371
376
|
|
|
372
377
|
_buildFragmentShader() {
|
|
373
378
|
const scene = this._scene;
|
|
374
|
-
const
|
|
375
|
-
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
379
|
+
const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
376
380
|
const src = [];
|
|
377
381
|
src.push('#version 300 es');
|
|
378
382
|
src.push("// Triangles dataTexture pick normals fragment shader");
|
|
@@ -392,7 +396,7 @@ export class TrianglesDataTexturePickNormalsRenderer {
|
|
|
392
396
|
if (clipping) {
|
|
393
397
|
src.push("in vec4 vWorldPosition;");
|
|
394
398
|
src.push("flat in uint vFlags2;");
|
|
395
|
-
for (var i = 0; i <
|
|
399
|
+
for (var i = 0; i < scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
396
400
|
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
397
401
|
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
398
402
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
@@ -405,7 +409,7 @@ export class TrianglesDataTexturePickNormalsRenderer {
|
|
|
405
409
|
src.push(" bool clippable = vFlags2 > 0u;");
|
|
406
410
|
src.push(" if (clippable) {");
|
|
407
411
|
src.push(" float dist = 0.0;");
|
|
408
|
-
for (var i = 0; i <
|
|
412
|
+
for (var i = 0; i < scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
409
413
|
src.push(" if (sectionPlaneActive" + i + ") {");
|
|
410
414
|
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
411
415
|
src.push(" }");
|
package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSilhouetteRenderer.js
CHANGED
|
@@ -123,25 +123,30 @@ export class TrianglesDataTextureSilhouetteRenderer {
|
|
|
123
123
|
const logDepthBufFC = 2.0 / (Math.log(frameCtx.pickZFar + 1.0) / Math.LN2);
|
|
124
124
|
gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
|
|
125
125
|
}
|
|
126
|
+
const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
|
|
126
127
|
const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
|
|
127
|
-
if (
|
|
128
|
+
if (numAllocatedSectionPlanes > 0) {
|
|
128
129
|
const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
|
|
129
130
|
const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes;
|
|
130
131
|
const renderFlags = model.renderFlags;
|
|
131
|
-
for (let sectionPlaneIndex = 0; sectionPlaneIndex <
|
|
132
|
+
for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
|
|
132
133
|
const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
|
|
133
134
|
if (sectionPlaneUniforms) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
135
|
+
if (sectionPlaneIndex < numSectionPlanes) {
|
|
136
|
+
const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
|
|
137
|
+
gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
|
|
138
|
+
if (active) {
|
|
139
|
+
const sectionPlane = sectionPlanes[sectionPlaneIndex];
|
|
140
|
+
if (origin) {
|
|
141
|
+
const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
|
|
142
|
+
gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
|
|
143
|
+
} else {
|
|
144
|
+
gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
|
|
145
|
+
}
|
|
146
|
+
gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
|
|
143
147
|
}
|
|
144
|
-
|
|
148
|
+
} else {
|
|
149
|
+
gl.uniform1i(sectionPlaneUniforms.active, 0);
|
|
145
150
|
}
|
|
146
151
|
}
|
|
147
152
|
}
|
|
@@ -198,7 +203,7 @@ export class TrianglesDataTextureSilhouetteRenderer {
|
|
|
198
203
|
this._uViewMatrix = program.getLocation("viewMatrix");
|
|
199
204
|
this._uProjMatrix = program.getLocation("projMatrix");
|
|
200
205
|
this._uSectionPlanes = [];
|
|
201
|
-
for (let i = 0, len = scene.
|
|
206
|
+
for (let i = 0, len = scene.getMaxSectionPlanes(); i < len; i++) {
|
|
202
207
|
this._uSectionPlanes.push({
|
|
203
208
|
active: program.getLocation("sectionPlaneActive" + i),
|
|
204
209
|
pos: program.getLocation("sectionPlanePos" + i),
|
|
@@ -243,8 +248,7 @@ export class TrianglesDataTextureSilhouetteRenderer {
|
|
|
243
248
|
_buildVertexShader() {
|
|
244
249
|
|
|
245
250
|
const scene = this._scene;
|
|
246
|
-
const
|
|
247
|
-
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
251
|
+
const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
248
252
|
|
|
249
253
|
const src = [];
|
|
250
254
|
src.push("#version 300 es");
|
|
@@ -398,8 +402,7 @@ export class TrianglesDataTextureSilhouetteRenderer {
|
|
|
398
402
|
|
|
399
403
|
_buildFragmentShader() {
|
|
400
404
|
const scene = this._scene;
|
|
401
|
-
const
|
|
402
|
-
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
405
|
+
const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
403
406
|
const src = [];
|
|
404
407
|
src.push('#version 300 es');
|
|
405
408
|
src.push("// Triangles dataTexture draw fragment shader");
|
|
@@ -418,7 +421,7 @@ export class TrianglesDataTextureSilhouetteRenderer {
|
|
|
418
421
|
if (clipping) {
|
|
419
422
|
src.push("in vec4 vWorldPosition;");
|
|
420
423
|
src.push("flat in uint vFlags2;");
|
|
421
|
-
for (let i = 0, len =
|
|
424
|
+
for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
|
|
422
425
|
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
423
426
|
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
424
427
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
@@ -431,7 +434,7 @@ export class TrianglesDataTextureSilhouetteRenderer {
|
|
|
431
434
|
src.push(" bool clippable = vFlags2 > 0u;");
|
|
432
435
|
src.push(" if (clippable) {");
|
|
433
436
|
src.push(" float dist = 0.0;");
|
|
434
|
-
for (let i = 0, len =
|
|
437
|
+
for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
|
|
435
438
|
src.push("if (sectionPlaneActive" + i + ") {");
|
|
436
439
|
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
437
440
|
src.push("}");
|
|
@@ -117,25 +117,30 @@ export class TrianglesDataTextureSnapDepthBufInitRenderer {
|
|
|
117
117
|
const logDepthBufFC = 2.0 / (Math.log(frameCtx.pickZFar + 1.0) / Math.LN2);
|
|
118
118
|
gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
|
|
119
119
|
}
|
|
120
|
+
const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
|
|
120
121
|
const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
|
|
121
|
-
if (
|
|
122
|
+
if (numAllocatedSectionPlanes > 0) {
|
|
122
123
|
const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
|
|
123
124
|
const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes;
|
|
124
125
|
const renderFlags = model.renderFlags;
|
|
125
|
-
for (let sectionPlaneIndex = 0; sectionPlaneIndex <
|
|
126
|
+
for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
|
|
126
127
|
const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
|
|
127
128
|
if (sectionPlaneUniforms) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
129
|
+
if (sectionPlaneIndex < numSectionPlanes) {
|
|
130
|
+
const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
|
|
131
|
+
gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
|
|
132
|
+
if (active) {
|
|
133
|
+
const sectionPlane = sectionPlanes[sectionPlaneIndex];
|
|
134
|
+
if (origin) {
|
|
135
|
+
const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
|
|
136
|
+
gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
|
|
137
|
+
} else {
|
|
138
|
+
gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
|
|
139
|
+
}
|
|
140
|
+
gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
|
|
137
141
|
}
|
|
138
|
-
|
|
142
|
+
} else {
|
|
143
|
+
gl.uniform1i(sectionPlaneUniforms.active, 0);
|
|
139
144
|
}
|
|
140
145
|
}
|
|
141
146
|
}
|
|
@@ -185,7 +190,7 @@ export class TrianglesDataTextureSnapDepthBufInitRenderer {
|
|
|
185
190
|
this._uViewMatrix = program.getLocation("viewMatrix");
|
|
186
191
|
this._uProjMatrix = program.getLocation("projMatrix");
|
|
187
192
|
this._uSectionPlanes = [];
|
|
188
|
-
for (let i = 0, len = scene.
|
|
193
|
+
for (let i = 0, len = scene.getMaxSectionPlanes(); i < len; i++) {
|
|
189
194
|
this._uSectionPlanes.push({
|
|
190
195
|
active: program.getLocation("sectionPlaneActive" + i),
|
|
191
196
|
pos: program.getLocation("sectionPlanePos" + i),
|
|
@@ -221,8 +226,7 @@ export class TrianglesDataTextureSnapDepthBufInitRenderer {
|
|
|
221
226
|
|
|
222
227
|
_buildVertexShader() {
|
|
223
228
|
const scene = this._scene;
|
|
224
|
-
const
|
|
225
|
-
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
229
|
+
const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
226
230
|
const src = [];
|
|
227
231
|
src.push("#version 300 es");
|
|
228
232
|
src.push("// TrianglesDataTextureSnapDepthBufInitRenderer vertex shader");
|
|
@@ -384,8 +388,7 @@ export class TrianglesDataTextureSnapDepthBufInitRenderer {
|
|
|
384
388
|
|
|
385
389
|
_buildFragmentShader() {
|
|
386
390
|
const scene = this._scene;
|
|
387
|
-
const
|
|
388
|
-
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
391
|
+
const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
389
392
|
const src = [];
|
|
390
393
|
src.push('#version 300 es');
|
|
391
394
|
src.push("// TrianglesDataTextureSnapDepthBufInitRenderer fragment shader");
|
|
@@ -407,7 +410,7 @@ export class TrianglesDataTextureSnapDepthBufInitRenderer {
|
|
|
407
410
|
src.push("flat in vec4 vPickColor;");
|
|
408
411
|
if (clipping) {
|
|
409
412
|
src.push("flat in uint vFlags2;");
|
|
410
|
-
for (let i = 0, len =
|
|
413
|
+
for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
|
|
411
414
|
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
412
415
|
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
413
416
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
@@ -422,7 +425,7 @@ export class TrianglesDataTextureSnapDepthBufInitRenderer {
|
|
|
422
425
|
src.push(" bool clippable = vFlags2 > 0u;");
|
|
423
426
|
src.push(" if (clippable) {");
|
|
424
427
|
src.push(" float dist = 0.0;");
|
|
425
|
-
for (var i = 0; i <
|
|
428
|
+
for (var i = 0; i < scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
426
429
|
src.push(" if (sectionPlaneActive" + i + ") {");
|
|
427
430
|
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
428
431
|
src.push(" }");
|