P3-02 P5-02: integrate Bitbybit OCCT geometry runtime
This commit is contained in:
23
src/facade/geometryWorker.ts
Normal file
23
src/facade/geometryWorker.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/// <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 {}
|
||||
Reference in New Issue
Block a user