duhaime
duhaime

Reputation: 27594

Three.js: What is the meshPerAttribute argument in an InstancedBufferAttribute

I'm confused about the argument meshPerAttribute in a Three.js InstancedBufferAttribute [docs]. What does the meshPerAttribute argument set? I've only seen the value 1 provided as an argument to this--why is that, and what does this argument do?

If someone can help me understand this, I'd be happy to translate your comment into a pull request to update the docs, which don't gloss this argument as far as I can see.

Upvotes: 0

Views: 363

Answers (1)

Mugen87
Mugen87

Reputation: 31026

It just means how often a value in the attribute array is used for drawing instances. A value of one means, a single attribute value is used for one instanced mesh. A value of two means, a single attribute value is used for two instanced meshes.

meshPerAttribute is directly mapped to the divisor parameter of vertexAttribDivisorANGLE(). More information here:

https://blog.tojicode.com/2013/07/webgl-instancing-with.html

Upvotes: 3

Related Questions