Browse Source

Editor: Fixed History.fromJSON().

Mugen87 5 năm trước cách đây
mục cha
commit
9cc2bafa7e
2 tập tin đã thay đổi với 25 bổ sung2 xóa
  1. 4 2
      editor/js/History.js
  2. 21 0
      editor/js/commands/Commands.js

+ 4 - 2
editor/js/History.js

@@ -3,6 +3,8 @@
  * Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
  */
 
+import * as Commands from './commands/Commands.js';
+
 var History = function ( editor ) {
 
 	this.editor = editor;
@@ -202,7 +204,7 @@ History.prototype = {
 		for ( var i = 0; i < json.undos.length; i ++ ) {
 
 			var cmdJSON = json.undos[ i ];
-			var cmd = new window[ cmdJSON.type ]();	// creates a new object of type "json.type"
+			var cmd = new Commands[ cmdJSON.type ](); // creates a new object of type "json.type"
 			cmd.json = cmdJSON;
 			cmd.id = cmdJSON.id;
 			cmd.name = cmdJSON.name;
@@ -214,7 +216,7 @@ History.prototype = {
 		for ( var i = 0; i < json.redos.length; i ++ ) {
 
 			var cmdJSON = json.redos[ i ];
-			var cmd = new window[ cmdJSON.type ]();	// creates a new object of type "json.type"
+			var cmd = new Commands[ cmdJSON.type ](); // creates a new object of type "json.type"
 			cmd.json = cmdJSON;
 			cmd.id = cmdJSON.id;
 			cmd.name = cmdJSON.name;

+ 21 - 0
editor/js/commands/Commands.js

@@ -0,0 +1,21 @@
+export { AddObjectCommand } from './AddObjectCommand.js';
+export { AddScriptCommand } from './AddScriptCommand.js';
+export { MoveObjectCommand } from './MoveObjectCommand.js';
+export { MultiCmdsCommand } from './MultiCmdsCommand.js';
+export { RemoveObjectCommand } from './RemoveObjectCommand.js';
+export { RemoveScriptCommand } from './RemoveScriptCommand.js';
+export { SetColorCommand } from './SetColorCommand.js';
+export { SetGeometryCommand } from './SetGeometryCommand.js';
+export { SetGeometryValueCommand } from './SetGeometryValueCommand.js';
+export { SetMaterialColorCommand } from './SetMaterialColorCommand.js';
+export { SetMaterialCommand } from './SetMaterialCommand.js';
+export { SetMaterialMapCommand } from './SetMaterialMapCommand.js';
+export { SetMaterialValueCommand } from './SetMaterialValueCommand.js';
+export { SetMaterialVectorCommand } from './SetMaterialVectorCommand.js';
+export { SetPositionCommand } from './SetPositionCommand.js';
+export { SetRotationCommand } from './SetRotationCommand.js';
+export { SetScaleCommand } from './SetScaleCommand.js';
+export { SetSceneCommand } from './SetSceneCommand.js';
+export { SetScriptValueCommand } from './SetScriptValueCommand.js';
+export { SetUuidCommand } from './SetUuidCommand.js';
+export { SetValueCommand } from './SetValueCommand.js';