1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- /**
- * Created by Daniel on 20.07.15.
- */
- CmdAddObject = function ( object ) {
- Cmd.call( this );
- this.type = 'CmdAddObject';
- this.object = object;
- if ( object !== undefined ) {
- object.updateMatrixWorld( true );
- meta = {
- geometries: {},
- materials: {},
- textures: {},
- images: {}
- };
- this.objectJSON = object.toJSON( meta );
- }
- };
- CmdAddObject.prototype = {
- execute: function () {
- this.editor.addObject( this.object );
- },
- undo: function () {
- this.editor.removeObject( this.object );
- this.editor.deselect();
- },
- toJSON: function () {
- var output = Cmd.prototype.toJSON.call( this );
- output.object = this.objectJSON;
- return output;
- },
- fromJSON: function ( json ) {
- Cmd.prototype.fromJSON.call( this, json );
- this.objectJSON = json.object;
- this.object = this.editor.objectByUuid( json.object.object.uuid );
- if ( this.object === undefined ) {
- var loader = new THREE.ObjectLoader();
- this.object = loader.parse( json.object );
- }
- }
- };
|