From 4ddb350fb3cd23b4054247a786c19a4a89e1b35a Mon Sep 17 00:00:00 2001 From: xeolabs Date: Wed, 27 Jan 2021 17:26:11 +0100 Subject: [PATCH] Fix surface picking option to not pick surface normal #550 --- .../scene/CameraControl/lib/controllers/PickController.js | 2 +- src/viewer/scene/scene/Scene.js | 2 +- src/viewer/scene/webgl/Renderer.js | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/viewer/scene/CameraControl/lib/controllers/PickController.js b/src/viewer/scene/CameraControl/lib/controllers/PickController.js index d967d8d53f..6959c4fa14 100644 --- a/src/viewer/scene/CameraControl/lib/controllers/PickController.js +++ b/src/viewer/scene/CameraControl/lib/controllers/PickController.js @@ -111,7 +111,7 @@ class PickController { this.pickResult = this._scene.pick({ pickSurface: true, - pickSurfaceNormal: true, + pickSurfaceNormal: false, canvasPos: this.pickCursorPos }); diff --git a/src/viewer/scene/scene/Scene.js b/src/viewer/scene/scene/Scene.js index 0aea4be6b6..e83a27438e 100644 --- a/src/viewer/scene/scene/Scene.js +++ b/src/viewer/scene/scene/Scene.js @@ -1988,7 +1988,7 @@ class Scene extends Component { pickResult = this._renderer.pick(params, pickResult); if (pickResult) { - if (pickResult.entity.fire) { + if (pickResult.entity && pickResult.entity.fire) { pickResult.entity.fire("picked", pickResult); // TODO: PerformanceModelNode doesn't fire events } return pickResult; diff --git a/src/viewer/scene/webgl/Renderer.js b/src/viewer/scene/webgl/Renderer.js index a76be4651a..a2f25b9ed8 100644 --- a/src/viewer/scene/webgl/Renderer.js +++ b/src/viewer/scene/webgl/Renderer.js @@ -894,7 +894,9 @@ const Renderer = function (scene, options) { nearAndFar[1] = scene.camera.project.far; pickWorldPos(pickable, canvasX, canvasY, pickViewMatrix, pickProjMatrix, nearAndFar, pickResult); - pickWorldNormal(pickable, canvasX, canvasY, pickViewMatrix, pickProjMatrix, nearAndFar, pickResult); + if (params.pickSurfaceNormal !== false) { + pickWorldNormal(pickable, canvasX, canvasY, pickViewMatrix, pickProjMatrix, nearAndFar, pickResult); + } } } }