import { createMeshDocument } from './facade/mesh'

self.addEventListener('message', (event: MessageEvent<{ positions: number[]; indices: number[]; targetTriangles: number }>) => {
  try {
    const mesh = createMeshDocument('worker-mesh', 'Worker mesh', event.data)
    self.postMessage({ lod: mesh.lod(event.data.targetTriangles) })
  } catch (error) {
    self.postMessage({ error: error instanceof Error ? error.message : String(error) })
  }
})

export {}
