This feature requires the p5.webgpu.js addon.
이 API는 실험적입니다
향후 p5.js 버전에서 동작이 변경될 수 있습니다.
Reads data from a storage buffer back into JavaScript.
Copies data from the GPU to the CPU using a temporary buffer, so it must be awaited. Returns a typed array (such as Float32Array or Uint32Array) for number buffers, or an array of plain objects for struct buffers.
Note: This is a GPU -> CPU read, so calling it often (like every frame) can be slow.
While p5.strands is still growing, there may be WGSL features it doesn't cover yet. You can still reach for them by writing WGSL directly, and the buffer will read back as the right kind of typed array. Atomics are one example: WGSL only allows them on u32 and i32, so a buffer used as array should be created with a Uint32Array.
예제
구문
read()
매개변수
반환값
Promise<Float32Array|Uint32Array|Int32Array|Object[]>:
Notice any errors or typos? Please let us know. Please feel free to edit src/webgpu/p5.RendererWebGPU.js and open a pull request!