WebXR, KeepAssets and AssetContainers


hopefully a quick question. I am looking at refactoring my project to use AssetContainers rather than multiple scenes, to allow easier transition when in WebXR (ie allow triggering from non-user interaction)

From what I can see there is no way to create an asset directly into a container but you must first add it to the scene then move it to the container
…which removes it from the scene… so you then add it back in…
That’s all fine.

But it looks like to me that if I create a default webXR experience this will add a few things to the scene, which is dependent on the users hardware. But I need to add everything that the webXR experience has added to the keepAssets so it doesn’t end up in the AssetContainer. Essentially I want a loading scene that just has all the webXR stuff and then I will add and remove containers to it.
But there doesn’t seem to be an equivalent way to add all the assets currently in the scene to keepAssets. Is there an easy way to do this that I am missing or do you have to iterate over assets and manually add them to the appropriate part of keepAssets?

Hey @MarkM ,

I assume you are referring to the assets created when the WebXR features are initialized. These are the only assets that you might need to recreate. Not that simple, as those assets are created and usually referenced in the features themselves.
I would recommend not to initialize the features before you actually need them. This way they are created only when needed and can be disposed when no longer needed. For example, don’t auto-init the teleportation feature (which creates the teleportation ring when initialized). Add the feature only when needed and when you are sure you are in the right scene.

Hey @RaananW ,
yes things added by the features but also the controllers, impostors and camera.
These are all added as root nodes, it might make it easier if they were added as a child of a root node positioned at the origin (say called webXR_root). Is that possible?
I am not sure if KeepAssets applies to the hierarchy (inc children) but it would make the scene tree cleaner anyway, not sure if there was a reason it was done that way or not, eg impostors.

Just wondering if you have a comment on this @RaananW ?
I have been pulled off onto another (non-BJS) project so haven’t looked at this for a while…just using a quiet time to come back in to visit the community and get a fix :slight_smile:

Hi @MarkM,

Sure, I’m not going to say it doesn’t make sense :slight_smile:
Having a single Node that is the root of all WebXR-related nodes makes sense, but might have different issues related to it. If you want to create an issue on github (as a feature request) it will be great. I’ll make sure it doesn’t cause any unwanted side effects. Hope this helps!

1 Like

Thanks as always @RaananW
I will add the feature request on github.