Browse Source

Big refactor

- Removed property ‚serialized‘ from Cmd
- Added property ‚inMemory‘ to Cmd. ‚inMemory‘ means that the command
can be executed or undone without calling .fromJSON()
- Updated constructor, execute, toJSON, fromJSON for every command,
except CmdMultiCmds and CmdSetScene
- Commands are now serialized immediately after being executed into the
property ‚cmd.json‘
Daniel 9 years ago
parent
commit
ceb151e536

+ 3 - 1
editor/js/Cmd.js

@@ -5,7 +5,7 @@
 Cmd = function ( editorRef ) {
 Cmd = function ( editorRef ) {
 
 
 	this.id = -1;
 	this.id = -1;
-	this.serialized = false;
+	this.inMemory = false;
 	this.updatable = false;
 	this.updatable = false;
 	this.type = '';
 	this.type = '';
 	this.name = '';
 	this.name = '';
@@ -32,8 +32,10 @@ Cmd.prototype.toJSON = function () {
 
 
 Cmd.prototype.fromJSON = function ( json ) {
 Cmd.prototype.fromJSON = function ( json ) {
 
 
+	this.inMemory = true;
 	this.type = json.type;
 	this.type = json.type;
 	this.id = json.id;
 	this.id = json.id;
 	this.name = json.name;
 	this.name = json.name;
+	this.json = json;
 
 
 };
 };

+ 39 - 42
editor/js/CmdAddObject.js

@@ -12,46 +12,6 @@ CmdAddObject = function ( object ) {
 	if ( object !== undefined ) {
 	if ( object !== undefined ) {
 
 
 		this.name = 'Add Object: ' + object.name;
 		this.name = 'Add Object: ' + object.name;
-		object.updateMatrixWorld( true );
-
-		meta = {
-			geometries: {},
-			materials: {},
-			textures: {},
-			images: {}
-		};
-		var json = object.toJSON( meta );
-
-		var geometries = extractFromCache( meta.geometries );
-		var materials = extractFromCache( meta.materials );
-		var textures = extractFromCache( meta.textures );
-		var images = extractFromCache( meta.images );
-
-		if ( geometries.length > 0 ) json.geometries = geometries;
-		if ( materials.length > 0 ) json.materials = materials;
-		if ( textures.length > 0 ) json.textures = textures;
-		if ( images.length > 0 ) json.images = images;
-
-		this.objectJSON = json;
-
-	}
-
-	// Note: The function 'extractFromCache' is copied from Object3D.toJSON()
-
-	// extract data from the cache hash
-	// remove metadata on each item
-	// and return as array
-	function extractFromCache ( cache ) {
-
-		var values = [];
-		for ( var key in cache ) {
-
-			var data = cache[ key ];
-			delete data.metadata;
-			values.push( data );
-
-		}
-		return values;
 
 
 	}
 	}
 
 
@@ -76,17 +36,54 @@ CmdAddObject.prototype = {
 
 
 		var output = Cmd.prototype.toJSON.call( this );
 		var output = Cmd.prototype.toJSON.call( this );
 
 
-		output.object = this.objectJSON;
+		this.object.updateMatrixWorld( true );
+
+		meta = {
+			geometries: {},
+			materials: {},
+			textures: {},
+			images: {}
+		};
+		var json = this.object.toJSON( meta );
+
+		var geometries = extractFromCache( meta.geometries );
+		var materials = extractFromCache( meta.materials );
+		var textures = extractFromCache( meta.textures );
+		var images = extractFromCache( meta.images );
 
 
+		if ( geometries.length > 0 ) json.geometries = geometries;
+		if ( materials.length > 0 ) json.materials = materials;
+		if ( textures.length > 0 ) json.textures = textures;
+		if ( images.length > 0 ) json.images = images;
+
+		output.object = json;
 		return output;
 		return output;
 
 
+		// Note: The function 'extractFromCache' is copied from Object3D.toJSON()
+
+		// extract data from the cache hash
+		// remove metadata on each item
+		// and return as array
+		function extractFromCache ( cache ) {
+
+			var values = [];
+			for ( var key in cache ) {
+
+				var data = cache[ key ];
+				delete data.metadata;
+				values.push( data );
+
+			}
+			return values;
+
+		}
+
 	},
 	},
 
 
 	fromJSON: function ( json ) {
 	fromJSON: function ( json ) {
 
 
 		Cmd.prototype.fromJSON.call( this, json );
 		Cmd.prototype.fromJSON.call( this, json );
 
 
-		this.objectJSON = json.object;
 		this.object = this.editor.objectByUuid( json.object.object.uuid );
 		this.object = this.editor.objectByUuid( json.object.object.uuid );
 
 
 		if ( this.object === undefined ) {
 		if ( this.object === undefined ) {

+ 1 - 4
editor/js/CmdAddScript.js

@@ -10,8 +10,6 @@ CmdAddScript = function ( object, script ) {
 	this.name = 'Add Script';
 	this.name = 'Add Script';
 
 
 	this.object = object;
 	this.object = object;
-	this.objectUuid = ( object !== undefined ) ? object.uuid : undefined;
-
 	this.script = script;
 	this.script = script;
 
 
 };
 };
@@ -52,7 +50,7 @@ CmdAddScript.prototype = {
 
 
 		var output = Cmd.prototype.toJSON.call( this );
 		var output = Cmd.prototype.toJSON.call( this );
 
 
-		output.objectUuid = this.objectUuid;
+		output.objectUuid = this.object.uuid;
 		output.script = this.script;
 		output.script = this.script;
 
 
 		return output;
 		return output;
@@ -63,7 +61,6 @@ CmdAddScript.prototype = {
 
 
 		Cmd.prototype.fromJSON.call( this, json );
 		Cmd.prototype.fromJSON.call( this, json );
 
 
-		this.objectUuid = json.objectUuid;
 		this.script = json.script;
 		this.script = json.script;
 		this.object = this.editor.objectByUuid( json.objectUuid );
 		this.object = this.editor.objectByUuid( json.objectUuid );
 
 

+ 11 - 12
editor/js/CmdMoveObject.js

@@ -10,14 +10,9 @@ CmdMoveObject = function ( object, newParent, newBefore ) {
 	this.name = 'Move Object';
 	this.name = 'Move Object';
 
 
 	this.object = object;
 	this.object = object;
-	this.objectUuid = ( object !== undefined ) ? object.uuid : undefined;
-
 	this.oldParent = ( object !== undefined ) ? object.parent : undefined;
 	this.oldParent = ( object !== undefined ) ? object.parent : undefined;
-	this.oldParentUuid = ( this.oldParent !== undefined ) ? this.oldParent.uuid : undefined;
 	this.oldIndex = ( this.oldParent !== undefined ) ? this.oldParent.children.indexOf( this.object ) : undefined;
 	this.oldIndex = ( this.oldParent !== undefined ) ? this.oldParent.children.indexOf( this.object ) : undefined;
-
 	this.newParent = newParent;
 	this.newParent = newParent;
-	this.newParentUuid = ( newParent !== undefined ) ? newParent.uuid : undefined;
 
 
 	if ( newBefore !== undefined ) {
 	if ( newBefore !== undefined ) {
 
 
@@ -69,9 +64,9 @@ CmdMoveObject.prototype = {
 
 
 		var output = Cmd.prototype.toJSON.call( this );
 		var output = Cmd.prototype.toJSON.call( this );
 
 
-		output.objectUuid = this.objectUuid;
-		output.newParentUuid = this.newParentUuid;
-		output.oldParentUuid = this.oldParentUuid;
+		output.objectUuid = this.object.uuid;
+		output.newParentUuid = this.newParent.uuid;
+		output.oldParentUuid = this.oldParent.uuid;
 		output.newIndex = this.newIndex;
 		output.newIndex = this.newIndex;
 		output.oldIndex = this.oldIndex;
 		output.oldIndex = this.oldIndex;
 
 
@@ -84,14 +79,18 @@ CmdMoveObject.prototype = {
 		Cmd.prototype.fromJSON.call( this, json );
 		Cmd.prototype.fromJSON.call( this, json );
 
 
 		this.object = this.editor.objectByUuid( json.objectUuid );
 		this.object = this.editor.objectByUuid( json.objectUuid );
-		this.objectUuid = json.objectUuid;
-
 		this.oldParent = this.editor.objectByUuid( json.oldParentUuid );
 		this.oldParent = this.editor.objectByUuid( json.oldParentUuid );
-		this.oldParentUuid = json.oldParentUuid;
+		if ( this.oldParent === undefined ) {
 
 
+			this.oldParent = this.editor.scene;
+
+		}
 		this.newParent = this.editor.objectByUuid( json.newParentUuid );
 		this.newParent = this.editor.objectByUuid( json.newParentUuid );
-		this.newParentUuid = json.newParentUuid;
+		if ( this.newParent === undefined ) {
+
+			this.newParent = this.editor.scene;
 
 
+		}
 		this.newIndex = json.newIndex;
 		this.newIndex = json.newIndex;
 		this.oldIndex = json.oldIndex;
 		this.oldIndex = json.oldIndex;
 
 

+ 45 - 50
editor/js/CmdRemoveObject.js

@@ -11,50 +11,9 @@ CmdRemoveObject = function ( object ) {
 
 
 	this.object = object;
 	this.object = object;
 	this.parent = ( object !== undefined ) ? object.parent : undefined;
 	this.parent = ( object !== undefined ) ? object.parent : undefined;
-	this.parentUuid = ( object !== undefined ) ? object.parent.uuid : undefined;
+	if ( this.parent !== undefined ) {
 
 
-	if ( object !== undefined ) {
-
-		object.updateMatrixWorld( true );
-
-		meta = {
-			geometries: {},
-			materials: {},
-			textures: {},
-			images: {}
-		};
-		var json = object.toJSON( meta );
-
-		var geometries = extractFromCache( meta.geometries );
-		var materials = extractFromCache( meta.materials );
-		var textures = extractFromCache( meta.textures );
-		var images = extractFromCache( meta.images );
-
-		if ( geometries.length > 0 ) json.geometries = geometries;
-		if ( materials.length > 0 ) json.materials = materials;
-		if ( textures.length > 0 ) json.textures = textures;
-		if ( images.length > 0 ) json.images = images;
-
-		this.objectJSON = json;
-
-	}
-
-	// Note: The function 'extractFromCache' is copied from Object3D.toJSON()
-
-	// extract data from the cache hash
-	// remove metadata on each item
-	// and return as array
-	function extractFromCache ( cache ) {
-
-		var values = [];
-		for ( var key in cache ) {
-
-			var data = cache[ key ];
-			delete data.metadata;
-			values.push( data );
-
-		}
-		return values;
+		this.index = this.parent.children.indexOf( this.object );
 
 
 	}
 	}
 
 
@@ -64,8 +23,6 @@ CmdRemoveObject.prototype = {
 
 
 	execute: function () {
 	execute: function () {
 
 
-		this.index = this.parent.children.indexOf( this.object );
-
 		var scope = this.editor;
 		var scope = this.editor;
 		this.object.traverse( function ( child ) {
 		this.object.traverse( function ( child ) {
 
 
@@ -105,12 +62,52 @@ CmdRemoveObject.prototype = {
 
 
 		var output = Cmd.prototype.toJSON.call( this );
 		var output = Cmd.prototype.toJSON.call( this );
 
 
-		output.object = this.objectJSON;
+		this.object.updateMatrixWorld( true );
+
+		meta = {
+			geometries: {},
+			materials: {},
+			textures: {},
+			images: {}
+		};
+		var json = this.object.toJSON( meta );
+
+		var geometries = extractFromCache( meta.geometries );
+		var materials = extractFromCache( meta.materials );
+		var textures = extractFromCache( meta.textures );
+		var images = extractFromCache( meta.images );
+
+		if ( geometries.length > 0 ) json.geometries = geometries;
+		if ( materials.length > 0 ) json.materials = materials;
+		if ( textures.length > 0 ) json.textures = textures;
+		if ( images.length > 0 ) json.images = images;
+
+		output.object = json;
 		output.index = this.index;
 		output.index = this.index;
-		output.parentUuid = this.parentUuid;
+		output.parentUuid = this.parent.uuid;
 
 
 		return output;
 		return output;
 
 
+
+		// Note: The function 'extractFromCache' is copied from Object3D.toJSON()
+
+		// extract data from the cache hash
+		// remove metadata on each item
+		// and return as array
+		function extractFromCache ( cache ) {
+
+			var values = [];
+			for ( var key in cache ) {
+
+				var data = cache[ key ];
+				delete data.metadata;
+				values.push( data );
+
+			}
+			return values;
+
+		}
+
 	},
 	},
 
 
 	fromJSON: function ( json ) {
 	fromJSON: function ( json ) {
@@ -123,18 +120,16 @@ CmdRemoveObject.prototype = {
 			this.parent = this.editor.scene;
 			this.parent = this.editor.scene;
 
 
 		}
 		}
-		this.parentUuid = json.parentUuid;
 
 
 		this.index = json.index;
 		this.index = json.index;
-		this.object = this.editor.objectByUuid( json.object.object.uuid );
 
 
+		this.object = this.editor.objectByUuid( json.object.object.uuid );
 		if ( this.object === undefined ) {
 		if ( this.object === undefined ) {
 
 
 			var loader = new THREE.ObjectLoader();
 			var loader = new THREE.ObjectLoader();
 			this.object = loader.parse( json.object );
 			this.object = loader.parse( json.object );
 
 
 		}
 		}
-		this.objectJSON = json.object;
 
 
 	}
 	}
 
 

+ 5 - 6
editor/js/CmdRemoveScript.js

@@ -10,10 +10,12 @@ CmdRemoveScript = function ( object, script ) {
 	this.name = 'Remove Script';
 	this.name = 'Remove Script';
 
 
 	this.object = object;
 	this.object = object;
-
-	this.objectUuid = ( object !== undefined ) ? object.uuid : undefined;
 	this.script = script;
 	this.script = script;
+	if ( this.object && this.script ) {
+
+		this.index = this.editor.scripts[ this.object.uuid ].indexOf( this.script );
 
 
+	}
 };
 };
 
 
 CmdRemoveScript.prototype = {
 CmdRemoveScript.prototype = {
@@ -22,8 +24,6 @@ CmdRemoveScript.prototype = {
 
 
 		if ( this.editor.scripts[ this.object.uuid ] === undefined ) return;
 		if ( this.editor.scripts[ this.object.uuid ] === undefined ) return;
 
 
-		this.index = this.editor.scripts[ this.object.uuid ].indexOf( this.script );
-
 		if ( this.index !== - 1 ) {
 		if ( this.index !== - 1 ) {
 
 
 			this.editor.scripts[ this.object.uuid ].splice( this.index, 1 );
 			this.editor.scripts[ this.object.uuid ].splice( this.index, 1 );
@@ -52,7 +52,7 @@ CmdRemoveScript.prototype = {
 
 
 		var output = Cmd.prototype.toJSON.call( this );
 		var output = Cmd.prototype.toJSON.call( this );
 
 
-		output.objectUuid = this.objectUuid;
+		output.objectUuid = this.object.uuid;
 		output.script = this.script;
 		output.script = this.script;
 		output.index = this.index;
 		output.index = this.index;
 
 
@@ -64,7 +64,6 @@ CmdRemoveScript.prototype = {
 
 
 		Cmd.prototype.fromJSON.call( this, json );
 		Cmd.prototype.fromJSON.call( this, json );
 
 
-		this.objectUuid = json.objectUuid;
 		this.script = json.script;
 		this.script = json.script;
 		this.index = json.index;
 		this.index = json.index;
 		this.object = this.editor.objectByUuid( json.objectUuid );
 		this.object = this.editor.objectByUuid( json.objectUuid );

+ 1 - 3
editor/js/CmdSetColor.js

@@ -11,7 +11,6 @@ CmdSetColor = function ( object, attributeName, newValue ) {
 	this.updatable = true;
 	this.updatable = true;
 
 
 	this.object = object;
 	this.object = object;
-	this.objectUuid = ( object !== undefined ) ? object.uuid : undefined;
 	this.attributeName = attributeName;
 	this.attributeName = attributeName;
 	this.oldValue = ( object !== undefined ) ? this.object[ this.attributeName ].getHex() : undefined;
 	this.oldValue = ( object !== undefined ) ? this.object[ this.attributeName ].getHex() : undefined;
 	this.newValue = newValue;
 	this.newValue = newValue;
@@ -44,7 +43,7 @@ CmdSetColor.prototype = {
 
 
 		var output = Cmd.prototype.toJSON.call( this );
 		var output = Cmd.prototype.toJSON.call( this );
 
 
-		output.objectUuid = this.objectUuid;
+		output.objectUuid = this.object.uuid;
 		output.attributeName = this.attributeName;
 		output.attributeName = this.attributeName;
 		output.oldValue = this.oldValue;
 		output.oldValue = this.oldValue;
 		output.newValue = this.newValue;
 		output.newValue = this.newValue;
@@ -58,7 +57,6 @@ CmdSetColor.prototype = {
 		Cmd.prototype.fromJSON.call( this, json );
 		Cmd.prototype.fromJSON.call( this, json );
 
 
 		this.object = this.editor.objectByUuid( json.objectUuid );
 		this.object = this.editor.objectByUuid( json.objectUuid );
-		this.objectUuid = json.objectUuid;
 		this.attributeName = json.attributeName;
 		this.attributeName = json.attributeName;
 		this.oldValue = json.oldValue;
 		this.oldValue = json.oldValue;
 		this.newValue = json.newValue;
 		this.newValue = json.newValue;

+ 5 - 15
editor/js/CmdSetGeometry.js

@@ -11,14 +11,9 @@ CmdSetGeometry = function ( object, newGeometry ) {
 	this.updatable = true;
 	this.updatable = true;
 
 
 	this.object = object;
 	this.object = object;
-	this.objectUuid = ( object !== undefined ) ? object.uuid : undefined;
-
 	this.oldGeometry = ( object !== undefined ) ? object.geometry : undefined;
 	this.oldGeometry = ( object !== undefined ) ? object.geometry : undefined;
 	this.newGeometry = newGeometry;
 	this.newGeometry = newGeometry;
 
 
-	this.oldGeometryJSON = ( object !== undefined ) ? object.geometry.toJSON() : undefined;
-	this.newGeometryJSON = ( newGeometry !== undefined ) ? newGeometry.toJSON() : undefined;
-
 };
 };
 
 
 CmdSetGeometry.prototype = {
 CmdSetGeometry.prototype = {
@@ -56,9 +51,9 @@ CmdSetGeometry.prototype = {
 
 
 		var output = Cmd.prototype.toJSON.call( this );
 		var output = Cmd.prototype.toJSON.call( this );
 
 
-		output.objectUuid = this.objectUuid;
-		output.oldGeometry = this.oldGeometryJSON;
-		output.newGeometry = this.newGeometryJSON;
+		output.objectUuid = this.object.uuid;
+		output.oldGeometry = this.object.geometry.toJSON();
+		output.newGeometry = this.newGeometry.toJSON();
 
 
 		return output;
 		return output;
 
 
@@ -69,13 +64,9 @@ CmdSetGeometry.prototype = {
 		Cmd.prototype.fromJSON.call( this, json );
 		Cmd.prototype.fromJSON.call( this, json );
 
 
 		this.object = this.editor.objectByUuid( json.objectUuid );
 		this.object = this.editor.objectByUuid( json.objectUuid );
-		this.objectUuid = json.objectUuid;
-		this.oldGeometryJSON = json.oldGeometry;
-		this.newGeometryJSON = json.newGeometry;
 
 
-
-		this.oldGeometry = parseGeometry( this.oldGeometryJSON );
-		this.newGeometry = parseGeometry( this.newGeometryJSON );
+		this.oldGeometry = parseGeometry( json.oldGeometry );
+		this.newGeometry = parseGeometry( json.newGeometry );
 
 
 		function parseGeometry ( data ) {
 		function parseGeometry ( data ) {
 
 
@@ -86,5 +77,4 @@ CmdSetGeometry.prototype = {
 
 
 	}
 	}
 
 
-
 };
 };

+ 2 - 5
editor/js/CmdSetGeometryValue.js

@@ -10,11 +10,9 @@ CmdSetGeometryValue = function ( object, attributeName, newValue ) {
 	this.name = 'Set Geometry.' + attributeName;
 	this.name = 'Set Geometry.' + attributeName;
 
 
 	this.object = object;
 	this.object = object;
-
 	this.attributeName = attributeName;
 	this.attributeName = attributeName;
 	this.oldValue = ( object !== undefined ) ? object.geometry[ attributeName ] : undefined;
 	this.oldValue = ( object !== undefined ) ? object.geometry[ attributeName ] : undefined;
 	this.newValue = newValue;
 	this.newValue = newValue;
-	this.objectUuid = ( object !== undefined ) ? object.uuid : undefined;
 
 
 };
 };
 
 
@@ -42,7 +40,7 @@ CmdSetGeometryValue.prototype = {
 
 
 		var output = Cmd.prototype.toJSON.call( this );
 		var output = Cmd.prototype.toJSON.call( this );
 
 
-		output.objectUuid = this.objectUuid;
+		output.objectUuid = this.object.uuid;
 		output.attributeName = this.attributeName;
 		output.attributeName = this.attributeName;
 		output.oldValue = this.oldValue;
 		output.oldValue = this.oldValue;
 		output.newValue = this.newValue;
 		output.newValue = this.newValue;
@@ -55,11 +53,10 @@ CmdSetGeometryValue.prototype = {
 
 
 		Cmd.prototype.fromJSON.call( this, json );
 		Cmd.prototype.fromJSON.call( this, json );
 
 
-		this.objectUuid = json.objectUuid;
+		this.object = this.editor.objectByUuid( json.objectUuid );
 		this.attributeName = json.attributeName;
 		this.attributeName = json.attributeName;
 		this.oldValue = json.oldValue;
 		this.oldValue = json.oldValue;
 		this.newValue = json.newValue;
 		this.newValue = json.newValue;
-		this.object = this.editor.objectByUuid( json.objectUuid );
 
 
 	}
 	}
 
 

+ 45 - 54
editor/js/CmdSetMaterial.js

@@ -13,81 +13,77 @@ CmdSetMaterial = function ( object, newMaterial ) {
 	this.oldMaterial = ( object !== undefined ) ? object.material : undefined;
 	this.oldMaterial = ( object !== undefined ) ? object.material : undefined;
 	this.newMaterial = newMaterial;
 	this.newMaterial = newMaterial;
 
 
-	this.objectUuid = ( object !== undefined ) ? object.uuid : undefined;
-	this.oldMaterialJSON = serializeMaterial( this.oldMaterial );
-	this.newMaterialJSON = serializeMaterial( this.newMaterial );
-
+};
 
 
-	function serializeMaterial ( material ) {
+CmdSetMaterial.prototype = {
 
 
-		if ( material === undefined ) return null;
+	execute: function () {
 
 
-		var meta = {
-			geometries: {},
-			materials: {},
-			textures: {},
-			images: {}
-		};
+		this.object.material = this.newMaterial;
+		this.editor.signals.materialChanged.dispatch( this.newMaterial );
 
 
-		var json = {};
-		json.materials = [ material.toJSON( meta ) ];
+	},
 
 
-		var textures = extractFromCache( meta.textures );
-		var images = extractFromCache( meta.images );
+	undo: function () {
 
 
-		if ( textures.length > 0 ) json.textures = textures;
-		if ( images.length > 0 ) json.images = images;
+		this.object.material = this.oldMaterial;
+		this.editor.signals.materialChanged.dispatch( this.oldMaterial );
 
 
-		return json;
+	},
 
 
-	}
+	toJSON: function () {
 
 
-	// Note: The function 'extractFromCache' is copied from Object3D.toJSON()
+		var output = Cmd.prototype.toJSON.call( this );
 
 
-	// extract data from the cache hash
-	// remove metadata on each item
-	// and return as array
-	function extractFromCache ( cache ) {
+		output.objectUuid = this.object.uuid;
+		output.oldMaterial = serializeMaterial( this.oldMaterial );
+		output.newMaterial = serializeMaterial( this.newMaterial );
 
 
-		var values = [];
-		for ( var key in cache ) {
+		return output;
 
 
-			var data = cache[ key ];
-			delete data.metadata;
-			values.push( data );
 
 
-		}
-		return values;
+		function serializeMaterial ( material ) {
 
 
-	}
+			if ( material === undefined ) return null;
 
 
-};
+			var meta = {
+				geometries: {},
+				materials: {},
+				textures: {},
+				images: {}
+			};
 
 
-CmdSetMaterial.prototype = {
+			var json = {};
+			json.materials = [ material.toJSON( meta ) ];
 
 
-	execute: function () {
+			var textures = extractFromCache( meta.textures );
+			var images = extractFromCache( meta.images );
 
 
-		this.object.material = this.newMaterial;
-		this.editor.signals.materialChanged.dispatch( this.newMaterial );
+			if ( textures.length > 0 ) json.textures = textures;
+			if ( images.length > 0 ) json.images = images;
 
 
-	},
+			return json;
 
 
-	undo: function () {
+		}
 
 
-		this.object.material = this.oldMaterial;
-		this.editor.signals.materialChanged.dispatch( this.oldMaterial );
+		// Note: The function 'extractFromCache' is copied from Object3D.toJSON()
 
 
-	},
+		// extract data from the cache hash
+		// remove metadata on each item
+		// and return as array
+		function extractFromCache ( cache ) {
 
 
-	toJSON: function () {
+			var values = [];
+			for ( var key in cache ) {
 
 
-		var output = Cmd.prototype.toJSON.call( this );
+				var data = cache[ key ];
+				delete data.metadata;
+				values.push( data );
 
 
-		output.objectUuid = this.objectUuid;
-		output.oldMaterial = this.oldMaterialJSON;
-		output.newMaterial = this.newMaterialJSON;
+			}
+			return values;
 
 
-		return output;
+		}
 
 
 	},
 	},
 
 
@@ -96,11 +92,6 @@ CmdSetMaterial.prototype = {
 		Cmd.prototype.fromJSON.call( this, json );
 		Cmd.prototype.fromJSON.call( this, json );
 
 
 		this.object = this.editor.objectByUuid( json.objectUuid );
 		this.object = this.editor.objectByUuid( json.objectUuid );
-		this.objectUuid = json.objectUuid;
-
-		this.oldMaterialJSON = json.oldMaterial;
-		this.newMaterialJSON = json.newMaterial;
-
 		this.oldMaterial = parseMaterial( json.oldMaterial );
 		this.oldMaterial = parseMaterial( json.oldMaterial );
 		this.newMaterial = parseMaterial( json.newMaterial );
 		this.newMaterial = parseMaterial( json.newMaterial );
 
 

+ 1 - 3
editor/js/CmdSetMaterialColor.js

@@ -11,7 +11,6 @@ CmdSetMaterialColor = function ( object, attributeName, newValue ) {
 	this.updatable = true;
 	this.updatable = true;
 
 
 	this.object = object;
 	this.object = object;
-	this.objectUuid = ( object !== undefined ) ? object.uuid : undefined;
 	this.attributeName = attributeName;
 	this.attributeName = attributeName;
 	this.oldValue = ( object !== undefined ) ? this.object.material[ this.attributeName ].getHex() : undefined;
 	this.oldValue = ( object !== undefined ) ? this.object.material[ this.attributeName ].getHex() : undefined;
 	this.newValue = newValue;
 	this.newValue = newValue;
@@ -44,7 +43,7 @@ CmdSetMaterialColor.prototype = {
 
 
 		var output = Cmd.prototype.toJSON.call( this );
 		var output = Cmd.prototype.toJSON.call( this );
 
 
-		output.objectUuid = this.objectUuid;
+		output.objectUuid = this.object.uuid;
 		output.attributeName = this.attributeName;
 		output.attributeName = this.attributeName;
 		output.oldValue = this.oldValue;
 		output.oldValue = this.oldValue;
 		output.newValue = this.newValue;
 		output.newValue = this.newValue;
@@ -58,7 +57,6 @@ CmdSetMaterialColor.prototype = {
 		Cmd.prototype.fromJSON.call( this, json );
 		Cmd.prototype.fromJSON.call( this, json );
 
 
 		this.object = this.editor.objectByUuid( json.objectUuid );
 		this.object = this.editor.objectByUuid( json.objectUuid );
-		this.objectUuid = json.objectUuid;
 		this.attributeName = json.attributeName;
 		this.attributeName = json.attributeName;
 		this.oldValue = json.oldValue;
 		this.oldValue = json.oldValue;
 		this.newValue = json.newValue;
 		this.newValue = json.newValue;

+ 45 - 58
editor/js/CmdSetMaterialMap.js

@@ -5,7 +5,6 @@
 CmdSetMaterialMap = function ( object, mapName, newMap ) {
 CmdSetMaterialMap = function ( object, mapName, newMap ) {
 
 
 	Cmd.call( this );
 	Cmd.call( this );
-
 	this.type = 'CmdSetMaterialMap';
 	this.type = 'CmdSetMaterialMap';
 	this.name = 'Set Material.' + mapName;
 	this.name = 'Set Material.' + mapName;
 
 
@@ -14,51 +13,6 @@ CmdSetMaterialMap = function ( object, mapName, newMap ) {
 	this.oldMap = ( object !== undefined ) ? object.material[ mapName ] : undefined;
 	this.oldMap = ( object !== undefined ) ? object.material[ mapName ] : undefined;
 	this.newMap = newMap;
 	this.newMap = newMap;
 
 
-	this.objectUuid = ( object !== undefined ) ? object.uuid : undefined;
-	this.newMapJSON = serializeMap( this.newMap );
-	this.oldMapJSON = serializeMap( this.oldMap );
-
-	// serializes a map (THREE.Texture)
-
-	function serializeMap ( map ) {
-
-		if ( map === null || map === undefined ) return null;
-
-		var meta = {
-			geometries: {},
-			materials: {},
-			textures: {},
-			images: {}
-		};
-
-		var json = map.toJSON( meta );
-		var images = extractFromCache( meta.images );
-		if ( images.length > 0 ) json.images = images;
-		json.sourceFile = map.sourceFile;
-
-		return json;
-
-	}
-
-	// Note: The function 'extractFromCache' is copied from Object3D.toJSON()
-
-	// extract data from the cache hash
-	// remove metadata on each item
-	// and return as array
-	function extractFromCache ( cache ) {
-
-		var values = [];
-		for ( var key in cache ) {
-
-			var data = cache[ key ];
-			delete data.metadata;
-			values.push( data );
-
-		}
-		return values;
-
-	}
-
 };
 };
 
 
 CmdSetMaterialMap.prototype = {
 CmdSetMaterialMap.prototype = {
@@ -83,32 +37,65 @@ CmdSetMaterialMap.prototype = {
 
 
 		var output = Cmd.prototype.toJSON.call( this );
 		var output = Cmd.prototype.toJSON.call( this );
 
 
-		output.objectUuid = this.objectUuid;
+		output.objectUuid = this.object.uuid;
 		output.mapName = this.mapName;
 		output.mapName = this.mapName;
-
-		output.oldMap = this.oldMapJSON;
-		output.newMap = this.newMapJSON;
+		output.newMap = serializeMap( this.newMap );
+		output.oldMap = serializeMap( this.oldMap );
 
 
 		return output;
 		return output;
 
 
+		// serializes a map (THREE.Texture)
+
+		function serializeMap ( map ) {
+
+			if ( map === null || map === undefined ) return null;
+
+			var meta = {
+				geometries: {},
+				materials: {},
+				textures: {},
+				images: {}
+			};
+
+			var json = map.toJSON( meta );
+			var images = extractFromCache( meta.images );
+			if ( images.length > 0 ) json.images = images;
+			json.sourceFile = map.sourceFile;
+
+			return json;
+
+		}
+
+		// Note: The function 'extractFromCache' is copied from Object3D.toJSON()
+
+		// extract data from the cache hash
+		// remove metadata on each item
+		// and return as array
+		function extractFromCache ( cache ) {
+
+			var values = [];
+			for ( var key in cache ) {
+
+				var data = cache[ key ];
+				delete data.metadata;
+				values.push( data );
+
+			}
+			return values;
+
+		}
+
 	},
 	},
 
 
 	fromJSON: function ( json ) {
 	fromJSON: function ( json ) {
 
 
 		Cmd.prototype.fromJSON.call( this, json );
 		Cmd.prototype.fromJSON.call( this, json );
 
 
-		this.objectUuid = json.objectUuid;
-		this.mapName = json.mapName;
-
 		this.object = this.editor.objectByUuid( json.objectUuid );
 		this.object = this.editor.objectByUuid( json.objectUuid );
-
-		this.oldMapJSON = json.oldMap;
-		this.newMapJSON = json.newMap;
-
+		this.mapName = json.mapName;
 		this.oldMap = parseTexture( json.oldMap );
 		this.oldMap = parseTexture( json.oldMap );
 		this.newMap = parseTexture( json.newMap );
 		this.newMap = parseTexture( json.newMap );
 
 
-
 		function parseTexture ( json ) {
 		function parseTexture ( json ) {
 
 
 			var map = null;
 			var map = null;

+ 1 - 3
editor/js/CmdSetMaterialValue.js

@@ -11,7 +11,6 @@ CmdSetMaterialValue = function ( object, attributeName, newValue ) {
 	this.updatable = true;
 	this.updatable = true;
 
 
 	this.object = object;
 	this.object = object;
-	this.objectUuid = ( object !== undefined ) ? object.uuid : undefined;
 	this.oldValue = ( object !== undefined ) ? object.material[ attributeName ] : undefined;
 	this.oldValue = ( object !== undefined ) ? object.material[ attributeName ] : undefined;
 	this.newValue = newValue;
 	this.newValue = newValue;
 	this.attributeName = attributeName;
 	this.attributeName = attributeName;
@@ -46,7 +45,7 @@ CmdSetMaterialValue.prototype = {
 
 
 		var output = Cmd.prototype.toJSON.call( this );
 		var output = Cmd.prototype.toJSON.call( this );
 
 
-		output.objectUuid = this.objectUuid;
+		output.objectUuid = this.object.uuid;
 		output.attributeName = this.attributeName;
 		output.attributeName = this.attributeName;
 		output.oldValue = this.oldValue;
 		output.oldValue = this.oldValue;
 		output.newValue = this.newValue;
 		output.newValue = this.newValue;
@@ -59,7 +58,6 @@ CmdSetMaterialValue.prototype = {
 
 
 		Cmd.prototype.fromJSON.call( this, json );
 		Cmd.prototype.fromJSON.call( this, json );
 
 
-		this.objectUuid = json.objectUuid;
 		this.attributeName = json.attributeName;
 		this.attributeName = json.attributeName;
 		this.oldValue = json.oldValue;
 		this.oldValue = json.oldValue;
 		this.newValue = json.newValue;
 		this.newValue = json.newValue;

+ 1 - 3
editor/js/CmdSetPosition.js

@@ -11,7 +11,6 @@ CmdSetPosition = function ( object, newPositionVector, oldPositionVector ) {
 	this.updatable = true;
 	this.updatable = true;
 
 
 	this.object = object;
 	this.object = object;
-	this.objectUuid = ( object !== undefined ) ? object.uuid : undefined;
 
 
 	if ( object !== undefined && newPositionVector !== undefined ) {
 	if ( object !== undefined && newPositionVector !== undefined ) {
 
 
@@ -55,7 +54,7 @@ CmdSetPosition.prototype = {
 
 
 		var output = Cmd.prototype.toJSON.call( this );
 		var output = Cmd.prototype.toJSON.call( this );
 
 
-		output.objectUuid = this.objectUuid;
+		output.objectUuid = this.object.uuid;
 		output.oldPosition = this.oldPosition.toArray();
 		output.oldPosition = this.oldPosition.toArray();
 		output.newPosition = this.newPosition.toArray();
 		output.newPosition = this.newPosition.toArray();
 
 
@@ -68,7 +67,6 @@ CmdSetPosition.prototype = {
 		Cmd.prototype.fromJSON.call( this, json );
 		Cmd.prototype.fromJSON.call( this, json );
 
 
 		this.object = this.editor.objectByUuid( json.objectUuid );
 		this.object = this.editor.objectByUuid( json.objectUuid );
-		this.objectUuid = json.objectUuid;
 		this.oldPosition = new THREE.Vector3().fromArray( json.oldPosition );
 		this.oldPosition = new THREE.Vector3().fromArray( json.oldPosition );
 		this.newPosition = new THREE.Vector3().fromArray( json.newPosition );
 		this.newPosition = new THREE.Vector3().fromArray( json.newPosition );
 
 

+ 1 - 3
editor/js/CmdSetRotation.js

@@ -11,7 +11,6 @@ CmdSetRotation = function ( object, newRotationEuler, oldRotationEuler ) {
 	this.updatable = true;
 	this.updatable = true;
 
 
 	this.object = object;
 	this.object = object;
-	this.objectUuid = ( object !== undefined ) ? object.uuid : undefined;
 
 
 	if ( object !== undefined && newRotationEuler !== undefined) {
 	if ( object !== undefined && newRotationEuler !== undefined) {
 
 
@@ -56,7 +55,7 @@ CmdSetRotation.prototype = {
 
 
 		var output = Cmd.prototype.toJSON.call( this );
 		var output = Cmd.prototype.toJSON.call( this );
 
 
-		output.objectUuid = this.objectUuid;
+		output.objectUuid = this.object.uuid;
 		output.oldRotation = this.oldRotation.toArray();
 		output.oldRotation = this.oldRotation.toArray();
 		output.newRotation = this.newRotation.toArray();
 		output.newRotation = this.newRotation.toArray();
 
 
@@ -69,7 +68,6 @@ CmdSetRotation.prototype = {
 		Cmd.prototype.fromJSON.call( this, json );
 		Cmd.prototype.fromJSON.call( this, json );
 
 
 		this.object = this.editor.objectByUuid( json.objectUuid );
 		this.object = this.editor.objectByUuid( json.objectUuid );
-		this.objectUuid = json.objectUuid;
 		this.oldRotation = new THREE.Euler().fromArray(json.oldRotation);
 		this.oldRotation = new THREE.Euler().fromArray(json.oldRotation);
 		this.newRotation = new THREE.Euler().fromArray(json.newRotation);
 		this.newRotation = new THREE.Euler().fromArray(json.newRotation);
 
 

+ 1 - 3
editor/js/CmdSetScale.js

@@ -11,7 +11,6 @@ CmdSetScale = function ( object, newScaleVector, oldScaleVector ) {
 	this.updatable = true;
 	this.updatable = true;
 
 
 	this.object = object;
 	this.object = object;
-	this.objectUuid = ( object !== undefined ) ? object.uuid : undefined;
 
 
 	if ( object !== undefined && newScaleVector !== undefined ) {
 	if ( object !== undefined && newScaleVector !== undefined ) {
 
 
@@ -55,7 +54,7 @@ CmdSetScale.prototype = {
 
 
 		var output = Cmd.prototype.toJSON.call( this );
 		var output = Cmd.prototype.toJSON.call( this );
 
 
-		output.objectUuid = this.objectUuid;
+		output.objectUuid = this.object.uuid;
 		output.oldScale = this.oldScale.toArray();
 		output.oldScale = this.oldScale.toArray();
 		output.newScale = this.newScale.toArray();
 		output.newScale = this.newScale.toArray();
 
 
@@ -68,7 +67,6 @@ CmdSetScale.prototype = {
 		Cmd.prototype.fromJSON.call( this, json );
 		Cmd.prototype.fromJSON.call( this, json );
 
 
 		this.object = this.editor.objectByUuid( json.objectUuid );
 		this.object = this.editor.objectByUuid( json.objectUuid );
-		this.objectUuid = json.objectUuid;
 		this.oldScale = new THREE.Vector3().fromArray( json.oldScale );
 		this.oldScale = new THREE.Vector3().fromArray( json.oldScale );
 		this.newScale = new THREE.Vector3().fromArray( json.newScale );
 		this.newScale = new THREE.Vector3().fromArray( json.newScale );
 
 

+ 2 - 6
editor/js/CmdSetScriptValue.js

@@ -16,9 +16,7 @@ CmdSetScriptValue = function ( object, script, attributeName, newValue, cursorPo
 	this.attributeName = attributeName;
 	this.attributeName = attributeName;
 	this.oldValue = ( script !== undefined ) ? script[ this.attributeName ] : undefined;
 	this.oldValue = ( script !== undefined ) ? script[ this.attributeName ] : undefined;
 	this.newValue = newValue;
 	this.newValue = newValue;
-	this.objectUuid = ( object !== undefined ) ? object.uuid : undefined;
 	this.cursorPosition = cursorPosition; // Format {line: 2, ch: 3}
 	this.cursorPosition = cursorPosition; // Format {line: 2, ch: 3}
-	this.index = this.editor.scripts[ this.objectUuid ].indexOf( this.script );
 
 
 };
 };
 
 
@@ -53,8 +51,8 @@ CmdSetScriptValue.prototype = {
 
 
 		var output = Cmd.prototype.toJSON.call( this );
 		var output = Cmd.prototype.toJSON.call( this );
 
 
-		output.objectUuid = this.objectUuid;
-		output.index = this.index;
+		output.objectUuid = this.object.uuid;
+		output.index = this.editor.scripts[ this.object.uuid ].indexOf( this.script );
 		output.attributeName = this.attributeName;
 		output.attributeName = this.attributeName;
 		output.oldValue = this.oldValue;
 		output.oldValue = this.oldValue;
 		output.newValue = this.newValue;
 		output.newValue = this.newValue;
@@ -68,8 +66,6 @@ CmdSetScriptValue.prototype = {
 
 
 		Cmd.prototype.fromJSON.call( this, json );
 		Cmd.prototype.fromJSON.call( this, json );
 
 
-		this.objectUuid = json.objectUuid;
-		this.index = json.index;
 		this.oldValue = json.oldValue;
 		this.oldValue = json.oldValue;
 		this.newValue = json.newValue;
 		this.newValue = json.newValue;
 		this.attributeName = json.attributeName;
 		this.attributeName = json.attributeName;

+ 1 - 3
editor/js/CmdSetValue.js

@@ -14,7 +14,6 @@ CmdSetValue = function ( object, attributeName, newValue ) {
 	this.attributeName = attributeName;
 	this.attributeName = attributeName;
 	this.oldValue = ( object !== undefined ) ? object[ attributeName ] : undefined;
 	this.oldValue = ( object !== undefined ) ? object[ attributeName ] : undefined;
 	this.newValue = newValue;
 	this.newValue = newValue;
-	this.objectUuid = ( object !== undefined ) ? object.uuid : undefined;
 
 
 };
 };
 
 
@@ -48,7 +47,7 @@ CmdSetValue.prototype = {
 
 
 		var output = Cmd.prototype.toJSON.call( this );
 		var output = Cmd.prototype.toJSON.call( this );
 
 
-		output.objectUuid = this.objectUuid;
+		output.objectUuid = this.object.uuid;
 		output.attributeName = this.attributeName;
 		output.attributeName = this.attributeName;
 		output.oldValue = this.oldValue;
 		output.oldValue = this.oldValue;
 		output.newValue = this.newValue;
 		output.newValue = this.newValue;
@@ -61,7 +60,6 @@ CmdSetValue.prototype = {
 
 
 		Cmd.prototype.fromJSON.call( this, json );
 		Cmd.prototype.fromJSON.call( this, json );
 
 
-		this.objectUuid = json.objectUuid;
 		this.attributeName = json.attributeName;
 		this.attributeName = json.attributeName;
 		this.oldValue = json.oldValue;
 		this.oldValue = json.oldValue;
 		this.newValue = json.newValue;
 		this.newValue = json.newValue;

+ 21 - 40
editor/js/History.js

@@ -72,6 +72,8 @@ History.prototype = {
 		}
 		}
 		cmd.name = optionalName !== undefined ? optionalName : cmd.name;
 		cmd.name = optionalName !== undefined ? optionalName : cmd.name;
 		cmd.execute();
 		cmd.execute();
+		cmd.inMemory = true;
+		cmd.json = cmd.toJSON();	// serialize cmd immediately after execution
 
 
 		this.lastCmdTime = new Date();
 		this.lastCmdTime = new Date();
 
 
@@ -97,11 +99,9 @@ History.prototype = {
 
 
 			var cmd = this.undos.pop();
 			var cmd = this.undos.pop();
 
 
-			if ( cmd.serialized ) {
+			if ( cmd.inMemory === false ) {
 
 
-				var json = cmd;
-				cmd = new window[ json.type ]();	// creates a new object of type "json.type"
-				cmd.fromJSON( json );
+				cmd.fromJSON( cmd.json );
 
 
 			}
 			}
 
 
@@ -134,11 +134,9 @@ History.prototype = {
 
 
 			var cmd = this.redos.pop();
 			var cmd = this.redos.pop();
 
 
-			if ( cmd.serialized ) {
+			if ( cmd.inMemory === false ) {
 
 
-				var json = cmd;
-				cmd = new window[ json.type ]();	// creates a new object of type "json.type"
-				cmd.fromJSON( json );
+				cmd.fromJSON( cmd.json );
 
 
 			}
 			}
 
 
@@ -167,16 +165,7 @@ History.prototype = {
 		for ( var i = 0 ; i < this.undos.length; i++ ) {
 		for ( var i = 0 ; i < this.undos.length; i++ ) {
 
 
 			var cmd = this.undos[ i ];
 			var cmd = this.undos[ i ];
-
-			if ( cmd.serialized ) {
-
-				undos.push( cmd );	// add without serializing
-
-			} else {
-
-				undos.push( cmd.toJSON() );
-
-			}
+			undos.push( cmd.json );
 
 
 		}
 		}
 
 
@@ -189,17 +178,7 @@ History.prototype = {
 		for ( var i = 0 ; i < this.redos.length; i++ ) {
 		for ( var i = 0 ; i < this.redos.length; i++ ) {
 
 
 			var cmd = this.redos[ i ];
 			var cmd = this.redos[ i ];
-
-			if ( cmd.serialized ) {
-
-				redos.push( cmd );	// add without serializing
-
-			} else {
-
-				redos.push( cmd.toJSON() );
-
-			}
-
+			redos.push( cmd.json );
 
 
 		}
 		}
 
 
@@ -215,19 +194,21 @@ History.prototype = {
 
 
 		for ( var i = 0; i < json.undos.length ; i++ ) {
 		for ( var i = 0; i < json.undos.length ; i++ ) {
 
 
-			json.undos[ i ].serialized = true;
-			this.undos.push( json.undos[ i ] );
-
-			this.idCounter = json.undos[ i ].id > this.idCounter ? json.undos[ i ].id : this.idCounter; // set last used idCounter
+			var cmdJSON = json.undos[ i ];
+			var cmd = new window[ cmdJSON.type ]();	// creates a new object of type "json.type"
+			cmd.json = cmdJSON;
+			this.undos.push( cmd );
+			this.idCounter = cmdJSON.id > this.idCounter ? cmdJSON.id : this.idCounter; // set last used idCounter
 
 
 		}
 		}
 
 
 		for ( var i = 0; i < json.redos.length ; i++ ) {
 		for ( var i = 0; i < json.redos.length ; i++ ) {
 
 
-			json.redos[ i ].serialized = true;
-			this.redos.push( json.redos[ i ] );
-
-			this.idCounter = json.redos[ i ].id > this.idCounter ? json.redos[ i ].id : this.idCounter; // set last used idCounter
+			var cmdJSON = json.redos[ i ];
+			var cmd = new window[ cmdJSON.type ]();	// creates a new object of type "json.type"
+			cmd.json = cmdJSON;
+			this.redos.push( cmd );
+			this.idCounter = cmdJSON.id > this.idCounter ? cmdJSON.id : this.idCounter; // set last used idCounter
 
 
 		}
 		}
 
 
@@ -259,10 +240,10 @@ History.prototype = {
 
 
 		var cmd = this.undos.length > 0 ? this.undos[ this.undos.length - 1 ] : undefined;	// next cmd to pop
 		var cmd = this.undos.length > 0 ? this.undos[ this.undos.length - 1 ] : undefined;	// next cmd to pop
 
 
-		if ( cmd === undefined || id > cmd.id ) {
+		if ( cmd === undefined || id > cmd.json.id ) {
 
 
 			cmd = this.redo();
 			cmd = this.redo();
-			while ( cmd !== undefined && id > cmd.id ) {
+			while ( cmd !== undefined && id > cmd.json.id ) {
 
 
 				cmd = this.redo();
 				cmd = this.redo();
 
 
@@ -274,7 +255,7 @@ History.prototype = {
 
 
 				cmd = this.undos[ this.undos.length - 1 ];	// next cmd to pop
 				cmd = this.undos[ this.undos.length - 1 ];	// next cmd to pop
 
 
-				if ( cmd === undefined || id === cmd.id ) break;
+				if ( cmd === undefined || id === cmd.json.id ) break;
 
 
 				cmd = this.undo();
 				cmd = this.undo();
 
 

+ 5 - 5
editor/js/Sidebar.History.js

@@ -51,9 +51,9 @@ Sidebar.History = function ( editor ) {
 
 
 				var object = objects[ i ];
 				var object = objects[ i ];
 
 
-				var html = pad + "<span style='color: #0000cc '>" + enumerator++ + ". Undo: " + object.name + "</span>";
+				var html = pad + "<span style='color: #0000cc '>" + enumerator++ + ". Undo: " + object.json.name + "</span>";
 
 
-				options.push( { value: object.id, html: html } );
+				options.push( { value: object.json.id, html: html } );
 
 
 			}
 			}
 
 
@@ -66,9 +66,9 @@ Sidebar.History = function ( editor ) {
 
 
 				var object = objects[ i ];
 				var object = objects[ i ];
 
 
-				var html = pad + "<span style='color: #71544e'>" + enumerator++ + ". Redo: " +  object.name + "</span>";
+				var html = pad + "<span style='color: #71544e'>" + enumerator++ + ". Redo: " +  object.json.name + "</span>";
 
 
-				options.push( { value: object.id, html: html } );
+				options.push( { value: object.json.id, html: html } );
 
 
 			}
 			}
 
 
@@ -87,7 +87,7 @@ Sidebar.History = function ( editor ) {
 	signals.historyChanged.add( refreshUI );
 	signals.historyChanged.add( refreshUI );
 	signals.historyChanged.add( function ( cmd ) {
 	signals.historyChanged.add( function ( cmd ) {
 		
 		
-		outliner.setValue( cmd !== undefined ? cmd.id : null );
+		outliner.setValue( cmd !== undefined ? cmd.json.id : null );
 
 
 	} );
 	} );