Skip to content

Commit

Permalink
refactor(vector-pools): add result generics for AttribPool.attribValu…
Browse files Browse the repository at this point in the history
…es() iterator
  • Loading branch information
postspectacular committed Jun 7, 2024
1 parent 4053e69 commit a63548c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/vector-pools/src/attrib-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,21 @@ export class AttribPool implements IRelease {
: this.attribs[id][i];
}

*attribValues(id: string) {
*attribValues<T extends number | TypedArray>(
id: string
): IterableIterator<T> {
const spec = this.specs[id];
ensureSpec(spec, id);
const buf = this.attribs[id];
const stride = spec.stride!;
const size = spec.size;
if (size > 1) {
for (let i = 0, j = 0, n = this.capacity; i < n; i++, j += stride) {
yield buf.subarray(j, j + size);
yield <T>buf.subarray(j, j + size);
}
} else {
for (let i = 0, n = this.capacity; i < n; i++) {
yield buf[i * stride];
yield <any>buf[i * stride];
}
}
}
Expand Down

0 comments on commit a63548c

Please sign in to comment.