Browse Source

Fix for issue #30

Daniel 10 years ago
parent
commit
916fa197c3
2 changed files with 39 additions and 8 deletions
  1. 14 0
      editor/js/CmdAddObject.js
  2. 25 8
      editor/js/CmdRemoveObject.js

+ 14 - 0
editor/js/CmdAddObject.js

@@ -12,6 +12,7 @@ CmdAddObject = function ( object ) {
 	if ( object !== undefined ) {
 
 		object.updateMatrixWorld( true );
+
 		meta = {
 			geometries: {},
 			materials: {},
@@ -20,6 +21,19 @@ CmdAddObject = function ( object ) {
 		};
 		this.objectJSON = object.toJSON( meta );
 
+		if ( object.geometry !== undefined ) {
+
+			this.objectJSON.geometries = [];
+			this.objectJSON.geometries.push( object.geometry.toJSON( meta ) );
+
+		}
+
+		if ( object.material !== undefined ) {
+
+			this.objectJSON.materials = [];
+			this.objectJSON.materials.push( object.material.toJSON( meta ) );
+		}
+
 	}
 
 };

+ 25 - 8
editor/js/CmdRemoveObject.js

@@ -8,18 +8,35 @@ CmdRemoveObject = function ( object ) {
 
 	this.type = 'CmdRemoveObject';
 
-	meta = {
-		geometries: {},
-		materials: {},
-		textures: {},
-		images: {}
-	};
-
 	this.object = object;
 	this.parent = object !== undefined ? object.parent : undefined;
-	this.objectJSON = object !== undefined ? object.toJSON( meta ) : undefined;
 	this.parentUuid = object !== undefined ? object.parent.uuid : undefined;
 
+	if ( object !== undefined ) {
+
+		meta = {
+			geometries: {},
+			materials: {},
+			textures: {},
+			images: {}
+		};
+		this.objectJSON = object.toJSON( meta );
+
+		if ( object.geometry !== undefined ) {
+
+			this.objectJSON.geometries = [];
+			this.objectJSON.geometries.push( object.geometry.toJSON( meta ) );
+
+		}
+
+		if ( object.material !== undefined ) {
+
+			this.objectJSON.materials = [];
+			this.objectJSON.materials.push( object.material.toJSON( meta ) );
+		}
+
+	}
+
 };
 
 CmdRemoveObject.prototype = {