Skip to content

@minecraft/server


@minecraft/server / Camera

Class: Camera ​

Defined in: @minecraft/server/index.d.ts:6058

Contains methods relating to the active camera for the specified player.

Properties ​

isValid ​

readonly isValid: boolean

Defined in: @minecraft/server/index.d.ts:6067

Remarks ​

Returns whether the Camera is valid to access and use. A Camera is considered valid when the owning Player of the Camera is loaded and valid itself.

Methods ​

attachToEntity() ​

attachToEntity(attachCameraOptions?): void

Defined in: @minecraft/server/index.d.ts:6079

Parameters ​

attachCameraOptions? ​

CameraAttachOptions

Options for the entity the camera is attaching to. Contains the entity identifier and optional entity location.

Returns ​

void

Remarks ​

Attaches the camera to a non-player entity.

This function can't be called in restricted-execution mode.

Throws ​

This function can throw errors.


clear() ​

clear(): void

Defined in: @minecraft/server/index.d.ts:6091

Returns ​

void

Remarks ​

Clears the active camera for the specified player. Causes the specified players to end any in-progress camera perspectives, including any eased camera motions, and return to their normal perspective.

This function can't be called in restricted-execution mode.

Throws ​

This function can throw errors.


fade() ​

fade(fadeCameraOptions?): void

Defined in: @minecraft/server/index.d.ts:6103

Parameters ​

fadeCameraOptions? ​

CameraFadeOptions

Additional options around camera fade operations.

Returns ​

void

Remarks ​

Begins a camera fade transition. A fade transition is a full-screen color that fades-in, holds, and then fades-out.

This function can't be called in restricted-execution mode.

Throws ​

This function can throw errors.


playAnimation() ​

playAnimation(splineType, cameraAnimationOptions): void

Defined in: @minecraft/server/index.d.ts:6110

Parameters ​

splineType ​

CatmullRomSpline | LinearSpline

cameraAnimationOptions ​

AnimationOptions

Returns ​

void

Remarks ​

This function can't be called in restricted-execution mode.

Throws ​

This function can throw errors.


setCamera() ​

setCamera(cameraPreset, setOptions?): void

Defined in: @minecraft/server/index.d.ts:6123

Parameters ​

cameraPreset ​

string

Identifier of a camera preset file defined within JSON.

setOptions? ​

CameraFixedBoomOptions | CameraSetFacingOptions | CameraSetLocationOptions | CameraSetPosOptions | CameraSetRotOptions | CameraTargetOptions

Additional options for the camera.

Returns ​

void

Remarks ​

Sets the current active camera for the specified player.

This function can't be called in restricted-execution mode.

Throws ​

This function can throw errors.


setDefaultCamera() ​

setDefaultCamera(cameraPreset, easeOptions?): void

Defined in: @minecraft/server/index.d.ts:6148

Parameters ​

cameraPreset ​

string

Identifier of a camera preset file defined within JSON.

easeOptions? ​

EaseOptions

Options to ease the camera back to its original position and rotation.

Returns ​

void

Remarks ​

Sets the current active camera for the specified player and resets the position and rotation to the values defined in the JSON.

This function can't be called in restricted-execution mode.

Throws ​

This function can throw errors.


setFov() ​

setFov(fovCameraOptions?): void

Defined in: @minecraft/server/index.d.ts:6155

Parameters ​

fovCameraOptions? ​

CameraFovOptions

Returns ​

void

Remarks ​

This function can't be called in restricted-execution mode.

Throws ​

This function can throw errors.