Workaround for loading animations using the the example project: Loading glTF GLBs

Bit of a gotcha in the [Loading glTF GLBs] example:(Loading glTF GLBs | Learn PlayCanvas)

In the glb-utils#loadGlbContainerFromUrl script, ‘.’ (periods) in filenames screw up assignAnimation() calls you might want to add the load-glb-url script.
This is as documented in the nodePath attribute of assignAnimation

Here’s a workaround for glb-utils#loadGlbContainerFromUrl :

if (animations.length == 1) {
                    animations[0].name = assetName.split('.').join('-');
                } else if (animations.length > 1) {
                    for (var i = 0; i < animations.length; ++i) {
                        animations[i].name = assetName.split('.').join('-') + ' ' + i.toString();
                    }
                }

bascially lines 2 & 5 just replace any dots with dashes which allows animations to be easily added.

2 Likes