Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/threejs_4_deno/src/Three.js>PerspectiveCamera

A simple transformation of three.js for use within a Deno workflow
Go to Latest
class PerspectiveCamera
extends Camera
Re-export
import { PerspectiveCamera } from "https://deno.land/x/threejs_4_deno@v121/src/Three.js";

Camera with perspective projection.

Constructors

new
PerspectiveCamera(
fov?: number,
aspect?: number,
near?: number,
far?: number,
)

Properties

aspect: number

Camera frustum aspect ratio, window width divided by window height.

far: number

Camera frustum far plane.

filmGauge: number
filmOffset: number
focus: number
fov: number

Camera frustum vertical field of view, from bottom to top of view, in degrees.

readonly
isPerspectiveCamera: true
near: number

Camera frustum near plane.

type: "PerspectiveCamera"
view: null | { enabled: boolean; fullWidth: number; fullHeight: number; offsetX: number; offsetY: number; width: number; height: number; }
zoom: number

Methods

getEffectiveFOV(): number
getFilmHeight(): number
getFilmWidth(): number
getFocalLength(): number
setFocalLength(focalLength: number): void
deprecated
setLens(focalLength: number, frameHeight?: number): void
setViewOffset(
fullWidth: number,
fullHeight: number,
x: number,
y: number,
width: number,
height: number,
): void

Sets an offset in a larger frustum. This is useful for multi-window or multi-monitor/multi-machine setups. For example, if you have 3x2 monitors and each monitor is 1920x1080 and the monitors are in grid like this:

	 +---+---+---+
	 | A | B | C |
	 +---+---+---+
	 | D | E | F |
	 +---+---+---+

then for each monitor you would call it like this:

	 const w = 1920;
	 const h = 1080;
	 const fullWidth = w * 3;
	 const fullHeight = h * 2;

	 // A
	 camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
	 // B
	 camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );
	 // C
	 camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );
	 // D
	 camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );
	 // E
	 camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );
	 // F
	 camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h ); Note there is no reason monitors have to be the same size or in a grid.
toJSON(meta?: any): any

Updates the camera projection matrix. Must be called after change of parameters.