UNPKG

@animech-public/playcanvas

Version:
2 lines (1 loc) 1.18 kB
import{EventHandler as t}from"../../core/event-handler.js";import{Quat as e}from"../../core/math/quat.js";import{Vec3 as i}from"../../core/math/vec3.js";let n=0;class o extends t{constructor(t,o){super(),this._id=void 0,this._planeDetection=void 0,this._xrPlane=void 0,this._lastChangedTime=void 0,this._orientation=void 0,this._position=new i,this._rotation=new e,this._id=++n,this._planeDetection=t,this._xrPlane=o,this._lastChangedTime=o.lastChangedTime,this._orientation=o.orientation}destroy(){this._xrPlane&&(this._xrPlane=null,this.fire("remove"))}update(t){const e=this._planeDetection._manager,i=t.getPose(this._xrPlane.planeSpace,e._referenceSpace);i&&(this._position.copy(i.transform.position),this._rotation.copy(i.transform.orientation)),this._lastChangedTime!==this._xrPlane.lastChangedTime&&(this._lastChangedTime=this._xrPlane.lastChangedTime,this.fire("change"))}getPosition(){return this._position}getRotation(){return this._rotation}get id(){return this._id}get orientation(){return this._orientation}get points(){return this._xrPlane.polygon}get label(){return this._xrPlane.semanticLabel||""}}o.EVENT_REMOVE="remove",o.EVENT_CHANGE="change";export{o as XrPlane};