XrPlane
Detected Plane instance that provides position, rotation and polygon points. Plane is a subject to change during its lifetime.
Summary
Properties
id | Unique identifier of a plane. |
orientation | Plane's specific orientation (horizontal or vertical) or null if orientation is anything else. |
points | Array of DOMPointReadOnly objects. |
Methods
getPosition | Get the world space position of a plane. |
getRotation | Get the world space rotation of a plane. |
Events
change | Fired when XrPlane attributes such as: orientation and/or points have been changed. |
remove | Fired when XrPlane is removed. |
Details
Properties
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);
}
Methods
getPosition()
Get the world space position of a plane.
Returns
Vec3The world space position of a plane.
getRotation()
Get the world space rotation of a plane.
Returns
QuatThe world space rotation of a plane.