TouchCamera

This represents a FPS type of camera controlled by touch. This is like a universal camera minus the Gamepad controls.

see

http://doc.babylonjs.com/features/cameras#universal-camera

Hierarchy

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

angularSensibility

angularSensibility: number

Sets the input sensibility for a mouse input. (default is 2000.0) Higher values reduce sensitivity.

animationPropertiesOverride

animationPropertiesOverride: Nullable<AnimationPropertiesOverride>

Gets or sets the animation properties override

animations

animations: Animation[]

Gets a list of Animations associated with the node

applyGravity

applyGravity: boolean

Enable or disable gravity on the camera.

behaviors

behaviors: Behavior<Node>[]

Gets the list of attached behaviors

see

http://doc.babylonjs.com/features/behaviour

cameraDirection

cameraDirection: Vector3

Define the current direction the camera is moving to

cameraRigMode

cameraRigMode: number

Rig mode of the camera. This is usefull to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes. This is normally controlled byt the camera themselves as internal use.

cameraRotation

cameraRotation: Vector2

Define the current rotation the camera is rotating to

checkCollisions

checkCollisions: boolean

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

collisionMask

collisionMask: number

Define a collision mask to limit the list of object the camera can collide with

customRenderTargets

customRenderTargets: RenderTargetTexture[]

Defines the list of custom render target the camera should render to. This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere else in the scene.

doNotSerialize

doNotSerialize: boolean

Gets or sets a boolean used to define if the node must be serialized

ellipsoid

ellipsoid: Vector3

Define the collision ellipsoid of the camera. This is helpful to simulate a camera body like the player body around the camera

see

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

ellipsoidOffset

ellipsoidOffset: Vector3

Define an offset for the position of the ellipsoid around the camera. This can be helpful to determine the center of the body near the gravity center of the body instead of its head.

fov

fov: number

Field Of View is set in Radians. (default is 0.8)

fovMode

fovMode: number

fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)

globalPosition

globalPosition: Vector3

Gets the current world space position of the camera.

id

id: string

Gets or sets the id of the node

inertia

inertia: number

Define the default inertia of the camera. This helps giving a smooth feeling to the camera movement.

inputs

Define the input manager associated to the camera.

interaxialDistance

interaxialDistance: number

Defines the distance between both "eyes" in case of a RIG

isIntermediate

isIntermediate: boolean

Define wether the camera is intermediate. This is usefull to not present the output directly to the screen in case of rig without post process for instance

isStereoscopicSideBySide

isStereoscopicSideBySide: boolean

Defines if stereoscopic rendering is done side by side or over under.

keysDown

keysDown: number[]

Gets or Set the list of keyboard keys used to control the backward move of the camera.

keysLeft

keysLeft: number[]

Gets or Set the list of keyboard keys used to control the left strafe move of the camera.

keysRight

keysRight: number[]

Gets or Set the list of keyboard keys used to control the right strafe move of the camera.

keysUp

keysUp: number[]

Gets or Set the list of keyboard keys used to control the forward move of the camera.

layerMask

layerMask: number

Restricts the camera to viewing objects with the same layerMask. A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0

leftCamera

leftCamera: Nullable<FreeCamera>

Gets the left camera of a rig setup in case of Rigged Camera

lockedTarget

lockedTarget: any

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

maxZ

maxZ: number

Define the maximum distance the camera can see to. This is important to note that the depth buffer are not infinite and the further it end the more your scene might encounter depth fighting issue.

metadata

metadata: any

Gets or sets an object used to store user defined information for the node

minZ

minZ: number

Define the minimum distance the camera can see from. This is important to note that the depth buffer are not infinite and the closer it starts the more your scene might encounter depth fighting issue.

mode

mode: number

Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)

name

name: string

Gets or sets the name of the node

noRotationConstraint

noRotationConstraint: boolean

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

onAfterCheckInputsObservable

onAfterCheckInputsObservable: Observable<Camera>

Observable triggered when the inputs have been processed.

onCollide

onCollide: function

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

Type declaration

onDispose

onDispose: function

Sets a callback that will be raised when the node will be disposed

Type declaration

    • (): void
    • Returns void

onDisposeObservable

onDisposeObservable: Observable<Node>

An event triggered when the mesh is disposed

onProjectionMatrixChangedObservable

onProjectionMatrixChangedObservable: Observable<Camera>

Observable triggered when the camera Projection matrix has changed.

onReady

onReady: function

Callback raised when the node is ready to be used

Type declaration

    • (node: Node): void
    • Parameters

      Returns void

onRestoreStateObservable

onRestoreStateObservable: Observable<Camera>

