explodorama / files / src / sim / scene-worker.ts
scene-worker.ts
| 1 | import { generateScene, type SceneKind } from './demo' |
| 2 | |
| 3 | /** |
| 4 | * Makes the demo's and the dialogs' scenes off the main thread (ui/scenes.ts): one can take up to |
| 5 | * ~0.45 s, which played on the page would stall the animation. A request is an id, a kind and a |
| 6 | * seed; the answer is the id and the scene, or null if none was found. |
| 7 | */ |
| 8 | self.onmessage = (e: MessageEvent<{ id: number; kind: SceneKind; seed: number }>) => { |
| 9 | const { id, kind, seed } = e.data |
| 10 | self.postMessage({ id, scene: generateScene(kind, seed) }) |
| 11 | } |