Save current state of a scene - in order to rebuild it later?

Hi there.
I’m wondering if there’s a method to save out and then re-build a scene (cameras, lights, etc). Lets say you were to load up a scene with a couple of cameras, a few lights, and a few meshes. And then you moved everything around a bit - and want to save the new state.

How would you export out all of the properties of the elements - and then load them back up again?

I’m currently saving out key properties and then re-creating the elements one by one - very manually. For lights, for example, I save out position, rotation, intensity, exponent, color, etc. And then re-build the light using that data.

But it occurred to me that there’s got to be an easier way? Are there functions to support this kind of behavior? Can i simply save scene.cameras, for example, and then somehow re-create the cameras with that json object?


1 Like

Hi @bigrig .Of course we have function for this :yum:


Oh wow. That makes everything 100x simpler. Amazing. Thx.

1 Like

One more question if you will.
If you wanted to save metadata with the scene - anyway to do that? Or would you save the metadata in a separate file - to be loaded along with the scene?

For example: if you wanted to say that a GLB that gets loaded, while it has a file name of “blah.glb” should be labeled “My Interesting World” in the UI.

And for clarification, reading the specs (and looking at the JSON), it looks like the meshes get serialized into the JSON scene object - rather than reloaded from source URL. Is that right? So, if the source mesh was updated between save and load, those changes wouldn’t be reflected. Yes?


Btw, I think i found a bug.
When serialized and reloaded, the scene doesn’t render any lines that were drawn in previously. PG here:

Before save/load:

After save/load:

Oh got it!
scene.metadata = {‘hello’:‘world’};


Oh and you can attach metadata to lights and cameras and such. Even better.

1 Like