Skip to content

PolyCamera

The camera component wraps a scene and controls how it is viewed — perspective depth, rotation angles, zoom, and optional pointer-driven interaction. For most use cases, pass camera attributes directly to the scene element / PolyScene component instead. The camera wrapper is useful when you need imperative camera control (e.g., animating the camera from code or syncing it to an external state) — it’s available as a React / Vue component (<PolyCamera>); vanilla users should set the same attributes (rot-x, rot-y, perspective, zoom, interactive) directly on <poly-scene>.

PropTypeDefaultDescription
zoomnumber1Scales the scene. 1 is the natural size; values above 1 zoom in, below 1 zoom out.
rotXnumber65Rotation around the X axis in degrees.
rotYnumber45Rotation around the Y axis in degrees (0–360).
perspectivenumber | false1000CSS perspective depth in pixels. Pass false for orthographic projection.
interactivebooleanfalseWhen true, users can click and drag to rotate the camera.
animateboolean | number | objectfalseAuto-rotate. true uses defaults, a number sets the speed, or pass { axis, speed, pauseOnInteraction }.

Set an initial angle and perspective.

<script type="module" src="https://esm.sh/polycss/elements"></script>
<!-- Vanilla scenes set camera attributes directly on <poly-scene>. -->
<poly-scene zoom="0.8" rot-x="70" rot-y="30">
<poly-mesh src="/cottage.glb"></poly-mesh>
</poly-scene>
<!-- Vanilla -->
<poly-scene interactive animate>
<poly-mesh src="/cottage.glb"></poly-mesh>
</poly-scene>
// React
<PolyCamera
interactive
animate={{ axis: "y", speed: 0.5, pauseOnInteraction: true }}
>
<PolyScene>
<PolyMesh src="/cottage.glb" />
</PolyScene>
</PolyCamera>

useCamera is used internally by <PolyCamera>. For most use cases, pass camera props directly to <PolyScene> — it accepts all of PolyCamera’s props. Use <PolyCamera> as a wrapper when you need to separate camera state from scene layout.