I have loaded a glb model via
PlayerModel = asset.resource.instantiateRenderEntity();
But I’m unable to access it’s meshInstances via
PlayerModel.model.meshInstances
Or
PlayerModel.meshInstances
Both of them are undefined
I have loaded a glb model via
PlayerModel = asset.resource.instantiateRenderEntity();
But I’m unable to access it’s meshInstances via
PlayerModel.model.meshInstances
Or
PlayerModel.meshInstances
Both of them are undefined
Hi @Gamer_Wael! I guess you need to access the render component instead of the model component.
PlayerModel.render.meshInstances
Hi Albertos, thanks for your response.
PlayerModel.render
is also undefined.
I couldn’t find any documentation for instantiateRenderEntity but I saw that asset.resource is a Model so I tried accessing
asset.resource.data.nodes
Before calling instantiateRenderEntity, and it works!
So after going through the documentation for RenderComponent I tried to create it as I would normally do it, but I’m running into some issues.
Right now I’m using:
app.assets.loadFromUrl('race.glb', 'container', function(err, asset) {
PlayerModel = asset.resource.instantiateRenderEntity();
}
And it works fine.
But I’m trying to change it to:
app.assets.loadFromUrl('race.glb', 'container', function(err, asset) {
PlayerModel = new pc.Entity('PlayerModel');
PlayerModel.addComponent('render', {
//asset: asset
//asset: asset.resource.model
asset: asset.resource
});
}
I’m trying to do it this way as I am familiar with this style and it makes it easier to pass attributes.
However this method isn’t working. What am I doing wrong?
see here on how to access mesh instances