# Skinweight, skinindices, vertex, oh my?

I’m trying to understand the data… Please correct me if I’m wrong. The skinIndex is the bone that influences a vertex. A skinWeight is the amount of influence the the bone has over the vertex. Where is it defined what vertex the bone is bound to? In the bufferGeometry is there a 1:1 relationship between the skinIndex and the skingWeight? In my example does 0: 43 map to 0: 0.5196999907493591?

Look at the `.itemSize` property of the `skinIndex` or `skinWeights` attribute. It’s probably four (4). This means that each 4 sequential entries in the underlying array provide bone indices and bone weights for a single vertex. The BufferAttribute helper methods make it easier to manage those in the correct groupings. To get the skin indices and weights for the Nth vertex in your geometry, you would call:

``````const vertexIndex = 40; // 40th vertex in `geometry.attributes.position`
const skinIndex = new Vector4()
.fromBufferAttribute( mesh.geometry.attributes.skinIndex, n );
const skinWeights = new Vector4()
.fromBufferAttribute( mesh.geometry.attributes.skinWeights, n );
``````

With that code, `skinIndex.toArray()` will give the indices of up to four bones that influence the Nth vertex. And `skinWeights.toArray()` will give the weights for each of those bones. Some weights may be zero, if the vertex is affected by fewer than four bones.

This also means that bones are not bound to any particular vertex — it’s the opposite. A single bone could influence any number of vertices, but vertices are only affected by 1-4 bones.

1 Like

When I started three.js over three years ago, I experimented with some things to understand them. Also with the bones etc.
The examples are partly with german names, because I publish in a german forum. But easy to translate. I always take https://www.deepl.comtranslator the same for that answer.

Maybe it’ll help with understanding. I like to experiment with these things.

See https://hofk.de/main/threejs/ further down the page.

The bone bumblebee there too. https://codepen.io/hofk/pen/eWdZMb

3 Likes

Thanks again Don, that will take some time to digest down to a solution for me but it surely does help. I love the math…

Hofk… I actually have visited your page and it is full of interesting experiments. Thanks for sharing it!