PerspectiveCamera
A camera using a perspective projection.
Perspective projection applies foreshortening: objects appear smaller the farther they are from the camera, which makes this the camera to use for 3D scenes such as volume rendering. It pairs naturally with OrbitControls.
The projection is defined by a vertical field of view, an aspect ratio, and near/far clipping planes. Zooming narrows or widens the field of view rather than moving the camera.
const camera = new PerspectiveCamera({ fov: 45 });
const controls = new OrbitControls(camera, {
radius: 1200,
target: [0, 0, 0],
});
const idetik = new Idetik({
canvas: document.querySelector('canvas')!,
viewports: [{ camera, layers: [volumeLayer], cameraControls: controls }],
});Extends Camera and inherits all public properties and methods.
Constructor
Creates a perspective camera from the given projection settings.
new PerspectiveCamera(props?): PerspectiveCamera;| Parameter | Description |
|---|---|
props: PerspectiveCameraProps | Initialization properties. Defaults to {}. |
Types
PerspectiveCameraProps
Initialization properties for constructing a perspective camera.
Accessors
type CameraType overrides
Identifies the camera type as PerspectiveCamera.
get type(): CameraType;fov number
The vertical field of view in degrees.
get fov(): number;Methods
setAspectRatio() void overrides
Sets the aspect ratio (width / height) of the viewport the camera renders into. Called automatically by the owning viewport when it resizes.
setAspectRatio(aspectRatio): void;| Parameter | Description |
|---|---|
aspectRatio: number | The viewport's width divided by its height. |
zoom() void overrides
Zooms the view by the given factor relative to the current zoom level. Factors greater than 1 zoom in and factors between 0 and 1 zoom out.
Zooming narrows or widens the field of view rather than moving the camera, and the result is clamped to valid angles.
zoom(factor): void;| Parameter | Description |
|---|---|
factor: number | The magnification factor to apply. |