Cannot Update Vertices transformed in bone with getPositionData(true,true)

I want to get the exact coordinates of the vertices of a mesh deformed by a skeleton (bones).
Of course i know it is the data in the gpu. But the bjs documentation says that the getPositionData that the Mesh class has will give me what I want.
However, it does not work well and returns the same FloatArray before and after deforming the skeleton, as in the PG below. What am I doing wrong?

To add to how I came to this approach, the Bjs documentation talks about updating CPU information in the Bones and Skeleton chapter.
Looking at the source of the refreshBoundingInfo written here, it looks like it uses _getPositionData to get the correct vertex information. It seems to me that _getPositionData is using getPositionData.

Thank you!

Heya, if you call prepare() on the skeleton it will recompute the bone’s world matrices so that getPositionData() can work with the updated matrices. Otherwise if you just change the bones without calling prepare() then their matrices will be outdated until the next frame is rendered. I also removed the 3rd param and just let it default to the position data. :slight_smile:

EDIT: One more thing I noticed, the call to updateVerticesData isn’t working because the old vertex buffer isn’t updatable, but you can call setVerticesData and it will work regardless by creating a new buffer. Then the head is scaled twice, as expected (once from setting the vertices and once from the bone).

1 Like

THANK YOUUU!!!
I need to read the documentation more carefully and then be a little more aware of WebGL behind the framework :stuck_out_tongue_closed_eyes:

1 Like