Browse Source

recovers camera with UUID (#28337)

ycw 1 year ago
parent
commit
db047d12ee
1 changed files with 9 additions and 0 deletions
  1. 9 0
      editor/js/Editor.js

+ 9 - 0
editor/js/Editor.js

@@ -659,7 +659,16 @@ Editor.prototype = {
 		var loader = new THREE.ObjectLoader();
 		var loader = new THREE.ObjectLoader();
 		var camera = await loader.parseAsync( json.camera );
 		var camera = await loader.parseAsync( json.camera );
 
 
+		const existingUuid = this.camera.uuid;
+		const incomingUuid = camera.uuid;
+
+		// copy all properties, including uuid
 		this.camera.copy( camera );
 		this.camera.copy( camera );
+		this.camera.uuid = incomingUuid;
+
+		delete this.cameras[ existingUuid ]; // remove old entry [existingUuid, this.camera]
+		this.cameras[ incomingUuid ] = this.camera; // add new entry [incomingUuid, this.camera]
+
 		this.signals.cameraResetted.dispatch();
 		this.signals.cameraResetted.dispatch();
 
 
 		this.history.fromJSON( json.history );
 		this.history.fromJSON( json.history );