Observable triggered when reset has been called and applied to the camera.

onViewMatrixChangedObservable

onViewMatrixChangedObservable: Observable<Camera>

Observable triggered when the camera view matrix has changed.

orthoBottom

orthoBottom: Nullable<number>

Define the current limit on the bottom side for an orthographic camera In scene unit

orthoLeft

orthoLeft: Nullable<number>

Define the current limit on the left side for an orthographic camera In scene unit

orthoRight

orthoRight: Nullable<number>

Define the current limit on the right side for an orthographic camera In scene unit

orthoTop

orthoTop: Nullable<number>

Define the current limit on the top side for an orthographic camera In scene unit

parent

parent: Nullable<Node>

Gets or sets the parent of the node

position

position: Vector3

Define the current local position of the camera in the scene

rigPostProcess

rigPostProcess: Nullable<PostProcess>

rightCamera

rightCamera: Nullable<FreeCamera>

Gets the right camera of a rig setup in case of Rigged Camera

rotation

rotation: Vector3

Define the current rotation of the camera

rotationQuaternion

rotationQuaternion: Quaternion

Define the current rotation of the camera as a quaternion to prevent Gimbal lock

speed

speed: number

Define the current speed of the camera

state

state: string

Gets or sets a string used to store user defined state for the node

touchAngularSensibility

touchAngularSensibility: number

Defines the touch sensibility for rotation. The higher the faster.

touchMoveSensibility

touchMoveSensibility: number

Defines the touch sensibility for move. The higher the faster.

uniqueId

uniqueId: number

Gets or sets the unique id of the node

upVector

upVector: Vector3

The vector the camera should consider as up. (default is Vector3(0, 1, 0) aka Vector3.Up())

viewport

viewport: Viewport

Define the viewport of the camera. This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.

worldMatrixFromCache

worldMatrixFromCache: Matrix

Returns directly the latest state of the mesh World matrix. A Matrix is returned.

Static FOVMODE_HORIZONTAL_FIXED

FOVMODE_HORIZONTAL_FIXED: number

This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.

Static FOVMODE_VERTICAL_FIXED

FOVMODE_VERTICAL_FIXED: number

This is the default FOV mode for perspective cameras. This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.

Static ForceAttachControlToAlwaysPreventDefault

ForceAttachControlToAlwaysPreventDefault: boolean

Defines if by default attaching controls should prevent the default javascript event to continue.

Static ORTHOGRAPHIC_CAMERA

ORTHOGRAPHIC_CAMERA: number

This helps creating camera with an orthographic mode. Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.

Static PERSPECTIVE_CAMERA

PERSPECTIVE_CAMERA: number

This is the default projection mode used by the cameras. It helps recreating a feeling of perspective and better appreciate depth. This is the best way to simulate real life cameras.

Static RIG_MODE_NONE

RIG_MODE_NONE: number

This specifies ther is no need for a camera rig. Basically only one eye is rendered corresponding to the camera.

Static RIG_MODE_STEREOSCOPIC_ANAGLYPH

RIG_MODE_STEREOSCOPIC_ANAGLYPH: number

Simulates a camera Rig with one blue eye and one red eye. This can be use with 3d blue and red glasses.

Static RIG_MODE_STEREOSCOPIC_OVERUNDER

RIG_MODE_STEREOSCOPIC_OVERUNDER: number

Defines that both eyes of the camera will be rendered over under each other.

Static RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED

RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number

Defines that both eyes of the camera will be rendered side by side with a none parallel target.

Static RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL

RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number

Defines that both eyes of the camera will be rendered side by side with a parallel target.

Static RIG_MODE_VR

RIG_MODE_VR: number

Defines that both eyes of the camera should be renderered in a VR mode (carbox).

Static RIG_MODE_WEBVR

RIG_MODE_WEBVR: number

Defines that both eyes of the camera should be renderered in a VR mode (webVR).

Methods

addBehavior

attachControl

  • attachControl(element: HTMLElement, noPreventDefault?: boolean): void

attachPostProcess

beginAnimation

  • beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: function): Nullable<Animatable>
  • Will start the animation sequence

    Parameters

    • name: string

      defines the range frames for animation sequence

    • Optional loop: boolean

      defines if the animation should loop (false by default)

    • Optional speedRatio: number

      defines the speed factor in which to run the animation (1 by default)

    • Optional onAnimationEnd: function

      defines a function to be executed when the animation ended (undefined by default)

        • (): void
        • Returns void

    Returns Nullable<Animatable>

    the object created for this animation. If range does not exist, it will return null

clone

  • Clones the current camera.

    Parameters

    • name: string

      The cloned camera name

    Returns Camera

    the cloned camera

