Private
_idPrivate
_lastPrivate
_orientationPrivate
_planePrivate
_positionPrivate
_rotationPrivate
_xrUnique identifier of a plane.
Semantic Label of a plane that is provided by underlying system. Current list includes (but not limited to): https://github.com/immersive-web/semantic-labels/blob/master/labels.json
Plane's specific orientation (horizontal or vertical) or null if orientation is anything else.
Array of DOMPointReadOnly objects. DOMPointReadOnly is an object with x y z
properties
that defines a local point of a plane's polygon.
// prepare reusable objects
const vecA = new pc.Vec3();
const vecB = new pc.Vec3();
const color = new pc.Color(1, 1, 1);
// update Mat4 to plane position and rotation
transform.setTRS(plane.getPosition(), plane.getRotation(), pc.Vec3.ONE);
// draw lines between points
for (let i = 0; i < plane.points.length; i++) {
vecA.copy(plane.points[i]);
vecB.copy(plane.points[(i + 1) % plane.points.length]);
// transform from planes local to world coords
transform.transformPoint(vecA, vecA);
transform.transformPoint(vecB, vecB);
// render line
app.drawLine(vecA, vecB, color);
}
Fire an event, all additional arguments are passed on to the event listener.
Name of event to fire.
Optional
arg1: anyFirst argument that is passed to the event handler.
Optional
arg2: anySecond argument that is passed to the event handler.
Optional
arg3: anyThird argument that is passed to the event handler.
Optional
arg4: anyFourth argument that is passed to the event handler.
Optional
arg5: anyFifth argument that is passed to the event handler.
Optional
arg6: anySixth argument that is passed to the event handler.
Optional
arg7: anySeventh argument that is passed to the event handler.
Optional
arg8: anyEighth argument that is passed to the event handler.
Self for chaining.
obj.fire('test', 'This is the message');
Test if there are any handlers bound to an event name.
The name of the event to test.
True if the object has handlers bound to the specified event name.
obj.on('test', function () { }); // bind an event to 'test'
obj.hasEvent('test'); // returns true
obj.hasEvent('hello'); // returns false
Detach an event handler from an event. If callback is not provided then all callbacks are unbound from the event, if scope is not provided then all events with the callback will be unbound.
Optional
name: stringName of the event to unbind.
Optional
callback: HandleEventCallbackFunction to be unbound.
Optional
scope: objectScope that was used as the this when the event is fired.
Self for chaining.
const handler = function () {
};
obj.on('test', handler);
obj.off(); // Removes all events
obj.off('test'); // Removes all events called 'test'
obj.off('test', handler); // Removes all handler functions, called 'test'
obj.off('test', handler, this); // Removes all handler functions, called 'test' with scope this
Attach an event handler to an event.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
Can be used for removing event in the future.
obj.on('test', function (a, b) {
console.log(a + b);
});
obj.fire('test', 1, 2); // prints 3 to the console
const evt = obj.on('test', function (a, b) {
console.log(a + b);
});
// some time later
evt.off();
Attach an event handler to an event. This handler will be removed after being fired once.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
obj.once('test', function (a, b) {
console.log(a + b);
});
obj.fire('test', 1, 2); // prints 3 to the console
obj.fire('test', 1, 2); // not going to get handled
Static
EVENT_Fired when XrPlane attributes such as: orientation and/or points have been changed.
Position and rotation can change at any time without triggering a change
event.
plane.on('change', () -> {
// plane has been changed
});
Static
EVENT_Fired when an XrPlane is removed.
plane.once('remove', () => {
// plane is not available anymore
});
Detected Plane instance that provides position, rotation, polygon points and its semantic label. Plane data is subject to change during its lifetime.