()
| 187 | |
| 188 | // Read back the RGBA8 values from the readback buffer. |
| 189 | async read(): Promise<Uint8Array> { |
| 190 | if (!this.readback) { |
| 191 | throw new Error("No readback"); |
| 192 | } |
| 193 | if (!this.array || this.array.length < this.count * 4) { |
| 194 | this.array = new Uint8Array(this.capacity * 4); |
| 195 | } |
| 196 | const result = await this.readback.readback({ readback: this.array }); |
| 197 | return result.subarray(0, this.count * 4); |
| 198 | } |
| 199 | |
| 200 | async getArray(): Promise<Uint8Array> { |
| 201 | if (this.readback) { |