Skip to content

Commit

Permalink
XCD-242 Fix near and far values for ray picking
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalDybizbanskiCreoox committed Jan 23, 2025
1 parent ac1d51b commit 328e955
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/viewer/scene/webgl/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,9 @@ const Renderer = function (scene, options) {
pickProjMatrix = scene.camera.projMatrix;
projection = scene.camera.projection;

nearAndFar[0] = scene.camera.project.near;
nearAndFar[1] = scene.camera.project.far;

pickResult.canvasPos = params.canvasPos;

} else {
Expand All @@ -948,6 +951,9 @@ const Renderer = function (scene, options) {
pickProjMatrix = scene.camera.projMatrix;
projection = scene.camera.projection;

nearAndFar[0] = scene.camera.project.near;
nearAndFar[1] = scene.camera.project.far;

} else {

worldRayOrigin.set(params.origin || [0, 0, 0]);
Expand All @@ -967,6 +973,9 @@ const Renderer = function (scene, options) {
pickProjMatrix = scene.camera.ortho.matrix;
projection = "ortho";

nearAndFar[0] = scene.camera.ortho.near;
nearAndFar[1] = scene.camera.ortho.far;

pickResult.origin = worldRayOrigin;
pickResult.direction = worldRayDir;
}
Expand Down Expand Up @@ -1021,9 +1030,6 @@ const Renderer = function (scene, options) {

if (pickable.canPickWorldPos && pickable.canPickWorldPos()) {

nearAndFar[0] = scene.camera.project.near;
nearAndFar[1] = scene.camera.project.far;

gpuPickWorldPos(pickBuffer, pickable, canvasPos, pickViewMatrix, pickProjMatrix, nearAndFar, pickResult);

if (params.pickSurfaceNormal !== false) {
Expand Down

0 comments on commit 328e955

Please sign in to comment.