im trying to render web GPU shader object in WebGpu
and it returning this error
Uncaught (in promise) TypeError: Cannot read property 'requestDevice' of null at cube.html:28
this is my code to the requestDevice
(async () => {
const [adapter, glslang] = await Promise.all([
navigator.gpu.requestAdapter(),
import("https://unpkg.com/@webgpu/glslang@0.0.7/web/glslang.js").then(m => m.default())
]);
const device = await adapter.requestDevice();
const canvas = document.getElementById("webgpu-canvas");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
});
any idea to fix this error ??