Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/lib/src/utils/picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ const getEntityAtPointerEvent = async (app : AppBase, picker: Picker, rect: DOMR
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;

// Account for canvas scaling
const scaleX = canvas.width / rect.width;
const scaleY = canvas.height / rect.height;
// Scale calculation using PlayCanvas's DPR
const scaleX = canvas.width / (rect.width * app.graphicsDevice.maxPixelRatio);
const scaleY = canvas.height / (rect.height * app.graphicsDevice.maxPixelRatio);

// prepare the picker and perform picking
try {
Expand All @@ -67,7 +67,6 @@ const getEntityAtPointerEvent = async (app : AppBase, picker: Picker, rect: DOMR
if (!meshInstance) return null

return meshInstance?.node as Entity;
return null
} catch {
// The picker can fail if the camera is not active or the canvas is not visible
return null;
Expand Down
Loading