Skip to content

Commit

Permalink
Merged changes from master- into dev-branch mrdoob#17
Browse files Browse the repository at this point in the history
- Resulting issues: mrdoob#29, mrdoob#30
- Player behaviour where the player stops when a command is executed,
undone or redone removed.
  • Loading branch information
dforrer committed Sep 1, 2015
1 parent 353a27e commit 472ed08
Show file tree
Hide file tree
Showing 68 changed files with 3,300 additions and 237 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.swp
.project
node_modules
.idea/
9 changes: 8 additions & 1 deletion editor/css/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,14 @@ input.Number {
#menubar .menu .options .option:active {
background: transparent;
}


#menubar .menu .options .inactive {
color: #444;
background-color: transparent;
padding: 5px 10px;
margin: 0px !important;
}

#sidebar {
position: absolute;
right: 0px;
Expand Down
7 changes: 7 additions & 0 deletions editor/css/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ input.Number {
background: transparent;
}

#menubar .menu .options .inactive {
color: #bbb;
background-color: transparent;
padding: 5px 10px;
margin: 0px !important;
}

#sidebar {
position: absolute;
right: 0px;
Expand Down
35 changes: 35 additions & 0 deletions editor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,30 @@
<script src="js/Sidebar.Geometry.TorusKnotGeometry.js"></script>
<script src="js/Sidebar.Material.js"></script>
<script src="js/Sidebar.Script.js"></script>
<script src="js/Sidebar.History.js"></script>
<script src="js/Toolbar.js"></script>
<script src="js/Viewport.js"></script>
<script src="js/Viewport.Info.js"></script>
<script src="js/Cmd.js"></script>
<script src="js/CmdAddObject.js"></script>
<script src="js/CmdRemoveObject.js"></script>
<script src="js/CmdMoveObject.js"></script>
<script src="js/CmdSetPosition.js"></script>
<script src="js/CmdSetRotation.js"></script>
<script src="js/CmdSetScale.js"></script>
<script src="js/CmdToggleBoolean.js"></script>
<script src="js/CmdSetValue.js"></script>
<script src="js/CmdSetUuid.js"></script>
<script src="js/CmdSetColor.js"></script>
<script src="js/CmdSetGeometry.js"></script>
<script src="js/CmdSetGeometryValue.js"></script>
<script src="js/CmdMultiCmds.js"></script>
<script src="js/CmdAddScript.js"></script>
<script src="js/CmdRemoveScript.js"></script>
<script src="js/CmdSetScriptName.js"></script>
<script src="js/CmdSetScriptSource.js"></script>
<script src="js/CmdSetMaterialValue.js"></script>
<script src="js/CmdSetScene.js"></script>

<script>

Expand Down Expand Up @@ -218,6 +239,7 @@
signals.materialChanged.add( saveState );
signals.sceneGraphChanged.add( saveState );
signals.scriptChanged.add( saveState );
signals.historyChanged.add( saveState );

/*
var showDialog = function ( content ) {
Expand Down Expand Up @@ -271,6 +293,19 @@
editor.select( parent );

break;

case 90: // Register Ctrl-Z for Undo, Ctrl-Shift-Z for Redo

if ( event.ctrlKey && event.shiftKey ) {

editor.redo();

} else if ( event.ctrlKey ) {

editor.undo();

}
break;

}

Expand Down
28 changes: 28 additions & 0 deletions editor/js/Cmd.js
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;

};
68 changes: 68 additions & 0 deletions editor/js/CmdAddObject.js
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 );

}

}

};
70 changes: 70 additions & 0 deletions editor/js/CmdAddScript.js
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 );

}

};
99 changes: 99 additions & 0 deletions editor/js/CmdMoveObject.js
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;

}

};
Loading

0 comments on commit 472ed08

Please sign in to comment.