Hello everyone!
I would like to do the following with the three.js editor (code here):
- Build a scene
- Export that scene/project to keep a copy saved for later use
- Import a scene/project from disk when needed (to continue my work)
As a minimal example (you can test it using the online editor):
- 
For nr. 1: Start from a blank scene and add an Ambient Light and move the camera’s position and change it’s orientation. 
- 
Then for nr. 2: Go to the Menu Bar, select “File”, then “Export Scene”. (As an additional step move the camera again, to verify if importing the previous scene loads the previous camera position and orientation.) 
- 
Finally for nr. 3: Go to the Menu Bar, select “File”, then “Import” and pick the previously saved scene. 
Unfortunately the scene/project is not the same scene/project that was exported. There are two issues I see:
- 
The scene that is currently open does not disappear/ is not cleared. Therefore importing a scene from a JSON file adds the objects (in this case a new ambient light, as defined in the saved file from the above example) to the current scene. You can see you will have 2 ambient lights in the scene. 
- 
The camera information is not saved to the JSON file. The camera position and orientation is not reestablished to how it was when the scene was saved. 
At the moment I am more concerned about nr.2, because I can avoid problem nr. 1 by using the FileLoader class to load the exported JSON file when launching the Editor.
Does anyone know how to export the camera’s matrix to a JSON file using the Three JS editor?
I am aware the PerspectiveCamera class has a .toJSON method, I just don’t know how to call it from the running three.js Editor.
This is how the scene.json file that I currently get looks like when I export the above mentioned scene:
{
	"metadata": {
		"version": 4.6,
		"type": "Object",
		"generator": "Object3D.toJSON"
	},
	"object": {
		"uuid": "3741222A-BD8F-401C-A5D2-5A907E891896",
		"type": "Scene",
		"name": "Scene",
		"layers": 1,
		"matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
		"up": [0,1,0],
		"children": [
			{
				"uuid": "770803a8-96cf-4c7b-b3cb-682a80d77591",
				"type": "AmbientLight",
				"name": "AmbientLight",
				"layers": 1,
				"matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,1,0,1],
				"up": [0,1,0],
				"color": 2236962,
				"intensity": 1
			}]
	}
}
And this is what expect to get (this includes the camera and ambient light and opens fine using the FileLoader class):
{
	"metadata": {
		"type": "App"
	},
	"project": {
		"shadows": true,
		"vr": false
	},
	"camera": {
		"metadata": {
			"version": 4.5,
			"type": "Object",
			"generator": "Object3D.toJSON"
		},
		"object": {
			"uuid": "60EBAF60-53DA-47B0-A028-8FC031B708F6",
			"type": "PerspectiveCamera",
			"name": "Camera",
			"layers": 1,
			"matrix": [0.970041,0,-0.242943,0,-0.048226,0.980099,-0.785398,0,0.238108,0.198509,0.950736,0,10,0,10,1],
			"fov": 50,
			"zoom": 1,
			"near": 0.1,
			"far": 100000,
			"focus": 10,
			"aspect": 1.428977,
			"filmGauge": 35,
			"filmOffset": 0
		}
	},
	"scene": {
		"metadata": {
			"version": 4.5,
			"type": "Object",
			"generator": "Object3D.toJSON"
		},
			"object": {
                "uuid": "3741222A-BD8F-401C-A5D2-5A907E891896",
                "type": "Scene",
                "name": "Scene",
                "layers": 1,
                "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
                "up": [0,1,0],
                "children": [
                    {
                        "uuid": "e36c689a-ba6e-4dae-a126-b864132885c0",
                        "type": "AmbientLight",
                        "name": "AmbientLight",
                        "layers": 1,
                        "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,2,0,1],
                        "up": [0,1,0],
                        "color": 16777215,
                        "intensity": 2
                    }]
            }
	}
}
So, how do I go about saving the camera position (in particular the camera matrix) when using the Three.js Editor? Is there a direct or indirect way of obtaining the Three.js Editor’s camera matrix for later use?
I appreciate your help with this.