[SOLVED] Load collision for Glb Mesh

Hi everyone,

I am having some problems at loading a glb mesh with collision to use with the raycaster.
I am not using the editor but playcanvas engine.

This is the snippet of code where I am trying to load the mesh:

let meshAsset = new pc.Asset('mesh', 'container', { url: '/mesh.glb' });
await new Promise<void>((resolve) => {
	new pc.AssetListLoader([meshAsset], this.app.assets).load(() => resolve());
});
const entity = meshAsset.resource.instantiateRenderEntity();
this.app.root.addChild(entity);
entity.addComponent('rigidbody', {
	type: 'static'
});
entity.addComponent('collision', {
	type: 'mesh'
});

The mesh is loaded correctly, I see it in the right position, but the raycasting is not working.
If I try to use a different collision type, like a box, it works.

Any idea on what I am doing wrong?
Thanks

Nevermind, I have solved.
Here the updated code:

let meshAsset = new pc.Asset('mesh', 'container', { url: '/mesh_van.glb' });
await new Promise<void>((resolve) => {
	new pc.AssetListLoader([meshAsset], this.app.assets).load(() => resolve());
});
console.log('Loading mesh asset:', meshAsset);
const entity = meshAsset.resource.instantiateRenderEntity();
this.app.root.addChild(entity);
entity.addComponent('rigidbody', {
	type: 'static'
});
entity.addComponent('collision', {
	type: 'mesh'
});
let renderAsset = meshAsset.resource.renders[0];
entity.collision.renderAsset = renderAsset;

What was the error … oh, and, can I see the whole example as I’m trying to learn this stuff too …