forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged changes from master- into dev-branch mrdoob#17
- Resulting issues: mrdoob#29, mrdoob#30 - Player behaviour where the player stops when a command is executed, undone or redone removed.
- Loading branch information
Showing
68 changed files
with
3,300 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
*.swp | ||
.project | ||
node_modules | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Created by Daniel on 20.07.15. | ||
*/ | ||
|
||
Cmd = function () { | ||
|
||
this.id = -1; | ||
this.serialized = false; | ||
this.updatable = false; | ||
this.type = ''; | ||
|
||
}; | ||
|
||
Cmd.prototype.toJSON = function () { | ||
|
||
var output = {}; | ||
output.type = this.type; | ||
output.id = this.id; | ||
return output; | ||
|
||
}; | ||
|
||
Cmd.prototype.fromJSON = function ( json ) { | ||
|
||
this.type = json.type; | ||
this.id = json.id; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* 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 ); | ||
|
||
} | ||
|
||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* Created by Daniel on 20.07.15. | ||
*/ | ||
|
||
CmdAddScript = function ( object, script ) { | ||
|
||
Cmd.call( this ); | ||
|
||
this.type = 'CmdAddScript'; | ||
|
||
this.object = object; | ||
this.objectUuid = object !== undefined ? object.uuid : undefined; | ||
|
||
this.script = script; | ||
}; | ||
|
||
CmdAddScript.prototype = { | ||
|
||
execute: function () { | ||
|
||
if ( this.editor.scripts[ this.object.uuid ] === undefined ) { | ||
|
||
this.editor.scripts[ this.object.uuid ] = []; | ||
|
||
} | ||
|
||
this.editor.scripts[ this.object.uuid ].push( this.script ); | ||
|
||
this.editor.signals.scriptAdded.dispatch( this.script ); | ||
|
||
}, | ||
|
||
undo: function () { | ||
|
||
if ( this.editor.scripts[ this.object.uuid ] === undefined ) return; | ||
|
||
var index = this.editor.scripts[ this.object.uuid ].indexOf( this.script ); | ||
|
||
if ( index !== - 1 ) { | ||
|
||
this.editor.scripts[ this.object.uuid ].splice( index, 1 ); | ||
|
||
} | ||
|
||
this.editor.signals.scriptRemoved.dispatch( this.script ); | ||
|
||
}, | ||
|
||
toJSON: function () { | ||
|
||
var output = Cmd.prototype.toJSON.call( this ); | ||
|
||
output.objectUuid = this.objectUuid; | ||
output.script = this.script; | ||
|
||
return output; | ||
|
||
}, | ||
|
||
fromJSON: function ( json ) { | ||
|
||
Cmd.prototype.fromJSON.call( this, json ); | ||
|
||
this.objectUuid = json.objectUuid; | ||
this.script = json.script; | ||
this.object = this.editor.objectByUuid( json.objectUuid ); | ||
|
||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/** | ||
* Created by Daniel on 20.07.15. | ||
*/ | ||
|
||
CmdMoveObject = function ( object, newParent, newBefore ) { | ||
|
||
Cmd.call( this ); | ||
|
||
this.type = 'CmdMoveObject'; | ||
|
||
this.object = object; | ||
this.objectUuid = object !== undefined ? object.uuid : 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.newParent = newParent; | ||
this.newParentUuid = newParent !== undefined ? newParent.uuid : undefined; | ||
|
||
if ( newBefore !== undefined ) { | ||
|
||
this.newIndex = newParent !== undefined ? newParent.children.indexOf( newBefore ) : undefined; | ||
|
||
} else { | ||
|
||
this.newIndex = newParent !== undefined ? newParent.children.length : undefined; | ||
|
||
} | ||
|
||
if ( this.oldParent === this.newParent && this.newIndex > this.oldIndex ) { | ||
|
||
this.newIndex --; | ||
|
||
} | ||
|
||
this.newBefore = newBefore; | ||
|
||
}; | ||
|
||
CmdMoveObject.prototype = { | ||
|
||
execute: function () { | ||
|
||
this.oldParent.remove( this.object ); | ||
|
||
var children = this.newParent.children; | ||
children.splice( this.newIndex, 0, this.object ); | ||
this.object.parent = this.newParent; | ||
|
||
this.editor.signals.sceneGraphChanged.dispatch(); | ||
|
||
}, | ||
|
||
undo: function () { | ||
|
||
this.newParent.remove( this.object ); | ||
|
||
var children = this.oldParent.children; | ||
children.splice( this.oldIndex, 0, this.object ); | ||
this.object.parent = this.oldParent; | ||
|
||
this.editor.signals.sceneGraphChanged.dispatch(); | ||
|
||
}, | ||
|
||
toJSON: function () { | ||
|
||
var output = Cmd.prototype.toJSON.call( this ); | ||
|
||
output.objectUuid = this.objectUuid; | ||
output.newParentUuid = this.newParentUuid; | ||
output.oldParentUuid = this.oldParentUuid; | ||
output.newIndex = this.newIndex; | ||
output.oldIndex = this.oldIndex; | ||
|
||
return output; | ||
|
||
}, | ||
|
||
fromJSON: function ( json ) { | ||
|
||
Cmd.prototype.fromJSON.call( this, json ); | ||
|
||
this.object = this.editor.objectByUuid( json.objectUuid ); | ||
this.objectUuid = json.objectUuid; | ||
|
||
this.oldParent = this.editor.objectByUuid( json.oldParentUuid ); | ||
this.oldParentUuid = json.oldParentUuid; | ||
|
||
this.newParent = this.editor.objectByUuid( json.newParentUuid ); | ||
this.newParentUuid = json.newParentUuid; | ||
|
||
this.newIndex = json.newIndex; | ||
this.oldIndex = json.oldIndex; | ||
|
||
} | ||
|
||
}; |
Oops, something went wrong.