SkeletonViewer v4.2 - What changed?

It used to be simple to preview bones with SkeletonViewer in v4.1.0. I could supply a simple box mesh without any weights set to the SkeletonViewer constructor. But my old code does not work anymore.

I figured v4.2.0 requires bone weights for each vertex so I tried that but struggle get the viewer to work. No bones are shown.

What has changed? Why do we even need a mesh to preview bones? Graphics card issue?

Here’s a playground.

Bones are shown if you run it in 4.1.0.
Something is wrong with the skinning though, as the box disappears.

Seems to be a bug. This will be corrected on Monday when @Deltakosh returns from the weekend.

I think I figured it out.

For a bone to be visible, it needs to be attached to at least one vertex. Changing the weights to:
0.98, 0.01, 0.01, 0 makes the two first bones show.

That’s stupid in my opinion, and I hope it’s a bug!

Still, I don’t get why the mesh disappears though!

Pinging @Pryme8 who is currently working in it:)

Seems like it was intentional: Make sure we display only bones used by the mesh

That means you need to mess around with vertex data of a dummy mesh just to debug your skeleton. Please change this behaviour!

I dont know when “Fix skeleton viewer by Popov72 · Pull Request #8698 · BabylonJS/Babylon.js · GitHub” got added,

but this change did break backward compatibility, Ill try to fix that today so at least your line render will work without an attached mesh for now.

Ill have to take a look at the spear and spurs mode and can prolly make that work as well without it, but the skeleton will always appear at origin if its not attached to a mesh.

Give me a second, I am doing pushes to the Viewer today and I think I see whats going wrong.

Sorry for the crossed wires, well get you back on track! @reimund

Well, it makes sense to me to only display bones used by the mesh as a skeleton viewer is created by providing a support mesh (that was already the case in 4.1).

Say for eg. you have N different meshes and each one uses a different part of a single skeleton: you don’t want to draw the full skeleton N times, you want to draw only the bones pertaining to each of the mesh. After you have drawn all N meshes, the full skeleton (meaning all the bones of the skeleton) will have been draw a single time instead of N.

Now I understand your need, maybe we can add an option to always display the full skeleton no matter what and make it true by default, to avoid a breaking change: @Deltakosh what do you think?

1 Like

That would be the quick and easy way!

You must provide a mesh to the SkeletonViewer constructor (even before the reworking), so you will always have a position to use.

1 Like

Let’s do it, I don’t think @Deltakosh will be against that change.

Second that motion are you on it then or am I?

No I let you do it as you are currently working on the matter.

Perfect, Ill wiggle it in with my other SkeletonViewer PR and try to get that wrapped up today so it can get merged hopefully.

I agree with you guys. Let’s not break the compatibility so let turn it on by default

Thanks team!

Wow that was quick! Awesome thanks!

I can report the same issue for 4.2. In my case, I have multiple meshes with also top, pants, hair, & shoes, and have my reasons for not merging. I am only working on the hands right now, but when I want add dancing while playing (also the reason I am switching to IK posing, & absolutely required for drumming) I will have to merge in dev.

In a situation like this you will have to do multiple viewers I originally had it so a mesh was not required, but that makes it so the skeleton technically has no transform Matrix then.

I think for comparability reasons you will nee to make multiple viewers in a situation like this.

I would just merge in Blender, export, and not save the .blend file. Later re-export the way I really want. This worked fine in 4.1, but am adding 4.2 stuff in other places, so will break at some point going that way.

@reimund Just waiting for my command line to build and ill push my PR

but looks like I got it for you.