24 lines
711 B
TypeScript
24 lines
711 B
TypeScript
/// <reference lib="webworker" />
|
|
|
|
import createBitbybitDevOcct from '@bitbybit-dev/occt/bitbybit-dev-occt/bitbybit-dev-occt'
|
|
import { initializationComplete, onMessageInput } from '@bitbybit-dev/occt-worker'
|
|
|
|
const workerScope = self as DedicatedWorkerGlobalScope
|
|
|
|
const initialize = async () => {
|
|
try {
|
|
const occt = await createBitbybitDevOcct()
|
|
initializationComplete(occt, undefined)
|
|
workerScope.onmessage = ({ data }) => onMessageInput(data, (message) => workerScope.postMessage(message))
|
|
} catch (error) {
|
|
workerScope.postMessage({
|
|
type: 'occ-initialization-failed',
|
|
error: error instanceof Error ? error.message : String(error),
|
|
})
|
|
}
|
|
}
|
|
|
|
void initialize()
|
|
|
|
export {}
|