瀏覽代碼

recovers camera with UUID (#28337)

ycw 1 年之前
父節點
當前提交
db047d12ee
共有 1 個文件被更改,包括 9 次插入0 次删除
  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 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.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.history.fromJSON( json.history );