computeWorldMatrix

  • computeWorldMatrix(): Matrix

createAnimationRange

  • createAnimationRange(name: string, from: number, to: number): void
  • Creates an animation range for this node

    Parameters

    • name: string

      defines the name of the range

    • from: number

      defines the starting key

    • to: number

      defines the end key

    Returns void

deleteAnimationRange

  • deleteAnimationRange(name: string, deleteFrames?: boolean): void
  • Delete a specific animation range

    Parameters

    • name: string

      defines the name of the range to delete

    • Optional deleteFrames: boolean

      defines if animation frames from the range must be deleted as well

    Returns void

detachControl

  • detachControl(element: HTMLElement): void
  • Detach the current controls from the camera. The camera will stop reacting to inputs.

    Parameters

    • element: HTMLElement

      Defines the element to stop listening the inputs from

    Returns void

detachPostProcess

dispose

  • dispose(): void

freezeProjectionMatrix

  • freezeProjectionMatrix(projection?: Matrix): void
  • Freeze the projection matrix. It will prevent the cache check of the camera projection compute and can speed up perf if no parameter of the camera are meant to change

    Parameters

    • Optional projection: Matrix

      Defines manually a projection if necessary

    Returns void

getActiveMeshes

getAnimationByName

  • Get an animation by name

    Parameters

    • name: string

      defines the name of the animation to look for

    Returns Nullable<Animation>

    null if not found else the requested animation

getAnimationRange

  • Get an animation range by name

    Parameters

    • name: string

      defines the name of the animation range to look for

    Returns Nullable<AnimationRange>

    null if not found else the requested animation range

getBehaviorByName

getChildMeshes

  • getChildMeshes(directDescendantsOnly?: boolean, predicate?: function): AbstractMesh[]
  • Get all child-meshes of this node

    Parameters

    • Optional directDescendantsOnly: boolean

      defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered

    • Optional predicate: function

      defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored

        • (node: Node): boolean
        • Parameters

          Returns boolean

    Returns AbstractMesh[]

    an array of {BABYLON.AbstractMesh}

getChildTransformNodes

  • getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: function): TransformNode[]
  • Get all child-transformNodes of this node

    Parameters

    • Optional directDescendantsOnly: boolean

      defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered

    • Optional predicate: function

      defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored

        • (node: Node): boolean
        • Parameters

          Returns boolean

    Returns TransformNode[]

    an array of {BABYLON.TransformNode}

getChildren

  • getChildren(predicate?: function): Node[]
  • Get all direct children of this node

    Parameters

    • Optional predicate: function

      defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored

        • (node: Node): boolean
        • Parameters

          Returns boolean

    Returns Node[]

    an array of {BABYLON.Node}

getClassName

  • getClassName(): string

getDescendants

  • getDescendants(directDescendantsOnly?: boolean, predicate?: function): Node[]
  • Will return all nodes that have this node as ascendant

    Parameters

    • Optional directDescendantsOnly: boolean

      defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered

    • Optional predicate: function

      defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored

        • (node: Node): boolean
        • Parameters

          Returns boolean

    Returns Node[]

    all children nodes of all types

getDirection

  • Gets the direction of the camera relative to a given local axis.

    Parameters

    • localAxis: Vector3

      Defines the reference axis to provide a relative direction.

    Returns Vector3

    the direction

getDirectionToRef

  • Gets the direction of the camera relative to a given local axis into a passed vector.

    Parameters

    • localAxis: Vector3

      Defines the reference axis to provide a relative direction.

    • result: Vector3

      Defines the vector to store the result in

    Returns void

getEngine

getForwardRay

  • Gets a ray in the forward direction from the camera.

    Parameters

    • Optional length: number

      Defines the length of the ray to create

    • Optional transform: Matrix

      Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray

    • Optional origin: Vector3

      Defines the start point of the ray which defaults to the camera position

    Returns Ray

    the forward ray

getFrontPosition

  • 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

getLeftTarget

getProjectionMatrix

  • getProjectionMatrix(force?: boolean): Matrix
  • Gets the current projection matrix of the camera.

    Parameters

    • Optional force: boolean

      forces the camera to recompute the matrix without looking at the cached state

    Returns Matrix

    the projection matrix

getRightTarget

getScene

  • Gets the scene of the node

    Returns Scene

    a {BABYLON.Scene}

getTarget

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

    Returns Vector3

    the target position

getTransformationMatrix

  • getTransformationMatrix(): Matrix

