@xeokit/xeokit-sdk 2.4.0-alpha-89 → 2.4.0-alpha-90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/xeokit-sdk.cjs.js +169 -92
  2. package/dist/xeokit-sdk.es.js +169 -92
  3. package/dist/xeokit-sdk.es5.js +58 -58
  4. package/dist/xeokit-sdk.min.cjs.js +3 -3
  5. package/dist/xeokit-sdk.min.es.js +3 -3
  6. package/dist/xeokit-sdk.min.es5.js +3 -3
  7. package/package.json +1 -1
  8. package/src/viewer/scene/mesh/pick/PickMeshRenderer.js +3 -0
  9. package/src/viewer/scene/mesh/pick/PickMeshShaderSource.js +11 -3
  10. package/src/viewer/scene/mesh/pick/PickTriangleRenderer.js +4 -0
  11. package/src/viewer/scene/mesh/pick/PickTriangleShaderSource.js +11 -4
  12. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickDepthRenderer.js +13 -2
  13. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickMeshRenderer.js +13 -2
  14. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickNormalsFlatRenderer.js +14 -2
  15. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickNormalsRenderer.js +13 -2
  16. package/src/viewer/scene/model/vbo/VBOSceneModelRenderers.js +17 -39
  17. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingPickDepthRenderer.js +3 -1
  18. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingPickMeshRenderer.js +3 -1
  19. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingPickDepthRenderer.js +4 -1
  20. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingPickMeshRenderer.js +3 -0
  21. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickDepthRenderer.js +4 -1
  22. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickMeshRenderer.js +3 -1
  23. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickNormalsFlatRenderer.js +3 -1
  24. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickNormalsRenderer.js +3 -1
  25. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickDepthRenderer.js +3 -1
  26. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickMeshRenderer.js +3 -1
  27. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickNormalsFlatRenderer.js +3 -1
  28. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickNormalsRenderer.js +3 -1
  29. package/src/viewer/scene/webgl/RenderBuffer.js +1 -1
  30. package/src/viewer/scene/webgl/Renderer.js +31 -29
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xeokit/xeokit-sdk",
3
- "version": "2.4.0-alpha-89",
3
+ "version": "2.4.0-alpha-90",
4
4
  "description": "Web Programming Toolkit for 3D/2D BIM and AEC Graphics",
5
5
  "module": "./dist/xeokit-sdk.es.js",
6
6
  "main": "./dist/xeokit-sdk.cjs.js",
