API

Class GeospatialCamera

Camera equipped to orbit a spherical planet centered at world origin

Hierarchy (View Summary)

Index
animations: Animation[] = []

Gets a list of Animations associated with the node

cameraRigMode: number = Camera.RIG_MODE_NONE

Rig mode of the camera. This is useful 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.

checkCollisions: boolean = false

Enable or disable collision checking for this camera. Default is false.

customRenderTargets: RenderTargetTexture[] = []

Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene This is pretty helpful if you wish to make a camera render to a texture you could reuse somewhere else in the scene. (Eg. security camera)

To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corresponding to an HMD)

fov: number = 0.8

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

fovMode: number = Camera.FOVMODE_VERTICAL_FIXED

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

id: string

Gets or sets the id of the node

ignoreCameraMaxZ: boolean = false

Ignores camera maxZ when computing the projection matrix (ie. use 0 instead of maxZ), meaning objects won't be culled by the far plane

inputs: GeospatialCameraInputsManager

Define the input manager associated with the camera.

inspectableCustomProperties: IInspectable[]

List of inspectable custom properties (used by the Inspector)

interaxialDistance: number

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

isIntermediate: boolean = false

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

isRigCamera: boolean = false

Is this camera a part of a rig system?

isStereoscopicSideBySide: boolean

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

layerMask: number = 0x0fffffff

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

maxZ: number = 10000.0

Define the maximum distance the camera can see to. (default is 10000) 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: any = null

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

minZ: number = 1

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.

Movement controller that provides input mapping and framerate-independent physics for geospatial interactions

name: string

Gets or sets the name of the node

oblique: Nullable<IObliqueParams> = null

Object containing oblique projection values (only used with ORTHOGRAPHIC_CAMERA)

onAccessibilityTagChangedObservable: Observable<Nullable<IAccessibilityTag>> = ...

Observable fired when an accessibility tag is changed

onAfterCheckInputsObservable: Observable<Camera> = ...

Observable triggered when the inputs have been processed.

onDisposeObservable: Observable<Node> = ...

An event triggered when the mesh is disposed

onProjectionMatrixChangedObservable: Observable<Camera> = ...

Observable triggered when the camera Projection matrix has changed.

onReady: Nullable<(node: Node) => void> = null

Callback raised when the node is ready to be used

onRestoreStateObservable: Observable<Camera> = ...

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

onViewMatrixChangedObservable: Observable<Camera> = ...

Observable triggered when the camera view matrix has changed. Beware of reentrance! Some methods like Camera.getViewMatrix and Camera.getWorldMatrix can trigger the onViewMatrixChangedObservable observable, so using them inside an observer will require additional logic to avoid a stack overflow error.

outputRenderTarget: Nullable<RenderTargetTexture> = null

When set, the camera will render to this render target instead of the default canvas

If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead

perFrameCollisionOffset: Vector3 = ...

Public option to customize the collision offset applied each frame - vs the one calculated using internal CollisionCoordinator

projectionPlaneTilt: number = 0

Projection plane tilt around the X axis (horizontal), set in Radians. (default is 0) Can be used to make vertical lines in world space actually vertical on the screen. See https://forum.babylonjs.com/t/add-vertical-shift-to-3ds-max-exporter-babylon-cameras/17480

renderPassId: number

Render pass id used by the camera to render into the main framebuffer

reservedDataStore: any = null

For internal use only. Please do not use.

rigParent?: Camera

If isRigCamera set to true this will be set with the parent camera. The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)

state: string = ""

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

uniqueId: number

Gets or sets the unique id of the node

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.

ForceAttachControlToAlwaysPreventDefault: boolean = false

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

FOVMODE_HORIZONTAL_FIXED: 1 = Constants.FOVMODE_HORIZONTAL_FIXED

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

FOVMODE_VERTICAL_FIXED: 0 = Constants.FOVMODE_VERTICAL_FIXED

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.

ORTHOGRAPHIC_CAMERA: 1 = Constants.ORTHOGRAPHIC_CAMERA

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.

PERSPECTIVE_CAMERA: 0 = Constants.PERSPECTIVE_CAMERA

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.

RIG_MODE_CUSTOM: 22 = Constants.RIG_MODE_CUSTOM

Custom rig mode allowing rig cameras to be populated manually with any number of cameras

RIG_MODE_NONE: 0 = Constants.RIG_MODE_NONE

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

RIG_MODE_STEREOSCOPIC_ANAGLYPH: 10 = Constants.RIG_MODE_STEREOSCOPIC_ANAGLYPH

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

RIG_MODE_STEREOSCOPIC_INTERLACED: 14 = Constants.RIG_MODE_STEREOSCOPIC_INTERLACED

Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.

