我试图在 WebGpu 中渲染 Web GPU 着色器对象
并返回此错误
未捕获(承诺)类型错误:无法在 cube.html:28 处读取 null 的属性“requestDevice”
这是我对 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;
});
Run Code Online (Sandbox Code Playgroud)
任何想法来解决这个错误?
我用 svg 创建了这个,这是我的代码
<body>
<div style="width: 100%; background-image: url('https://t4.ftcdn.net/jpg/01/25/20/05/360_F_125200542_AyamLpAFVwGqUx2ntcrQpLQE3pde3h23.jpg'); background-repeat: no-repeat; background-size: cover;">
<svg viewbox="0 0 20 13.4">
<defs>
<clipPath id="top">
<polygon points="0 0, 9.9 0, 9.9 5, 0 8" />
</clipPath>
<clipPath id="right">
<polygon points="9.9 0, 9.9 5, 20 8, 20 0" />
</clipPath>
</defs>
<image xlink:href="http://i.imgur.com/RECDV24.jpg" x="0" y="0" height="13.4" width="20" clip-path="url(#top)"/>
<image xlink:href="http://i.imgur.com/5NK0H1e.jpg" x="0" y="0" height="13.4" width="20" clip-path="url(#right)"/>
</svg>
</div>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
我如何将它转换为没有 svg 标签的只有 html 和 css