diff --git a/Sources/Interaction/Style/InteractorStyleTrackballCamera/index.js b/Sources/Interaction/Style/InteractorStyleTrackballCamera/index.js index dee4ed7856e..2f6e41b6cef 100644 --- a/Sources/Interaction/Style/InteractorStyleTrackballCamera/index.js +++ b/Sources/Interaction/Style/InteractorStyleTrackballCamera/index.js @@ -183,25 +183,28 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) { const pos = model.interactor.getEventPosition( model.interactor.getPointerIndex() ); - publicAPI.findPokedRenderer(pos.x, pos.y); - if (model.currentRenderer === null) { - return; - } - const camera = model.currentRenderer.getActiveCamera(); + if (pos) { + publicAPI.findPokedRenderer(pos.x, pos.y); + if (model.currentRenderer === null) { + return; + } - const dyf = model.interactor.getScale() / model.interactor.getLastScale(); - if (camera.getParallelProjection()) { - camera.setParallelScale(camera.getParallelScale() / dyf); - } else { - camera.dolly(dyf); - if (model.autoAdjustCameraClippingRange) { - model.currentRenderer.resetCameraClippingRange(); + const camera = model.currentRenderer.getActiveCamera(); + + const dyf = model.interactor.getScale() / model.interactor.getLastScale(); + if (camera.getParallelProjection()) { + camera.setParallelScale(camera.getParallelScale() / dyf); + } else { + camera.dolly(dyf); + if (model.autoAdjustCameraClippingRange) { + model.currentRenderer.resetCameraClippingRange(); + } } - } - if (model.interactor.getLightFollowCamera()) { - model.currentRenderer.updateLightsGeometryToFollowCamera(); + if (model.interactor.getLightFollowCamera()) { + model.currentRenderer.updateLightsGeometryToFollowCamera(); + } } };