Skip to main content

XR8.XrController.pipelineModule()

XR8.XrController.pipelineModule()

Description

Creates a camera pipeline module that, when installed, receives callbacks on when the camera has started, camera proessing events, and other state changes. These are used to calculate the camera's position.

Parameters

None

Returns

Return value is an object made available to onUpdate as:

processCpuResult.reality: { rotation, position, intrinsics, trackingStatus, trackingReason, worldPoints, realityTexture, lighting }

PropertyTypeDescription
rotation{w, x, y, z}The orientation (quaternion) of the camera in the scene.
position{x, y, z}The position of the camera in the scene.
intrinsics[Number]A 16 dimensional column-major 4x4 projection matrix that gives the scene camera the same field of view as the rendered camera feed.
trackingStatusStringOne of 'LIMITED' or 'NORMAL'.
trackingReasonStringOne of 'UNSPECIFIED' or'INITIALIZING'.
worldPoints[{id, confidence, position: {x, y, z}}]An array of detected points in the world at their location in the scene. Only filled if XrController is configured to return world points and trackingReason != 'INITIALIZING'.
realityTextureWebGLTextureThe texture containing camera feed data.
lighting{exposure, temperature}Exposure of the lighting in your environment. Note: temperature has not yet been implemented.

Dispatched Events

trackingStatus: Fires when XrController starts and tracking status or reason changes.

reality.trackingstatus : { status, reason }

PropertyTypeDescription
statusStringOne of 'LIMITED' or 'NORMAL'.
reasonStringOne of 'INITIALIZING' or 'UNDEFINED'.

imageloading: Fires when detection image loading begins.

imageloading.detail : { imageTargets: {name, type, metadata} }

PropertyTypeDescription
nameStringThe image's name.
typeStringOne of 'FLAT', 'CYLINDRICAL', 'CONICAL'.
metadataObjectUser metadata.

imagescanning: Fires when all detection images have been loaded and scanning has begun.

imagescanning.detail : { imageTargets: {name, type, metadata, geometry} }

PropertyTypeDescription
nameStringThe image's name.
typeStringOne of 'FLAT', 'CYLINDRICAL', 'CONICAL'.
metadataObjectUser metadata.
geometryObjectObject containing geometry data. If type=FLAT: {scaledWidth, scaledHeight}, else if type=CYLINDRICAL or type=CONICAL: {height, radiusTop, radiusBottom, arcStartRadians, arcLengthRadians}

If type = FLAT, geometry:

PropertyTypeDescription
scaledWidthNumberThe width of the image in the scene, when multiplied by scale.
scaledHeightNumberThe height of the image in the scene, when multiplied by scale.

If type= CYLINDRICAL or CONICAL, geometry:

PropertyTypeDescription
heightNumberHeight of the curved target.
radiusTopNumberRadius of the curved target at the top.
radiusBottomNumberRadius of the curved target at the bottom.
arcStartRadiansNumberStarting angle in radians.
arcLengthRadiansNumberCentral angle in radians.

imagefound: Fires when an image target is first found.

imagefound.detail : { name, type, position, rotation, scale, scaledWidth, scaledHeight, height, radiusTop, radiusBottom, arcStartRadians, arcLengthRadians }

PropertyTypeDescription
nameStringThe image's name.
typeNumberOne of 'FLAT', 'CYLINDRICAL', 'CONICAL'.`
position{x, y, z}The 3d position of the located image.
rotation{w, x, y, z}The 3d local orientation of the located image.
scaleNumberA scale factor that should be applied to object attached to this image.

If type = FLAT:

PropertyTypeDescription
scaledWidthNumberThe width of the image in the scene, when multiplied by scale.
scaledHeightNumberThe height of the image in the scene, when multiplied by scale.

If type= CYLINDRICAL or CONICAL:

PropertyTypeDescription
heightNumberHeight of the curved target.
radiusTopNumberRadius of the curved target at the top.
radiusBottomNumberRadius of the curved target at the bottom.
arcStartRadiansNumberStarting angle in radians.
arcLengthRadiansNumberCentral angle in radians.

imageupdated: Fires when an image target changes position, rotation or scale.

imageupdated.detail : { name, type, position, rotation, scale, scaledWidth, scaledHeight, height, radiusTop, radiusBottom, arcStartRadians, arcLengthRadians }

PropertyTypeDescription
nameStringThe image's name.
typeNumberOne of 'FLAT', 'CYLINDRICAL', 'CONICAL'.`
position{x, y, z}The 3d position of the located image.
rotation{w, x, y, z}The 3d local orientation of the located image.
scaleNumberA scale factor that should be applied to object attached to this image.

If type = FLAT:

PropertyTypeDescription
scaledWidthNumberThe width of the image in the scene, when multiplied by scale.
scaledHeightNumberThe height of the image in the scene, when multiplied by scale.

If type= CYLINDRICAL or CONICAL:

PropertyTypeDescription
heightNumberHeight of the curved target.
radiusTopNumberRadius of the curved target at the top.
radiusBottomNumberRadius of the curved target at the bottom.
arcStartRadiansNumberStarting angle in radians.
arcLengthRadiansNumberCentral angle in radians.

imagelost: Fires when an image target is no longer being tracked.

imagelost.detail : { name, type, position, rotation, scale, scaledWidth, scaledHeight, height, radiusTop, radiusBottom, arcStartRadians, arcLengthRadians }

PropertyTypeDescription
nameStringThe image's name.
typeNumberOne of 'FLAT', 'CYLINDRICAL', 'CONICAL'.`
position{x, y, z}The 3d position of the located image.
rotation{w, x, y, z}The 3d local orientation of the located image.
scaleNumberA scale factor that should be applied to object attached to this image.

If type = FLAT:

PropertyTypeDescription
scaledWidthNumberThe width of the image in the scene, when multiplied by scale.
scaledHeightNumberThe height of the image in the scene, when multiplied by scale.

If type= CYLINDRICAL or CONICAL:

PropertyTypeDescription
heightNumberHeight of the curved target.
radiusTopNumberRadius of the curved target at the top.
radiusBottomNumberRadius of the curved target at the bottom.
arcStartRadiansNumberStarting angle in radians.
arcLengthRadiansNumberCentral angle in radians.

Example - adding pipeline module

XR8.addCameraPipelineModule(XR8.XrController.pipelineModule())

Example - dispatched events

const logEvent = ({name, detail}) => {
console.log(`Handling event ${name}, got detail, ${JSON.stringify(detail)}`)
}

XR8.addCameraPipelineModule({
name: 'eventlogger',
listeners: [
{event: 'reality.imageloading', process: logEvent},
{event: 'reality.imagescanning', process: logEvent},
{event: 'reality.imagefound', process: logEvent},
{event: 'reality.imageupdated', process: logEvent},
{event: 'reality.imagelost', process: logEvent},
],
})