Jump to content

Maintain cameras and lights while doing addAllToScene and removeAllFromScene


oschakravarthi
 Share

Recommended Posts

Hi guys, sorry to interrupt, but I MIGHT know a "dirty" way.

http://playground.babylonjs.com/#YATDM6

Just include those top two functions... into your project... at the top (like that playground does).  Scary kind of hacking.  :o

I didn't test it... but in theory, it MIGHT work... at least for a temporary solve.

Keep in mind that this PERMANENTLY modifies the container's add-all and remove-all.  You will need to MANUALLY default the code back to normal, if you need default ops, later.

Sorry for the interrupt... back to wisdom and sanity, now.  :)

Link to comment
Share on other sites

8 hours ago, trevordev said:

@oschakravarthi see https://doc.babylonjs.com/how_to/how_to_use_assetcontainer , KeepAssets can be used to maintain objects when removing objects from the scene. When adding objects to the scene, you can inspect the scene.activeCamera and scene.lights and remove the ones that are not in your keep assets object.

1

 

Hi @trevordev

 

Thanks a lot for your continuous support.

So, we need to load all the assets before calling scene.createDefaultVRExperience(). 

If we load assets after instantiating scene.createDefaultVRExperience(), it causes a big problem. The VRExperienceHelper creates some cameras and adds them the scene. If we use moveAllFromScene, it will move all the cameras including those who are created by the VRExperienceHelper. It is the problem I am facing.

 

So, you may ask for such a scenario where we load assets after entering VR mode.

Scenario 1: Assume that we are in a VR game. We have our assets like Level1.babylon, Level2.babylon etc... in the server.  While the user is playing and progressing, new levels will be loaded. 

Scenario 2: There is a Real estate application in which the user can explore various flats and projects in VR mode. 

 

There can be many scenarios like this.

 

So, what I did? I have taken the source code of AssetContainer and commented the lines which add or remove cameras. It worked.

 

As these scenarios are very valid, I request some more options in AssetContainer.

Link to comment
Share on other sites

On 10/6/2018 at 7:08 AM, oschakravarthi said:

 

Hi @trevordev

 

Thanks a lot for your continuous support.

So, we need to load all the assets before calling scene.createDefaultVRExperience(). 

If we load assets after instantiating scene.createDefaultVRExperience(), it causes a big problem. The VRExperienceHelper creates some cameras and adds them the scene. If we use moveAllFromScene, it will move all the cameras including those who are created by the VRExperienceHelper. It is the problem I am facing.

 

So, you may ask for such a scenario where we load assets after entering VR mode.

Scenario 1: Assume that we are in a VR game. We have our assets like Level1.babylon, Level2.babylon etc... in the server.  While the user is playing and progressing, new levels will be loaded. 

Scenario 2: There is a Real estate application in which the user can explore various flats and projects in VR mode. 

 

There can be many scenarios like this.

 

So, what I did? I have taken the source code of AssetContainer and commented the lines which add or remove cameras. It worked.

 

As these scenarios are very valid, I request some more options in AssetContainer.

@ssaket, please look at this as well

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...