Skip to content

Commit

Permalink
Merge pull request #73 from codename-gadget/feature/webgl/variable-in…
Browse files Browse the repository at this point in the history
…stance-count

Make instance count variable
  • Loading branch information
johh authored Aug 18, 2023
2 parents ffc8ed0 + c869fb8 commit 19760e4
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/webgl/src/lib/geometry/Geometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,12 @@ export default class Geometry<T extends GeometryProps = GeometryProps> extends C
private attributeInfo: InternalAttributeInfo[];
private indicesInfo: { buffer: Buffer, type: IndicesDeclaration['type'] };
private primitiveCount: number;
private instanceCount: number;
private isInstanced = false;
private mode: GeometryDrawMode;

/** How many geometry instances will be drawn. */
public instanceCount: number;

/** The underlying attribute buffers. */
public readonly attributes: {
[key in keyof T['attributes']]:
Expand Down Expand Up @@ -330,6 +332,20 @@ export default class Geometry<T extends GeometryProps = GeometryProps> extends C
}


/**
* Sets the amount of geometry instances to draw.
*
* Keep in mind that this shouldn't exceed the number of instances
* specified in any instanced attribute.
*
* @param count - The amount of geometry instances to draw.
*/
public setInstanceCount( count: number ): void {
this.instanceCount = count;
this.isInstanced = true;
}


/**
* Calls `upload()` on all attribute buffers and the index buffer.
*/
Expand Down

0 comments on commit 19760e4

Please sign in to comment.