@@ -152,6 +152,8 @@ PickMeshRenderer.prototype.drawMesh = function (frameCtx, mesh) {
152
152
  const r = pickID & 0xFF;
153
153
  gl.uniform4f(this._uPickColor, r / 255, g / 255, b / 255, a / 255);
154
154
 
155
+ gl.uniform2fv(this._uPickClipPos, frameCtx.pickClipPos);
156
+
155
157
  if (geometryState.indicesBuf) {
156
158
  gl.drawElements(geometryState.primitive, geometryState.indicesBuf.numItems, geometryState.indicesBuf.itemType, 0);
157
159
  frameCtx.drawElements++;
@@ -185,6 +187,7 @@ PickMeshRenderer.prototype._allocate = function (mesh) {
185
187
  this._aPosition = program.getAttribute("position");
186
188
  this._uClippable = program.getLocation("clippable");
187
189
  this._uPickColor = program.getLocation("pickColor");
190
+ this._uPickClipPos = program.getLocation("pickClipPos");
188
191
  this._uOffset = program.getLocation("offset");
189
192
  if (scene.logarithmicDepthBufferEnabled ) {
190
193
  this._uLogDepthBufFC = program.getLocation("logDepthBufFC");
@@ -2,8 +2,6 @@
2
2
  * @author xeolabs / https://github.com/xeolabs
3
3
  */
4
4
 
5
- import {WEBGL_INFO} from "../../webglInfo.js";
6
-
7
5
  /**
8
6
  * @private
9
7
  */
@@ -58,6 +56,16 @@ function buildVertex(mesh) {
58
56
  src.push(" mat[2][2] =1.0;");
59
57
  src.push("}");
60
58
  }
59
+
60
+ src.push("uniform vec2 pickClipPos;");
61
+
62
+ src.push("vec4 remapClipPos(vec4 clipPos) {");
63
+ src.push(" clipPos.xy /= clipPos.w;")
64
+ src.push(" clipPos.xy -= pickClipPos;");
65
+ src.push(" clipPos.xy *= clipPos.w;")
66
+ src.push(" return clipPos;")
67
+ src.push("}");
68
+
61
69
  src.push("void main(void) {");
62
70
  src.push("vec4 localPosition = vec4(position, 1.0); ");
63
71
  if (quantizedGeometry) {
@@ -84,7 +92,7 @@ function buildVertex(mesh) {
84
92
  src.push("vFragDepth = 1.0 + clipPos.w;");
85
93
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
86
94
  }
87
- src.push("gl_Position = clipPos;");
95
+ src.push("gl_Position = remapClipPos(clipPos);");
88
96
  src.push("}");
89
97
  return src;
90
98
  }
@@ -142,6 +142,9 @@ PickTriangleRenderer.prototype.drawMesh = function (frameCtx, mesh) {
142
142
  } else {
143
143
  this._aPosition.bindArrayBuffer(positionsBuf);
144
144
  }
145
+
146
+ gl.uniform2fv(this._uPickClipPos, frameCtx.pickClipPos);
147
+
145
148
  pickColorsBuf.bind();
146
149
  gl.enableVertexAttribArray(this._aColor.location);
147
150
  gl.vertexAttribPointer(this._aColor.location, pickColorsBuf.itemSize, pickColorsBuf.itemType, true, 0, 0); // Normalize
@@ -173,6 +176,7 @@ PickTriangleRenderer.prototype._allocate = function (mesh) {
173
176
  }
174
177
  this._aPosition = program.getAttribute("position");
175
178
  this._aColor = program.getAttribute("color");
179
+ this._uPickClipPos = program.getLocation("pickClipPos");
176
180
  this._uClippable = program.getLocation("clippable");
177
181
  this._uOffset = program.getLocation("offset");
178
182
  if (scene.logarithmicDepthBufferEnabled ) {
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * @private
3
3
  */
4
- import {WEBGL_INFO} from "../../webglInfo.js";
5
4
 
6
5
  class PickTriangleShaderSource {
7
6
  constructor(mesh) {
@@ -14,8 +13,6 @@ function buildVertex(mesh) {
14
13
  const scene = mesh.scene;
15
14
  const clipping = scene._sectionPlanesState.sectionPlanes.length > 0;
16
15
  const quantizedGeometry = !!mesh._geometry._state.compressGeometry;
17
- const billboard = mesh._state.billboard;
18
- const stationary = mesh._state.stationary;
19
16
  const src = [];
20
17
  src.push('#version 300 es');
21
18
  src.push("// Surface picking vertex shader");
@@ -37,6 +34,16 @@ function buildVertex(mesh) {
37
34
  src.push("}");
38
35
  src.push("out float isPerspective;");
39
36
  }
37
+
38
+ src.push("uniform vec2 pickClipPos;");
39
+
40
+ src.push("vec4 remapClipPos(vec4 clipPos) {");
41
+ src.push(" clipPos.xy /= clipPos.w;")
42
+ src.push(" clipPos.xy -= pickClipPos;");
43
+ src.push(" clipPos.xy *= clipPos.w;")
44
+ src.push(" return clipPos;")
45
+ src.push("}");
46
+
40
47
  src.push("out vec4 vColor;");
41
48
  if (quantizedGeometry) {
42
49
  src.push("uniform mat4 positionsDecodeMatrix;");
@@ -58,7 +65,7 @@ function buildVertex(mesh) {
58
65
  src.push("vFragDepth = 1.0 + clipPos.w;");
59
66
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
60
67
  }
61
- src.push("gl_Position = clipPos;");
68
+ src.push("gl_Position = remapClipPos(clipPos);");
62
69
  src.push("}");
63
70
  return src;
64
71
  }
@@ -21,7 +21,7 @@ export class TrianglesDataTexturePickDepthRenderer {
21
21
 
22
22
  getValid() {
23
23
  return this._hash === this._getHash();
24
- };
24
+ }
25
25
 
26
26
  _getHash() {
27
27
  return this._scene._sectionPlanesState.getHash();
@@ -95,6 +95,7 @@ export class TrianglesDataTexturePickDepthRenderer {
95
95
  gl.uniform3fv(this._uCameraEyeRtc, rtcCameraEye);
96
96
  gl.uniform1i(this._uRenderPass, renderPass);
97
97
  gl.uniform1i(this._uPickInvisible, frameCtx.pickInvisible);
98
+ gl.uniform2fv(this._uPickClipPos, frameCtx.pickClipPos);
98
99
  gl.uniform1f(this._uPickZNear, frameCtx.pickZNear);
99
100
  gl.uniform1f(this._uPickZFar, frameCtx.pickZFar);
100
101
  gl.uniformMatrix4fv(this._uWorldMatrix, false, rotationMatrixConjugate);
@@ -169,6 +170,7 @@ export class TrianglesDataTexturePickDepthRenderer {
169
170
  const program = this._program;
170
171
  this._uRenderPass = program.getLocation("renderPass");
171
172
  this._uPickInvisible = program.getLocation("pickInvisible");
173
+ this._uPickClipPos = program.getLocation("pickClipPos");
172
174
  this._uWorldMatrix = program.getLocation("worldMatrix");
173
175
  this._uViewMatrix = program.getLocation("viewMatrix");
174
176
  this._uProjMatrix = program.getLocation("projMatrix");
@@ -258,6 +260,15 @@ export class TrianglesDataTexturePickDepthRenderer {
258
260
  src.push("out float isPerspective;");
259
261
  }
260
262
 
263
+ src.push("uniform vec2 pickClipPos;");
264
+
265
+ src.push("vec4 remapClipPos(vec4 clipPos) {");
266
+ src.push(" clipPos.xy /= clipPos.w;")
267
+ src.push(" clipPos.xy -= pickClipPos;");
268
+ src.push(" clipPos.xy *= clipPos.w;")
269
+ src.push(" return clipPos;")
270
+ src.push("}");
271
+
261
272
  src.push("bool isPerspectiveMatrix(mat4 m) {");
262
273
  src.push(" return (m[2][3] == - 1.0);");
263
274
  src.push("}");
@@ -364,7 +375,7 @@ export class TrianglesDataTexturePickDepthRenderer {
364
375
  src.push("vFragDepth = 1.0 + clipPos.w;");
365
376
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
366
377
  }
367
- src.push("gl_Position = clipPos;");
378
+ src.push("gl_Position = remapClipPos(clipPos);");
368
379
  src.push(" }");
369
380
  src.push("}");
370
381
  return src;
@@ -20,7 +20,7 @@ export class TrianglesDataTexturePickMeshRenderer {
20
20
 
21
21
  getValid() {
22
22
  return this._hash === this._getHash();
23
- };
23
+ }
24
24
 
25
25
  _getHash() {
26
26
  return this._scene._sectionPlanesState.getHash();
@@ -81,6 +81,7 @@ export class TrianglesDataTexturePickMeshRenderer {
81
81
  rtcViewMatrix = camera.viewMatrix;
82
82
  rtcCameraEye = camera.eye;
83
83
  }
84
+ gl.uniform2fv(this._uPickClipPos, frameCtx.pickClipPos);
84
85
  gl.uniformMatrix4fv(this._uSceneModelWorldMatrix, false, rotationMatrixConjugate);
85
86
  gl.uniformMatrix4fv(this._uViewMatrix, false, rtcViewMatrix);
86
87
  gl.uniformMatrix4fv(this._uProjMatrix, false, camera.projMatrix);
@@ -154,6 +155,7 @@ export class TrianglesDataTexturePickMeshRenderer {
154
155
  const program = this._program;
155
156
  this._uRenderPass = program.getLocation("renderPass");
156
157
  this._uPickInvisible = program.getLocation("pickInvisible");
158
+ this._uPickClipPos = program.getLocation("pickClipPos");
157
159
  this._uSceneModelWorldMatrix = program.getLocation("sceneModelWorldMatrix");
158
160
  this._uViewMatrix = program.getLocation("viewMatrix");
159
161
  this._uProjMatrix = program.getLocation("projMatrix");
@@ -251,6 +253,15 @@ export class TrianglesDataTexturePickMeshRenderer {
251
253
  src.push("out float isPerspective;");
252
254
  }
253
255
 
256
+ src.push("uniform vec2 pickClipPos;");
257
+
258
+ src.push("vec4 remapClipPos(vec4 clipPos) {");
259
+ src.push(" clipPos.xy /= clipPos.w;")
260
+ src.push(" clipPos.xy -= pickClipPos;");
261
+ src.push(" clipPos.xy *= clipPos.w;")
262
+ src.push(" return clipPos;")
263
+ src.push("}");
264
+
254
265
  src.push("bool isPerspectiveMatrix(mat4 m) {");
255
266
  src.push(" return (m[2][3] == - 1.0);");
256
267
  src.push("}");
@@ -361,7 +372,7 @@ export class TrianglesDataTexturePickMeshRenderer {
361
372
  src.push("vFragDepth = 1.0 + clipPos.w;");
362
373
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
363
374
  }
364
- src.push("gl_Position = clipPos;");
375
+ src.push("gl_Position = remapClipPos(clipPos);");
365
376
  src.push(" }");
366
377
  src.push("}");
367
378
  return src;
@@ -17,7 +17,7 @@ export class TrianglesDataTexturePickNormalsFlatRenderer {
17
17
 
18
18
  getValid() {
19
19
  return this._hash === this._getHash();
20
- };
20
+ }
21
21
 
22
22
  _getHash() {
23
23
  return this._scene._sectionPlanesState.getHash();
@@ -90,6 +90,7 @@ export class TrianglesDataTexturePickNormalsFlatRenderer {
90
90
 
91
91
  gl.uniform1i(this._uRenderPass, renderPass);
92
92
  gl.uniform1i(this._uPickInvisible, frameCtx.pickInvisible);
93
+ gl.uniform2fv(this._uPickClipPos, frameCtx.pickClipPos);
93
94
 
94
95
  gl.uniformMatrix4fv(this._uWorldMatrix, false, model.worldMatrix);
95
96
 
@@ -258,6 +259,7 @@ export class TrianglesDataTexturePickNormalsFlatRenderer {
258
259
 
259
260
  this._uRenderPass = program.getLocation("renderPass");
260
261
  this._uPickInvisible = program.getLocation("pickInvisible");
262
+ this._uPickClipPos = program.getLocation("pickClipPos");
261
263
  this._uPositionsDecodeMatrix = program.getLocation("positionsDecodeMatrix");
262
264
  this._uWorldMatrix = program.getLocation("worldMatrix");
263
265
  this._uViewMatrix = program.getLocation("viewMatrix");
@@ -347,6 +349,16 @@ export class TrianglesDataTexturePickNormalsFlatRenderer {
347
349
  src.push("}");
348
350
  src.push("out float isPerspective;");
349
351
  }
352
+
353
+ src.push("uniform vec2 pickClipPos;");
354
+
355
+ src.push("vec4 remapClipPos(vec4 clipPos) {");
356
+ src.push(" clipPos.xy /= clipPos.w;")
357
+ src.push(" clipPos.xy -= pickClipPos;");
358
+ src.push(" clipPos.xy *= clipPos.w;")
359
+ src.push(" return clipPos;")
360
+ src.push("}");
361
+
350
362
  src.push("out vec4 vWorldPosition;");
351
363
  if (clipping) {
352
364
  src.push("out int vFlags2;");
@@ -425,7 +437,7 @@ export class TrianglesDataTexturePickNormalsFlatRenderer {
425
437
  src.push("vFragDepth = 1.0 + clipPos.w;");
426
438
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
427
439
  }
428
- src.push("gl_Position = clipPos;");
440
+ src.push("gl_Position = remapClipPos(clipPos);");
429
441
  src.push(" }");
430
442
  src.push("}");
431
443
  return src;
@@ -17,7 +17,7 @@ export class TrianglesDataTexturePickNormalsRenderer {
17
17
 
18
18
  getValid() {
19
19
  return this._hash === this._getHash();
20
- };
20
+ }
21
21
 
22
22
  _getHash() {
23
23
  return this._scene._sectionPlanesState.getHash();
@@ -75,6 +75,7 @@ export class TrianglesDataTexturePickNormalsRenderer {
75
75
  gl.uniform3fv(this._uCameraEyeRtc, originCameraEye);
76
76
 
77
77
  gl.uniform1i(this._uPickInvisible, frameCtx.pickInvisible);
78
+ gl.uniform2fv(this._uPickClipPos, frameCtx.pickClipPos);
78
79
 
79
80
  if (scene.logarithmicDepthBufferEnabled) {
80
81
  const logDepthBufFC = 2.0 / (Math.log(camera.project.far + 1.0) / Math.LN2); // TODO: Far should be from projection matrix?
@@ -157,6 +158,7 @@ export class TrianglesDataTexturePickNormalsRenderer {
157
158
 
158
159
  this._uRenderPass = program.getLocation("renderPass");
159
160
  this._uPickInvisible = program.getLocation("pickInvisible");
161
+ this._uPickClipPos = program.getLocation("pickClipPos");
160
162
 
161
163
  this._uSectionPlanes = [];
162
164
 
@@ -241,6 +243,15 @@ export class TrianglesDataTexturePickNormalsRenderer {
241
243
  src.push("out float isPerspective;");
242
244
  }
243
245
 
246
+ src.push("uniform vec2 pickClipPos;");
247
+
248
+ src.push("vec4 remapClipPos(vec4 clipPos) {");
249
+ src.push(" clipPos.xy /= clipPos.w;")
250
+ src.push(" clipPos.xy -= pickClipPos;");
251
+ src.push(" clipPos.xy *= clipPos.w;")
252
+ src.push(" return clipPos;")
253
+ src.push("}");
254
+
244
255
  src.push("bool isPerspectiveMatrix(mat4 m) {");
245
256
  src.push(" return (m[2][3] == - 1.0);");
246
257
  src.push("}");
@@ -355,7 +366,7 @@ export class TrianglesDataTexturePickNormalsRenderer {
355
366
  src.push(" vWorldPosition = worldPosition;");
356
367
  src.push(" vFlags2 = flags2.w;");
357
368
  }
358
- src.push("gl_Position = clipPos;");
369
+ src.push("gl_Position = remapClipPos(clipPos);");
359
370
  src.push("}");
360
371
 
361
372
  src.push("}");
@@ -10,7 +10,6 @@ const edgesDefaultColor = new Float32Array([0, 0, 0, 1]);
10
10
 
11
11
  const tempVec4 = math.vec4();
12
12
  const tempVec3a = math.vec3();
13
- const tempVec3b = math.vec3();
14
13
  const tempVec3c = math.vec3();
15
14
  const tempMat4a = math.mat4();
16
15
 
@@ -83,6 +82,18 @@ class VBOSceneModelRenderer {
83
82
  return src;
84
83
  }
85
84
 
85
+ _addRemapClipPosLines(src) {
86
+ src.push("uniform vec2 pickClipPos;");
87
+
88
+ src.push("vec4 remapClipPos(vec4 clipPos) {");
89
+ src.push(" clipPos.xy /= clipPos.w;")
90
+ src.push(" clipPos.xy -= pickClipPos;");
91
+ src.push(" clipPos.xy *= clipPos.w;")
92
+ src.push(" return clipPos;")
93
+ src.push("}");
94
+ return src;
95
+ }
96
+
86
97
  getValid() {
87
98
  return this._hash === this._getHash();
88
99
  }
@@ -216,6 +227,7 @@ class VBOSceneModelRenderer {
216
227
  this._aPickColor = program.getAttribute("pickColor");
217
228
  this._uPickZNear = program.getLocation("pickZNear");
218
229
  this._uPickZFar = program.getLocation("pickZFar");
230
+ this._uPickClipPos = program.getLocation("pickClipPos");
219
231
 
220
232
  this._uColorMap = "uColorMap";
221
233
  this._uMetallicRoughMap = "uMetallicRoughMap";
@@ -256,7 +268,6 @@ class VBOSceneModelRenderer {
256
268
  const program = this._program;
257
269
  const lightsState = scene._lightsState;
258
270
  const lights = lightsState.lights;
259
- const project = scene.camera.project;
260
271
 
261
272
  program.bind();
262
273
 
@@ -283,43 +294,6 @@ class VBOSceneModelRenderer {
283
294
  gl.uniform3fv(this._uLightDir[i], light.dir);
284
295
  }
285
296
  }
286
-
287
- if (this._withSAO) {
288
- const sao = scene.sao;
289
- const saoEnabled = sao.possible;
290
- if (saoEnabled) {
291
- const viewportWidth = gl.drawingBufferWidth;
292
- const viewportHeight = gl.drawingBufferHeight;
293
- tempVec4[0] = viewportWidth;
294
- tempVec4[1] = viewportHeight;
295
- tempVec4[2] = sao.blendCutoff;
296
- tempVec4[3] = sao.blendFactor;
297
- gl.uniform4fv(this._uSAOParams, tempVec4);
298
- this._program.bindTexture(this._uOcclusionTexture, frameCtx.occlusionTexture, 0);
299
- }
300
- }
301
-
302
- if (scene.logarithmicDepthBufferEnabled) {
303
- const logDepthBufFC = 2.0 / (Math.log(project.far + 1.0) / Math.LN2);
304
- gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
305
- }
306
-
307
- if (this._uGammaFactor) {
308
- gl.uniform1f(this._uGammaFactor, scene.gammaFactor);
309
- }
310
-
311
- if (this._uPickInvisible) {
312
- gl.uniform1i(this._uPickInvisible, frameCtx.pickInvisible);
313
- }
314
-
315
-
316
- if (this._uShadowViewMatrix) {
317
- gl.uniformMatrix4fv(this._uShadowViewMatrix, false, frameCtx.shadowViewMatrix);
318
- }
319
-
320
- if (this._uShadowProjMatrix) {
321
- gl.uniformMatrix4fv(this._uShadowProjMatrix, false, frameCtx.shadowProjMatrix);
322
- }
323
297
  }
324
298
 
325
299
  _makeVAO(state) {
@@ -516,6 +490,10 @@ class VBOSceneModelRenderer {
516
490
  gl.uniform1f(this._uPickZFar, frameCtx.pickZFar);
517
491
  }
518
492
 
493
+ if (this._uPickClipPos) {
494
+ gl.uniform2fv(this._uPickClipPos, frameCtx.pickClipPos);
495
+ }
496
+
519
497
  if (this._uPositionsDecodeMatrix) {
520
498
  gl.uniformMatrix4fv(this._uPositionsDecodeMatrix, false, state.positionsDecodeMatrix);
521
499
  }
@@ -27,6 +27,8 @@ class PointsBatchingPickDepthRenderer extends VBOSceneModelPointBatchingRenderer
27
27
 
28
28
  this._addMatricesUniformBlockLines(src);
29
29
 
30
+ this._addRemapClipPosLines(src);
31
+
30
32
  src.push("uniform float pointSize;");
31
33
  if (pointsMaterial.perspectivePoints) {
32
34
  src.push("uniform float nearPlaneHeight;");
@@ -65,7 +67,7 @@ class PointsBatchingPickDepthRenderer extends VBOSceneModelPointBatchingRenderer
65
67
  if (scene.logarithmicDepthBufferEnabled) {
66
68
  src.push("vFragDepth = 1.0 + clipPos.w;");
67
69
  }
68
- src.push("gl_Position = clipPos;");
70
+ src.push("gl_Position = remapClipPos(clipPos);");
69
71
  if (pointsMaterial.perspectivePoints) {
70
72
  src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");
71
73
  src.push("gl_PointSize = max(gl_PointSize, " + Math.floor(pointsMaterial.minPerspectivePointSize) + ".0);");
@@ -30,6 +30,8 @@ class PointsBatchingPickMeshRenderer extends VBOSceneModelPointBatchingRenderer
30
30
 
31
31
  this._addMatricesUniformBlockLines(src);
32
32
 
33
+ this._addRemapClipPosLines(src);
34
+
33
35
  src.push("uniform float pointSize;");
34
36
  if (pointsMaterial.perspectivePoints) {
35
37
  src.push("uniform float nearPlaneHeight;");
@@ -71,7 +73,7 @@ class PointsBatchingPickMeshRenderer extends VBOSceneModelPointBatchingRenderer
71
73
  if (scene.logarithmicDepthBufferEnabled) {
72
74
  src.push("vFragDepth = 1.0 + clipPos.w;");
73
75
  }
74
- src.push("gl_Position = clipPos;");
76
+ src.push("gl_Position = remapClipPos(clipPos);");
75
77
  if (pointsMaterial.perspectivePoints) {
76
78
  src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");
77
79
  src.push("gl_PointSize = max(gl_PointSize, " + Math.floor(pointsMaterial.minPerspectivePointSize) + ".0);");
@@ -35,6 +35,8 @@ class PointsInstancingPickDepthRenderer extends VBOSceneModelPointInstancingRend
35
35
 
36
36
  this._addMatricesUniformBlockLines(src);
37
37
 
38
+ this._addRemapClipPosLines(src);
39
+
38
40
  src.push("uniform float pointSize;");
39
41
  if (pointsMaterial.perspectivePoints) {
40
42
  src.push("uniform float nearPlaneHeight;");
@@ -74,10 +76,11 @@ class PointsInstancingPickDepthRenderer extends VBOSceneModelPointInstancingRend
74
76
  }
75
77
  src.push(" vViewPosition = viewPosition;");
76
78
  src.push("vec4 clipPos = projMatrix * viewPosition;");
79
+ src.push("gl_Position = remapClipPos(clipPos);");
77
80
  if (scene.logarithmicDepthBufferEnabled) {
78
81
  src.push("vFragDepth = 1.0 + clipPos.w;");
79
82
  }
80
- src.push("gl_Position = clipPos;");
83
+ src.push("gl_Position = remapClipPos(clipPos);");
81
84
  if (pointsMaterial.perspectivePoints) {
82
85
  src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");
83
86
  src.push("gl_PointSize = max(gl_PointSize, " + Math.floor(pointsMaterial.minPerspectivePointSize) + ".0);");
@@ -32,6 +32,8 @@ class PointsInstancingPickMeshRenderer extends VBOSceneModelPointInstancingRende
32
32
 
33
33
  this._addMatricesUniformBlockLines(src);
34
34
 
35
+ this._addRemapClipPosLines(src);
36
+
35
37
  src.push("uniform float pointSize;");
36
38
  if (pointsMaterial.perspectivePoints) {
37
39
  src.push("uniform float nearPlaneHeight;");
@@ -73,6 +75,7 @@ class PointsInstancingPickMeshRenderer extends VBOSceneModelPointInstancingRende
73
75
  src.push(" vFlags = flags;");
74
76
  }
75
77
  src.push("vec4 clipPos = projMatrix * viewPosition;");
78
+ src.push("gl_Position = remapClipPos(clipPos);");
76
79
  if (scene.logarithmicDepthBufferEnabled) {
77
80
  src.push("vFragDepth = 1.0 + clipPos.w;");
78
81
  }
@@ -40,6 +40,9 @@ class TrianglesBatchingPickDepthRenderer extends VBOSceneModelTriangleBatchingRe
40
40
  src.push("out vec4 vWorldPosition;");
41
41
  src.push("out float vFlags;");
42
42
  }
43
+
44
+ this._addRemapClipPosLines(src);
45
+
43
46
  src.push("out vec4 vViewPosition;");
44
47
  src.push("void main(void) {");
45
48
 
@@ -65,7 +68,7 @@ class TrianglesBatchingPickDepthRenderer extends VBOSceneModelTriangleBatchingRe
65
68
  src.push("vFragDepth = 1.0 + clipPos.w;");
66
69
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
67
70
  }
68
- src.push("gl_Position = clipPos;");
71
+ src.push("gl_Position = remapClipPos(clipPos);");
69
72
  src.push(" }");
70
73
  src.push("}");
71
74
  return src;
@@ -41,6 +41,8 @@ class TrianglesBatchingPickMeshRenderer extends VBOSceneModelTriangleBatchingRen
41
41
  src.push("out float vFlags;");
42
42
  }
43
43
 
44
+ this._addRemapClipPosLines(src);
45
+
44
46
  src.push("out vec4 vPickColor;");
45
47
 
46
48
  src.push("void main(void) {");
@@ -68,7 +70,7 @@ class TrianglesBatchingPickMeshRenderer extends VBOSceneModelTriangleBatchingRen
68
70
  src.push("vFragDepth = 1.0 + clipPos.w;");
69
71
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
70
72
  }
71
- src.push("gl_Position = clipPos;");
73
+ src.push("gl_Position = remapClipPos(clipPos);");
72
74
  src.push(" }");
73
75
  src.push("}");
74
76
  return src;
@@ -23,6 +23,8 @@ class TrianglesBatchingPickNormalsFlatRenderer extends VBOSceneModelTriangleBatc
23
23
 
24
24
  this._addMatricesUniformBlockLines(src);
25
25
 
26
+ this._addRemapClipPosLines(src);
27
+
26
28
  if (scene.logarithmicDepthBufferEnabled) {
27
29
  src.push("uniform float logDepthBufFC;");
28
30
  src.push("out float vFragDepth;");
@@ -56,7 +58,7 @@ class TrianglesBatchingPickNormalsFlatRenderer extends VBOSceneModelTriangleBatc
56
58
  src.push("vFragDepth = 1.0 + clipPos.w;");
57
59
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
58
60
  }
59
- src.push("gl_Position = clipPos;");
61
+ src.push("gl_Position = remapClipPos(clipPos);");
60
62
  src.push(" }");
61
63
  src.push("}");
62
64
  return src;
@@ -24,6 +24,8 @@ class TrianglesBatchingPickNormalsRenderer extends VBOSceneModelTriangleBatching
24
24
 
25
25
  this._addMatricesUniformBlockLines(src);
26
26
 
27
+ this._addRemapClipPosLines(src);
28
+
27
29
  if (scene.logarithmicDepthBufferEnabled) {
28
30
  src.push("uniform float logDepthBufFC;");
29
31
  src.push("out float vFragDepth;");
@@ -68,7 +70,7 @@ class TrianglesBatchingPickNormalsRenderer extends VBOSceneModelTriangleBatching
68
70
  src.push("vFragDepth = 1.0 + clipPos.w;");
69
71
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
70
72
  }
71
- src.push("gl_Position = clipPos;");
73
+ src.push("gl_Position = remapClipPos(clipPos);");
72
74
  src.push(" }");
73
75
  src.push("}");
74
76
  return src;
@@ -30,6 +30,8 @@ class TrianglesInstancingPickDepthRenderer extends VBOSceneModelTriangleInstanci
30
30
 
31
31
  this._addMatricesUniformBlockLines(src);
32
32
 
33
+ this._addRemapClipPosLines(src);
34
+
33
35
  if (scene.logarithmicDepthBufferEnabled) {
34
36
  src.push("uniform float logDepthBufFC;");
35
37
  src.push("out float vFragDepth;");
@@ -72,7 +74,7 @@ class TrianglesInstancingPickDepthRenderer extends VBOSceneModelTriangleInstanci
72
74
  src.push("vFragDepth = 1.0 + clipPos.w;");
73
75
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
74
76
  }
75
- src.push("gl_Position = clipPos;");
77
+ src.push("gl_Position = remapClipPos(clipPos);");
76
78
  src.push("}");
77
79
  src.push("}");
78
80
  return src;
@@ -29,6 +29,8 @@ class TrianglesInstancingPickMeshRenderer extends VBOSceneModelTriangleInstancin
29
29
 
30
30
  this._addMatricesUniformBlockLines(src);
31
31
 
32
+ this._addRemapClipPosLines(src);
33
+
32
34
  if (scene.logarithmicDepthBufferEnabled) {
33
35
  src.push("uniform float logDepthBufFC;");
34
36
  src.push("out float vFragDepth;");
@@ -73,7 +75,7 @@ class TrianglesInstancingPickMeshRenderer extends VBOSceneModelTriangleInstancin
73
75
  src.push("vFragDepth = 1.0 + clipPos.w;");
74
76
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
75
77
  }
76
- src.push("gl_Position = clipPos;");
78
+ src.push("gl_Position = remapClipPos(clipPos);");
77
79
  src.push("}");
78
80
  src.push("}");
79
81
  return src;
@@ -27,6 +27,8 @@ class TrianglesInstancingPickNormalsFlatRenderer extends VBOSceneModelTriangleIn
27
27
 
28
28
  this._addMatricesUniformBlockLines(src);
29
29
 
30
+ this._addRemapClipPosLines(src);
31
+
30
32
  if (scene.logarithmicDepthBufferEnabled) {
31
33
  src.push("uniform float logDepthBufFC;");
32
34
  src.push("out float vFragDepth;");
@@ -65,7 +67,7 @@ class TrianglesInstancingPickNormalsFlatRenderer extends VBOSceneModelTriangleIn
65
67
  src.push("vFlags = flags;");
66
68
  }
67
69
 
68
- src.push("gl_Position = clipPos;");
70
+ src.push("gl_Position = remapClipPos(clipPos);");
69
71
  src.push("}");
70
72
  src.push("}");
71
73
  return src;
@@ -31,6 +31,8 @@ class TrianglesInstancingPickNormalsRenderer extends VBOSceneModelTriangleInstan
31
31
 
32
32
  this._addMatricesUniformBlockLines(src);
33
33
 
34
+ this._addRemapClipPosLines(src);
35
+
34
36
  if (scene.logarithmicDepthBufferEnabled) {
35
37
  src.push("uniform float logDepthBufFC;");
36
38
  src.push("out float vFragDepth;");
@@ -79,7 +81,7 @@ class TrianglesInstancingPickNormalsRenderer extends VBOSceneModelTriangleInstan
79
81
  src.push("vFragDepth = 1.0 + clipPos.w;");
80
82
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
81
83
  }
82
- src.push("gl_Position = clipPos;");
84
+ src.push("gl_Position = remapClipPos(clipPos);");
83
85
  src.push("}");
84
86
  src.push("}");
85
87
  return src;
@@ -167,7 +167,7 @@ class RenderBuffer {
167
167
 
168
168
  read(pickX, pickY, glFormat = null, glType = null, arrayType = Uint8Array, arrayMultiplier = 4) {
169
169
  const x = pickX;
170
- const y = (this.buffer.height || this.gl.drawingBufferHeight) - pickY;
170
+ const y = this.buffer.height ? (this.buffer.height - pickY - 1) : (this.gl.drawingBufferHeight - pickY);
171
171
  const pix = new arrayType(arrayMultiplier);
172
172
  const gl = this.gl;
173
173
  gl.readPixels(x, y, 1, 1, glFormat || gl.RGBA, glType || gl.UNSIGNED_BYTE, pix, 0);