Skip to content

Commit 52baaaa

Browse files
authored
Merge pull request #90 from tentone/copilot/fix-scissor-multiply-pixel-ratio
fix: correct scissor region on high-DPI displays (pixelRatio > 1)
2 parents 3e2f261 + 2a2e67c commit 52baaaa

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

source/point-cloud-octree-picker.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ export class PointCloudOctreePicker
157157
renderer.setRenderTarget(pickState.renderTarget);
158158

159159
// Render the intersected nodes onto the pick render target, clipping to a small pick window.
160-
renderer.setScissor(x, y, pickWndSize, pickWndSize);
160+
// x, y and pickWndSize are in device pixels. setScissor() multiplies by pixelRatio internally,
161+
// so we must divide first to avoid applying the pixel ratio twice on high-DPI displays.
162+
const pixelRatio = renderer.getPixelRatio();
163+
renderer.setScissor(x / pixelRatio, y / pixelRatio, pickWndSize / pixelRatio, pickWndSize / pixelRatio);
161164
renderer.setScissorTest(true);
162165
renderer.state.buffers.depth.setTest(pickMaterial.depthTest);
163166
renderer.state.buffers.depth.setMask(pickMaterial.depthWrite);

0 commit comments

Comments
 (0)