From 6e43668984204a4af0461427fd6003c840ae8f1c Mon Sep 17 00:00:00 2001 From: Lukas Herzberger Date: Wed, 6 Jul 2022 14:20:54 -0400 Subject: [PATCH] add hello in worker example --- examples-gpu/hello-worker.js | 1 + examples-gpu/index.html | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 examples-gpu/hello-worker.js diff --git a/examples-gpu/hello-worker.js b/examples-gpu/hello-worker.js new file mode 100644 index 000000000000..59596f831025 --- /dev/null +++ b/examples-gpu/hello-worker.js @@ -0,0 +1 @@ +import("./wasm/hello.js").then(module => module.default()); diff --git a/examples-gpu/index.html b/examples-gpu/index.html index f2f5d50b0362..b076a2536bc9 100644 --- a/examples-gpu/index.html +++ b/examples-gpu/index.html @@ -67,6 +67,7 @@ "skybox", // "texture-arrays", // "water", + "hello-worker", ]; const list = document.createElement("ul"); for (let exampleName of exampleNames) { @@ -82,7 +83,10 @@ const currentExample = new URLSearchParams(window.location.search).get( "example" ); - if (currentExample) { + if (currentExample === "hello-worker") { + console.info("Note: loading modules in web workers is currently not supported on Firefox"); + const worker = new Worker("hello-worker.js", { type: "module" }); + } else if (currentExample) { import(`./wasm/${currentExample}.js`).then((module) => module.default()); } else { window.location.assign(