UNPKG

@animech-public/playcanvas

Version:
2 lines (1 loc) 1.19 kB
import{EventHandler as t}from"../../core/event-handler.js";import{Vec3 as i}from"../../core/math/vec3.js";import{Quat as e}from"../../core/math/quat.js";class s extends t{constructor(t,s){super(),this._image=void 0,this._width=void 0,this._bitmap=null,this._measuredWidth=0,this._trackable=!1,this._tracking=!1,this._emulated=!1,this._pose=null,this._position=new i,this._rotation=new e,this._image=t,this._width=s}get image(){return this._image}set width(t){this._width=t}get width(){return this._width}get trackable(){return this._trackable}get tracking(){return this._tracking}get emulated(){return this._emulated}prepare(){return this._bitmap?{image:this._bitmap,widthInMeters:this._width}:createImageBitmap(this._image).then((t=>(this._bitmap=t,{image:this._bitmap,widthInMeters:this._width})))}destroy(){this._image=null,this._pose=null,this._bitmap&&(this._bitmap.close(),this._bitmap=null)}getPosition(){return this._pose&&this._position.copy(this._pose.transform.position),this._position}getRotation(){return this._pose&&this._rotation.copy(this._pose.transform.orientation),this._rotation}}s.EVENT_TRACKED="tracked",s.EVENT_UNTRACKED="untracked";export{s as XrTrackedImage};