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.

meshfound: Fires when a mesh is first found either after start or after a recenter().

xrmeshfound.detail : { id, position, rotation, geometry }

PropertyTypeDescription
idStringAn id for this mesh that is stable within a session
position{x, y, z}The 3d position of the located mesh.
rotation{w, x, y, z}The 3d local orientation (quaternion) of the located mesh.
geometry{index, attributes}An object containing raw mesh geometry data. Attributes contain position and color attributes.

geometry is an object with the following properties:

PropertyTypeDescription
indexUint32ArrayThe vertices of the mesh where 3 contiguous vertices make up a triangle.
attributes[{name: 'position', array: Float32Array(), itemSize: 3}, {name: 'color', array: Float32Array(), itemSize: 3}]The raw mesh geometry data.

meshupdated: Fires when a the first mesh we found changes position or rotation.

meshupdated.detail : { id, position, rotation }

PropertyTypeDescription
idStringAn id for this mesh that is stable within a session
position{x, y, z}The 3d position of the located mesh.
rotation{w, x, y, z}The 3d local orientation (quaternion) of the located mesh.

meshlost: Fires when recenter is called.

xrmeshlost.detail : { id }

PropertyTypeDescription
idStringAn id for this mesh that is stable within a session

projectwayspotscanning: Fires when all Project Locations have been loaded for scanning.

projectwayspotscanning.detail : { wayspots: [] }

PropertyTypeDescription
wayspots[Object]An array objects containing Location information.

wayspots is an array of objects with the following properties:

PropertyTypeDescription
idStringAn id for this Project Location that is stable within a session
nameStringProject Location name.
imageUrlStringURL to a representative image for this Project Location.
titleStringProject Location title.
latNumberLatitude of this Project Location.
lngNumberLongitude of this Project Location.

projectwayspotfound: Fires when a Project Location is first found.

projectwayspotfound.detail : { name, position, rotation }

PropertyTypeDescription
nameStringThe Project Location name.
position{x, y, z}The 3d position of the located Project Location.
rotation{w, x, y, z}The 3d local orientation (quaternion) of the located Project Location.

projectwayspotupdated: Fires when a Project Location changes position or rotation.

projectwayspotupdated.detail : { name, position, rotation }

PropertyTypeDescription
nameStringThe Project Location name.
position{x, y, z}The 3d position of the located Project Location.
rotation{w, x, y, z}The 3d local orientation (quaternion) of the located Project Location.

projectwayspotlost: Fires when a Project Location is no longer being tracked.

projectwayspotlost.detail : { name, position, rotation }

PropertyTypeDescription
nameStringThe Project Location name.
position{x, y, z}The 3d position of the located Project Location.
rotation{w, x, y, z}The 3d local orientation (quaternion) of the located Project Location.

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},
],
})