Skip to content

usePixelPerfectCamera

usePixelPerfectCamera(options?): PixelPerfectCamera

Defined in: packages/three-flatland/src/react/usePixelPerfectCamera.ts:42

Create and resize a PixelPerfectCamera from R3F’s CSS size and DPR.

The hook installs the camera as the root default unless makeDefault is false, and restores the previous camera when unmounted. R3F’s own orthographic resize path is marked manual so it cannot overwrite the physical-pixel projection. The renderer viewport, R3F viewport metrics, and pointer-event mapping follow the camera’s centered pixel viewport.

UsePixelPerfectCameraOptions = {}

PixelPerfectCamera

function Scene() {
usePixelPerfectCamera({ viewSize: 240 })
return <sprite2D pixelPerfect texture={texture} />
}