ArSystem

ArSystem

Processes all entities with an ArAnchorComponent.
Allows and abstracts access to device-specific AR APIs (ARKit, ARCore, etc.).

Constructor

new ArSystem(delegate)

Parameters:
Name Type Description
delegate Object

An object that implements:
requestHitTest(requestId, screenX, screenY) => (), which performs a hit test and calls _hitTestResponse to report the results.
registerAnchor(requestId, transform) => (), which registers an anchor and calls _registerAnchorResponse to report the results.

Methods

_hitTestResponse(requestId, transform)

Called by the delegate to report the results of previous call to the delegate's requestHitTest function.

Parameters:
Name Type Description
requestId string

request id passed to a prior call of requestHitTest().

transform Matrix4

transform representing the result of the hit test, or null if the test was unsuccessful.

_registerAnchorResponse(requestId, anchorId)

Called by the delegate to report the results of previous call to the delegate's registerAnchor function.

Parameters:
Name Type Description
requestId string

request id passed to a prior call of registerAnchor().

anchorId string

a unique identifier for the anchor added to the scene.

_setAnchorTransform(anchorId, transform)

Updates the transform associated with an anchor.

Parameters:
Name Type Description
anchorId string

id of the anchor to update.

transform Matrix4

world transform to associate with the anchor.

getAmbientColorTemperature() → {number}

Returns the color component of the ambient lighting estimation.

getAmbientIntensity() → {number}

Returns the intensity component of the ambient lighting estimation.

getProjectionMatrix() → {Matrix4}

Returns a projection matrix appropriate for rendering the scene in AR.

getViewMatrix() → {Matrix4}

Returns a view matrix appropriate for rendering the scene in AR.

hitTest(screenX, screenY, callback)

Performs a hit test on the environment by casting a ray out from the camera eye point through the specified
screen coordinates, returning a transform (through a callback) which represents the first object with which the ray intersects.

Parameters:
Name Type Description
screenX number

x-coordinate through which the hit test will be performed in normalized image coordinates [0.0, 1.0].

screenY number

y-coordinate through which the hit test will be performed in normalized image coordinates [0.0, 1.0].

callback function

Callback to handle the result of type: (transform: Matrix4) => (). transform may be null if the hit test was unsuccessful.

process(entities, tpf)

Called on each render frame, if the system is not passive. For each entity with an ArAnchorComponent, update its transform
based on the component's anchor id.

Parameters:
Name Type Description
entities array
tpf number

registerAnchor(transform, callback)

Registers an anchor to be tracked in the environment. Returns (through a callback) an identifier for the anchor.

Parameters:
Name Type Description
transform Matrix4

Transform representing the anchor's position in the world.

callback function

Callback to handle the result of type: (anchorId: String) => (). anchorId may be null if registration was unsuccessful.

registerImage(imageName, callback)

Registers an image to be detected in the environment.

Parameters:
Name Type Description
imageName string

Name of the image to be detected

callback function

Callback to handle the result of type: (anchorId: String, transform: Matrix4) => ().