From 7b7a989b1e7e92f8093a81a4340afc238ad06556 Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Wed, 5 May 2021 08:09:08 +0200 Subject: [PATCH] Fix object detection under mouse. --- source/viewer/viewer.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/viewer/viewer.js b/source/viewer/viewer.js index abd2798..15c76d4 100644 --- a/source/viewer/viewer.js +++ b/source/viewer/viewer.js @@ -347,7 +347,13 @@ OV.Viewer = class GetMeshUserDataUnderMouse (mouseCoords) { - let mesh = this.geometry.GetModelMeshUnderMouse (mouseCoords, this.camera, this.canvas.width, this.canvas.height); + let width = this.canvas.width; + let height = this.canvas.height; + if (window.devicePixelRatio) { + width /= window.devicePixelRatio; + height /= window.devicePixelRatio; + } + let mesh = this.geometry.GetModelMeshUnderMouse (mouseCoords, this.camera, width, height); if (mesh === null) { return null; }