RIG_MODE_STEREOSCOPIC_OVERUNDER: 13 = Constants.RIG_MODE_STEREOSCOPIC_OVERUNDER

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

RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: 12 = Constants.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED

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

RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: 11 = Constants.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL

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

RIG_MODE_VR: 20 = Constants.RIG_MODE_VR

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

  • get doNotSerialize(): boolean

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

    Returns boolean

  • set doNotSerialize(value: boolean): void

    Parameters

    • value: boolean

    Returns void

  • get inheritVisibility(): boolean

    If set to true, this node, when renderable, will only be visible if its parent(s) are also visible.

    Returns boolean

    false
    
  • set inheritVisibility(value: boolean): void

    Parameters

    • value: boolean

    Returns void

  • get isVisible(): boolean

    Gets or sets a boolean indicating whether this node is visible, either this node itself when it is renderable or its renderable child nodes when inheritVisibility is true.

    Returns boolean

    true
    
  • set isVisible(value: boolean): void

    Parameters

    • value: boolean

    Returns void

  • set onDispose(callback: () => void): void

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

    Parameters

    • callback: () => void

    Returns void

  • get onEffectiveEnabledStateChangedObservable(): Observable<boolean>

    An event triggered when the effective enabled state of the node changes, i.e. whenever the value returned by isEnabled changes. Unlike onEnabledStateChangedObservable, this fires for changes caused by an ancestor's enabled state as well as this node's own state. The observable is created on first access, so no cost is incurred for nodes that never observe it.

    Returns Observable<boolean>

  • get pitch(): number

    Gets the camera's pitch (angle from looking straight at globe) Pitch is measured from looking straight down at planet center:

    • zero pitch = looking straight at planet center (down)
    • positive pitch = tilting up away from planet
    • π/2 pitch = looking at horizon (perpendicular to geocentric normal)

    Returns number

  • set pitch(pitch: number): void

    Sets the camera's pitch (angle from looking straight at globe). Will wrap value to [-π, π)

    Parameters

    • pitch: number

      The desired pitch angle in radians (0 = looking at planet center, π/2 = looking at horizon)

    Returns void

  • Will start the animation sequence

    Parameters

    • name: string

      defines the range frames for animation sequence

    • Optionalloop: boolean

      defines if the animation should loop (false by default)

    • OptionalspeedRatio: number

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

    • OptionalonAnimationEnd: () => void

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

    Returns Nullable<Animatable>

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

  • 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

  • Delete a specific animation range

    Parameters

    • name: string

      defines the name of the range to delete

    • deleteFrames: boolean = true

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

    Returns void

  • Releases resources associated with this node.

    Parameters

    • OptionaldoNotRecurse: boolean

      Set to true to not recurse into each children (recurse into each children by default)

    • disposeMaterialAndTextures: boolean = false

      Set to true to also dispose referenced materials and textures (false by default)

    Returns void

  • Animate camera towards passed in property values. If undefined, will use current value

    Parameters

    • OptionaltargetYaw: number

      Target yaw in radians, or undefined to keep the current yaw.

    • OptionaltargetPitch: number

      Target pitch in radians, or undefined to keep the current pitch.

    • OptionaltargetRadius: number

      Target radius (distance from the look-at center), or undefined to keep the current radius.

    • OptionaltargetCenter: Vector3

      Target look-at center in scene coordinates, or undefined to keep the current center.

    • flightDurationMs: number = 1000

      Total duration of the animation in milliseconds. Defaults to 1000ms.

    • OptionaleasingFunction: EasingFunction

      Optional easing function applied to the animation curve.

    • OptionalcenterHopScale: number

      If supplied, will define the parabolic hop height scale for center animation to create a "bounce" effect

    Returns Promise<void>

    Promise that will return when the animation is complete (or interuppted by pointer input)

  • Helper function to move camera towards a given point by distanceScale of the current camera-to-destination distance (by default 50%).

    Parameters

    • destination: Vector3

      point to move towards

    • distanceScale: number = 0.5

      value between 0 and 1, % of distance to move

    • durationMs: number = 1000

      duration of flight, default 1s

    • OptionaleasingFn: EasingFunction

      optional easing function for flight interpolation of properties

    • OptionalcenterHopScale: number

      If supplied, will define the parabolic hop height scale for center animation to create a "bounce" effect

    Returns Promise<void>

  • Get all child-meshes of this node

    Type Parameters

    Parameters

    • OptionaldirectDescendantsOnly: 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 (Default: false)

    • Optionalpredicate: (node: Node) => node is T

      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

    Returns T[]

    an array of AbstractMesh

  • Get all child-meshes of this node

    Parameters

    • OptionaldirectDescendantsOnly: 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 (Default: false)

    • Optionalpredicate: (node: Node) => boolean

      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

    Returns AbstractMesh[]

    an array of AbstractMesh

  • Get all direct children of this node

    Type Parameters

    Parameters

    • Optionalpredicate: (node: Node) => node is T

      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

    • OptionaldirectDescendantsOnly: 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 (Default: true)

    Returns T[]

    an array of Node

  • Get all direct children of this node

    Parameters

    • Optionalpredicate: (node: Node) => boolean

      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

    • OptionaldirectDescendantsOnly: 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 (Default: true)

    Returns Node[]

    an array of Node

  • Will return all nodes that have this node as ascendant

    Type Parameters

    Parameters

    • OptionaldirectDescendantsOnly: 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

    • Optionalpredicate: (node: Node) => node is T

      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

    Returns T[]

    all children nodes of all types

  • Will return all nodes that have this node as ascendant

    Parameters

    • OptionaldirectDescendantsOnly: 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

    • Optionalpredicate: (node: Node) => boolean

      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

    Returns Node[]

    all children nodes of all types

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

    Parameters

    • length: number = 100

      Defines the length of the ray to create

    • Optionaltransform: Matrix

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

    • Optionalorigin: Vector3

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

    Returns Ray

    the forward ray

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

    Parameters

    • refRay: Ray

      the ray to (re)use when setting the values

    • length: number = 100

      Defines the length of the ray to create

    • Optionaltransform: Matrix

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

    • Optionalorigin: Vector3

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

    Returns Ray

    the forward ray

  • Return the minimum and maximum world vectors of the entire hierarchy under current node

    Parameters

    • includeDescendants: boolean = true

      Include bounding info from descendants as well (true by default)

    • predicate: Nullable<(abstractMesh: AbstractMesh) => boolean> = null

      defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors

    Returns { max: Vector3; min: Vector3 }

    the new bounding vectors

  • 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

  • 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

    • checkAncestors: boolean = true

      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

    To observe changes to the value returned when calling this with checkAncestors set to true (the default, i.e. the effective enabled state), subscribe to onEffectiveEnabledStateChangedObservable. To observe changes to the value returned when calling this with checkAncestors set to false (i.e. this node's own enabled state only), subscribe to onEnabledStateChangedObservable.

  • 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

    • target: ICullable

      The object to check

    • checkRigCameras: boolean = false

      If the rig cameras should be checked (eg. with VR camera both eyes should be checked) (Default: false)

    Returns boolean

    true if the object is in frustum otherwise false

  • Is this camera ready to be used/rendered

    Parameters

    • completeCheck: boolean = false

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

    Returns boolean

    true if the camera is ready

  • Sets the camera's field of view in radians based on the focal length and sensor size.

    Parameters

    • value: number

      the focal length of the camera in mm.

    • sensorSize: number = 36

      the sensor width size of the camera in mm. (default is 36mm, which is a full frame sensor)

    Returns void

  • Gets a string representation of the camera useful for debug purpose.

    Parameters

    • OptionalfullDetails: boolean

      Defines that a more verbose level of logging is required

    Returns string

    the string representation

  • If the camera is actively in flight, redirects it toward a new destination, using up the remaining duration from the original flyToAsync call. The redirect starts from the camera's current pose, so it stays smooth (no snap). If the camera is not currently in flight this is a no-op; start a new flight with flyToAsync instead.

    Note: redirecting interrupts the in-flight animation, so the promise returned by the original flyToAsync call resolves early. Await the promise returned here to be notified when the redirected flight actually completes.

    Any property left undefined is frozen at its current value (matching flyToAsync), it does not continue toward the original flight's destination for that property.

    Parameters

    • OptionaltargetYaw: number

      Target yaw in radians, or undefined to freeze yaw at its current value.

    • OptionaltargetPitch: number

      Target pitch in radians, or undefined to freeze pitch at its current value.

    • OptionaltargetRadius: number

      Target radius (distance from the look-at center), or undefined to freeze radius at its current value.

    • OptionaltargetCenter: Vector3

      Target look-at center in scene coordinates, or undefined to freeze the center at its current value.

    Returns Promise<void> | undefined

    Promise that resolves when the redirected flight completes (or is interrupted), or undefined if the camera was not in flight.

  • 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

    • Optionaloptions: any

      defines optional options to transmit to constructors

    Returns Nullable<() => Node>

    the new constructor or null

  • 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

    • interaxial_distance: number = 0

      In case of stereoscopic setup, the distance between both eyes

    • isStereoscopicSideBySide: boolean = true

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

    Returns () => Camera

    a factory method to construct the camera

  • 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