export declare class Camera
cameraRoll |
The camera roll angle.
Signature
cameraRoll: HorizonProperty<number>; Remarks You can change this value over time using . |
collisionEnabled |
Indicates whether camera collision is enabled.
Signature
collisionEnabled: HorizonProperty<boolean>; |
currentMode |
The type of camera that is active.
Signature
currentMode: ReadableHorizonProperty<CameraMode>; Remarks For native cameras, this propety indicates whether the camera is in first or third person mode. |
forward |
Gets the forward direction of the camera.
Signature
forward: ReadableHorizonProperty<Vec3>; Examples if (LocalCamera !== null) { LocalCamera.forward.get() } |
isForceLookAtcamera |
Is current active camera force looking at something.
Signature
isForceLookAtcamera: ReadableHorizonProperty<boolean>; |
lookAtPosition |
Gets the world space position that first intersects the center of the camera view, ignoring the avatar of the local player.
Signature
lookAtPosition: ReadableHorizonProperty<Vec3>; Examples if (LocalCamera !== null) { var lookAtPosition = LocalCamera.lookAtPosition.get(); } |
perspectiveSwitchingEnabled |
Indicates whether the player is allowed to toggle between first and third person modes.
Signature
perspectiveSwitchingEnabled: HorizonProperty<boolean>; Examples if (LocalCamera !== null) { LocalCamera.position.get() } Remarks This property does not affect a script's ability to forcibly enable 1st or 3rd person mode with or . This property has as no effect in VR, where first person is always enabled. |
position |
Gets the position of the camera.
Signature
position: ReadableHorizonProperty<Vec3>; Examples if (LocalCamera !== null) { LocalCamera.position.get() } |
rotation |
Gets the rotation of the camera.
Signature
rotation: ReadableHorizonProperty<Quaternion>; Examples if (LocalCamera !== null) { LocalCamera.rotation.get() } |
up |
Gets the up direction of the camera.
Signature
up: ReadableHorizonProperty<Vec3>; Examples if (LocalCamera !== null) { LocalCamera.up.get() } |
convertWorldToScreenPoint(worldPos) |
Converts a world position to a screen position on mobile and desktop. X: 0.0, Y: 0.0 represents the top left of the screen X: 0.5, Y: 0.5 represents the center of the screen X: 1.0, Y: 1.0 represents the bottom right of the screen Z represents the distance to the object, negative will be behind the camera
Signature
convertWorldToScreenPoint(worldPos: Vec3): Vec3;
Parameters
worldPos: Vec3 the world position to convert Returns Vec3 A Vec3 representing the screen position |
forceLookAt(target, options) |
Forces the camera to look at a target or position. Supported camera modes: - AttachCamera - OrbitCamera - FollowCamera
Signature
forceLookAt(target: Player | Entity | Vec3, options?: ForceLookAtOptions): void;
Parameters
target: Player | Entity | Vec3 the target to look at options: ForceLookAtOptions (Optional) options for the transition to and from the forced look at Returns void |
getCameraModeObjectAs(classType) |
Get the current camera mode object as a specific type.
Signature
getCameraModeObjectAs<TRuntimeCameraMode extends ICameraMode>(classType: new () => TRuntimeCameraMode): TRuntimeCameraMode | null;
Parameters
classType: new () => TRuntimeCameraMode The type of camera mode object to get, must extend ICameraMode. Returns TRuntimeCameraMode | null The camera mode object as the specified type, or null if the camera mode object is not of the specified type. Examples
Get the current camera mode object as OrbitCameraMode:
LocalCamera.getCameraModeObjectAs(OrbitCameraMode); |
overrideCameraFarClipPlane(farClipPlane, options) |
Set the far clip plane of the camera.
Signature
overrideCameraFarClipPlane(farClipPlane: number, options?: CameraTransitionOptions): Promise<CameraTransitionEndReason>;
Parameters
farClipPlane: number The new far clip plane value to transition towards. options: CameraTransitionOptions (Optional) Optional CameraTransitionOptions that define how the previous far clip plane should transition to the new one. If not set, the transition is instant. Returns Promise<CameraTransitionEndReason> Examples
Adjust the camera far clip plane to 50 over a period of 1 second.
localCamera.overrideCameraFarClipPlane(50.0, {duration: 1.0); Remarks Prevents the native camera from adjusting the far clip plane automatically, until Camera.resetCameraFarClipPlane() is called. |
overrideCameraFOV(fov, options) |
Set the field of view of the camera.
Signature
overrideCameraFOV(fov: number, options?: CameraTransitionOptions): Promise<CameraTransitionEndReason>;
Parameters
fov: number The new field of view value to transition towards. options: CameraTransitionOptions (Optional) Optional CameraTransitionOptions that define how the previous field of view should transition to the new one. If not set, the transition is instant. Returns Promise<CameraTransitionEndReason> Examples
Adjust the camera field of view to 50 over a period of 1 second.
localCamera.overrideCameraFOV(50.0, {duration: 1.0); Remarks Prevents the native camera from adjusting the field of view automatically, until Camera.resetCameraFOV() is called. For example, the third person camera zooms in a little while you sprint. |
resetCameraFarClipPlane(options) |
Clears any far clip plane override, resetting it to the default native camera value.
Signature
resetCameraFarClipPlane(options?: CameraTransitionOptions): Promise<CameraTransitionEndReason>;
Parameters
options: CameraTransitionOptions (Optional) Optional CameraTransitionOptions that define how the far clip plane should transition to the default far clip plane. If not set, the transition is instant. Returns Promise<CameraTransitionEndReason> Examples
Reset the far clip plane over a period of 1 second.
localCamera.resetCameraFarClipPlane({duration: 1.0); |
resetCameraFOV(options) |
Clears any field of view override, resetting it to the default native camera value.
Signature
resetCameraFOV(options?: CameraTransitionOptions): Promise<CameraTransitionEndReason>;
Parameters
options: CameraTransitionOptions (Optional) Optional CameraTransitionOptions that define how the previous field of view should transition to the new field of view. If not set, the transition is instant. Returns Promise<CameraTransitionEndReason> Examples
Reset the field of view over a period of 1 second.
localCamera.resetCameraFOV({duration: 1.0); Remarks Prevents the native camera from adjusting the field of view automatically until Camera.resetCameraFOV() is called. For example, the third person camera zooms in a little while the player sprints. |
setCameraModeAttach(target, options) |
Enables attach mode for a camera, which automatically follows a target entity's position and rotation.
Signature
setCameraModeAttach(target: CameraTarget, options?: AttachCameraOptions & CameraTransitionOptions): Promise<CameraTransitionEndReason>;
Parameters
target: CameraTarget The entity for the tracking camera to follow. options: AttachCameraOptions & CameraTransitionOptions (Optional) If not set, the camera instantly matches the target's position and rotation. Returns Promise<CameraTransitionEndReason> Examples
Place the camera at a fixed position relative to the player, over a period of 1 second.
localCamera.setCameraModeAttach(player, {positionOffset = position, duration: 1.0}); Remarks If the target entity is destroyed, camera tracking stops with the camera remaining where it was before losing the target. This method has no effect in VR, where only first person cameras are permitted. |
setCameraModeFirstPerson(options) |
Enables the standard first-person game camera, which uses a camera view from the eyes of the player avatar.
Signature
setCameraModeFirstPerson(options?: CameraTransitionOptions): Promise<CameraTransitionEndReason>;
Parameters
options: CameraTransitionOptions (Optional) Optional CameraTransitionOptions that define how the previous camera should transition to this new camera. If not set, the transition is instant. Returns Promise<CameraTransitionEndReason> Examples
Enable the first person camera after a delay of 1 second.
localCamera.setCameraModeFirstPerson({delay: 1.0}); Remarks Disables any previously set camera. Ignores the current value of Camera.perspectiveSwitchingEnabled. Has no effect in VR, where first person is always enabled. |
setCameraModeFixed(options) |
Sets the current camera to a fixed world position and rotation.
Signature
setCameraModeFixed(options?: FixedCameraOptions & CameraTransitionOptions): Promise<CameraTransitionEndReason>;
Parameters
options: FixedCameraOptions & CameraTransitionOptions (Optional) If not set, the camera remains fixed in place from it's current position and orientation. Returns Promise<CameraTransitionEndReason> Examples Example 1
Move the camera to a new position over a period of 1 second, maintaining its current orientation.
localCamera.setFixedCameraPosition({position: pos}, {duration: 1.0}); Example 2
Keep the camera where it currently is, but point it straight downwards instantly.
localCamera.setFixedCameraPosition({lookAt: getCameraPos() + new Vec3(0,-1,0)}); |
setCameraModeFollow(options) |
Enables the follow camera, which follows and auto-turns to be behind the local player avatar.
Signature
setCameraModeFollow(options?: FollowCameraOptions & CameraTransitionOptions): Promise<CameraTransitionEndReason>;
Parameters
options: FollowCameraOptions & CameraTransitionOptions (Optional) Optional CameraTransitionOptions that define how the previous camera should transition to this new camera. If not set, the transition is instant. Returns Promise<CameraTransitionEndReason> Examples
Enable the follow camera after a delay of 1 second.
localCamera.setCameraModeFollow({delay: 1.0}); Remarks Disables any previously set camera. Ignores the current value of . and has no effect in VR where only first person is allowed. |
setCameraModeOrbit(options) |
Enables the orbit camera, which follows the local player avatar.
Signature
setCameraModeOrbit(options?: OrbitCameraOptions & CameraTransitionOptions): Promise<CameraTransitionEndReason>;
Parameters
options: OrbitCameraOptions & CameraTransitionOptions (Optional) Optional CameraTransitionOptions that define how the previous camera should transition to this new camera. If not set, the transition is instant. Returns Promise<CameraTransitionEndReason> Examples
Enable the orbit camera after a delay of 1 second.
localCamera.setCameraModeOrbit({delay: 1.0}); Remarks Disables any previously set camera. Ignores the current value of . and has no effect in VR where only first person is allowed. |
setCameraModePan(options) |
Enables the pan camera, which follows the local player avatar at a fixed vector offset.
Signature
setCameraModePan(options?: PanCameraOptions & CameraTransitionOptions): Promise<CameraTransitionEndReason>;
Parameters
options: PanCameraOptions & CameraTransitionOptions (Optional) Optional CameraTransitionOptions that define how the previous camera should transition to this new camera. If not set, the transition is instant. Returns Promise<CameraTransitionEndReason> Examples
Enable the pan camera after a delay of 1 second.
localCamera.setCameraModePan({delay: 1.0}); Remarks Disables any previously set camera. Ignores the current value of . and has no effect in VR where only first person is allowed. |
setCameraModeThirdPerson(options) |
Enables the standard third-person game camera, which follows the local player avatar.
Signature
setCameraModeThirdPerson(options?: CameraTransitionOptions): Promise<CameraTransitionEndReason>;
Parameters
options: CameraTransitionOptions (Optional) Optional CameraTransitionOptions that define how the previous camera should transition to this new camera. If not set, the transition is instant. Returns Promise<CameraTransitionEndReason> Examples
Enable the third person over a period of 1 second.
localCamera.setCameraModeThirdPerson({duration: 1.0}); Remarks Disables any previously set camera, ignores the current value of Camera.perspectiveSwitchingEnabled, and has no effect in VR where only first person is allowed. |
setCameraRollWithOptions(rollAngle, options) |
Adjusts the current camera roll over time.
Signature
setCameraRollWithOptions(rollAngle: number, options?: CameraTransitionOptions): Promise<CameraTransitionEndReason>;
Parameters
rollAngle: number The roll rotation, in degrees, to set on the the current camera. options: CameraTransitionOptions (Optional) Optional CameraTransitionOptions that define how the previous roll should transition to the new roll. If not set, the transition is instant. Returns Promise<CameraTransitionEndReason> Examples
Roll the camera by 10 degrees left over 1 second.
localCamera.setCameraRoll(-10, {duration: 1.0}); |
stopForceLookAt(options) |
Stop a force look at if any is active. If options is not provided, an instant transition will be used.
Signature
stopForceLookAt(options?: StopLookAtOptions): void;
Parameters
options: StopLookAtOptions (Optional) Returns void |