Skip to content

View

import { View } from '../lib/fabric'
<View track={fabric} />
<View track={heroRef} camera={{ fov: 30 }} index={1} />

<View> registers a DOM rectangle with the engine. The frame is rendered clipped to that rectangle, with its own camera overrides. The scene does not draw without at least one.

PropTypeDefaultNotes
tracksignal, getter, { current } ref, or the fabric contextThe element whose box the view follows
camera{ fov?, zoom?, position? }Overrides for this view; unset fields fall back to <Camera>
visiblebooleantrueSkip rendering this view
indexnumber0Render order, low to high

track accepts useFabric() directly — the view reads its canvas — so the common case needs no element pulled out.

The view re-measures its rectangle on resize and scroll, and re-registers if the tracked reference changes. An IntersectionObserver marks it off-screen, and an off-screen view is skipped entirely.

Multiple views render the scene once each, in index order, with viewport and scissor set to the view’s rectangle and the projection’s aspect matched to it — so a sphere stays round in a tall view and a wide one. position on a view’s camera moves the eye for that view only; the camera always looks at the origin.

With views registered, autoCull on <Scene> is disabled, since one cull cannot serve several cameras.