InstancedMesh - can it be used to draw hundreds of planes with different textures?

Yes, but it’s hard to map it onto your use case because of the massive amount of different textures. Can you really use 250 texture objects in your app without crashing? TBH, that sounds a bit extreme. I would suggest to merge all textures into a single texture atlas, use it as the diffuse map for a single material. You can then use an additional instanced attribute to define texture offsets per instance. Then, and only then, instanced rendering makes sense.

When using InstancedMesh, it’s easy to change position and rotation per instance. Since the color attribute is not defined by default, you have to define it yourself and enhance the respective shader code. Fortunately, there is an example that demonstrates this workflow:

https://threejs.org/examples/webgl_instancing_modified

It’s no problem to add and remove instance however you can’t exceed the instance count define when creating your InstancedMesh. So you need to know the maximum number of instances right from the beginning.

5 Likes