I have a .glb car asset from Kenney’s car Kit.
When I try to load it in PlayCanvas (engine only), it doesn’t show up. I tried to upload it to the PlayCanvas viewer and this is what I get.(with bounds enabled)
I tried a lot of models from the car Kit and all of them behaved the same.
However if I upload it to the editor and export it as json and then import it using the engine only, it works!
Thanks! I can now access the model in the viewer, but I’m still having trouble loading it in the engine.
Here’s how I’m loading it:
var test = new pc.Entity();
app.assets.loadFromUrl('race.glb', 'container', function(err, asset) {
test.addComponent('model', {
type: 'asset',
asset: asset.resource.model,
});
app.root.addChild(test);
});
I set up a reproducible page at GitHub using the latest stable release:
https://waelshaikh.github.io/glb-test/
Source:
see the example here on how to load it and add it to the scene
http://playcanvas.github.io/#/loaders/glb
1 Like
If I use instantiateRenderEntity to load this model, it works. But the code I used above works for almost all other models except the ones from Kenney’s Car Kit. Is instantiateRenderEntity a new/improved way to load models? Should I stop using the method I posted above?
yes, instantiateRenderEntity is the new recommended way to do this.
1 Like
Interesting that instantiateRenderEntity
works and instantiateModelEntity
doesn’t 
Looking at the model asset that is created, instantiateModelEntity
doesn’t create meshInstances
Example project https://playcanvas.com/editor/scene/1215465
Looks like ContainerResource.createModel is not creating mesh instances because all the graph nodes from the GLB have their root on the tmpParent
whereas the model.graph is the ambulance
node.
Perhaps it is due to the way that the GLB is exported?
Just to come back to this, using the glTF validator, Kenney’s assets have errors in the export: glTF Validator