Interface CameraManagerInterface

The CameraManagerInterface interface is used to manipulate the camera, and thus to change the viewpoint.

This interface allows to create camera animations and manipulate the orientation cube (a cube that allows the user to see its current orientation).

The CameraManagerInterface also features a way to change the camera manipulator, which is the way user inputs are processed to infer a camera move, by using the CameraControllerMode. The CameraManagerInterface uses the CameraControllerMode.CCM_ORBIT as default. Whenever the camera location and orientation (frame) are changed, CameraManagerInterfaceSignal signals are sent.

This interface also allows to set the camera sensibility, which is the default distance and rotation angle induced by a single user input. This may increase or lower the camera speed. The camera sensitivity is a strictly positive number, that defaults to 1. Depending on the CameraControllerMode, the camera sensibility may change when the CameraManagerInterface changes its mode, as each mode has its own sensibility.

If the developer wants to create its own camera manipulator, he may disable the CameraManagerInterface by :

/** 
* Sample to illustrate the change of camera controller.
*/
import { InfiniteEngineInterface, CameraControllerMode } from 'generated_files/documentation/appinfiniteapi';

let lEngine : InfiniteEngineInterface;
lEngine.getCameraManager().setCameraControllerMode(CameraControllerMode.CCM_NONE);

There is no way to create a new CameraManagerInterface, the camera handler is owned and accessed by the InfiniteEngineInterface (InfiniteEngineInterface.getCameraManager).

The camera features a perspective or orthographic projection (pyramid) expressed as frustum values. See ViewFrustum. The frustum values are used to compute the perspective/orthographic projection of the virtual camera. There are a lot of online courses available if you want to get more information about perspective and orthographic projections.

frustum illustration
The camera is composed of 6 planes : A near and far plane orthogonal to the camera at the distance respectively near and far. Up, Bottom, Right and Left planes go through the camera location and intersect the near plane forming 4 points (see the figure).
The coordinates of these 4 points can be expressed as :
Be P0 the bottom left point, P1 the bottom right point, P2 the top right point, P3 the top left point.
Be D the normalized directional vector of the camera, U the normalized Up vector of the camera, R the normalized right vector of the camera and L the camera location.
P0 = L + Dmin * D + Rmin * R + Umin * U
P1 = L + Dmin * D + Rmax * R + Umin * U
P2 = L + Dmin * D + Rmax * R + Umax * U
P3 = L + Dmin * D + Rmin * R + Umax * U

In cases of symmetrical frustum (usually the case) :
Rmin = -Rmax
Dmin = -Dmax.
/** 
* Sample to illustrate some CameraManagerInterface accessors.
*/
import { InfiniteEngineInterface, CameraManagerInterface } from 'generated_files/documentation/appinfiniteapi';

let lEngine : InfiniteEngineInterface;
const lCameraManager : CameraManagerInterface = lEngine.getCameraManager();
// and go on ...
console.log(lCameraManager.getDMax());

The CameraManagerInterface send signals when animations are started and stopped.

The orientation cube allows the user to set some specific orientation by clicking on some area of the cube (orthogonal to a face, straight to an edge, to a vertex of the cube).

Camera parameters may be dumped/restored with toJSON and fromJSON.

The camera projection may be set to an orthographic projection, in this case the camera location is constraint on a 3D sphere centered on the center of the DMU.


3D Rendering

interface CameraManagerInterface {
    addEventListener(pType, pListener, pObject): string;
    addEventListener(pType, pListener): string;
    areSignalsBlocked(): boolean;
    asyncWaitForAnimationEnded(): Promise<AsyncResultReason>;
    blockSignals(pBlock): void;
    createExportViewpoint(pAspectRatio): CameraViewpointJSONInterface;
    enableNavigationCube(pEnabled): boolean;
    fitBox(pAABB, pAnimationDurationInMilliseconds): boolean;
    fitBox(pAABB): boolean;
    fitGeometry(pGeometryInstanceId, pAnimationDurationInMilliseconds): boolean;
    fitGeometry(pGeometryInstanceId): boolean;
    fromJSON(pCameraData): boolean;
    getCameraBehaviorOnDMULoaded(): CameraControllerOnStartBehavior;
    getCameraControllerMode(): CameraControllerMode;
    getCameraFrame(pDirVector, pUpVector?, pRightVector?): boolean;
    getCameraLocation(pOut?): Vector3;
    getCenterOfInterest(pOut?): Vector3;
    getControllerSensitivity(): number;
    getDMax(): number;
    getDMin(): number;
    getDefaultNavigationCubeFacesName(pDefaultFaceNames): boolean;
    getFlyKeyMapping(): Object;
    getFrameReference(pFrontDir, pTopDir?): boolean;
    getFrustum(pFrustum): boolean;
    getHorizontalFieldOfView(): number;
    getLockedElevation(): number;
    getNavigationCubeFacesName(pFaceNames): boolean;
    getNavigationCubeHTMLElement(): HTMLElement;
    getNavigationCubeScaleFactor(): number;
    getRMax(): number;
    getRMin(): number;
    getUMax(): number;
    getUMin(): number;
    getVerticalFieldOfView(): number;
    getXRReferenceFrame(): any;
    hasEventListener(pType, pListener): boolean;
    hasEventListenerById(pId): boolean;
    isCameraAnimationRunning(): boolean;
    isConstraintUpAxis(): boolean;
    isHorizontalFieldOfViewConstrained(): boolean;
    isNavigationCubeEnabled(): boolean;
    isNavigationCubeVisible(): boolean;
    isPerspective(): boolean;
    isPerspectiveChangedOnDMUChange(): boolean;
    lookAt(pCenterOfInterest, pAnimationDurationInMilliseconds): boolean;
    lookAt(pCenterOfInterest): boolean;
    moveTo(pPosition, pDirection, pAnimationDurationInMilliseconds): boolean;
    moveTo(pPosition, pDirection): boolean;
    removeAllEventListeners(): boolean;
    removeEventListener(pType, pListener, pObject): boolean;
    removeEventListener(pType, pListener): boolean;
    removeEventListenerById(pId): boolean;
    resetCamera(pAnimationDurationInMilliseconds): boolean;
    resetCamera(): boolean;
    restoreDefaultFlyKeyMapping(): void;
    setCameraBehaviorOnDMULoaded(pBehavior): boolean;
    setCameraControllerMode(pCameraControllerMode): boolean;
    setCameraFrame(pDirVector, pUpVector, pRightVector): boolean;
    setCameraLocation(pLocation): boolean;
    setCameraLocation(pLocation, pChangeOrientationAccordingToControllerMode): boolean;
    setConstraintUpAxis(pConstraint): boolean;
    setControllerSensitivity(pSensitivity): boolean;
    setFlyKeyMapping(pKeyMapping): boolean;
    setFrameReference(pFrontDir, pTopDir): boolean;
    setLockedElevation(pElevation, pAnimationDurationInMilliseconds?): boolean;
    setNavigationCubeFacesName(pFrontFaceName, pLeftFaceName, pBackFaceName, pRightFaceName, pTopName, pBottomName): boolean;
    setNavigationCubeScaleFactor(pScale): boolean;
    setNavigationCubeVisible(pVisible): boolean;
    setPerspective(pPerspective, pPerspectiveValue?, pIsHorizontal?): boolean;
    setPerspectiveChangedOnDMULoaded(pAllowChanges): boolean;
    setXRControllersEnabled(pLeftControllerEnabled, pRightControllerEnabled): boolean;
    toJSON(pKey?): Object;
    zoomToScreenRegion(pRegion): boolean;
}

