Class: Lens.Marker

Markers are images that LuminAR watches for and tracks. They can be used to track physical objects within LuminAR's field of view. They can track objects even if they are rotated or scaled.

Static Methods

Lens.Marker.clear() ARCore/marker.js, line 564

Stops tracking of all markers.

Lens.Marker.fromImageData(image, mask) → {Lens.Marker} ARCore/marker.js, line 456

Creates a marker from base64-encoded PNG data.

Argument Type Attributes Description
image String

Base64-encoded data.

mask String <optional>

Optional base64-encoded mask. The mask should be an image of the same size as the image with only black and white pixels. Any areas of black will be ignored when processing the image.

Returns:

The newly-created Marker.

Lens.Marker.fromImageURL(imageURL, maskURL) → {Lens.Marker} ARCore/marker.js, line 489

Creates a marker from the URL of a PNG image.

Argument Type Attributes Description
imageURL String

URL of an image. The image must be on the same host as the Lens app to comply with the same-origin policy.

maskURL String <optional>

Optional URL of a mask image. The image must be on the same host as the Lens app to comply with the same-origin policy. The mask should be an image of the same size as the image with only black and white pixels. Any areas of black will be ignored when processing the image.

Returns:

The newly-created Marker.

Lens.Marker.fromSnapshot(el) → {Lens.Marker} ARCore/marker.js, line 543

Creates a marker by taking a snapshot of a page element with the LuminAR camera and tracking that image.

Argument Type Description
el string | Element | jQuery

The snapshot taken by the LuminAR HD camera will be cropped to this element. This can be a CSS selector string, DOM element, or jQuery object. This element must be rendered to the screen; it can't have been hidden with display: none in CSS or with jQuery's .hide().

Returns:

The newly-created Marker.

Instance Properties

id: String

Unique ID for the Marker.

origWidth: Number

Original width of the tracked image. May be null for a short time after marker creation.

origHeight: Number

Original height of the tracked image. May be null for a short time after marker creation.

Instance Methods

_setOrigDims(x, y) ARCore/marker.js, line 218

Sets the original width and height of this marker. Used so factories can calculate these dimensions asynchronously.

Argument Type Description
x Number
y Number

appeared(fn) → {Binding} ARCore/marker.js, line 243

Subscribes a function to be called any time this marker appears.

Argument Type Description
fn function

The function to subscribe. Gets this marker as an argument when called.

Returns:

A binding that allows this handler to be cleared.

deregister() ARCore/marker.js, line 265

Stops tracking of this marker.

disappeared(fn) → {Binding} ARCore/marker.js, line 256

Subscribes a function to be called any time this marker disappears.

Argument Type Description
fn function

The function to subscribe. Gets this marker as an argument when called.

Returns:

A binding that allows this handler to be cleared.

getCSSTransform() → {String} ARCore/marker.js, line 366

Returns a CSS transform that represents the transformation of a rectangle the side of the tracked image anchored at the top-left corner of the screen to the current positon of the marker. Returns a transform with the identity matrix if the marker is not on screen.

Returns:

The CSS transform, suitable for use as the value of the "transform" CSS property.

getRotation() → {Number} ARCore/marker.js, line 399

Gets the angle of rotation of this marker. Return null if the marker is not visible.

Returns:

Rotation, in radians, clockwise.

getScale() → {Number} ARCore/marker.js, line 409

Gets the scale of the object, e.g. how much larger or smaller it is than the tracked image. Return null if the marker is not visible.

Returns:

The scale, as a multiple of the original size (e.g. a value of 1 indicates no scale).

getSkew() → {Number} ARCore/marker.js, line 424

Gets the skew of the object, e.g. how much is is deformed into a trapezoid, or null if the marker is not visible.

Returns:

The skew of the object.

getTransform() → {Array} ARCore/marker.js, line 337

Returns a 4x4 transformation matrix that represents the transformation of a rectangle the side of the tracked image anchored at the top-left corner of the screen to the current positon of the marker. Returns null if the marker is not visible.

Returns:

16-element array of Numbers representing the 3-D transformation matrix in row-major order.

getX() ARCore/marker.js, line 381

Gets the X coordinate of the left side of the marker. Return null if the marker is not visible.

getY() → {Number} ARCore/marker.js, line 390

Gets the Y coordinate of the top side of the marker. Return null if the marker is not visible.

Returns:

Y coordinate, in pixels.

moved(fn) → {Binding} ARCore/marker.js, line 230

Subscribes a function to be called any time this marker is moved.

Argument Type Description
fn function

The function to subscribe. Gets this marker as an argument when called.

Returns:

A binding that allows this handler to be cleared.

pin(el, clone, onPinStart) ARCore/marker.js, line 286

Pins an element to this marker. The element's CSS will be modified to move/resize/rotate/transform it to match the tracked object.

Argument Type Attributes Description
el string | Element | jQuery

The element to track with. This can be a CSS selector string, DOM element, or jQuery object.

clone Boolean <optional>

If true, a clone of the element will be used to track the object. The clone will be destroyed when the object is no longer visible. Defaults to false.

onPinStart function <optional>

Optional. If given, this function will be invoked when we start pinning the element. It will get the pinned element as an argument.

visible() → {Boolean} ARCore/marker.js, line 324

Return true if this marker is on screen, false otherwise.