Hi, I want to set up lod levels for loaded meshes (gltf), but don’t know how to properly do it.
Please have a look on not working playgound https://www.babylonjs-playground.com/#WANXPQ#2
In my mind, promise should work - but nothing is shown. What’s worse:
babylon.js:16:37009
BJS - [18:42:36]: Instances should only be created for meshes with geometry. 59
Hi @Anderson34, meshes actually load (I disabled them to check if isntance was being created, please see playground @ lines 24,32 ). Error is shown in browser console, so most likely it’s related to reason I can’t use lods (or so I think).
Yes, I tried to base on that one. But not working in my version, of course.
– edit not that one, the one in documentation, thing is that they create from Babylon.Mesh which seems faster than loading external files, that’s why I’m using promise (most likely wrong)
Thanks a lot @bghgary , I thought getMeshByName would actually get mesh geometry, so I’ll better check out indexes.
Follow ups if you don’t mind please:
a) I tried to clone / instance the object, but clones / instances don’t show up the avocado.
In clone -> boombox remains boombox
In instance -> no avocado is shown, only boombox goes to null after set distance (or so it seems). https://www.babylonjs-playground.com/#WANXPQ#4
b) Outside of this particular promise, how can I instance or clone later on the game?
c) If I have multiple parts (lets say boombox + table) in gltf file, every part should be treated as a different object for lod, right? (table Lod 0, table Lod 1… boombox Lod 0, boombox Lod1…)
I’m not exactly sure what you are asking. Wait for the promise to finish and do the same thing as you are already doing to get the main mesh and create instances from it?
One way is to store the resulting promise in a variable (say loadPromise) and call .then on it. There are lots of different things you would do for this depending on how your code is set up.
Thank you very much. Hopefully some more information will be shared on if it’s possible to use the cloned objects as well (would like to change some materials on clones afterwards).