itemSize < 1: itemSize of BufferAttribute for polygon-wise attribute

Hi,

THREE.BufferAttribute takes typed array and itemSize. In my understanding, itemSize is the number of elements assigned for each vertex (e.g. itemSize = 3 for position array because a vertex requires three values x, y and z)

Now I have a rectangle which is a collection of 4 vertices. I want to add attribute, say, isClickable to each rectangle.

A naive way is to set itemSize 1 and repeat same isClickable value 4 times.

isClickableArray = [ 0, 0, 0, 0, 1, 1, 1, 1 ... ]

This is apparently inefficient because 4 vertices use same value. However, itemSize cannot be less than 1.

How can I assign same attribute to 4 vertices?

Thanks

AFAIK, something like this is not possible. If you render your rectangles as separate meshes, you might want to use instanced rendering. You would define the rectangle’s vertices just once and then use an InstancedBufferAttribute to define a single value (clickable) per instance. The following example demonstrates this approach:

https://threejs.org/examples/#webgl_buffergeometry_instancing

1 Like