Skip to main content

Camera

class Camera

Camera that renders the scene of View3D

constructor

new Camera(view3D)

Create new Camera instance

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
view3DView3DAn instance of View3D

Properties

threeCamera

readonly

Three.js PerspectiveCamera instance

Type: THREE.PerspectiveCamera

defaultPose

readonly

Camera's default pose(yaw, pitch, zoom, pivot)
This will be new currentPose when reset() is called

Type: Pose

Returns: Pose

currentPose

readonly

Camera's current pose value

Type: Pose

Returns: Pose

newPose

Camera's new pose that will be applied on the next frame
Camera#updatePosition should be called after changing this value.

Type: Pose

Returns: Pose

yaw

Camera's current yaw
Camera#updatePosition should be called after changing this value.

Type: number

pitch

Camera's current pitch
Camera#updatePosition should be called after changing this value.

Type: number

zoom

Camera's current zoom value
Camera#updatePosition should be called after changing this value.

Type: number

distance

readonly

Camera's disatance from current camera pivot(target)

Type: number

baseDistance

readonly

Camera's default distance from the model center.
This will be automatically calculated based on the model size.

Type: number

baseFov

readonly

Camera's default fov value.
This will be automatically chosen when view3D.fov is "auto", otherwise it is equal to view3D.fov

Type: number

pivot

readonly

Current pivot point of camera rotation

Type: THREE.Vector3

See:

fov

readonly

Camera's focus of view value (vertical)

Type: number

See:

renderWidth

readonly

Camera's frustum width

Type: number

renderHeight

readonly

Camera's frustum height

Type: number

Methods

reset

Reset camera to default pose

Returns: Promise<void>

  • Promise that resolves when the animation finishes
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
durationnumber✔️0Duration of the reset animation
easingfunction✔️DEFAULT.EASINGEasing function for the reset animation
posePose✔️Pose to reset, camera will reset to defaultPose if pose is not given.

resize

Update camera's aspect to given size

Returns: void

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
sizeobjectNew size to apply
size.widthnumber✔️nullNew width
size.heightnumber✔️New height

fit

Fit camera frame to the given model

Returns: void

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
modelModel

updatePosition

Update camera position

Returns: void