I am trying to set the weight of a morph target, but the weights array is empty due to which I cannot set the weight of the morph target.
Above as you can there are 73 morph targets and the weights array is empty so if I do this:
Lets say I want to get the 33 morph target from the 73 targets I get undefined, hence I cannot set them too.
Here’s how I load the glb, if I load it in here: https://gltf-viewer.donmccurdy.com/
I see the morph targets on the right side ( in a slider, all 72) and also can change their weights from 1 to 0 etc, meaning their is no issue with the glb
The weights array on MorphInstance is empty, I think I’ll change the engine code to initialize it to default weights at the creation for next release.
But you can still go and set the weights, even when the array is empty, that works fine in js. You could even loop over _targets, and set the weight to target.defaultWeight. That is set to either default weight from glb if specified, otherwise it will be set to 0.
Have a look at our new viewer source code, which displays sliders for morph targets at well. It’s not published anywhere yet, but if you build / host engine locally, you can try it too.
Thanks @mvaligursky your right, setting the weight worked.
Thanks @yaustar, will check that out
also, note that current morphing code handles either 8 active positional morph targets, or 4 positional and 4 normal targets. If you have more, targets with smaller weights are not used.
This PR https://github.com/playcanvas/engine/pull/2123 which will be released in about a week or so gives you support for larger number of active weights - which is something you might need if you’re using 72 targets (looks like some facial animation).