/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import t from"../../../core/Error.js";import{throwIfAborted as e}from"../../../core/promiseUtils.js";import{open as n}from"../../../core/workers.js";class o{constructor(){this._connection=null,this.convertPixelBlockToImageData=async e=>{if(!this._connection)throw new t("panoramic-mesh-manager:convertPixelBlockToImageData","Panoramic mesh manager is not loaded");const n=e.clone(),{pixelBlock:o,transferList:i}=n.getTransferableObject();return await this._connection.invoke("convertPixelBlockToImageData",o,{transferList:i})},this.getFacesWithVertexAttributes=async e=>{if(!this._connection)throw new t("panoramic-mesh-manager:getFacesWithVertexAttributes","Panoramic mesh manager is not loaded");return await this._connection.invoke("getFacesWithVertexAttributes",e)}}destroy(){this._connection?.close()}async _startWorker(t){this._connection=await n("PanoramicMeshWorker",t)}static getInstance(){return o._instance||(o._instance=new o),o._instance}async load(t){return e(t),await this._startWorker(t),this}async recomputePositions(e,n,o,i){if(!this._connection)throw new t("panoramic-mesh-manager:recomputePositions","Panoramic mesh manager is not loaded");return await this._connection.invoke("recomputePositions",{oldDistance:e,newDistance:n,position:o},{...i,transferList:[o.buffer.slice()]})}}export{o as default};