getViewMatrix

  • getViewMatrix(force?: boolean): Matrix
  • Gets the current view matrix of the camera.

    Parameters

    • Optional force: boolean

      forces the camera to recompute the matrix without looking at the cached state

    Returns Matrix

    the view matrix

getWorldMatrix

isActiveMesh

  • isActiveMesh(mesh: Mesh): boolean
  • Check wether a mesh is part of the current active mesh list of the camera

    Parameters

    • mesh: Mesh

      Defines the mesh to check

    Returns boolean

    true if active, false otherwise

isCompletelyInFrustum

  • isCompletelyInFrustum(target: ICullable): boolean
  • Checks if a cullable object (mesh...) is in the camera frustum Unlike isInFrustum this cheks the full bounding box

    Parameters

    Returns boolean

    true if the object is in frustum otherwise false

isDescendantOf

  • isDescendantOf(ancestor: Node): boolean
  • Is this node a descendant of the given node? The function will iterate up the hierarchy until the ancestor was found or no more parents defined

    Parameters

    • ancestor: Node

      defines the parent node to inspect

    Returns boolean

    a boolean indicating if this node is a descendant of the given node

isDisposed

  • isDisposed(): boolean
  • Gets a boolean indicating if the node has been disposed

    Returns boolean

    true if the node was disposed

isEnabled

  • isEnabled(checkAncestors?: boolean): boolean
  • Is this node enabled? If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true

    Parameters

    • Optional checkAncestors: boolean

      indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors

    Returns boolean

    whether this node (and its parent) is enabled

isInFrustum

  • Checks if a cullable object (mesh...) is in the camera frustum This checks the bounding box center. See isCompletelyInFrustum for a full bounding check

    Parameters

    Returns boolean

    true if the object is in frustum otherwise false

isReady

  • isReady(completeCheck?: boolean): boolean
  • Is this camera ready to be used/rendered

    Parameters

    • Optional completeCheck: boolean

      defines if a complete check (including post processes) has to be done (false by default)

    Returns boolean

    true if the camera is ready

removeBehavior

restoreState

  • restoreState(): boolean
  • Restored camera state. You must call storeState() first.

    Returns boolean

    true if restored and false otherwise

serialize

  • serialize(): any
  • Serialiaze the camera setup to a json represention

    Returns any

    the JSON representation

serializeAnimationRanges

  • serializeAnimationRanges(): any

setEnabled

  • setEnabled(value: boolean): void
  • Set the enabled state of this node

    Parameters

    • value: boolean

      defines the new enabled state

    Returns void

storeState

toString

  • toString(fullDetails?: boolean): string
  • Gets a string representation of the camera usefull for debug purpose.

    Parameters

    • Optional fullDetails: boolean

      Defines that a more verboe level of logging is required

    Returns string

    the string representation

unfreezeProjectionMatrix

  • unfreezeProjectionMatrix(): void
  • Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.

    Returns void

update

  • update(): void
  • Update the camera state according to the different inputs gathered during the frame.

    Returns void

Static AddNodeConstructor

  • Add a new node constructor

    Parameters

    • type: string

      defines the type name of the node to construct

    • constructorFunc: NodeConstructor

      defines the constructor function

    Returns void

Static Construct

  • Construct(type: string, name: string, scene: Scene, options?: any): Nullable<function>
  • Returns a node constructor based on type name

    Parameters

    • type: string

      defines the type name

    • name: string

      defines the new node name

    • scene: Scene

      defines the hosting scene

    • Optional options: any

      defines optional options to transmit to constructors

    Returns Nullable<function>

    the new constructor or null

Static GetConstructorFromName

  • GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): function
  • Gets a camera constructor for a given camera type

    Parameters

    • type: string

      The type of the camera to construct (should be equal to one of the camera class name)

    • name: string

      The name of the camera the result will be able to instantiate

    • scene: Scene

      The scene the result will construct the camera in

    • Optional interaxial_distance: number

      In case of stereoscopic setup, the distance between both eyes

    • Optional isStereoscopicSideBySide: boolean

      In case of stereoscopic setup, should the sereo be side b side

    Returns function

    a factory method to construc the camera

Static Parse

  • Parse a JSON and creates the camera from the parsed information

    Parameters

    • parsedCamera: any

      The JSON to parse

    • scene: Scene

      The scene to instantiate the camera in

    Returns Camera

    the newly constructed camera

Static ParseAnimationRanges

  • ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void
  • Parse animation range data from a serialization object and store them into a given node

    Parameters

    • node: Node

      defines where to store the animation ranges

    • parsedNode: any

      defines the serialization object to read data from

    • scene: Scene

      defines the hosting scene

    Returns void

Generated using TypeDoc