Selaa lähdekoodia

changed CmdSetGeometry to be more in line with the rest of the commands

Removed „public“ function parseGeometry
Daniel 10 vuotta sitten
vanhempi
commit
b437c3725f
1 muutettua tiedostoa jossa 13 lisäystä ja 8 poistoa
  1. 13 8
      editor/js/CmdSetGeometry.js

+ 13 - 8
editor/js/CmdSetGeometry.js

@@ -12,12 +12,12 @@ CmdSetGeometry = function ( object, newGeometry ) {
 	this.object = object;
 	this.object = object;
 	this.objectUuid = object !== undefined ? object.uuid : undefined;
 	this.objectUuid = object !== undefined ? object.uuid : undefined;
 
 
-	this.newGeometry = newGeometry;	// only needed for update(cmd)
+	this.oldGeometry = object !== undefined ? object.geometry : undefined;
+	this.newGeometry = newGeometry;
 
 
 	this.oldGeometryJSON = object !== undefined ? object.geometry.toJSON() : undefined;
 	this.oldGeometryJSON = object !== undefined ? object.geometry.toJSON() : undefined;
 	this.newGeometryJSON = newGeometry !== undefined ? newGeometry.toJSON() : undefined;
 	this.newGeometryJSON = newGeometry !== undefined ? newGeometry.toJSON() : undefined;
 
 
-
 };
 };
 
 
 CmdSetGeometry.prototype = {
 CmdSetGeometry.prototype = {
@@ -25,7 +25,7 @@ CmdSetGeometry.prototype = {
 	execute: function () {
 	execute: function () {
 
 
 		this.object.geometry.dispose();
 		this.object.geometry.dispose();
-		this.object.geometry = this.parseGeometry( this.newGeometryJSON );
+		this.object.geometry = this.newGeometry;
 		this.object.geometry.computeBoundingSphere();
 		this.object.geometry.computeBoundingSphere();
 
 
 		this.editor.signals.geometryChanged.dispatch( this.object );
 		this.editor.signals.geometryChanged.dispatch( this.object );
@@ -36,7 +36,7 @@ CmdSetGeometry.prototype = {
 	undo: function () {
 	undo: function () {
 
 
 		this.object.geometry.dispose();
 		this.object.geometry.dispose();
-		this.object.geometry = this.parseGeometry( this.oldGeometryJSON );
+		this.object.geometry = this.oldGeometry;
 		this.object.geometry.computeBoundingSphere();
 		this.object.geometry.computeBoundingSphere();
 
 
 		this.editor.signals.geometryChanged.dispatch( this.object );
 		this.editor.signals.geometryChanged.dispatch( this.object );
@@ -46,6 +46,7 @@ CmdSetGeometry.prototype = {
 
 
 	update: function ( cmd ) {
 	update: function ( cmd ) {
 
 
+		this.newGeometry = cmd.newGeometry;
 		this.newGeometryJSON = cmd.newGeometry.toJSON();
 		this.newGeometryJSON = cmd.newGeometry.toJSON();
 
 
 	},
 	},
@@ -72,13 +73,17 @@ CmdSetGeometry.prototype = {
 		this.oldGeometryJSON = json.oldGeometryJSON;
 		this.oldGeometryJSON = json.oldGeometryJSON;
 		this.newGeometryJSON = json.newGeometryJSON;
 		this.newGeometryJSON = json.newGeometryJSON;
 
 
-	},
+		this.oldGeometry = this.parseGeometry( this.oldGeometryJSON );
+		this.newGeometry = this.parseGeometry( this.newGeometryJSON );
 
 
-	parseGeometry: function ( data ) {
+		function parseGeometry ( data ) {
 
 
-		var loader = new THREE.ObjectLoader();
-		return loader.parseGeometries( [ data ] )[ data.uuid ];
+			var loader = new THREE.ObjectLoader();
+			return loader.parseGeometries( [ data ] )[ data.uuid ];
+
+		}
 
 
 	}
 	}
 
 
+
 };
 };