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.
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.
The id of the inserted callback (actually an UUID).
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();
A promise. The promise is resolved with the reason (success, disposed).
Creates an export viewpoint of the current camera for the given resulting image aspect ratio.
The CameraViewpointJSONInterface should be used with DataSessionInterface.export2D, DataSessionInterface.exportSVG.
Returns undefined if pAspectRatio is not correct.
The CameraViewpointJSONInterface of the current camera with the given aspect ratio.
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).
true else it is disabled.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);
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);
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);
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);
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#"
}
true if the data is set.
Gets the current camera behavior when a new DMU is loaded.
The default behavior is CameraControllerOnStartBehavior.CCB_SetDMUStartPosAndAnimation.
Warning: this parameter is not set nor dumped through toJSON and fromJSON.
The current camera behavior when a new DMU is loaded.
Gets the current camera controller mode.
The current camera controller mode.
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,+∞[.
The actual sensitivity of the camera controller.
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.
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 default value is :
{
"shift": "ShiftLeft",
"forward": "KeyW",
"backward": "KeyS",
"left": "KeyA",
"right": "KeyD",
"up": "KeyR",
"down": "KeyF",
"version": 1
}
The actual key mapping that follows the given json schema.
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.
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).
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.
true if the call is successful.
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.
The current navigation cube scale factor.
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.
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: {} });
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.
true if such a listener is installed for the given type of event.
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.
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.
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.
true if the navigation cube is visible.
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.
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.
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.
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);
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.
The listener function that gets removed.
The listener object that was used when addEventListener was called.
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.
The listener function that gets removed.
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.
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.
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);
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 default value is :
{
"shift": "ShiftLeft",
"forward": "KeyW",
"backward": "KeyS",
"left": "KeyA",
"right": "KeyD",
"up": "KeyR",
"down": "KeyF",
"version": 1
}
Sets the way the camera should be updated when a new DMU is loaded.
The default behavior is CameraControllerOnStartBehavior.CCB_SetDMUStartPosAndAnimation.
Returns true if the call changed the CameraControllerOnStartBehavior.
Warning: this parameter is not set nor dumped through toJSON and fromJSON.
true if the call actually changed the current CameraControllerOnStartBehavior.
Sets the camera controller mode to use when processing user inputs.
In case of an orthographic projection, some CameraControllerMode are not allowed.
true if the controller mode has changed.
Sets the camera frame (orientation) of the camera.
Warning, the three vectors must be orthogonal between them.
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.
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.
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.
true, the camera cannot roll.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.
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 default value is :
{
"shift": "ShiftLeft",
"forward": "KeyW",
"backward": "KeyS",
"left": "KeyA",
"right": "KeyD",
"up": "KeyR",
"down": "KeyF",
"version": 1
}
In this case, version is mandatory, but only a subset of the keys may be set.
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.
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.
Optional pAnimationDurationInMilliseconds: numbertrue 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.
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.
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.
true else it is hidden.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.
true, the camera will be set to perspective, else orthographic.Optional pPerspectiveValue: numberOptional pIsHorizontal: booleanpPerspectiveValue 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.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.
trueif the call succeeded.
(WebXR) Enables/Disables the default WebXR controllers behavior.
true if the call is successful.
Gets a deep copy of the internal data of the CameraManagerInterface.
Please refer to JSON.stringify.
Optional pKey: anyThe internal CameraManagerInterface data.
Changes the camera location to zoom in the defined 2D screen region rectangle.
true if the controller accepts to move to the region.
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 :
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.
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.
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.
See