☑ model.meshInstances throwing core error?

Trying to access any meshInstances in my scene is throwing the following error in the console:

[Exception: TypeError: Cannot read property 'meshInstances' of null at Object.get (https://code.playcanvas.com/playcanvas-stable.js:19628:22) at Object.remoteFunction (<anonymous>:3:14)]

Might anybody have any insight as to what could possibly cause that failure?

Can you share a minimal scene that illustrates the problem? That’s the beauty of PlayCanvas - you can just share a link to a problem! :wink:


The issue here is that model component model property can be null, as it might not have model set, or not being loaded or initialized. In that case model will be null. So it wont have any meshInstances. But engine does not check for such case in meshInstances property on model component, so it has a bug.
It has been fixed here: https://github.com/playcanvas/engine/commit/3a515f40085fd1a0ecb96f47eefa38894c012394
And will be deployed soon.

For now you can check if entity.model.model is defined.
And do please share you project or small example with replication in the future if you mention a problem, as it will help to debug the issue.