threejs-webgpu

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

WebGPU and TSL

WebGPU 与 TSL

Use the project's installed versions and existing architecture. These instructions supplement the user's task; they do not authorize unrelated changes or external actions.
Check the installed Three.js exports and matching renderer/TSL documentation first. These APIs evolve quickly; use the project's pinned revision rather than mixing current snippets into an older install.
List required features and backend constraints. WebGPURenderer can use a WebGL backend when supported, but backend selection does not guarantee every compute or effect feature works on both. Test the actual selected backend. Do not replace a working WebGLRenderer unless the requested feature or migration warrants it.
Follow the revision's asynchronous initialization contract before rendering or capability-dependent setup. Handle initialization failure and unsupported devices with an explicit fallback state. Keep imports consistent with the renderer build to avoid duplicate class/module instances.
Express materials through supported node/TSL mechanisms. Port custom GLSL, shader patches, and composer effects intentionally; they are not automatically compatible. For compute, define storage layouts, bounds checks, dispatch sizes, synchronization, and readback frequency. Avoid per-frame CPU readback when data can stay on the GPU.
Manage compute buffers, render targets, and backend device loss according to current APIs. Avoid unbounded workload retries after initialization failure.
Verify on the requested WebGPU device/browser and any promised fallback backend. Report backend and feature results separately; a browser exposing navigator.gpu is not proof that this scene rendered successfully.
使用项目已安装的版本和现有架构。这些说明是对用户任务的补充,并不授权进行无关更改或外部操作。
首先检查已安装的 Three.js 导出项以及匹配的 renderer/TSL 文档。这些 API 演进迅速;应使用项目固定的修订版本,避免将当前代码片段混入较旧的安装版本中。
列出所需功能和后端约束。在支持的情况下,WebGPURenderer 可以使用 WebGL 后端,但选择后端并不保证所有 compute 或 effect 功能在两者上均可运行。请测试实际选定的后端。除非所需功能或迁移任务确有需要,否则不要替换可正常工作的 WebGLRenderer。
在开始渲染或执行依赖设备能力的设置之前,遵循该修订版本的异步初始化约定。对于初始化失败和不支持的设备,应通过明确的回退状态进行处理。保持 imports 与 renderer 构建版本一致,以避免出现重复的 class/module 实例。
通过受支持的 node/TSL 机制实现材质。有意识地迁移自定义 GLSL、shader patch 和 composer effect;它们不会自动兼容。对于 compute,请明确定义存储布局、边界检查、dispatch 尺寸、同步机制和回读频率。当数据可以保留在 GPU 上时,避免每帧进行 CPU 回读。
根据当前 API 管理 compute buffer、render target 和后端设备丢失。初始化失败后,避免无限制地重试工作负载。
在请求的 WebGPU 设备/浏览器以及承诺支持的回退后端上进行验证。分别报告后端和功能测试结果;浏览器暴露 navigator.gpu 并不能证明此场景已成功渲染。

API reference

API 参考

Consult the official documentation for exact signatures and revision-specific behavior. If documentation access is unavailable, inspect installed types/source and state any remaining uncertainty.
查阅官方文档,以了解确切的函数签名和修订版本特有的行为。如果无法访问文档,请检查已安装的类型定义/源代码,并说明任何尚存的不确定性。