Hierarchy (view full)

Methods

  • Adds a listener to an event type.

    When an event of the type pType fires, the callback pListener will be called. This function returns a unique string id that may be used in removeEventListenerById to allow simple listener removal. It is possible to add an object that will be included in the callback to avoid creating too many closures. Calling twice addEventListener with the same parameters results in the second call to be ignored, only unique pairs callback / object are allowed, in order to avoid calling multiple times the same thing.

    Parameters

    • pType: string
      in
      The type of the event pListener will be called upon.
    • pListener: tListenerCallback
      in
      The listener function that fires when the given event type occurs.
    • pObject: Object
      in
      The optional object the callback will be called with when the given event fires.

    Returns string

    The id of the inserted callback (actually an UUID).

  • Adds a listener to an event type.

    When an event of the type pType fires, the callback pListener will be called. This function returns a unique string id that may be used in removeEventListenerById to allow simple listener removal.

    Parameters

    • pType: string
      in
      The type of the event pListener will be called upon.
    • pListener: tListenerCallback
      in
      The listener function that fires when the given event type occurs.

    Returns string

    The id of the inserted callback (actually an UUID).

  • Tells if signals sent by the object are blocked or not.

    If signals are blocked, no signal will be emitted nor buffered, such signal will be lost.

    Returns boolean

    true if signals are blocked.

  • Requests an asynchronous wait for animation ended.

    The promise is signaled when the animation is over, i.e. when isCameraAnimationRunning returns false.

    An example with a animation procedure :

    /** 
    * Sample to illustrate the asynchronous screenshot procedure of the InfiniteEngineInterface.
    */
    import {
    InfiniteEngineInterface, LoadingStates, Vector3,
    InfiniteImageInterface, ScreenshotType, AsyncDataLoadedResult, AsyncResultReason, AsyncScreenshotResult
    } from 'generated_files/documentation/appinfiniteapi';

    // We try to make a screenshot when all data is loaded

    // the div to render the 3D display
    let lView3D: HTMLElement;

    // created previously, should receive the image data to be displayed to the user (or ask for a download maybe ?)
    let lImageData : HTMLImageElement;

    // created previously the position of the camera for the screenshot
    let lCameraLocation : Vector3;

    // created previously the camera center of interest
    let lCenterOfInterest : Vector3;

    // created previously the 3D engine
    let lInfiniteEngine: InfiniteEngineInterface;

    const takeScreenshot = async () : Promise<void> =>
    {
    // bind the 3D rendering to the div (should have been done earlier :) )
    lInfiniteEngine.setView(lView3D);

    // we will make screenshot of 1024x1024
    lInfiniteEngine.setFixedResolution(1024, 1024, 1);

    // go to the expected position / location
    lInfiniteEngine.getCameraManager().setCameraLocation(lCameraLocation);
    lInfiniteEngine.getCameraManager().lookAt(lCenterOfInterest, 0);

    // What to do when all data is loaded ?
    const lDataLoaded : AsyncDataLoadedResult = await lInfiniteEngine.asyncWaitForDataLoaded();
    if (lDataLoaded.reason !== AsyncResultReason.ARR_Success || lDataLoaded.value === undefined)
    {
    // this is an error that should not happen (perhaps the engine interface has been destroyed ?)
    console.log('screenshot procedure failed for some reason');
    return;
    }
    const lDataLoadedState : LoadingStates = lDataLoaded.value.newLoadingState;
    switch (lDataLoadedState)
    {
    case LoadingStates.S_Loading:
    // this is an unexpected error
    console.log('unexpected error');
    return;
    case LoadingStates.S_OutOfBudget:
    // some fancy message
    console.log('Taking a screenshot without everything loaded');
    // but we still make a screenshot :)
    break;
    default:
    break;
    }
    const lScreenshot : AsyncScreenshotResult = await lInfiniteEngine.asyncScreenshot(ScreenshotType.ST_Color, true, 'image/jpeg', 0.95);
    if (lScreenshot.reason !== AsyncResultReason.ARR_Success || lScreenshot.value === undefined)
    {
    // this is an error that may happen (perhaps the engine interface has been destroyed ?, or bad inputs ?)
    console.log('screenshot procedure failed for some reason');
    return;
    }
    // What to do when screenshot is ready ?

    // the image result
    const lInfiniteImage : InfiniteImageInterface = lScreenshot.value;

    // is the image valid ? and base64 encoded ?
    if ((lInfiniteImage.width === 0) || (!lInfiniteImage.data) || (!lInfiniteImage.base64))
    {
    console.log('Unexpected screenshot error, aborting');
    return;
    }

    // create the data url in base64
    // even if we did not get the expected format, we still get the result
    const lDataUrl : string = 'data:' + lInfiniteImage.format + ';base64,' + lInfiniteImage.data;

    // resize the image markup
    lImageData.width = lInfiniteImage.width;
    lImageData.height = lInfiniteImage.height;
    // and set data
    lImageData.src = lDataUrl;

    // we get back to the size of the 3d view but this is up to the application needs
    lInfiniteEngine.unsetFixedResolution();
    };

    takeScreenshot();

    Please make sure the destination browser supports promises before using async calls.

    Returns Promise<AsyncResultReason>

    A promise. The promise is resolved with the reason (success, disposed).

  • Blocks / Unblocks all signals sent by the object.

    If signals are blocked, no signal will be emitted nor buffered, such signal will be lost.

    Parameters

    • pBlock: boolean
      in
      If set to true, all further signals will be silently discarded.

    Returns void

  • Enables/Disables the navigation cube (i.e. it responds to user inputs).

    The navigation cube is enabled by default.

    The navigation cube is an html widget located on the bottom right of the 3d rendering area, which helps the user knowing its current orientation. Information like FRONT, LEFT etc are displayed.

    Returns trueif the call was successful (i.e. pEnabled is of the correct type).

    Parameters

    • pEnabled: boolean
      in
      The navigation cube is enabled if true else it is disabled.

    Returns boolean

    true if the call succeeded.

  • Changes the camera position to fit the given AABB to the screen.

    The current orientation of the camera and the center of the Box are used to get a virtual line. The camera changes its position to get on that line, its orientation is unchanged. The camera position is set along this line to maximize the drawing of the Box, without any loss of content.

    /** 
    * Sample to illustrate the CameraManagerInterface fit box.
    */
    import { AABB, CameraManagerInterface, DataSessionInterface } from 'generated_files/documentation/appinfiniteapi';

    // created previously
    let lCameraManager : CameraManagerInterface;
    // the DataSessionInterface has been created previously and is connected
    let lDataSession : DataSessionInterface;
    // get box of given instance id (retrieved by picking ?)
    const pGeometryInstanceId : number = 10;
    // time of animation
    const pAnimationDurationInMilliseconds : number = 150;

    // create an AABB to get the box
    const lAABB : AABB = new AABB();
    // get the box
    lDataSession.getGeometricAABB(pGeometryInstanceId, lAABB);
    // and change camera orientation to fit the box
    lCameraManager.fitBox(lAABB, pAnimationDurationInMilliseconds);

    resetCamera uses FitBox internally.

    Parameters

    • pAABB: AABB
      in
      The box to fit on screen.
    • pAnimationDurationInMilliseconds: number
      in
      The duration of the animation in milliseconds. 0 means immediate movement.

    Returns boolean

    true if the call is successful.

  • Changes the camera position to fit the given AABB to the screen.

    The current orientation of the camera and the center of the Box are used to get a virtual line. The camera changes its position to get on that line, its orientation is unchanged. The camera position is set along this line to maximize the drawing of the Box, without any loss of content.

    The default animation duration is 350 ms.

    This is equivalent to :

    fitBox(pAABB,350);
    

    You may use fitGeometry instead.

    Parameters

    • pAABB: AABB
      in
      The box to fit on screen.

    Returns boolean

    true if the call is successful.

  • Changes the camera position to fit the given geometry to the screen.

    This is equivalent to a fixBox with the AABB of the given geometry.

    This is equivalent to :

    /** 
    * Sample to illustrate the CameraManagerInterface fit box.
    */
    import { AABB, CameraManagerInterface, DataSessionInterface } from 'generated_files/documentation/appinfiniteapi';

    // created previously
    let lCameraManager : CameraManagerInterface;
    // the DataSessionInterface has been created previously and is connected
    let lDataSession : DataSessionInterface;
    // get box of given instance id (retrieved by picking ?)
    const pGeometryInstanceId : number = 10;
    // time of animation
    const pAnimationDurationInMilliseconds : number = 150;

    // create an AABB to get the box
    const lAABB : AABB = new AABB();
    // get the box
    lDataSession.getGeometricAABB(pGeometryInstanceId, lAABB);
    // and change camera orientation to fit the box
    lCameraManager.fitBox(lAABB, pAnimationDurationInMilliseconds);

    Please see fitBox.

    Parameters

    • pGeometryInstanceId: number
      in
      The geometry instance id of the object to "move to".
    • pAnimationDurationInMilliseconds: number
      in
      The duration of the animation in milliseconds. 0 means immediate movement.

    Returns boolean

    true if the geometry exists and the call is successful.

  • Changes the camera position to fit the given geometry to the screen.

    This is equivalent to a fixBox with the AABB of the given geometry.

    The default animation duration is 350 ms.

    This is equivalent to :

    fitGeometry(pGeometryInstanceId,350);
    

    Please see fitBox.

    Parameters

    • pGeometryInstanceId: number
      in
      The geometry instance id of the object to "move to".

    Returns boolean

    true if the call is successful.

  • Sets the content of the CameraManagerInterface from a former call to toJSON.

    Camera parameters may be streamed, using the following schema :

    {
    "$defs": {
    "camera": {
    "additionalProperties": false,
    "description": "Define the values of a Camera",
    "properties": {
    "coi": {
    "$ref": "#/$defs/vec3"
    },
    "dvector": {
    "$ref": "#/$defs/vec3"
    },
    "frontdir": {
    "$ref": "#/$defs/vec3"
    },
    "location": {
    "$ref": "#/$defs/vec3"
    },
    "projection": {
    "$ref": "#/$defs/cameraprojection"
    },
    "rvector": {
    "$ref": "#/$defs/vec3"
    },
    "topdir": {
    "$ref": "#/$defs/vec3"
    },
    "uvector": {
    "$ref": "#/$defs/vec3"
    }
    },
    "required": [
    "location",
    "dvector",
    "uvector",
    "rvector",
    "coi",
    "frontdir",
    "topdir",
    "projection"
    ],
    "title": "Camera definition",
    "type": "object"
    },
    "cameracontroller": {
    "additionalProperties": false,
    "description": "Define the values of a Camera controller",
    "properties": {
    "camera": {
    "$ref": "#/$defs/camera"
    },
    "currentcameramode": {
    "$ref": "#/$defs/cameramode"
    },
    "fly": {
    "$ref": "#/$defs/flymode"
    },
    "orbit": {
    "$ref": "#/$defs/orbitmode"
    },
    "version": {
    "description": "Define the version of the object",
    "example": 1,
    "type": "integer"
    }
    },
    "required": [],
    "title": "Camera controller definition",
    "type": "object"
    },
    "cameramode": {
    "enum": [
    "orbit",
    "examine",
    "none",
    "fly"
    ],
    "type": "string"
    },
    "cameraprojection": {
    "additionalProperties": false,
    "properties": {
    "horizontal": {
    "type": "boolean"
    },
    "isperspective": {
    "type": "boolean"
    },
    "projectionvalue": {
    "exclusiveMinimum": 0,
    "type": "number"
    }
    },
    "required": [
    "isperspective",
    "projectionvalue"
    ],
    "title": "Camera projection definition",
    "type": "object"
    },
    "flymode": {
    "additionalProperties": false,
    "properties": {
    "heightlocked": {
    "type": "boolean"
    },
    "keymapping": {
    "$ref": "#/$defs/flymode_keymapping"
    },
    "rotationspeed": {
    "exclusiveMinimum": 0,
    "type": "number"
    },
    "translationspeed": {
    "exclusiveMinimum": 0,
    "type": "number"
    }
    },
    "required": [],
    "title": "Fly mode definition",
    "type": "object"
    },
    "flymode_keymapping": {
    "additionalProperties": false,
    "properties": {
    "backward": {
    "default": "KeyS",
    "type": "string"
    },
    "down": {
    "default": "KeyF",
    "type": "string"
    },
    "forward": {
    "default": "KeyW",
    "type": "string"
    },
    "left": {
    "default": "KeyA",
    "type": "string"
    },
    "right": {
    "default": "KeyD",
    "type": "string"
    },
    "shift": {
    "default": "ShiftLeft",
    "type": "string"
    },
    "up": {
    "default": "KeyR",
    "type": "string"
    },
    "version": {
    "description": "Define the version of the object",
    "example": 1,
    "type": "integer"
    }
    },
    "required": [],
    "title": "Fly mode key mapping definition",
    "type": "object"
    },
    "orbitmode": {
    "additionalProperties": false,
    "properties": {
    "controllersensitivity": {
    "exclusiveMinimum": 0,
    "type": "number"
    },
    "upconstraint": {
    "type": "boolean"
    }
    },
    "required": [],
    "title": "Orbit mode definition",
    "type": "object"
    },
    "vec3": {
    "description": "Define the coordinates [x,y,z] of a point / vector",
    "items": {
    "type": "number"
    },
    "maxItems": 3,
    "minItems": 3,
    "title": "3D Vector definition",
    "type": "array"
    }
    },
    "$ref": "#/$defs/cameracontroller",
    "$schema": "https://json-schema.org/draft-07/schema#"
    }

    This schema may evolve in the future.

    Parameters

    • pCameraData: string | Object
      in
      Internal CameraManagerInterface data to set.

    Returns boolean

    true if the data is set.

  • Gets the current frame of the camera.

    Parameters

    • pDirVector: Vector3
      out
      The directional vector of the camera.
    • Optional pUpVector: Vector3
      out
      The up vector of the camera.
    • Optional pRightVector: Vector3
      out
      The right vector of the camera.

    Returns boolean

    true if the call is successful.

  • Gets the camera location.

    Parameters

    • Optional pOut: Vector3
      out
      The camera location.

    Returns Vector3

    pOut.

  • Gets the current center of interest of the camera.

    The camera rotates around this point.

    Parameters

    • Optional pOut: Vector3
      out
      The current center of interest.

    Returns Vector3

    pOut.

  • Gets the sensibility of the current controller mode.

    The controller sensitivity is 1 by default.

    A value greater than 1 increases the speed of the camera, a value lower than 1 decreases the speed of the camera. A zero or negative value is invalid.

    Returns the sensitivity of the camera controller in the range ]0,+∞[.

    Returns number

    The actual sensitivity of the camera controller.

  • Gets the distance from the camera to the far view plane.

    Returns number

    The distance from the camera to the far view plane.

  • Gets the distance from the camera to the near view plane.

    Returns number

    The distance from the camera to the near view plane.

  • Gets the navigation cube default face names.

    Navigation cube face names are displayed on each face of the navigation cube.

    The navigation cube is an html widget located on the bottom right of the 3d rendering area, which helps the user knowing its current orientation. Information like FRONT, LEFT etc are displayed.

    Positions inside pDefaultFaceNames are indicated by NavigationCubeFaceID.

    Parameters

    • pDefaultFaceNames: string[]
      out
      The default navigation cube face names.

    Returns boolean

    true if the call is successful.

  • Gets the key mapping in use for the fly mode.

    The key mapping uses the following schema.

    {
    "$defs": {
    "flymode_keymapping": {
    "additionalProperties": false,
    "properties": {
    "backward": {
    "default": "KeyS",
    "type": "string"
    },
    "down": {
    "default": "KeyF",
    "type": "string"
    },
    "forward": {
    "default": "KeyW",
    "type": "string"
    },
    "left": {
    "default": "KeyA",
    "type": "string"
    },
    "right": {
    "default": "KeyD",
    "type": "string"
    },
    "shift": {
    "default": "ShiftLeft",
    "type": "string"
    },
    "up": {
    "default": "KeyR",
    "type": "string"
    },
    "version": {
    "description": "Define the version of the object",
    "example": 1,
    "type": "integer"
    }
    },
    "required": [],
    "title": "Fly mode key mapping definition",
    "type": "object"
    }
    },
    "$ref": "#/$defs/flymode_keymapping",
    "$schema": "https://json-schema.org/draft-07/schema#"
    }

    The key mapping is the content of the keys to use to move the camera in fly mode. It is the content of the `KeyboardEvent.code` field. This value is the non translated value of keyboard (e.g. on a french keyboard, 'KeyW' corresponds to the 'Z' key).

    The default value is :

    {
    "shift": "ShiftLeft",
    "forward": "KeyW",
    "backward": "KeyS",
    "left": "KeyA",
    "right": "KeyD",
    "up": "KeyR",
    "down": "KeyF",
    "version": 1
    }

    This schema may evolve in the future.

    Returns Object

    The actual key mapping that follows the given json schema.

  • Gets the DMU main vectors.

    This will get the orientation of the orientation cube (FRONT, TOP etc).

    Parameters

    • pFrontDir: Vector3
      out
      The current front vector of the scene (if set to undefined, no change).
    • Optional pTopDir: Vector3
      out
      The current up vector of the scene (if set to undefined, no change).

    Returns boolean

    true if the call is successful.

  • Gets the frustum values of the camera.

    Parameters

    • pFrustum: number[] | Float32Array
      out
      The frustum values will be copied there.

    Returns boolean

    true if pFrustum is a number array, or if pFrustum is a Float32Array of 6 values.

  • Tells the value of the current horizontal field of view in radian.

    If the view is orthographic, undefined is returned.

    The value will stay the same during the execution if setPerspective was called with pIsHorizontal set to true.

    Returns number

    The value of the horizontal field of view in radian if the projection is perspective.

  • Gets the locked elevation.

    If setLockedElevation has not been called or reset, returns undefined.

    If setLockedElevation has been called, returns the current elevation, i.e. the dot product between the camera location and the current up camera frame (see getFrameReference).

    Returns number

    The current locked elevation, or undefined if setLockedElevation has not been called or reset.

  • Gets the navigation cube face names.

    Navigation cube face names are displayed on each face of the navigation cube.

    The navigation cube is an html widget located on the bottom right of the 3d rendering area, which helps the user knowing its current orientation. Information like FRONT, LEFT etc are displayed.

    Positions inside pDefaultFaceNames are indicated by NavigationCubeFaceID.

    Parameters

    • pFaceNames: string[]
      out
      The current navigation cube face names.

    Returns boolean

    true if the call is successful.

  • Gets the HTML representation of the navigation cube.

    You may change its look and feel.

    If no view is set, then returns undefined.

    Returns HTMLElement

    The HTML representation of the navigation cube or undefined if no view is set.

  • Gets the scale factor of the navigation cube.

    The default scale factor of the cube is 1, meaning a size of approximately 132x132 pixels. Value scales are strictly non negative values.

    The navigation cube is an html widget located on the bottom right of the 3d rendering area, which helps the user knowing its current orientation. Information like FRONT, LEFT etc are displayed.

    Returns number

    The current navigation cube scale factor.

  • Gets the "distance" to the right view plane.

    Returns number

    The "distance" to the right view plane.

  • Gets the "distance" to the left view plane.

    Returns number

    The "distance" to the left view plane.

  • Gets the "distance" to the top view plane.

    Returns number

    The "distance" to the top view plane.

  • Gets the "distance" to the bottom view plane.

    Returns number

    The "distance" to the bottom view plane.

  • Tells the value of the current horizontal field of view in radian.

    If the view is orthographic, undefined is returned.

    The value will stay the same if setPerspective was called with pIsHorizontal set to false.

    Returns number

    The value of the horizontal field of view in radian if the projection is perspective.

  • (WebXR) Gets the InfiniteXRReferenceSpace that represents the current orientation / position of the camera.

    getXRReferenceFrame can be called with the WebXR api to make some computations on inputs.

    /** 
    * Sample to illustrate using a webxr session.
    */
    import {
    InfiniteEngineInterface, InfiniteEngineInterfaceSignal, InfiniteEvent, InfiniteXRSession,
    CameraManagerInterfaceSignal, InfiniteXRReferenceSpace
    } from 'generated_files/documentation/appinfiniteapi';

    // We try to make a screenshot when all data is loaded

    // created previously the 3D engine
    let lInfiniteEngine: InfiniteEngineInterface;
    // the webXR session
    let lCurSession : InfiniteXRSession;

    // store the XRSession when ready
    lInfiniteEngine.addEventListener(
    InfiniteEngineInterfaceSignal.XRSessionReady,
    (pEvent: InfiniteEvent) : void =>
    {
    lCurSession = pEvent.attachments;
    }
    );

    // make some fancy things on camera changes
    // we may have used InfiniteEngineInterfaceSignal.DisplayDone
    // to be called each frame
    lInfiniteEngine.getCameraManager().addEventListener(
    CameraManagerInterfaceSignal.CameraLocationChanged,
    (_pEvent: InfiniteEvent) : void =>
    {
    if (!lCurSession)
    {
    return;
    }
    const lXRRefSpace : InfiniteXRReferenceSpace | undefined = lInfiniteEngine.getCameraManager().getXRReferenceFrame();
    if (!lXRRefSpace)
    {
    return;
    }
    // make some computations with XRSession inputs
    console.log(lCurSession.inputSources.length);
    }
    );

    // bind the 3D rendering to the div (should have been done earlier :) )
    lInfiniteEngine.setView(undefined, { type: 'webxr', options: {} });

    Please cast InfiniteXRReferenceSpace to XRReferenceSpace.

    Returns any

    The current XRReferenceSpace of the camera, or undefined if no XRSession is started (please refer to InfiniteEngineInterface.setView).

  • Tells if the EventDispatcher has such a callback registered for the given event type.

    Parameters

    • pType: string
      in
      The type of the event to test.
    • pListener: tListenerCallback
      in
      The listener function that gets tested.

    Returns boolean

    true if such a listener is installed for the given type of event.

  • Tells if the EventDispatcher has such a callback registered for the given callback id.

    Parameters

    • pId: string
      in
      The id of the callback to test.

    Returns boolean

    true if such a listener is installed for the given callback id.

  • Tells if the camera is moving at the current time.

    Returns boolean

    true if a camera animation is running at the moment.

  • Tells if the CameraManagerInterface prevents the camera from rotating around the up-axis (rolling).

    isConstraintUpAxis is true as default.

    Returns boolean

    true if the CameraManagerInterface prevents the camera from rolling.

  • Tells the way rendering is updated when the window size is changed.

    If isHorizontalFieldOfViewConstrained returns true, then the horizontal field of view will stay the same in case of window resizing, else the vertical field of view will remain constant.

    The return value will refer to the value of pIsHorizontal set by either the last call to setPerspective or the value set by the maintainer of the current DMU, whichever is the more recent.

    Returns boolean

    true if the field of view is horizontally constrained, 'false if vertically constrained.

  • Tells if the navigation cube is enabled (i.e. it responds to user inputs).

    The navigation cube is enabled by default.

    The navigation cube is an html widget located on the bottom right of the 3d rendering area, which helps the user knowing its current orientation. Information like FRONT, LEFT etc are displayed.

    Returns boolean

    true if the navigation cube is enabled.

  • Tells if the navigation cube is visible.

    The navigation cube is visible by default.

    The navigation cube is an html widget located on the bottom right of the 3d rendering area, which helps the user knowing its current orientation. Information like FRONT, LEFT etc are displayed.

    Returns boolean

    true if the navigation cube is visible.

  • Tells if the camera projection is perspective.

    Returns boolean

    true f the camera projection is perspective.

  • Tells if the default perspective parameters of a dmu should be set when a new DMU is loaded.

    Defaults to true.

    Returns boolean

    true if the default perspective parameters of a dmu will be set when a new DMU is loaded.

  • Sets the position of the center of interest (COI), the camera will turn to look at the point without changing its location.

    This function also sets the center of interest of the CameraManagerInterface. The default animation duration is 250 ms.

    Parameters

    • pCenterOfInterest: Vector3
      in
      The new center of interest.
    • pAnimationDurationInMilliseconds: number
      in
      The duration of the animation in milliseconds (default value is 250). 0 means immediate movement.

    Returns boolean

    true if the call is successful.

  • Sets the position of the center of interest (COI), the camera will turn to look at the point without changing its location.

    This function also sets the center of interest of the CameraManagerInterface.

    The default animation duration is 250 ms.

    Parameters

    • pCenterOfInterest: Vector3
      in
      The new center of interest.

    Returns boolean

    true if the call is successful.

  • Sets the position and direction of the camera.

    The camera orientation will be set on a virtual plane composed of the given direction and the reference frame of the camera.

    In case of an orthographic projection, the camera location is constrained on a fixed 3D sphere centered on the center of the DMU. In this case, calling moveTo followed by getCameraLocation will not return the same value.

    Parameters

    • pPosition: Vector3
      in
      The position of the camera.
    • pDirection: Vector3
      in
      The direction of the camera, up and right vectors will be calculated accordingly.
    • pAnimationDurationInMilliseconds: number
      in
      The duration of the animation in milliseconds. 0 means immediate movement.

    Returns boolean

    true if the camera was correctly set.

  • Sets the position and direction of the camera.

    The camera orientation will be set on a virtual plane composed of the given direction and the reference frame of the camera.

    In case of an orthographic projection, the camera location is constrained on a fixed 3D sphere centered on the center of the DMU. In this case, calling moveTo followed by getCameraLocation will not return the same value.

    The default animation duration is 350 ms.

    This is equivalent to :

    moveTo(pPosition,pDirection,350);
    

    Up and right vectors will be recalculated.

    Parameters

    • pPosition: Vector3
      in
      The position of the camera.
    • pDirection: Vector3
      in
      The direction of the camera, up and right vectors will be calculated accordingly.

    Returns boolean

    true if the camera was correctly set.

  • Removes a listener from an event type.

    If no such listener is found, then the function returns false and does nothing. You must use the exact parameters that were used in addEventListener to actually remove the listener.

    Parameters

    • pType: string
      in
      The type of the listener that gets removed.
    • pListener: tListenerCallback

      The listener function that gets removed.

    • pObject: Object

      The listener object that was used when addEventListener was called.

    Returns boolean

    true if the callback was removed else false.

  • Removes a listener from an event type.

    If no such listener is found, then the function returns false and does nothing. You must use the exact parameters that were used in addEventListener to actually remove the listener.

    Parameters

    • pType: string
      in
      The type of the listener that gets removed.
    • pListener: tListenerCallback

      The listener function that gets removed.

    Returns boolean

    true if the callback was removed else false.

  • Removes a listener by its id.

    If no such listener is found, then the function returns false and does nothing. You must use the return value of addEventListener to actually remove the listener.

    Parameters

    • pId: string
      in
      The id returned by the call to addEventListener that you want to remove.

    Returns boolean

    true if the callback was removed else false.

  • Resets the camera position to fit the entire scene.

    The current orientation of the camera and the center of the DMU are used to get a virtual line. The camera changes its position to get on that line, its orientation is unchanged. The camera position is set along this line to maximize the drawing of the DMU, without any loss of content.

    This is actually a fitBox to the AABB of the DMU.

    Parameters

    • pAnimationDurationInMilliseconds: number
      in
      The duration of the animation in milliseconds. 0 means immediate movement.

    Returns boolean

    true if the call is successful.

  • Resets the camera position to fit the entire scene.

    The current orientation of the camera and the center of the DMU are used to get a virtual line. The camera changes its position to get on that line, its orientation is unchanged. The camera position is set along this line to maximize the drawing of the DMU, without any loss of content.

    The default animation duration is 350 ms.

    This is equivalent to :

    resetCamera(350);
    

    This is actually a fitBox to the AABB of the DMU.

    Returns boolean

    true if the call is successful.

  • Restores the default key mapping in use for the fly mode.

    The key mapping uses the following schema.

    {
    "$defs": {
    "flymode_keymapping": {
    "additionalProperties": false,
    "properties": {
    "backward": {
    "default": "KeyS",
    "type": "string"
    },
    "down": {
    "default": "KeyF",
    "type": "string"
    },
    "forward": {
    "default": "KeyW",
    "type": "string"
    },
    "left": {
    "default": "KeyA",
    "type": "string"
    },
    "right": {
    "default": "KeyD",
    "type": "string"
    },
    "shift": {
    "default": "ShiftLeft",
    "type": "string"
    },
    "up": {
    "default": "KeyR",
    "type": "string"
    },
    "version": {
    "description": "Define the version of the object",
    "example": 1,
    "type": "integer"
    }
    },
    "required": [],
    "title": "Fly mode key mapping definition",
    "type": "object"
    }
    },
    "$ref": "#/$defs/flymode_keymapping",
    "$schema": "https://json-schema.org/draft-07/schema#"
    }

    The key mapping is the content of the keys to use to move the camera in fly mode. It is the content of the `KeyboardEvent.code` field. This value is the non translated value of keyboard (e.g. on a french keyboard, 'KeyW' corresponds to the 'Z' key).

    The default value is :

    {
    "shift": "ShiftLeft",
    "forward": "KeyW",
    "backward": "KeyS",
    "left": "KeyA",
    "right": "KeyD",
    "up": "KeyR",
    "down": "KeyF",
    "version": 1
    }

    This schema may evolve in the future.

    Returns void

  • Sets the camera controller mode to use when processing user inputs.

    In case of an orthographic projection, some CameraControllerMode are not allowed.

    Parameters

    Returns boolean

    true if the controller mode has changed.

  • Sets the camera frame (orientation) of the camera.

    Warning, the three vectors must be orthogonal between them.

    Parameters

    • pDirVector: Vector3
      in
      The new camera direction.
    • pUpVector: Vector3
      in
      The new camera up.
    • pRightVector: Vector3
      in
      The new camera right.

    Returns boolean

    false if the three vectors do not represent an orthogonal coordinate system or at least one vector is not normalized, else true.

  • Sets the camera location.

    The current orientation of the camera is left unchanged.

    In case of an orthographic projection, the camera location is constrained on a fixed 3D sphere centered on the center of the DMU. In this case, calling setCameraLocation followed by getCameraLocation will not return the same value.

    Parameters

    • pLocation: Vector3
      in
      The location of the camera.

    Returns boolean

    true if the camera was correctly set.

  • Sets the camera location.

    The current orientation of the camera is changed according to the current mode. For example, if the controller mode is CameraControllerMode.CCM_ORBIT or CameraControllerMode.CCM_EXAMINE, the camera frame is set according to the current Center Of Interest.

    In case of an orthographic projection, the camera location is constrained on a fixed 3D sphere centered on the center of the DMU. In this case, calling setCameraLocation followed by getCameraLocation will not return the same value.

    Parameters

    • pLocation: Vector3
      in
      The location of the camera.
    • pChangeOrientationAccordingToControllerMode: boolean
      in
      If true, and if the controller mode has a COI, then the camera orientation is set from this COI.

    Returns boolean

    true if the camera was correctly set.

  • Sets if the CameraManagerInterface should prevent the camera from rotating around the up-axis (rolling).

    setConstraintUpAxis is true as default.

    Parameters

    • pConstraint: boolean
      in
      If true, the camera cannot roll.

    Returns boolean

    true if the call changed the constraint.

  • Specifies the sensibility of the controller.

    The controller sensitivity is 1 by default.

    A value greater than 1 will increase the speed of the camera, a value lower than 1 will decrease the speed of the camera. Setting a zero or negative value is invalid. Each CameraControllerMode has its own sensibility. This function only changes the sensibility of the current mode.

    Returns true if the sensitivity is valid and if the sensitivity was changed.

    Parameters

    • pSensitivity: number
      in
      the new sensitivity of the camera (1 by default).

    Returns boolean

    true if pSensitivity is strictly superior to 1.

  • Sets the key mapping to use for the fly mode.

    The key mapping uses the following schema.

    {
    "$defs": {
    "flymode_keymapping": {
    "additionalProperties": false,
    "properties": {
    "backward": {
    "default": "KeyS",
    "type": "string"
    },
    "down": {
    "default": "KeyF",
    "type": "string"
    },
    "forward": {
    "default": "KeyW",
    "type": "string"
    },
    "left": {
    "default": "KeyA",
    "type": "string"
    },
    "right": {
    "default": "KeyD",
    "type": "string"
    },
    "shift": {
    "default": "ShiftLeft",
    "type": "string"
    },
    "up": {
    "default": "KeyR",
    "type": "string"
    },
    "version": {
    "description": "Define the version of the object",
    "example": 1,
    "type": "integer"
    }
    },
    "required": [],
    "title": "Fly mode key mapping definition",
    "type": "object"
    }
    },
    "$ref": "#/$defs/flymode_keymapping",
    "$schema": "https://json-schema.org/draft-07/schema#"
    }

    The key mapping is the content of the keys to use to move the camera in fly mode. It is the content of the `KeyboardEvent.code` field. This value is the non translated value of keyboard (e.g. on a french keyboard, 'KeyW' corresponds to the 'Z' key).

    The default value is :

    {
    "shift": "ShiftLeft",
    "forward": "KeyW",
    "backward": "KeyS",
    "left": "KeyA",
    "right": "KeyD",
    "up": "KeyR",
    "down": "KeyF",
    "version": 1
    }

    This schema may evolve in the future.

    In this case, version is mandatory, but only a subset of the keys may be set.

    Parameters

    • pKeyMapping: string | Object
      in
      The key mapping to set.

    Returns boolean

    true if the data is set.

  • Sets the DMU main vectors.

    This will set the orientation of the orientation cube (FRONT, TOP etc) and also sets the up vector of the DMU, which affects the way the camera is managed, since the camera needs a top reference when rotating around an object.

    Parameters

    • pFrontDir: Vector3
      in
      The new front vector of the scene.
    • pTopDir: Vector3
      in
      The new up vector of the scene.

    Returns boolean

    true if the call is successful.

  • Sets the elevation of the camera.

    When set, the elevation of the camera will remain the same till reset by setLockedElevation. Setting pElevation as undefined will remove the constraint.

    Calling setLockedElevation when the camera is not perspective does nothing, but the elevation will be locked when a fly or XR mode is activated afterwards.

    Calling setLockedElevation when the current camera mode is not fly nor XR will change the current elevation, but the camera elevation will not be locked to this value (in Orbit or Examine, setting a locked elevation is a nonsense). However, the camera elevation will be locked when the fly or XR mode is activated (to the current elevation when the mode is changed, and not to the value of pElevation).

    Calling setLockedElevation when the current camera mode is fly or XR will change the current elevation and the user will not be able to change the elevation of the camera by the controllers.

    The elevation is the dot product between the camera location and the current up camera frame (see getFrameReference). If the frame reference is changed after calling setLockedElevation, the current elevation will stay the same (the camera will not therefore change its position), and the elevation will be computed from the new camera frame.

    Calling setLockedElevation with pAnimationDurationInMilliseconds > 0 will trigger an animation, but if the camera is changed during the animation, the elevation will be set to the current elevation at the time of the change. Calling setLockedElevation without pAnimationDurationInMilliseconds or set as undefined will set the elevation with the default animation duration.

    The default animation duration is 250 ms.

    Parameters

    • pElevation: number
      in
      The elevation to set if pElevation is a number, or removes the constraint if undefined.
    • Optional pAnimationDurationInMilliseconds: number
      in
      The animation time (250 ms as default).

    Returns boolean

    true if the call succeeded.

  • Sets the navigation cube face names.

    Navigation cube face names are displayed on each face of the navigation cube.

    The navigation cube is an html widget located on the bottom right of the 3d rendering area, which helps the user knowing its current orientation. Information like FRONT, LEFT etc are displayed.

    Parameters

    • pFrontFaceName: string
      in
      The new navigation cube front face name.
    • pLeftFaceName: string
      in
      The new navigation cube left face name.
    • pBackFaceName: string
      in
      The new navigation cube back face name.
    • pRightFaceName: string
      in
      The new navigation cube right face name.
    • pTopName: string
      in
      The new navigation cube top face name.
    • pBottomName: string
      in
      The new navigation cube bottom face name.

    Returns boolean

    true if the call is successful.

  • Sets the scale factor of the navigation cube.

    The default scale factor of the cube is 1, meaning a size of approximately 132x132 pixels. Value scales are strictly non negative values.

    The navigation cube is an html widget located on the bottom right of the 3d rendering area, which helps the user knowing its current orientation. Information like FRONT, LEFT etc are displayed.

    Parameters

    • pScale: number
      in
      The new scale to set.

    Returns boolean

    true if pScale is a valid number.

  • Sets the navigation cube visible.

    The navigation cube is visible by default.

    The navigation cube is an html widget located on the bottom right of the 3d rendering area, which helps the user knowing its current orientation. Information like FRONT, LEFT etc are displayed.

    Parameters

    • pVisible: boolean
      in
      The navigation cube is visible if true else it is hidden.

    Returns boolean

    true if the call is successful.

  • Changes the camera projection (perspective or ortho).

    If pPerspective is true, then pPerspectiveValue represents the field of view in radian (the full angle, not half the angle). Valid values range from ]0, 2.9670597[ (in degrees: ]0, 170[). If pIsHorizontal is set, then the pPerspectiveValue is the horizontal field of view, else the vertical one.

    If pPerspective is false, then pPerspectiveValue will refer to the width or height (depending on pIsHorizontal) in DMU units of the camera plane distances. If pIsHorizontal is omitted, then the pPerspectiveValue will refer to the previous value set by either the last call to setPerspective or the value set by the maintainer of the current DMU, whichever is the more recent.

    If pIsHorizontal is set, then the behavior in case of window resizing will maintain the current field of view horizontal or vertical, depending on the value of pIsHorizontal.

    The generated frustum is always symmetric.

    Parameters

    • pPerspective: boolean
      in
      If true, the camera will be set to perspective, else orthographic.
    • Optional pPerspectiveValue: number
      in
      The field of view of the camera in radian if perspective, or the camera plane distance else.
    • Optional pIsHorizontal: boolean
      in
      If set to true, pPerspectiveValue refers to an horizontal value, else a vertical one. If not defined, pPerspectiveValue refers to the last call to setPerspective or the value set by the maintainer of the current DMU, whichever is the more recent.

    Returns boolean

    true if the field of view was set.

  • Sets if the default perspective parameters of a dmu should be set when a new DMU is loaded.

    Defaults to true.

    Parameters

    • pAllowChanges: boolean
      in
      If true, the default perspective parameters of a dmu will be set when a new DMU is loaded.

    Returns boolean

    trueif the call succeeded.

  • (WebXR) Enables/Disables the default WebXR controllers behavior.

    Parameters

    • pLeftControllerEnabled: boolean
      in
      If true, the left controller is enabled.
    • pRightControllerEnabled: boolean
      in
      If true, the right controller is enabled.

    Returns boolean

    true if the call is successful.

  • Gets a deep copy of the internal data of the CameraManagerInterface.

    Please refer to JSON.stringify.

    Parameters

    • Optional pKey: any
      in
      Unused.

    Returns Object

    The internal CameraManagerInterface data.

  • Changes the camera location to zoom in the defined 2D screen region rectangle.

    Parameters

    • pRegion: Rectangle
      in
      The screen region to zoom in.

    Returns boolean

    true if the controller accepts to move to the region.