123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- /**
- * 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 );
- if ( object.geometry !== undefined ) {
- this.objectJSON.geometries = [ object.geometry.toJSON( meta ) ];
- }
- if ( object.material !== undefined ) {
- this.objectJSON.materials = [ object.material.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 );
- }
- }
- };
|