FlyCamera

This is a flying camera, designed for 3D movement and rotation in all directions, such as in a 3D Space Shooter or a Flight Simulator.

Hierarchy

Index

Constructors

constructor

Find examples in Playground
  • new FlyCamera(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean): FlyCamera
  • Instantiates a FlyCamera. This is a flying camera, designed for 3D movement and rotation in all directions, such as in a 3D Space Shooter or a Flight Simulator.

    Parameters

    • name: string

      Define the name of the camera in the scene.

    • position: Vector3

      Define the starting position of the camera in the scene.

    • scene: Scene

      Define the scene the camera belongs to.

    • Optional setActiveOnSceneIfNoneActive: boolean

      Defines wheter the camera should be marked as active, if no other camera has been defined as active.

    Returns FlyCamera

Properties

_trackRoll

Find examples in Playground
_trackRoll: number

Track Roll to maintain the wanted Rolling when looking around.

applyGravity

Find examples in Playground
applyGravity: boolean

Enable or disable gravity on the camera.

bankedTurn

Find examples in Playground
bankedTurn: boolean

Mimic a banked turn, Rolling the camera when Yawing. It's recommended to use rollCorrect = 10 for faster banking correction.

bankedTurnLimit

Find examples in Playground
bankedTurnLimit: number

Limit in radians for how much Roll banking will add. (Default: 90°)

bankedTurnMultiplier

Find examples in Playground
bankedTurnMultiplier: number

Value of 0 disables the banked Roll. Value of 1 is equal to the Yaw angle in radians.

cameraDirection

Find examples in Playground
cameraDirection: Vector3

Define the current direction the camera is moving to.

cameraRotation

Find examples in Playground
cameraRotation: Vector2

Define the current rotation the camera is rotating to

checkCollisions

Find examples in Playground
checkCollisions: boolean

Enable or disable collisions of the camera with the rest of the scene objects.

ellipsoid

Find examples in Playground
ellipsoid: Vector3

Define the collision ellipsoid of the camera. This is helpful for simulating a camera body, like a player's body.

see

https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera

ellipsoidOffset

Find examples in Playground
ellipsoidOffset: Vector3

Define an offset for the position of the ellipsoid around the camera. This can be helpful if the camera is attached away from the player's body center, such as at its head.

ignoreParentScaling

Find examples in Playground
ignoreParentScaling: boolean

Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera

inputs

Find examples in Playground

The inputs manager loads all the input sources, such as keyboard and mouse.

inverseRotationSpeed

Find examples in Playground
inverseRotationSpeed: number

Speed multiplier for inverse camera panning

invertRotation

Find examples in Playground
invertRotation: boolean

Reverses mouselook direction to 'natural' panning as opposed to traditional direct panning

lockedTarget

Find examples in Playground
lockedTarget: any

Define the current target of the camera as an object or a position.

noRotationConstraint

Find examples in Playground
noRotationConstraint: boolean

Add constraint to the camera to prevent it to move freely in all directions and around all axis.

onCollide

Find examples in Playground
onCollide: function

Event raised when the camera collides with a mesh in the scene.

Type declaration

rollCorrect

Find examples in Playground
rollCorrect: number

Slowly correct the Roll to its original value after a Pitch+Yaw rotation.

rotation

Find examples in Playground
rotation: Vector3

Define the current rotation of the camera

rotationQuaternion

Find examples in Playground
rotationQuaternion: Quaternion

Define the current local rotation of the camera as a quaternion to prevent Gimbal lock. This overrides and empties cameraRotation.

speed

Find examples in Playground
speed: number

Define the current speed of the camera

updateUpVectorFromRotation

Find examples in Playground
updateUpVectorFromRotation: boolean

When set, the up vector of the camera will be updated by the rotation of the camera

Accessors

angularSensibility

Find examples in Playground
  • get angularSensibility(): number
  • set angularSensibility(value: number): any
  • Gets the input sensibility for mouse input. Higher values reduce sensitivity.

    Returns number

  • Sets the input sensibility for a mouse input. Higher values reduce sensitivity.

    Parameters

    • value: number

    Returns any

collisionMask

Find examples in Playground
  • get collisionMask(): number
  • set collisionMask(mask: number): any
  • Get the mask that the camera ignores in collision events.

    Returns number

  • Set the mask that the camera ignores in collision events.

    Parameters

    • mask: number

    Returns any

keysBackward

Find examples in Playground
  • get keysBackward(): number[]
  • set keysBackward(value: number[]): any
  • Get the keys for camera movement backward.

    Returns number[]

  • Get the keys for camera movement backward.

    Parameters

    • value: number[]

    Returns any

keysDown

Find examples in Playground
  • get keysDown(): number[]
  • set keysDown(value: number[]): any
  • Get the keys for camera movement down.

    Returns number[]

  • Set the keys for camera movement down.

    Parameters

    • value: number[]

    Returns any

keysForward

Find examples in Playground
  • get keysForward(): number[]
  • set keysForward(value: number[]): any
  • Get the keys for camera movement forward.

    Returns number[]

  • Set the keys for camera movement forward.

    Parameters

    • value: number[]

    Returns any

keysLeft

Find examples in Playground
  • get keysLeft(): number[]
  • set keysLeft(value: number[]): any
  • Get the keys for camera movement left.

    Returns number[]

  • Set the keys for camera movement left.

    Parameters

    • value: number[]

    Returns any

keysRight

Find examples in Playground
  • get keysRight(): number[]
  • set keysRight(value: number[]): any
  • Set the keys for camera movement right.

    Returns number[]

  • Set the keys for camera movement right.

    Parameters

    • value: number[]

    Returns any

keysUp

Find examples in Playground
  • get keysUp(): number[]
  • set keysUp(value: number[]): any
  • Get the keys for camera movement up.

    Returns number[]

  • Set the keys for camera movement up.

    Parameters

    • value: number[]

    Returns any

Methods

attachControl

Find examples in Playground
  • attachControl(element: HTMLElement, noPreventDefault?: boolean): void

detachControl

Find examples in Playground
  • detachControl(element: HTMLElement): void
  • Detach a control from the HTML DOM element. The camera will stop reacting to that input.

    Parameters

    • element: HTMLElement

      Defines the element that listens to the input events.

    Returns void

dispose

Find examples in Playground
  • dispose(): void
  • Destroy the camera and release the current resources held by it.

    Returns void

getClassName

Find examples in Playground
  • getClassName(): string

getFrontPosition

Find examples in Playground
  • getFrontPosition(distance: number): Vector3
  • Gets the position in front of the camera at a given distance.

    Parameters

    • distance: number

      The distance from the camera we want the position to be

    Returns Vector3

    the position

getTarget

Find examples in Playground
  • Return the current target position of the camera. This value is expressed in local space.

    Returns Vector3

    the target position

setTarget

Find examples in Playground
  • Defines the target the camera should look at.

    Parameters

    • target: Vector3

      Defines the new target as a Vector or a mesh

    Returns void

storeState

Find examples in Playground
  • Store current camera state of the camera (fov, position, rotation, etc..)

    Returns Camera

    the camera

Generated using TypeDoc