Hi all.
I’m getting errors when trying to instance a loaded GLB, “Instances should only be created for meshes with geometry.”
Reading up on past threads and see that we should use instantiateHierarchy on the loaded meshes array. Tried that, but the instance a) doesn’t seem to appear on screen and b) when moved to a different position using the inspector, throws the “with geometry” error.
In my PG above, I’d simplified out the AssetsManager component to focus on the problem, but was then worried after seeing your example that it’d be incompatible with AssetsManager. Looks like there’s already a fix there though. Trying it shortly.
So basically, that’s what I used to do, but I stopped because some models would just not render, bounding boxes display stopped working and a whole lot of other related things. For example, when you change the inserted but hidden models’ parent - instantiateModelsToScene stops working completely.
So - I suppose all of these are bugs?
Begrudgingly, what I do currently is hide the warnings and not call addAllToScene.
On that note - would it maybe be possible not to print this warning millions of times in the render loop?
I’m sure being told once per mesh would be fine… If it’s a warning, it doesn’t really warrant killing the developer console withing a minute of starting it, no?
Thanks!
edit: maybe it wasn’t clear, but not calling addAllToScene makes all these strange issues go away for me. except those warnings.
How do I properly move the instance parent? See here, if I move it after being instaniated once, instantiateToScene still breaks after: https://playground.babylonjs.com/#WGZLGJ#7488
I have thousands of models in a scene, them being loaded does not imply they will be instantiated immediately (or ever), also I’d like to use the inspector (which implies they can’t just all sit in the root, that makes the inspector rather unusable).
I have a feeling that could be related to sometimes entire meshes not being drawn when addAllToScene is called (but sorry: no repro, will try again some day.
Back to that warning…
If it’s truly just a warning and not an error, it shouldn’t break the dev console. Could it maybe not be in the render loop?
Are they still container objects after calling addAllToScene?
Look, I’m not trying to be negative here, I just don’t see how this is supposed to work. Using addAllToScene has issues and that warning you get otherwise is absolutely not useful or helpful.
won’t work, because the instantiateModelsToScene method only deals with root objects, i.e. objects with parent === null.
If what you want is parenting to avoid having lots of objects at the root level in the inspector, set a parent as you do, before calling duplicate do task.loadedContainer.rootNodes[0].parent = null; and after it returns set task.loadedContainer.rootNodes[0].parent = group; again.
Note that “house task” is the initial object that you set to invisible after loading, so it’s expected the bounding box does not show up for these invisible objects.
It sure does work now. It absolutely wasn’t when I made the pg the other day. I distinctly remember trying to enable the bounding boxes on several of the instances. scratches head
I’ll have a look if I can figure out what’s going on there.
I suppose that’s a workaround that might do.
Maybe it’s something to consider “featurizing” - I can’t be the only one who wants to do this.
Actually, there’s a bug in instantiateModelsToScene, that’s why you get these warnings => you can see that the original tree is not instantiated correctly, some foliages are missing in the instances.
@RaananW It seems this PR does not handle the case where the instanced mesh is not at the root level but is a child of another mesh. Try this PG for eg: