How to get URL for AssetListLoader?

I’m trying to port some of the code from this example over to an actual project: https://playcanvas.github.io/#/animation/locomotion

Specifically, I’m trying to use the AssetListLoader code to load a GLB model and some animations. In the example the urls for the various assets are static urls. I’m unsure how to correctly get the urls for my assets.

So in the example there is:

model: new pc.Asset("model", "container", {
	url: "/static/assets/models/bitmoji.glb",
}),
idleAnim: new pc.Asset("idleAnim", "container", {
	url: "/static/assets/animations/bitmoji/idle.glb",
}),

But I’m trying this:

model: new pc.Asset("model", "container", {
	url: this.app.assets.find('RPM_Avatar_Steve_01.glb').getFileUrl(),
}),
idleAnim: new pc.Asset("idleAnim", "container", {
	url: this.app.assets.find('talkingAnim.glb').getFileUrl(),
}),

But then I get this error:
Uncaught TypeError: Cannot read properties of undefined (reading ‘instantiateRenderEntity’)

So clearly this is not working as intended. What is the correct method here?

If they are already assets, then it be:

const assets = [
  this.app.assets.find('RPM_Avatar_Steve_01.glb'),
  this.app.assets.find('talkingAnim.glb')
];

const assetListLoader = new AssetListLoader(assets, app.assets);

Assuming those are the names of the assets.

See: AssetListLoader | PlayCanvas API Reference

1 Like

Ah OK. I’ve modified the code, but I’ve left it as an object since I need to refer to assets.model and assets.idleAnim further into the code, as per the example.
Not getting any errors, but nothing seems to actually get loaded.

Would you mind taking a look at the scene? PlayCanvas | HTML5 Game Engine

Thanks!

This is more tricky as you have GLBs as binary assets in the project and therefore need to processed differently as we don’t yet support importing GLB files in the Editor.

I’ve fixed all the loading issues in the project which include:

  • Creating a new asset of container type for the GLB binary
  • Fixing the state graph JSON
  • Fixing the animation resource assignment to the anim component

https://playcanvas.com/project/966576/overview/f-charactertests

The avatar doesn’t animate but that’s because the animation rig and avatar don’t much:

There was also a bug with the AssetListLoader where if all the assets are already loaded, it doesn’t call the done callback which I worked around in the project: https://github.com/playcanvas/engine/issues/4512

Incredible, thank you so much.

It’s strange because Mixamo and ReadyPlayerMe advertise their animations as being compatible with each other, but I guess there’s a retargeting step that needs to be done first.

Thanks again, this is VERY helpful.