提交 359acf03 编写于 作者: M Mr.doob

Merge pull request #7400 from lxxxvi/dev

Renaming of commands (aesthetics)
......@@ -12,7 +12,7 @@ It would also be possible to only store the difference between the old and the n
**Before implementing your own command you should look if you can't reuse one of the already existing ones.**
For numbers, strings or booleans the CmdSet...Value-commands can be used.
For numbers, strings or booleans the Set...ValueCommand-commands can be used.
Then there are separate commands for:
- setting a color property (THREE.Color)
- setting maps (THREE.Texture)
......@@ -26,12 +26,12 @@ Every command needs a constructor. In the constructor
```javascript
CmdXXX = function () {
var DoSomethingCommand = function () {
Cmd.call( this ); // Required: Call default constructor
Command.call( this ); // Required: Call default constructor
this.type = 'CmdXXX'; // Required: has to match the object-name!
this.name = 'Set/Do/Update XXX'; // Required: description of the command, used in Sidebar.History
this.type = 'DoSomethingCommand'; // Required: has to match the object-name!
this.name = 'Set/Do/Update Something'; // Required: description of the command, used in Sidebar.History
// TODO: store all the relevant information needed to
// restore the old and the new state
......@@ -46,7 +46,7 @@ And as part of the prototype you need to implement four functions
- **fromJSON:** which deserializes the command
```javascript
CmdXXX.prototype = {
DoSomethingCommand.prototype = {
execute: function () {
......@@ -62,21 +62,21 @@ CmdXXX.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this ); // Required: Call 'toJSON'-method of prototype 'Cmd'
var output = Command.prototype.toJSON.call( this ); // Required: Call 'toJSON'-method of prototype 'Command'
// TODO: serialize all the necessary information as part of 'output' (JSON-format)
// so that it can be restored in 'fromJSON'
return output;
},
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json ); // Required: Call 'fromJSON'-method of prototype 'Cmd'
Command.prototype.fromJSON.call( this, json ); // Required: Call 'fromJSON'-method of prototype 'Command'
// TODO: restore command from json
}
};
......@@ -89,9 +89,9 @@ To execute a command we need an instance of the main editor-object. The editor-o
On **editor** we then call **.execute(...)*** with the new command-object which in turn calls **history.execute(...)** and adds the command to the undo-stack.
```javascript
editor.execute( new CmdXXX() );
editor.execute( new DoSomethingCommand() );
```
### Updatable commands ###
......@@ -99,7 +99,7 @@ editor.execute( new CmdXXX() );
Some commands are also **updatable**. By default a command is not updatable. Making a command updatable means that you
have to implement a fifth function 'update' as part of the prototype. In it only the 'new' state gets updated while the old one stays the same.
Here as an example is the update-function of **CmdSetColor**:
Here as an example is the update-function of **SetColorCommand**:
```javascript
update: function ( cmd ) {
......@@ -112,15 +112,15 @@ update: function ( cmd ) {
#### List of updatable commands
- CmdSetColor
- CmdSetGeometry
- CmdSetMaterialColor
- CmdSetMaterialValue
- CmdSetPosition
- CmdSetRotation
- CmdSetScale
- CmdSetValue
- CmdSetScriptValue
- SetColorCommand
- SetGeometryCommand
- SetMaterialColorCommand
- SetMaterialValueCommand
- SetPositionCommand
- SetRotationCommand
- SetScaleCommand
- SetValueCommand
- SetScriptValueCommand
The idea behind 'updatable commands' is that two commands of the same type which occur
within a short period of time should be merged into one.
......
......@@ -16,19 +16,19 @@ Each of the listed steps will now be described in detail.
### 1. Create a new unit test file ###
Create a new file in path `test/unit/editor/TestCmdXXX.js`.
Create a new file in path `test/unit/editor/TestDoSomethingCommand.js`.
### 2. Include the new command in the editor test suite ###
Navigate to the editor test suite `test/unit/unittests_editor.html` and open it.
Within the file, go to the `<!-- command object classes -->` and include the new command:
```javascript
```html
// <!-- command object classes -->
//...
<script src="../../editor/js/CmdSetUuid.js"></script>
<script src="../../editor/js/CmdSetValue.js"></script>
<script src="../../editor/js/CmdXXX.js"></script> // add this line
<script src="../../editor/js/commands/AddScriptCommand.js"></script>
<script src="../../editor/js/commands/DoSomethingCommand.js"></script> // add this line
<script src="../../editor/js/commands/MoveObjectCommand.js"></script>
//...
```
......@@ -36,12 +36,12 @@ It is recommended to keep the script inclusions in alphabetical order, if possib
Next, in the same file, go to `<!-- Undo-Redo tests -->` and include the test file for the new command:
```javascript
```html
// <!-- Undo-Redo tests -->
//...
<script src="editor/TestCmdSetValue.js"></script>
<script src="editor/TestCmdXXX.js"></script> // add this line
<script src="editor/TestNestedDoUndoRedo.js"></script>
<script src="editor/TestAddScriptCommand.js"></script>
<script src="editor/TestDoSomethingCommand.js"></script> // add this line
<script src="editor/TestMoveObjectCommand.js"></script>
//...
```
......@@ -51,12 +51,12 @@ Again, keeping the alphabetical order is recommended.
#### Template ####
Open the unit test file `test/unit/editor/TestCmdXXX.js` and paste following code:
Open the unit test file `test/unit/editor/TestDoSomethingCommand.js` and paste following code:
```javascript
module( "CmdXXX" );
module( "DoSomethingCommand" );
test("Test CmdXXX (Undo and Redo)", function() {
test("Test DoSomethingCommand (Undo and Redo)", function() {
var editor = new Editor();
......@@ -68,19 +68,19 @@ test("Test CmdXXX (Undo and Redo)", function() {
// var perspectiveCamera = aPerspectiveCamera( 'Name your perspectiveCamera' );
// in most cases you'll need to add the object to work with
editor.execute( new CmdAddObject( box ) );
editor.execute( new AddObjectCommand( box ) );
// your test begins here...
});
} );
```
The predefined code is just meant to ease the development, you do not have to stick with it.
However, the test should cover at least one `editor.execute()`, one `editor.undo()` and one `editor.redo()` call.
Best practice is to call `editor.execute( new CmdXXX( {custom parameters} ) )` **twice**. Since you'll have to do one undo (go one step back), it is recommended to have a custom state for comparison. Try to avoid assertions `ok()` against default values.
Best practice is to call `editor.execute( new DoSomethingCommand( {custom parameters} ) )` **twice**. Since you'll have to do one undo (go one step back), it is recommended to have a custom state for comparison. Try to avoid assertions `ok()` against default values.
#### Assertions ####
After performing `editor.execute()` twice, you can do your first assertion to check whether the executes are done correctly.
......
......@@ -124,27 +124,27 @@
<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/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/CmdSetScriptValue.js"></script>
<script src="js/CmdSetMaterial.js"></script>
<script src="js/CmdSetMaterialValue.js"></script>
<script src="js/CmdSetMaterialColor.js"></script>
<script src="js/CmdSetMaterialMap.js"></script>
<script src="js/CmdSetScene.js"></script>
<script src="js/Command.js"></script>
<script src="js/commands/AddObjectCommand.js"></script>
<script src="js/commands/RemoveObjectCommand.js"></script>
<script src="js/commands/MoveObjectCommand.js"></script>
<script src="js/commands/SetPositionCommand.js"></script>
<script src="js/commands/SetRotationCommand.js"></script>
<script src="js/commands/SetScaleCommand.js"></script>
<script src="js/commands/SetValueCommand.js"></script>
<script src="js/commands/SetUuidCommand.js"></script>
<script src="js/commands/SetColorCommand.js"></script>
<script src="js/commands/SetGeometryCommand.js"></script>
<script src="js/commands/SetGeometryValueCommand.js"></script>
<script src="js/commands/MultiCmdsCommand.js"></script>
<script src="js/commands/AddScriptCommand.js"></script>
<script src="js/commands/RemoveScriptCommand.js"></script>
<script src="js/commands/SetScriptValueCommand.js"></script>
<script src="js/commands/SetMaterialCommand.js"></script>
<script src="js/commands/SetMaterialValueCommand.js"></script>
<script src="js/commands/SetMaterialColorCommand.js"></script>
<script src="js/commands/SetMaterialMapCommand.js"></script>
<script src="js/commands/SetSceneCommand.js"></script>
<script>
......@@ -286,7 +286,7 @@
if ( confirm( 'Delete ' + object.name + '?' ) === false ) return;
var parent = object.parent;
if ( parent !== null ) editor.execute( new CmdRemoveObject( object ) );
if ( parent !== null ) editor.execute( new RemoveObjectCommand( object ) );
break;
......
......@@ -9,7 +9,7 @@
* @constructor
*/
Cmd = function ( editorRef ) {
var Command = function ( editorRef ) {
this.id = - 1;
this.inMemory = false;
......@@ -19,15 +19,15 @@ Cmd = function ( editorRef ) {
if ( editorRef !== undefined ) {
Cmd.editor = editorRef;
Command.editor = editorRef;
}
this.editor = Cmd.editor;
this.editor = Command.editor;
};
Cmd.prototype.toJSON = function () {
Command.prototype.toJSON = function () {
var output = {};
output.type = this.type;
......@@ -37,7 +37,7 @@ Cmd.prototype.toJSON = function () {
};
Cmd.prototype.fromJSON = function ( json ) {
Command.prototype.fromJSON = function ( json ) {
this.inMemory = true;
this.type = json.type;
......
......@@ -14,9 +14,9 @@ History = function ( editor ) {
this.historyDisabled = false;
this.config = editor.config;
//Set editor-reference in Cmd
//Set editor-reference in Command
Cmd( editor );
Command( editor );
// signals
......@@ -51,9 +51,9 @@ History.prototype = {
lastCmd.script === cmd.script &&
lastCmd.attributeName === cmd.attributeName;
if ( isUpdatableCmd && cmd.type === "CmdSetScriptValue" ) {
if ( isUpdatableCmd && cmd.type === "SetScriptValueCommand" ) {
// When the cmd.type is "CmdSetScriptValue" the timeDifference is ignored
// When the cmd.type is "SetScriptValueCommand" the timeDifference is ignored
lastCmd.update( cmd );
cmd = lastCmd;
......
......@@ -24,7 +24,7 @@ var Loader = function ( editor ) {
var loader = new THREE.AMFLoader();
var amfobject = loader.parse( event.target.result );
editor.execute( new CmdAddObject( amfobject ) );
editor.execute( new AddObjectCommand( amfobject ) );
}, false );
reader.readAsArrayBuffer( file );
......@@ -39,7 +39,7 @@ var Loader = function ( editor ) {
var loader = new THREE.AWDLoader();
var scene = loader.parse( event.target.result );
editor.execute( new CmdSetScene( scene ) );
editor.execute( new SetSceneCommand( scene ) );
}, false );
reader.readAsArrayBuffer( file );
......@@ -57,7 +57,7 @@ var Loader = function ( editor ) {
var loader = new THREE.BabylonLoader();
var scene = loader.parse( json );
editor.execute( new CmdSetScene( scene ) );
editor.execute( new SetSceneCommand( scene ) );
}, false );
reader.readAsText( file );
......@@ -80,7 +80,7 @@ var Loader = function ( editor ) {
var mesh = new THREE.Mesh( geometry, material );
mesh.name = filename;
editor.execute( new CmdAddObject( mesh ) );
editor.execute( new AddObjectCommand( mesh ) );
}, false );
reader.readAsText( file );
......@@ -108,7 +108,7 @@ var Loader = function ( editor ) {
var mesh = new THREE.Mesh( geometry, material );
mesh.name = filename;
editor.execute( new CmdAddObject( mesh ) );
editor.execute( new AddObjectCommand( mesh ) );
} );
......@@ -129,7 +129,7 @@ var Loader = function ( editor ) {
collada.scene.name = filename;
editor.execute( new CmdAddObject( collada.scene ) );
editor.execute( new AddObjectCommand( collada.scene ) );
}, false );
reader.readAsText( file );
......@@ -204,7 +204,7 @@ var Loader = function ( editor ) {
collada.scene.name = filename;
editor.execute( new CmdAddObject( collada.scene ) );
editor.execute( new AddObjectCommand( collada.scene ) );
}, false );
reader.readAsArrayBuffer( file );
......@@ -228,7 +228,7 @@ var Loader = function ( editor ) {
mesh.mixer = new THREE.AnimationMixer( mesh )
mesh.name = filename;
editor.execute( new CmdAddObject( mesh ) );
editor.execute( new AddObjectCommand( mesh ) );
}, false );
reader.readAsArrayBuffer( file );
......@@ -245,7 +245,7 @@ var Loader = function ( editor ) {
var object = new THREE.OBJLoader().parse( contents );
object.name = filename;
editor.execute( new CmdAddObject( object ) );
editor.execute( new AddObjectCommand( object ) );
}, false );
reader.readAsText( file );
......@@ -263,7 +263,7 @@ var Loader = function ( editor ) {
var loader = new THREE.PlayCanvasLoader();
var object = loader.parse( json );
editor.execute( new CmdAddObject( object ) );
editor.execute( new AddObjectCommand( object ) );
}, false );
reader.readAsText( file );
......@@ -286,7 +286,7 @@ var Loader = function ( editor ) {
var mesh = new THREE.Mesh( geometry, material );
mesh.name = filename;
editor.execute( new CmdAddObject( mesh ) );
editor.execute( new AddObjectCommand( mesh ) );
}, false );
reader.readAsText( file );
......@@ -309,7 +309,7 @@ var Loader = function ( editor ) {
var mesh = new THREE.Mesh( geometry, material );
mesh.name = filename;
editor.execute( new CmdAddObject( mesh ) );
editor.execute( new AddObjectCommand( mesh ) );
}, false );
......@@ -338,7 +338,7 @@ var Loader = function ( editor ) {
var mesh = new THREE.Mesh( geometry, material );
editor.execute( new CmdAddObject( mesh ) );
editor.execute( new AddObjectCommand( mesh ) );
}, false );
reader.readAsBinaryString( file );
......@@ -362,7 +362,7 @@ var Loader = function ( editor ) {
var mesh = new THREE.Mesh( geometry, material );
mesh.name = filename;
editor.execute( new CmdAddObject( mesh ) );
editor.execute( new AddObjectCommand( mesh ) );
}, false );
reader.readAsText( file );
......@@ -378,7 +378,7 @@ var Loader = function ( editor ) {
var result = new THREE.VRMLLoader().parse( contents );
editor.execute( new CmdSetScene( result ) );
editor.execute( new SetSceneCommand( result ) );
}, false );
reader.readAsText( file );
......@@ -422,7 +422,7 @@ var Loader = function ( editor ) {
var mesh = new THREE.Mesh( result );
editor.execute( new CmdAddObject( mesh ) );
editor.execute( new AddObjectCommand( mesh ) );
} else if ( data.metadata.type.toLowerCase() === 'geometry' ) {
......@@ -469,7 +469,7 @@ var Loader = function ( editor ) {
mesh.name = filename;
editor.execute( new CmdAddObject( mesh ) );
editor.execute( new AddObjectCommand( mesh ) );
} else if ( data.metadata.type.toLowerCase() === 'object' ) {
......@@ -480,11 +480,11 @@ var Loader = function ( editor ) {
if ( result instanceof THREE.Scene ) {
editor.execute( new CmdSetScene( result ) );
editor.execute( new SetSceneCommand( result ) );
} else {
editor.execute( new CmdAddObject( result ) );
editor.execute( new AddObjectCommand( result ) );
}
......@@ -495,7 +495,7 @@ var Loader = function ( editor ) {
var loader = new THREE.SceneLoader();
loader.parse( data, function ( result ) {
editor.execute( new CmdSetScene( result.scene ) );
editor.execute( new SetSceneCommand( result.scene ) );
}, '' );
......
......@@ -40,7 +40,7 @@ Menubar.Add = function ( editor ) {
var mesh = new THREE.Group();
mesh.name = 'Group ' + ( ++ meshCount );
editor.execute( new CmdAddObject( mesh ) );
editor.execute( new AddObjectCommand( mesh ) );
} );
options.add( option );
......@@ -67,7 +67,7 @@ Menubar.Add = function ( editor ) {
var mesh = new THREE.Mesh( geometry, material );
mesh.name = 'Plane ' + ( ++ meshCount );
editor.execute( new CmdAddObject( mesh ) );
editor.execute( new AddObjectCommand( mesh ) );
} );
options.add( option );
......@@ -91,7 +91,7 @@ Menubar.Add = function ( editor ) {
var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial() );
mesh.name = 'Box ' + ( ++ meshCount );
editor.execute( new CmdAddObject( mesh ) );
editor.execute( new AddObjectCommand( mesh ) );
} );
options.add( option );
......@@ -110,7 +110,7 @@ Menubar.Add = function ( editor ) {
var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial() );
mesh.name = 'Circle ' + ( ++ meshCount );
editor.execute( new CmdAddObject( mesh ) );
editor.execute( new AddObjectCommand( mesh ) );
} );
options.add( option );
......@@ -133,7 +133,7 @@ Menubar.Add = function ( editor ) {
var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial() );
mesh.name = 'Cylinder ' + ( ++ meshCount );
editor.execute( new CmdAddObject( mesh ) );
editor.execute( new AddObjectCommand( mesh ) );
} );
options.add( option );
......@@ -157,7 +157,7 @@ Menubar.Add = function ( editor ) {
var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial() );
mesh.name = 'Sphere ' + ( ++ meshCount );
editor.execute( new CmdAddObject( mesh ) );
editor.execute( new AddObjectCommand( mesh ) );
} );
options.add( option );
......@@ -176,7 +176,7 @@ Menubar.Add = function ( editor ) {
var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial() );
mesh.name = 'Icosahedron ' + ( ++ meshCount );
editor.execute( new CmdAddObject( mesh ) );
editor.execute( new AddObjectCommand( mesh ) );
} );
options.add( option );
......@@ -198,7 +198,7 @@ Menubar.Add = function ( editor ) {
var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial() );
mesh.name = 'Torus ' + ( ++ meshCount );
editor.execute( new CmdAddObject( mesh ) );
editor.execute( new AddObjectCommand( mesh ) );
} );
options.add( option );
......@@ -222,7 +222,7 @@ Menubar.Add = function ( editor ) {
var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial() );
mesh.name = 'TorusKnot ' + ( ++ meshCount );
editor.execute( new CmdAddObject( mesh ) );
editor.execute( new AddObjectCommand( mesh ) );
} );
options.add( option );
......@@ -267,7 +267,7 @@ Menubar.Add = function ( editor ) {
var sprite = new THREE.Sprite( new THREE.SpriteMaterial() );
sprite.name = 'Sprite ' + ( ++ meshCount );
editor.execute( new CmdAddObject( sprite ) );
editor.execute( new AddObjectCommand( sprite ) );
} );
options.add( option );
......@@ -290,7 +290,7 @@ Menubar.Add = function ( editor ) {
var light = new THREE.PointLight( color, intensity, distance );
light.name = 'PointLight ' + ( ++ lightCount );
editor.execute( new CmdAddObject( light ) );
editor.execute( new AddObjectCommand( light ) );
} );
options.add( option );
......@@ -314,7 +314,7 @@ Menubar.Add = function ( editor ) {
light.position.set( 0.5, 1, 0.75 ).multiplyScalar( 200 );
editor.execute( new CmdAddObject( light ) );
editor.execute( new AddObjectCommand( light ) );
} );
options.add( option );
......@@ -335,7 +335,7 @@ Menubar.Add = function ( editor ) {
light.position.set( 0.5, 1, 0.75 ).multiplyScalar( 200 );
editor.execute( new CmdAddObject( light ) );
editor.execute( new AddObjectCommand( light ) );
} );
options.add( option );
......@@ -356,7 +356,7 @@ Menubar.Add = function ( editor ) {
light.position.set( 0.5, 1, 0.75 ).multiplyScalar( 200 );
editor.execute( new CmdAddObject( light ) );
editor.execute( new AddObjectCommand( light ) );
} );
options.add( option );
......@@ -373,7 +373,7 @@ Menubar.Add = function ( editor ) {
var light = new THREE.AmbientLight( color );
light.name = 'AmbientLight ' + ( ++ lightCount );
editor.execute( new CmdAddObject( light ) );
editor.execute( new AddObjectCommand( light ) );
} );
options.add( option );
......@@ -392,7 +392,7 @@ Menubar.Add = function ( editor ) {
var camera = new THREE.PerspectiveCamera( 50, 1, 1, 10000 );
camera.name = 'PerspectiveCamera ' + ( ++ cameraCount );
editor.execute( new CmdAddObject( camera ) );
editor.execute( new AddObjectCommand( camera ) );
} );
options.add( option );
......
......@@ -95,7 +95,7 @@ Menubar.Edit = function ( editor ) {
object = object.clone();
editor.execute( new CmdAddObject( object ) );
editor.execute( new AddObjectCommand( object ) );
} );
options.add( option );
......@@ -114,7 +114,7 @@ Menubar.Edit = function ( editor ) {
var parent = object.parent;
if ( parent === undefined ) return; // avoid deleting the camera or scene
editor.execute( new CmdRemoveObject( object ) );
editor.execute( new RemoveObjectCommand( object ) );
} );
options.add( option );
......@@ -158,8 +158,8 @@ Menubar.Edit = function ( editor ) {
var shader = glslprep.minifyGlsl( [
material.vertexShader, material.fragmentShader ] );
cmds.push( new CmdSetMaterialValue( object, 'vertexShader', shader[ 0 ] ) );
cmds.push( new CmdSetMaterialValue( object, 'fragmentShader', shader[ 1 ] ) );
cmds.push( new SetMaterialValueCommand( object, 'vertexShader', shader[ 0 ] ) );
cmds.push( new SetMaterialValueCommand( object, 'fragmentShader', shader[ 1 ] ) );
++nMaterialsChanged;
......@@ -189,7 +189,7 @@ Menubar.Edit = function ( editor ) {
if ( nMaterialsChanged > 0 ) {
editor.execute( new CmdMultiCmds( cmds ), 'Minify Shaders' );
editor.execute( new MultiCmdsCommand( cmds ), 'Minify Shaders' );
}
......
......@@ -82,7 +82,7 @@ var Script = function ( editor ) {
if ( value !== currentScript.source ) {
editor.execute( new CmdSetScriptValue( currentObject, currentScript, 'source', value, codemirror.getCursor() ) );
editor.execute( new SetScriptValueCommand( currentObject, currentScript, 'source', value, codemirror.getCursor() ) );
}
return;
......@@ -94,21 +94,21 @@ var Script = function ( editor ) {
if ( JSON.stringify( currentObject.material.defines ) !== JSON.stringify( json.defines ) ) {
var cmd = new CmdSetMaterialValue( currentObject, 'defines', json.defines );
var cmd = new SetMaterialValueCommand( currentObject, 'defines', json.defines );
cmd.updatable = false;
editor.execute( cmd );
}
if ( JSON.stringify( currentObject.material.uniforms ) !== JSON.stringify( json.uniforms ) ) {
var cmd = new CmdSetMaterialValue( currentObject, 'uniforms', json.uniforms );
var cmd = new SetMaterialValueCommand( currentObject, 'uniforms', json.uniforms );
cmd.updatable = false;
editor.execute( cmd );
}
if ( JSON.stringify( currentObject.material.attributes ) !== JSON.stringify( json.attributes ) ) {
var cmd = new CmdSetMaterialValue( currentObject, 'attributes', json.attributes );
var cmd = new SetMaterialValueCommand( currentObject, 'attributes', json.attributes );
cmd.updatable = false;
editor.execute( cmd );
......
......@@ -74,7 +74,7 @@ Sidebar.Geometry.BoxGeometry = function ( editor, object ) {
function update() {
editor.execute( new CmdSetGeometry( object, new THREE.BoxGeometry(
editor.execute( new SetGeometryCommand( object, new THREE.BoxGeometry(
width.getValue(),
height.getValue(),
depth.getValue(),
......
......@@ -54,7 +54,7 @@ Sidebar.Geometry.CircleGeometry = function ( editor, object ) {
function update() {
editor.execute( new CmdSetGeometry( object, new THREE.CircleGeometry(
editor.execute( new SetGeometryCommand( object, new THREE.CircleGeometry(
radius.getValue(),
segments.getValue(),
thetaStart.getValue(),
......
......@@ -74,7 +74,7 @@ Sidebar.Geometry.CylinderGeometry = function ( editor, object ) {
function update() {
editor.execute( new CmdSetGeometry( object, new THREE.CylinderGeometry(
editor.execute( new SetGeometryCommand( object, new THREE.CylinderGeometry(
radiusTop.getValue(),
radiusBottom.getValue(),
height.getValue(),
......
......@@ -35,7 +35,7 @@ Sidebar.Geometry.IcosahedronGeometry = function ( editor, object ) {
function update() {
editor.execute( new CmdSetGeometry( object, new THREE.IcosahedronGeometry(
editor.execute( new SetGeometryCommand( object, new THREE.IcosahedronGeometry(
radius.getValue(),
detail.getValue()
) ) );
......
......@@ -55,7 +55,7 @@ Sidebar.Geometry.PlaneGeometry = function ( editor, object ) {
function update() {
editor.execute( new CmdSetGeometry( object, new THREE.PlaneGeometry(
editor.execute( new SetGeometryCommand( object, new THREE.PlaneGeometry(
width.getValue(),
height.getValue(),
widthSegments.getValue(),
......
......@@ -85,7 +85,7 @@ Sidebar.Geometry.SphereGeometry = function ( editor, object ) {
function update() {
editor.execute( new CmdSetGeometry( object, new THREE.SphereGeometry(
editor.execute( new SetGeometryCommand( object, new THREE.SphereGeometry(
radius.getValue(),
widthSegments.getValue(),
heightSegments.getValue(),
......
......@@ -65,7 +65,7 @@ Sidebar.Geometry.TorusGeometry = function ( editor, object ) {
function update() {
editor.execute( new CmdSetGeometry( object, new THREE.TorusGeometry(
editor.execute( new SetGeometryCommand( object, new THREE.TorusGeometry(
radius.getValue(),
tube.getValue(),
radialSegments.getValue(),
......
......@@ -85,7 +85,7 @@ Sidebar.Geometry.TorusKnotGeometry = function ( editor, object ) {
function update() {
editor.execute( new CmdSetGeometry( object, new THREE.TorusKnotGeometry(
editor.execute( new SetGeometryCommand( object, new THREE.TorusKnotGeometry(
radius.getValue(),
tube.getValue(),
radialSegments.getValue(),
......
......@@ -51,7 +51,7 @@ Sidebar.Geometry = function ( editor ) {
var newPosition = object.position.clone();
newPosition.sub( offset );
editor.execute( new CmdSetPosition( object, newPosition ) );
editor.execute( new SetPositionCommand( object, newPosition ) );
editor.signals.geometryChanged.dispatch( object );
......@@ -61,7 +61,7 @@ Sidebar.Geometry = function ( editor ) {
if ( geometry instanceof THREE.Geometry ) {
editor.execute( new CmdSetGeometry( object, new THREE.BufferGeometry().fromGeometry( geometry ) ) );
editor.execute( new SetGeometryCommand( object, new THREE.BufferGeometry().fromGeometry( geometry ) ) );
}
......@@ -73,12 +73,12 @@ Sidebar.Geometry = function ( editor ) {
newGeometry.uuid = geometry.uuid;
newGeometry.applyMatrix( object.matrix );
var cmds = [ new CmdSetGeometry( object, newGeometry ),
new CmdSetPosition( object, new THREE.Vector3( 0, 0, 0 ) ),
new CmdSetRotation( object, new THREE.Euler( 0, 0, 0 ) ),
new CmdSetScale( object, new THREE.Vector3( 1, 1, 1 ) ) ];
var cmds = [ new SetGeometryCommand( object, newGeometry ),
new SetPositionCommand( object, new THREE.Vector3( 0, 0, 0 ) ),
new SetRotationCommand( object, new THREE.Euler( 0, 0, 0 ) ),
new SetScaleCommand( object, new THREE.Vector3( 1, 1, 1 ) ) ];
editor.execute( new CmdMultiCmds( cmds ), 'Flatten Geometry' );
editor.execute( new MultiCmdsCommand( cmds ), 'Flatten Geometry' );
break;
......@@ -99,7 +99,7 @@ Sidebar.Geometry = function ( editor ) {
geometryUUID.setValue( THREE.Math.generateUUID() );
editor.execute( new CmdSetGeometryValue( editor.selected, 'uuid', geometryUUID.getValue() ) );
editor.execute( new SetGeometryValueCommand( editor.selected, 'uuid', geometryUUID.getValue() ) );
} );
......@@ -114,7 +114,7 @@ Sidebar.Geometry = function ( editor ) {
var geometryNameRow = new UI.Panel();
var geometryName = new UI.Input().setWidth( '150px' ).setFontSize( '12px' ).onChange( function () {
editor.execute( new CmdSetGeometryValue( editor.selected, 'name', geometryName.getValue() ) );
editor.execute( new SetGeometryValueCommand( editor.selected, 'name', geometryName.getValue() ) );
} );
......
......@@ -42,7 +42,7 @@ Sidebar.Material = function ( editor ) {
var materialNameRow = new UI.Panel();
var materialName = new UI.Input().setWidth( '150px' ).setFontSize( '12px' ).onChange( function () {
editor.execute( new CmdSetMaterialValue( editor.selected, 'name', materialName.getValue() ) );
editor.execute( new SetMaterialValueCommand( editor.selected, 'name', materialName.getValue() ) );
} );
......@@ -402,7 +402,7 @@ Sidebar.Material = function ( editor ) {
if ( material.uuid !== undefined && material.uuid !== materialUUID.getValue() ) {
editor.execute( new CmdSetMaterialValue( currentObject, 'uuid', materialUUID.getValue() ) );
editor.execute( new SetMaterialValueCommand( currentObject, 'uuid', materialUUID.getValue() ) );
}
......@@ -410,7 +410,7 @@ Sidebar.Material = function ( editor ) {
material = new THREE[ materialClass.getValue() ]();
editor.execute( new CmdSetMaterial( currentObject, material ), 'New Material: ' + materialClass.getValue() );
editor.execute( new SetMaterialCommand( currentObject, material ), 'New Material: ' + materialClass.getValue() );
// TODO Copy other references in the scene graph
// keeping name and UUID then.
// Also there should be means to create a unique
......@@ -421,25 +421,25 @@ Sidebar.Material = function ( editor ) {
if ( material.color !== undefined && material.color.getHex() !== materialColor.getHexValue() ) {
editor.execute( new CmdSetMaterialColor( currentObject, 'color', materialColor.getHexValue() ) );
editor.execute( new SetMaterialColorCommand( currentObject, 'color', materialColor.getHexValue() ) );
}
if ( material.emissive !== undefined && material.emissive.getHex() !== materialEmissive.getHexValue() ) {
editor.execute( new CmdSetMaterialColor( currentObject, 'emissive', materialEmissive.getHexValue() ) );
editor.execute( new SetMaterialColorCommand( currentObject, 'emissive', materialEmissive.getHexValue() ) );
}
if ( material.specular !== undefined && material.specular.getHex() !== materialSpecular.getHexValue() ) {
editor.execute( new CmdSetMaterialColor( currentObject, 'specular', materialSpecular.getHexValue() ) );
editor.execute( new SetMaterialColorCommand( currentObject, 'specular', materialSpecular.getHexValue() ) );
}
if ( material.shininess !== undefined && Math.abs( material.shininess - materialShininess.getValue() ) >= 0.01 ) {
editor.execute( new CmdSetMaterialValue( currentObject, 'shininess', materialShininess.getValue() ) );
editor.execute( new SetMaterialValueCommand( currentObject, 'shininess', materialShininess.getValue() ) );
}
......@@ -449,7 +449,7 @@ Sidebar.Material = function ( editor ) {
if ( material.vertexColors !== vertexColors ) {
editor.execute( new CmdSetMaterialValue( currentObject, 'vertexColors', vertexColors ) );
editor.execute( new SetMaterialValueCommand( currentObject, 'vertexColors', vertexColors ) );
}
......@@ -457,7 +457,7 @@ Sidebar.Material = function ( editor ) {
if ( material.skinning !== undefined && material.skinning !== materialSkinning.getValue() ) {
editor.execute( new CmdSetMaterialValue( currentObject, 'skinning', materialSkinning.getValue() ) );
editor.execute( new SetMaterialValueCommand( currentObject, 'skinning', materialSkinning.getValue() ) );
}
......@@ -470,7 +470,7 @@ Sidebar.Material = function ( editor ) {
var map = mapEnabled ? materialMap.getValue() : null;
if ( material.map !== map ) {
editor.execute( new CmdSetMaterialMap( currentObject, 'map', map ) );
editor.execute( new SetMaterialMapCommand( currentObject, 'map', map ) );
}
......@@ -491,7 +491,7 @@ Sidebar.Material = function ( editor ) {
var alphaMap = mapEnabled ? materialAlphaMap.getValue() : null;
if ( material.alphaMap !== alphaMap ) {
editor.execute( new CmdSetMaterialMap( currentObject, 'alphaMap', alphaMap ) );
editor.execute( new SetMaterialMapCommand( currentObject, 'alphaMap', alphaMap ) );
}
......@@ -512,13 +512,13 @@ Sidebar.Material = function ( editor ) {
var bumpMap = bumpMapEnabled ? materialBumpMap.getValue() : null;
if ( material.bumpMap !== bumpMap ) {
editor.execute( new CmdSetMaterialMap( currentObject, 'bumpMap', bumpMap ) );
editor.execute( new SetMaterialMapCommand( currentObject, 'bumpMap', bumpMap ) );
}
if ( material.bumpScale !== materialBumpScale.getValue() ) {
editor.execute( new CmdSetMaterialValue( currentObject, 'bumpScale', materialBumpScale.getValue() ) );
editor.execute( new SetMaterialValueCommand( currentObject, 'bumpScale', materialBumpScale.getValue() ) );
}
......@@ -539,7 +539,7 @@ Sidebar.Material = function ( editor ) {
var normalMap = normalMapEnabled ? materialNormalMap.getValue() : null;
if ( material.normalMap !== normalMap ) {
editor.execute( new CmdSetMaterialMap( currentObject, 'normalMap', normalMap ) );
editor.execute( new SetMaterialMapCommand( currentObject, 'normalMap', normalMap ) );
}
......@@ -560,13 +560,13 @@ Sidebar.Material = function ( editor ) {
var displacementMap = displacementMapEnabled ? materialDisplacementMap.getValue() : null;
if ( material.displacementMap !== displacementMap ) {
editor.execute( new CmdSetMaterialMap( currentObject, 'displacementMap', displacementMap ) );
editor.execute( new SetMaterialMapCommand( currentObject, 'displacementMap', displacementMap ) );
}
if ( material.displacementScale !== materialDisplacementScale.getValue() ) {
editor.execute( new CmdSetMaterialValue( currentObject, 'displacementScale', materialDisplacementScale.getValue() ) );
editor.execute( new SetMaterialValueCommand( currentObject, 'displacementScale', materialDisplacementScale.getValue() ) );
}
......@@ -587,7 +587,7 @@ Sidebar.Material = function ( editor ) {
var specularMap = specularMapEnabled ? materialSpecularMap.getValue() : null;
if ( material.specularMap !== specularMap ) {
editor.execute( new CmdSetMaterialMap( currentObject, 'specularMap', specularMap ) );
editor.execute( new SetMaterialMapCommand( currentObject, 'specularMap', specularMap ) );
}
......@@ -607,13 +607,13 @@ Sidebar.Material = function ( editor ) {
if ( material.envMap !== envMap ) {
editor.execute( new CmdSetMaterialMap( currentObject, 'envMap', envMap ) );
editor.execute( new SetMaterialMapCommand( currentObject, 'envMap', envMap ) );
}
if ( material.reflectivity !== materialReflectivity.getValue() ) {
editor.execute( new CmdSetMaterialValue( currentObject, 'reflectivity', materialReflectivity.getValue() ) );
editor.execute( new SetMaterialValueCommand( currentObject, 'reflectivity', materialReflectivity.getValue() ) );
}
......@@ -628,7 +628,7 @@ Sidebar.Material = function ( editor ) {
var lightMap = lightMapEnabled ? materialLightMap.getValue() : null;
if ( material.lightMap !== lightMap ) {
editor.execute( new CmdSetMaterialMap( currentObject, 'lightMap', lightMap ) );
editor.execute( new SetMaterialMapCommand( currentObject, 'lightMap', lightMap ) );
}
......@@ -649,13 +649,13 @@ Sidebar.Material = function ( editor ) {
var aoMap = aoMapEnabled ? materialAOMap.getValue() : null;
if ( material.aoMap !== aoMap ) {
editor.execute( new CmdSetMaterialMap( currentObject, 'aoMap', aoMap ) );
editor.execute( new SetMaterialMapCommand( currentObject, 'aoMap', aoMap ) );
}
if ( material.aoMapIntensity !== materialAOScale.getValue() ) {
editor.execute( new CmdSetMaterialValue( currentObject, 'aoMapIntensity', materialAOScale.getValue() ) );
editor.execute( new SetMaterialValueCommand( currentObject, 'aoMapIntensity', materialAOScale.getValue() ) );
}
......@@ -672,7 +672,7 @@ Sidebar.Material = function ( editor ) {
var side = parseInt( materialSide.getValue() );
if ( material.side !== side ) {
editor.execute( new CmdSetMaterialValue( currentObject, 'side', side ) );
editor.execute( new SetMaterialValueCommand( currentObject, 'side', side ) );
}
......@@ -684,7 +684,7 @@ Sidebar.Material = function ( editor ) {
var shading = parseInt( materialShading.getValue() );
if ( material.shading !== shading ) {
editor.execute( new CmdSetMaterialValue( currentObject, 'shading', shading ) );
editor.execute( new SetMaterialValueCommand( currentObject, 'shading', shading ) );
}
......@@ -695,7 +695,7 @@ Sidebar.Material = function ( editor ) {
var blending = parseInt( materialBlending.getValue() );
if ( material.blending !== blending ) {
editor.execute( new CmdSetMaterialValue( currentObject, 'blending', blending ) );
editor.execute( new SetMaterialValueCommand( currentObject, 'blending', blending ) );
}
......@@ -703,31 +703,31 @@ Sidebar.Material = function ( editor ) {
if ( material.opacity !== undefined && Math.abs( material.opacity - materialOpacity.getValue() ) >= 0.01 ) {
editor.execute( new CmdSetMaterialValue( currentObject, 'opacity', materialOpacity.getValue() ) );
editor.execute( new SetMaterialValueCommand( currentObject, 'opacity', materialOpacity.getValue() ) );
}
if ( material.transparent !== undefined && material.transparent !== materialTransparent.getValue() ) {
editor.execute( new CmdSetMaterialValue( currentObject, 'transparent', materialTransparent.getValue() ) );
editor.execute( new SetMaterialValueCommand( currentObject, 'transparent', materialTransparent.getValue() ) );
}
if ( material.alphaTest !== undefined && Math.abs( material.alphaTest - materialAlphaTest.getValue() ) >= 0.01 ) {
editor.execute( new CmdSetMaterialValue( currentObject, 'alphaTest', materialAlphaTest.getValue() ) );
editor.execute( new SetMaterialValueCommand( currentObject, 'alphaTest', materialAlphaTest.getValue() ) );
}
if ( material.wireframe !== undefined && material.wireframe !== materialWireframe.getValue() ) {
editor.execute( new CmdSetMaterialValue( currentObject, 'wireframe', materialWireframe.getValue() ) );
editor.execute( new SetMaterialValueCommand( currentObject, 'wireframe', materialWireframe.getValue() ) );
}
if ( material.wireframeLinewidth !== undefined && Math.abs( material.wireframeLinewidth - materialWireframeLinewidth.getValue() ) >= 0.01 ) {
editor.execute( new CmdSetMaterialValue( currentObject, 'wireframeLinewidth', materialWireframeLinewidth.getValue() ) );
editor.execute( new SetMaterialValueCommand( currentObject, 'wireframeLinewidth', materialWireframeLinewidth.getValue() ) );
}
......
......@@ -41,15 +41,15 @@ Sidebar.Object3D = function ( editor ) {
switch ( this.getValue() ) {
case 'Reset Position':
editor.execute( new CmdSetPosition( object, new THREE.Vector3( 0, 0, 0 ) ) );
editor.execute( new SetPositionCommand( object, new THREE.Vector3( 0, 0, 0 ) ) );
break;
case 'Reset Rotation':
editor.execute( new CmdSetRotation( object, new THREE.Euler( 0, 0, 0 ) ) );
editor.execute( new SetRotationCommand( object, new THREE.Euler( 0, 0, 0 ) ) );
break;
case 'Reset Scale':
editor.execute( new CmdSetScale( object, new THREE.Vector3( 1, 1, 1 ) ) );
editor.execute( new SetScaleCommand( object, new THREE.Vector3( 1, 1, 1 ) ) );
break;
}
......@@ -69,7 +69,7 @@ Sidebar.Object3D = function ( editor ) {
objectUUID.setValue( THREE.Math.generateUUID() );
editor.execute( new CmdSetUuid( editor.selected, objectUUID.getValue() ) );
editor.execute( new SetUuidCommand( editor.selected, objectUUID.getValue() ) );
} );
......@@ -84,7 +84,7 @@ Sidebar.Object3D = function ( editor ) {
var objectNameRow = new UI.Panel();
var objectName = new UI.Input().setWidth( '150px' ).setFontSize( '12px' ).onChange( function () {
editor.execute( new CmdSetValue( editor.selected, 'name', objectName.getValue() ) );
editor.execute( new SetValueCommand( editor.selected, 'name', objectName.getValue() ) );
} );
......@@ -373,7 +373,7 @@ Sidebar.Object3D = function ( editor ) {
if ( object.parent.id !== newParentId && object.id !== newParentId ) {
editor.execute( new CmdMoveObject( object, editor.scene.getObjectById( newParentId ) ) );
editor.execute( new MoveObjectCommand( object, editor.scene.getObjectById( newParentId ) ) );
}
......@@ -383,100 +383,100 @@ Sidebar.Object3D = function ( editor ) {
var newPosition = new THREE.Vector3( objectPositionX.getValue(), objectPositionY.getValue(), objectPositionZ.getValue() );
if ( object.position.distanceTo( newPosition ) >= 0.01 ) {
editor.execute( new CmdSetPosition( object, newPosition ) );
editor.execute( new SetPositionCommand( object, newPosition ) );
}
var newRotation = new THREE.Euler( objectRotationX.getValue(), objectRotationY.getValue(), objectRotationZ.getValue() );
if ( object.rotation.toVector3().distanceTo( newRotation.toVector3() ) >= 0.01 ) {
editor.execute( new CmdSetRotation( object, newRotation ) );
editor.execute( new SetRotationCommand( object, newRotation ) );
}
var newScale = new THREE.Vector3( objectScaleX.getValue(), objectScaleY.getValue(), objectScaleZ.getValue() );
if ( object.scale.distanceTo( newScale ) >= 0.01 ) {
editor.execute( new CmdSetScale( object, newScale ) );
editor.execute( new SetScaleCommand( object, newScale ) );
}
if ( object.fov !== undefined && Math.abs( object.fov - objectFov.getValue() ) >= 0.01 ) {
editor.execute( new CmdSetValue( object, 'fov', objectFov.getValue() ) );
editor.execute( new SetValueCommand( object, 'fov', objectFov.getValue() ) );
object.updateProjectionMatrix();
}
if ( object.near !== undefined && Math.abs( object.near - objectNear.getValue() ) >= 0.01 ) {
editor.execute( new CmdSetValue( object, 'near', objectNear.getValue() ) );
editor.execute( new SetValueCommand( object, 'near', objectNear.getValue() ) );
}
if ( object.far !== undefined && Math.abs( object.far - objectFar.getValue() ) >= 0.01 ) {
editor.execute( new CmdSetValue( object, 'far', objectFar.getValue() ) );
editor.execute( new SetValueCommand( object, 'far', objectFar.getValue() ) );
}
if ( object.intensity !== undefined && Math.abs( object.intensity - objectIntensity.getValue() ) >= 0.01 ) {
editor.execute( new CmdSetValue( object, 'intensity', objectIntensity.getValue() ) );
editor.execute( new SetValueCommand( object, 'intensity', objectIntensity.getValue() ) );
}
if ( object.color !== undefined && object.color.getHex() !== objectColor.getHexValue() ) {
editor.execute( new CmdSetColor( object, 'color', objectColor.getHexValue() ) );
editor.execute( new SetColorCommand( object, 'color', objectColor.getHexValue() ) );
}
if ( object.groundColor !== undefined && object.groundColor.getHex() !== objectGroundColor.getHexValue() ) {
editor.execute( new CmdSetColor( object, 'groundColor', objectGroundColor.getHexValue() ) );
editor.execute( new SetColorCommand( object, 'groundColor', objectGroundColor.getHexValue() ) );
}
if ( object.distance !== undefined && Math.abs( object.distance - objectDistance.getValue() ) >= 0.01 ) {
editor.execute( new CmdSetValue( object, 'distance', objectDistance.getValue() ) );
editor.execute( new SetValueCommand( object, 'distance', objectDistance.getValue() ) );
}
if ( object.angle !== undefined && Math.abs( object.angle - objectAngle.getValue() ) >= 0.01 ) {
editor.execute( new CmdSetValue( object, 'angle', objectAngle.getValue() ) );
editor.execute( new SetValueCommand( object, 'angle', objectAngle.getValue() ) );
}
if ( object.exponent !== undefined && Math.abs( object.exponent - objectExponent.getValue() ) >= 0.01 ) {
editor.execute( new CmdSetValue( object, 'exponent', objectExponent.getValue() ) );
editor.execute( new SetValueCommand( object, 'exponent', objectExponent.getValue() ) );
}
if ( object.decay !== undefined && Math.abs( object.decay - objectDecay.getValue() ) >= 0.01 ) {
editor.execute( new CmdSetValue( object, 'decay', objectDecay.getValue() ) );
editor.execute( new SetValueCommand( object, 'decay', objectDecay.getValue() ) );
}
if ( object.visible !== objectVisible.getValue() ) {
editor.execute( new CmdSetValue( object, 'visible', objectVisible.getValue() ) );
editor.execute( new SetValueCommand( object, 'visible', objectVisible.getValue() ) );
}
if ( object.castShadow !== objectCastShadow.getValue() ) {
editor.execute( new CmdSetValue( object, 'castShadow', objectCastShadow.getValue() ) );
editor.execute( new SetValueCommand( object, 'castShadow', objectCastShadow.getValue() ) );
}
if ( object.receiveShadow !== objectReceiveShadow.getValue() ) {
editor.execute( new CmdSetValue( object, 'receiveShadow', objectReceiveShadow.getValue() ) );
editor.execute( new SetValueCommand( object, 'receiveShadow', objectReceiveShadow.getValue() ) );
object.material.needsUpdate = true;
}
......@@ -486,7 +486,7 @@ Sidebar.Object3D = function ( editor ) {
var userData = JSON.parse( objectUserData.getValue() );
if ( JSON.stringify( object.userData ) != JSON.stringify( userData ) ) {
editor.execute( new CmdSetValue( object, 'userData', userData ) );
editor.execute( new SetValueCommand( object, 'userData', userData ) );
}
......
......@@ -27,7 +27,7 @@ Sidebar.Script = function ( editor ) {
newScript.onClick( function () {
var script = { name: '', source: 'function update( event ) {}' };
editor.execute( new CmdAddScript( editor.selected, script ) );
editor.execute( new AddScriptCommand( editor.selected, script ) );
} );
container.add( newScript );
......@@ -63,7 +63,7 @@ Sidebar.Script = function ( editor ) {
var name = new UI.Input( script.name ).setWidth( '130px' ).setFontSize( '12px' );
name.onChange( function () {
editor.execute( new CmdSetScriptValue( editor.selected, script, 'name', this.getValue() ) );
editor.execute( new SetScriptValueCommand( editor.selected, script, 'name', this.getValue() ) );
} );
scriptsContainer.add( name );
......@@ -83,7 +83,7 @@ Sidebar.Script = function ( editor ) {
if ( confirm( 'Are you sure?' ) ) {
editor.execute( new CmdRemoveScript( editor.selected, script ) );
editor.execute( new RemoveScriptCommand( editor.selected, script ) );
}
......
......@@ -82,21 +82,21 @@ var Viewport = function ( editor ) {
case 'translate':
if (!objectPositionOnDown.equals(object.position)) {
editor.execute(new CmdSetPosition( object, object.position, objectPositionOnDown ));
editor.execute(new SetPositionCommand( object, object.position, objectPositionOnDown ));
}
break;
case 'rotate':
if (!objectRotationOnDown.equals(object.rotation)) {
editor.execute(new CmdSetRotation( object, object.rotation, objectRotationOnDown ));
editor.execute(new SetRotationCommand( object, object.rotation, objectRotationOnDown ));
}
break;
case 'scale':
if (!objectScaleOnDown.equals(object.scale)) {
editor.execute(new CmdSetScale( object, object.scale, objectScaleOnDown ));
editor.execute(new SetScaleCommand( object, object.scale, objectScaleOnDown ));
}
break;
......
......@@ -8,11 +8,11 @@
* @constructor
*/
CmdAddObject = function ( object ) {
var AddObjectCommand = function ( object ) {
Cmd.call( this );
Command.call( this );
this.type = 'CmdAddObject';
this.type = 'AddObjectCommand';
this.object = object;
if ( object !== undefined ) {
......@@ -23,7 +23,7 @@ CmdAddObject = function ( object ) {
};
CmdAddObject.prototype = {
AddObjectCommand.prototype = {
execute: function () {
......@@ -41,7 +41,7 @@ CmdAddObject.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
output.object = this.object.toJSON();
return output;
......@@ -50,7 +50,7 @@ CmdAddObject.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
this.object = this.editor.objectByUuid( json.object.object.uuid );
......
......@@ -9,11 +9,11 @@
* @constructor
*/
CmdAddScript = function ( object, script ) {
var AddScriptCommand = function ( object, script ) {
Cmd.call( this );
Command.call( this );
this.type = 'CmdAddScript';
this.type = 'AddScriptCommand';
this.name = 'Add Script';
this.object = object;
......@@ -21,7 +21,7 @@ CmdAddScript = function ( object, script ) {
};
CmdAddScript.prototype = {
AddScriptCommand.prototype = {
execute: function () {
......@@ -55,7 +55,7 @@ CmdAddScript.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
output.objectUuid = this.object.uuid;
output.script = this.script;
......@@ -66,7 +66,7 @@ CmdAddScript.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
this.script = json.script;
this.object = this.editor.objectByUuid( json.objectUuid );
......
......@@ -10,11 +10,11 @@
* @constructor
*/
CmdMoveObject = function ( object, newParent, newBefore ) {
var MoveObjectCommand = function ( object, newParent, newBefore ) {
Cmd.call( this );
Command.call( this );
this.type = 'CmdMoveObject';
this.type = 'MoveObjectCommand';
this.name = 'Move Object';
this.object = object;
......@@ -42,7 +42,7 @@ CmdMoveObject = function ( object, newParent, newBefore ) {
};
CmdMoveObject.prototype = {
MoveObjectCommand.prototype = {
execute: function () {
......@@ -70,7 +70,7 @@ CmdMoveObject.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
output.objectUuid = this.object.uuid;
output.newParentUuid = this.newParent.uuid;
......@@ -84,7 +84,7 @@ CmdMoveObject.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
this.object = this.editor.objectByUuid( json.objectUuid );
this.oldParent = this.editor.objectByUuid( json.oldParentUuid );
......
......@@ -8,18 +8,18 @@
* @constructor
*/
CmdMultiCmds = function ( cmdArray ) {
var MultiCmdsCommand = function ( cmdArray ) {
Cmd.call( this );
Command.call( this );
this.type = 'CmdMultiCmds';
this.type = 'MultiCmdsCommand';
this.name = 'Multiple Changes';
this.cmdArray = ( cmdArray !== undefined ) ? cmdArray : [];
};
CmdMultiCmds.prototype = {
MultiCmdsCommand.prototype = {
execute: function () {
......@@ -53,7 +53,7 @@ CmdMultiCmds.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
var cmds = [];
for ( var i = 0; i < this.cmdArray.length; i ++ ) {
......@@ -69,7 +69,7 @@ CmdMultiCmds.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
var cmds = json.cmds;
for ( var i = 0; i < cmds.length; i ++ ) {
......
......@@ -8,11 +8,11 @@
* @constructor
*/
CmdRemoveObject = function ( object ) {
var RemoveObjectCommand = function ( object ) {
Cmd.call( this );
Command.call( this );
this.type = 'CmdRemoveObject';
this.type = 'RemoveObjectCommand';
this.name = 'Remove Object';
this.object = object;
......@@ -25,7 +25,7 @@ CmdRemoveObject = function ( object ) {
};
CmdRemoveObject.prototype = {
RemoveObjectCommand.prototype = {
execute: function () {
......@@ -68,7 +68,7 @@ CmdRemoveObject.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
output.object = this.object.toJSON();
output.index = this.index;
output.parentUuid = this.parent.uuid;
......@@ -79,7 +79,7 @@ CmdRemoveObject.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
this.parent = this.editor.objectByUuid( json.parentUuid );
if ( this.parent === undefined ) {
......
......@@ -9,11 +9,11 @@
* @constructor
*/
CmdRemoveScript = function ( object, script ) {
var RemoveScriptCommand = function ( object, script ) {
Cmd.call( this );
Command.call( this );
this.type = 'CmdRemoveScript';
this.type = 'RemoveScriptCommand';
this.name = 'Remove Script';
this.object = object;
......@@ -26,7 +26,7 @@ CmdRemoveScript = function ( object, script ) {
};
CmdRemoveScript.prototype = {
RemoveScriptCommand.prototype = {
execute: function () {
......@@ -58,7 +58,7 @@ CmdRemoveScript.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
output.objectUuid = this.object.uuid;
output.script = this.script;
......@@ -70,7 +70,7 @@ CmdRemoveScript.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
this.script = json.script;
this.index = json.index;
......
......@@ -10,11 +10,11 @@
* @constructor
*/
CmdSetColor = function ( object, attributeName, newValue ) {
var SetColorCommand = function ( object, attributeName, newValue ) {
Cmd.call( this );
Command.call( this );
this.type = 'CmdSetColor';
this.type = 'SetColorCommand';
this.name = 'Set ' + attributeName;
this.updatable = true;
......@@ -25,7 +25,7 @@ CmdSetColor = function ( object, attributeName, newValue ) {
};
CmdSetColor.prototype = {
SetColorCommand.prototype = {
execute: function () {
......@@ -49,7 +49,7 @@ CmdSetColor.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
output.objectUuid = this.object.uuid;
output.attributeName = this.attributeName;
......@@ -62,7 +62,7 @@ CmdSetColor.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
this.object = this.editor.objectByUuid( json.objectUuid );
this.attributeName = json.attributeName;
......
......@@ -9,11 +9,11 @@
* @constructor
*/
CmdSetGeometry = function ( object, newGeometry ) {
var SetGeometryCommand = function ( object, newGeometry ) {
Cmd.call( this );
Command.call( this );
this.type = 'CmdSetGeometry';
this.type = 'SetGeometryCommand';
this.name = 'Set Geometry';
this.updatable = true;
......@@ -23,7 +23,7 @@ CmdSetGeometry = function ( object, newGeometry ) {
};
CmdSetGeometry.prototype = {
SetGeometryCommand.prototype = {
execute: function () {
......@@ -55,7 +55,7 @@ CmdSetGeometry.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
output.objectUuid = this.object.uuid;
output.oldGeometry = this.object.geometry.toJSON();
......@@ -67,7 +67,7 @@ CmdSetGeometry.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
this.object = this.editor.objectByUuid( json.objectUuid );
......
......@@ -10,11 +10,11 @@
* @constructor
*/
CmdSetGeometryValue = function ( object, attributeName, newValue ) {
var SetGeometryValueCommand = function ( object, attributeName, newValue ) {
Cmd.call( this );
Command.call( this );
this.type = 'CmdSetGeometryValue';
this.type = 'SetGeometryValueCommand';
this.name = 'Set Geometry.' + attributeName;
this.object = object;
......@@ -24,7 +24,7 @@ CmdSetGeometryValue = function ( object, attributeName, newValue ) {
};
CmdSetGeometryValue.prototype = {
SetGeometryValueCommand.prototype = {
execute: function () {
......@@ -46,7 +46,7 @@ CmdSetGeometryValue.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
output.objectUuid = this.object.uuid;
output.attributeName = this.attributeName;
......@@ -59,7 +59,7 @@ CmdSetGeometryValue.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
this.object = this.editor.objectByUuid( json.objectUuid );
this.attributeName = json.attributeName;
......
......@@ -10,11 +10,11 @@
* @constructor
*/
CmdSetMaterialColor = function ( object, attributeName, newValue ) {
var SetMaterialColorCommand = function ( object, attributeName, newValue ) {
Cmd.call( this );
Command.call( this );
this.type = 'CmdSetMaterialColor';
this.type = 'SetMaterialColorCommand';
this.name = 'Set Material.' + attributeName;
this.updatable = true;
......@@ -25,7 +25,7 @@ CmdSetMaterialColor = function ( object, attributeName, newValue ) {
};
CmdSetMaterialColor.prototype = {
SetMaterialColorCommand.prototype = {
execute: function () {
......@@ -49,7 +49,7 @@ CmdSetMaterialColor.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
output.objectUuid = this.object.uuid;
output.attributeName = this.attributeName;
......@@ -62,7 +62,7 @@ CmdSetMaterialColor.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
this.object = this.editor.objectByUuid( json.objectUuid );
this.attributeName = json.attributeName;
......
......@@ -9,11 +9,11 @@
* @constructor
*/
CmdSetMaterial = function ( object, newMaterial ) {
var SetMaterialCommand = function ( object, newMaterial ) {
Cmd.call( this );
Command.call( this );
this.type = 'CmdSetMaterial';
this.type = 'SetMaterialCommand';
this.name = 'New Material';
this.object = object;
......@@ -22,7 +22,7 @@ CmdSetMaterial = function ( object, newMaterial ) {
};
CmdSetMaterial.prototype = {
SetMaterialCommand.prototype = {
execute: function () {
......@@ -40,7 +40,7 @@ CmdSetMaterial.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
output.objectUuid = this.object.uuid;
output.oldMaterial = this.oldMaterial.toJSON();
......@@ -52,7 +52,7 @@ CmdSetMaterial.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
this.object = this.editor.objectByUuid( json.objectUuid );
this.oldMaterial = parseMaterial( json.oldMaterial );
......
......@@ -10,10 +10,10 @@
* @constructor
*/
CmdSetMaterialMap = function ( object, mapName, newMap ) {
var SetMaterialMapCommand = function ( object, mapName, newMap ) {
Cmd.call( this );
this.type = 'CmdSetMaterialMap';
Command.call( this );
this.type = 'SetMaterialMapCommand';
this.name = 'Set Material.' + mapName;
this.object = object;
......@@ -23,7 +23,7 @@ CmdSetMaterialMap = function ( object, mapName, newMap ) {
};
CmdSetMaterialMap.prototype = {
SetMaterialMapCommand.prototype = {
execute: function () {
......@@ -43,7 +43,7 @@ CmdSetMaterialMap.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
output.objectUuid = this.object.uuid;
output.mapName = this.mapName;
......@@ -97,7 +97,7 @@ CmdSetMaterialMap.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
this.object = this.editor.objectByUuid( json.objectUuid );
this.mapName = json.mapName;
......
......@@ -10,11 +10,11 @@
* @constructor
*/
CmdSetMaterialValue = function ( object, attributeName, newValue ) {
var SetMaterialValueCommand = function ( object, attributeName, newValue ) {
Cmd.call( this );
Command.call( this );
this.type = 'CmdSetMaterialValue';
this.type = 'SetMaterialValueCommand';
this.name = 'Set Material.' + attributeName;
this.updatable = true;
......@@ -25,7 +25,7 @@ CmdSetMaterialValue = function ( object, attributeName, newValue ) {
};
CmdSetMaterialValue.prototype = {
SetMaterialValueCommand.prototype = {
execute: function () {
......@@ -51,7 +51,7 @@ CmdSetMaterialValue.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
output.objectUuid = this.object.uuid;
output.attributeName = this.attributeName;
......@@ -64,7 +64,7 @@ CmdSetMaterialValue.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
this.attributeName = json.attributeName;
this.oldValue = json.oldValue;
......
......@@ -10,11 +10,11 @@
* @constructor
*/
CmdSetPosition = function ( object, newPosition, optionalOldPosition ) {
var SetPositionCommand = function ( object, newPosition, optionalOldPosition ) {
Cmd.call( this );
Command.call( this );
this.type = 'CmdSetPosition';
this.type = 'SetPositionCommand';
this.name = 'Set Position';
this.updatable = true;
......@@ -34,7 +34,7 @@ CmdSetPosition = function ( object, newPosition, optionalOldPosition ) {
}
};
CmdSetPosition.prototype = {
SetPositionCommand.prototype = {
execute: function () {
......@@ -60,7 +60,7 @@ CmdSetPosition.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
output.objectUuid = this.object.uuid;
output.oldPosition = this.oldPosition.toArray();
......@@ -72,7 +72,7 @@ CmdSetPosition.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
this.object = this.editor.objectByUuid( json.objectUuid );
this.oldPosition = new THREE.Vector3().fromArray( json.oldPosition );
......
......@@ -10,11 +10,11 @@
* @constructor
*/
CmdSetRotation = function ( object, newRotation, optionalOldRotation ) {
var SetRotationCommand = function ( object, newRotation, optionalOldRotation ) {
Cmd.call( this );
Command.call( this );
this.type = 'CmdSetRotation';
this.type = 'SetRotationCommand';
this.name = 'Set Rotation';
this.updatable = true;
......@@ -35,7 +35,7 @@ CmdSetRotation = function ( object, newRotation, optionalOldRotation ) {
};
CmdSetRotation.prototype = {
SetRotationCommand.prototype = {
execute: function () {
......@@ -61,7 +61,7 @@ CmdSetRotation.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
output.objectUuid = this.object.uuid;
output.oldRotation = this.oldRotation.toArray();
......@@ -73,7 +73,7 @@ CmdSetRotation.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
this.object = this.editor.objectByUuid( json.objectUuid );
this.oldRotation = new THREE.Euler().fromArray( json.oldRotation );
......
......@@ -10,11 +10,11 @@
* @constructor
*/
CmdSetScale = function ( object, newScale, optionalOldScale ) {
var SetScaleCommand = function ( object, newScale, optionalOldScale ) {
Cmd.call( this );
Command.call( this );
this.type = 'CmdSetScale';
this.type = 'SetScaleCommand';
this.name = 'Set Scale';
this.updatable = true;
......@@ -35,7 +35,7 @@ CmdSetScale = function ( object, newScale, optionalOldScale ) {
};
CmdSetScale.prototype = {
SetScaleCommand.prototype = {
execute: function () {
......@@ -61,7 +61,7 @@ CmdSetScale.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
output.objectUuid = this.object.uuid;
output.oldScale = this.oldScale.toArray();
......@@ -73,7 +73,7 @@ CmdSetScale.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
this.object = this.editor.objectByUuid( json.objectUuid );
this.oldScale = new THREE.Vector3().fromArray( json.oldScale );
......
......@@ -8,25 +8,25 @@
* @constructor
*/
CmdSetScene = function ( scene ) {
var SetSceneCommand = function ( scene ) {
Cmd.call( this );
Command.call( this );
this.type = 'CmdSetScene';
this.type = 'SetSceneCommand';
this.name = 'Set Scene';
this.cmdArray = [];
if ( scene !== undefined ) {
this.cmdArray.push( new CmdSetUuid( this.editor.scene, scene.uuid ) );
this.cmdArray.push( new CmdSetValue( this.editor.scene, 'name', scene.name ) );
this.cmdArray.push( new CmdSetValue( this.editor.scene, 'userData', JSON.parse( JSON.stringify( scene.userData ) ) ) );
this.cmdArray.push( new SetUuidCommand( this.editor.scene, scene.uuid ) );
this.cmdArray.push( new SetValueCommand( this.editor.scene, 'name', scene.name ) );
this.cmdArray.push( new SetValueCommand( this.editor.scene, 'userData', JSON.parse( JSON.stringify( scene.userData ) ) ) );
while ( scene.children.length > 0 ) {
var child = scene.children.pop();
this.cmdArray.push( new CmdAddObject( child ) );
this.cmdArray.push( new AddObjectCommand( child ) );
}
......@@ -34,7 +34,7 @@ CmdSetScene = function ( scene ) {
};
CmdSetScene.prototype = {
SetSceneCommand.prototype = {
execute: function () {
......@@ -68,7 +68,7 @@ CmdSetScene.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
var cmds = [];
for ( var i = 0; i < this.cmdArray.length; i ++ ) {
......@@ -84,7 +84,7 @@ CmdSetScene.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
var cmds = json.cmds;
for ( var i = 0; i < cmds.length; i ++ ) {
......
......@@ -12,11 +12,11 @@
* @constructor
*/
CmdSetScriptValue = function ( object, script, attributeName, newValue, cursorPosition ) {
var SetScriptValueCommand = function ( object, script, attributeName, newValue, cursorPosition ) {
Cmd.call( this );
Command.call( this );
this.type = 'CmdSetScriptValue';
this.type = 'SetScriptValueCommand';
this.name = 'Set Script.' + attributeName;
this.updatable = true;
......@@ -30,7 +30,7 @@ CmdSetScriptValue = function ( object, script, attributeName, newValue, cursorPo
};
CmdSetScriptValue.prototype = {
SetScriptValueCommand.prototype = {
execute: function () {
......@@ -59,7 +59,7 @@ CmdSetScriptValue.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
output.objectUuid = this.object.uuid;
output.index = this.editor.scripts[ this.object.uuid ].indexOf( this.script );
......@@ -74,7 +74,7 @@ CmdSetScriptValue.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
this.oldValue = json.oldValue;
this.newValue = json.newValue;
......
......@@ -9,11 +9,11 @@
* @constructor
*/
CmdSetUuid = function ( object, newUuid ) {
var SetUuidCommand = function ( object, newUuid ) {
Cmd.call( this );
Command.call( this );
this.type = 'CmdSetUuid';
this.type = 'SetUuidCommand';
this.name = 'Update UUID';
this.object = object;
......@@ -23,7 +23,7 @@ CmdSetUuid = function ( object, newUuid ) {
};
CmdSetUuid.prototype = {
SetUuidCommand.prototype = {
execute: function () {
......@@ -43,7 +43,7 @@ CmdSetUuid.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
output.oldUuid = this.oldUuid;
output.newUuid = this.newUuid;
......@@ -54,7 +54,7 @@ CmdSetUuid.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
this.oldUuid = json.oldUuid;
this.newUuid = json.newUuid;
......
......@@ -10,11 +10,11 @@
* @constructor
*/
CmdSetValue = function ( object, attributeName, newValue ) {
var SetValueCommand = function ( object, attributeName, newValue ) {
Cmd.call( this );
Command.call( this );
this.type = 'CmdSetValue';
this.type = 'SetValueCommand';
this.name = 'Set ' + attributeName;
this.updatable = true;
......@@ -25,7 +25,7 @@ CmdSetValue = function ( object, attributeName, newValue ) {
};
CmdSetValue.prototype = {
SetValueCommand.prototype = {
execute: function () {
......@@ -51,7 +51,7 @@ CmdSetValue.prototype = {
toJSON: function () {
var output = Cmd.prototype.toJSON.call( this );
var output = Command.prototype.toJSON.call( this );
output.objectUuid = this.object.uuid;
output.attributeName = this.attributeName;
......@@ -64,7 +64,7 @@ CmdSetValue.prototype = {
fromJSON: function ( json ) {
Cmd.prototype.fromJSON.call( this, json );
Command.prototype.fromJSON.call( this, json );
this.attributeName = json.attributeName;
this.oldValue = json.oldValue;
......
......@@ -158,12 +158,12 @@ UI.Outliner = function ( editor ) {
if ( item.nextSibling === null ) {
editor.execute( new CmdMoveObject( object, editor.scene ) );
editor.execute( new MoveObjectCommand( object, editor.scene ) );
} else {
var nextObject = scene.getObjectById( item.nextSibling.value );
editor.execute( new CmdMoveObject( object, nextObject.parent, nextObject ) );
editor.execute( new MoveObjectCommand( object, nextObject.parent, nextObject ) );
}
......
......@@ -3,9 +3,9 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module( "CmdAddObjectAndCmdRemoveObject" );
module( "AddObjectCommandAndRemoveObjectCommand" );
test( "Test CmdAddObject and CmdRemoveObject (Undo and Redo)", function() {
test( "Test AddObjectCommand and RemoveObjectCommand (Undo and Redo)", function() {
// setup
var editor = new Editor();
......@@ -19,7 +19,7 @@ test( "Test CmdAddObject and CmdRemoveObject (Undo and Redo)", function() {
objects.map( function( object ) {
// Test Add
var cmd = new CmdAddObject( object );
var cmd = new AddObjectCommand( object );
cmd.updatable = false;
editor.execute( cmd );
......@@ -35,7 +35,7 @@ test( "Test CmdAddObject and CmdRemoveObject (Undo and Redo)", function() {
// Test Remove
var cmd = new CmdRemoveObject( object );
var cmd = new RemoveObjectCommand( object );
cmd.updatable = false;
editor.execute( cmd );
......
......@@ -3,9 +3,9 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module( "CmdAddScript" );
module( "AddScriptCommand" );
test( "Test CmdAddScript (Undo and Redo)", function() {
test( "Test AddScriptCommand (Undo and Redo)", function() {
var editor = new Editor();
......@@ -21,7 +21,7 @@ test( "Test CmdAddScript (Undo and Redo)", function() {
// add objects to editor
objects.map( function( item ) {
editor.execute( new CmdAddObject( item ) );
editor.execute( new AddObjectCommand( item ) );
} );
ok( editor.scene.children.length == 2, "OK, the box and the sphere have been added" );
......@@ -29,7 +29,7 @@ test( "Test CmdAddScript (Undo and Redo)", function() {
// add scripts to the objects
for ( var i = 0; i < scripts.length; i ++ ) {
var cmd = new CmdAddScript( objects[ i ], scripts[ i ] );
var cmd = new AddScriptCommand( objects[ i ], scripts[ i ] );
cmd.updatable = false;
editor.execute( cmd );
......
......@@ -16,7 +16,7 @@ test( "MassUndoAndRedo (stress test)", function() {
while ( i < MAX_OBJECTS ) {
var object = aSphere( 'Sphere #' + i );
var cmd = new CmdAddObject( object );
var cmd = new AddObjectCommand( object );
cmd.updatable = false;
editor.execute( cmd );
......
......@@ -3,9 +3,9 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module( "CmdMoveObject" );
module( "MoveObjectCommand" );
test( "Test CmdMoveObject (Undo and Redo)", function() {
test( "Test MoveObjectCommand (Undo and Redo)", function() {
var editor = new Editor();
......@@ -15,15 +15,15 @@ test( "Test CmdMoveObject (Undo and Redo)", function() {
var anakinSkywalker = aSphere( anakinsName );
var lukeSkywalker = aBox( lukesName );
editor.execute( new CmdAddObject( anakinSkywalker ) );
editor.execute( new CmdAddObject( lukeSkywalker ) );
editor.execute( new AddObjectCommand( anakinSkywalker ) );
editor.execute( new AddObjectCommand( lukeSkywalker ) );
ok( anakinSkywalker.parent.name == "Scene", "OK, Anakin's parent is 'Scene' " );
ok( lukeSkywalker.parent.name == "Scene", "OK, Luke's parent is 'Scene' " );
// Tell Luke, Anakin is his father
editor.execute( new CmdMoveObject( lukeSkywalker, anakinSkywalker ) );
editor.execute( new MoveObjectCommand( lukeSkywalker, anakinSkywalker ) );
ok( true === true, "(Luke has been told who his father is)" );
ok( anakinSkywalker.parent.name == "Scene", "OK, Anakin's parent is still 'Scene' " );
......
......@@ -3,9 +3,9 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module( "CmdMultiCmds" );
module( "MultiCmdsCommand" );
test( "Test CmdMultiCmds (Undo and Redo)", function() {
test( "Test MultiCmdsCommand (Undo and Redo)", function() {
var editor = new Editor();
var box = aBox( 'Multi Command Box' );
......@@ -13,17 +13,17 @@ test( "Test CmdMultiCmds (Undo and Redo)", function() {
var boxGeometry2 = { geometry: { parameters: { width: 50, height: 51, depth: 52, widthSegments: 7, heightSegments: 8, depthSegments: 9 } } };
var boxGeometries = [ getGeometry( "BoxGeometry", boxGeometry1 ), getGeometry( "BoxGeometry", boxGeometry2 ) ];
var cmd = new CmdAddObject( box );
var cmd = new AddObjectCommand( box );
cmd.updatable = false;
editor.execute( cmd );
// setup first multi commands
var firstMultiCmds = [
new CmdSetGeometry( box, boxGeometries[ 0 ] ),
new CmdSetPosition( box, new THREE.Vector3( 1, 2, 3 ) ),
new CmdSetRotation( box, new THREE.Euler( 0.1, 0.2, 0.2 ) ),
new CmdSetScale( box, new THREE.Vector3( 1.1, 1.2, 1.3 ) )
new SetGeometryCommand( box, boxGeometries[ 0 ] ),
new SetPositionCommand( box, new THREE.Vector3( 1, 2, 3 ) ),
new SetRotationCommand( box, new THREE.Euler( 0.1, 0.2, 0.2 ) ),
new SetScaleCommand( box, new THREE.Vector3( 1.1, 1.2, 1.3 ) )
];
......@@ -33,7 +33,7 @@ test( "Test CmdMultiCmds (Undo and Redo)", function() {
} );
var firstMultiCmd = new CmdMultiCmds( firstMultiCmds );
var firstMultiCmd = new MultiCmdsCommand( firstMultiCmds );
firstMultiCmd.updatable = false;
editor.execute( firstMultiCmd );
......@@ -41,10 +41,10 @@ test( "Test CmdMultiCmds (Undo and Redo)", function() {
// setup second multi commands
var secondMultiCmds = [
new CmdSetGeometry( box, boxGeometries[ 1 ] ),
new CmdSetPosition( box, new THREE.Vector3( 4, 5, 6 ) ),
new CmdSetRotation( box, new THREE.Euler( 0.4, 0.5, 0.6 ) ),
new CmdSetScale( box, new THREE.Vector3( 1.4, 1.5, 1.6 ) )
new SetGeometryCommand( box, boxGeometries[ 1 ] ),
new SetPositionCommand( box, new THREE.Vector3( 4, 5, 6 ) ),
new SetRotationCommand( box, new THREE.Euler( 0.4, 0.5, 0.6 ) ),
new SetScaleCommand( box, new THREE.Vector3( 1.4, 1.5, 1.6 ) )
];
......@@ -54,7 +54,7 @@ test( "Test CmdMultiCmds (Undo and Redo)", function() {
} );
var secondMultiCmd = new CmdMultiCmds( secondMultiCmds );
var secondMultiCmd = new MultiCmdsCommand( secondMultiCmds );
secondMultiCmd.updatable = false;
editor.execute( secondMultiCmd );
......
......@@ -21,7 +21,7 @@ test( "Test unwanted situations ", function() {
var box = aBox();
var cmd = new CmdAddObject( box );
var cmd = new AddObjectCommand( box );
cmd.updatable = false;
editor.execute( cmd );
......
......@@ -32,16 +32,16 @@ test( "Test nested Do's, Undo's and Redo's", function() {
mesh.scale.z = initScaleZ ;
// let's begin
editor.execute( new CmdAddObject( mesh ) );
editor.execute( new AddObjectCommand( mesh ) );
var newPos = new THREE.Vector3( initPosX + 100, initPosY, initPosZ );
editor.execute( new CmdSetPosition( mesh, newPos ) );
editor.execute( new SetPositionCommand( mesh, newPos ) );
var newRotation = new THREE.Euler( initRotationX, initRotationY + 1000, initRotationZ );
editor.execute( new CmdSetRotation( mesh, newRotation ) );
editor.execute( new SetRotationCommand( mesh, newRotation ) );
var newScale = new THREE.Vector3( initScaleX, initScaleY, initScaleZ + 10000 );
editor.execute( new CmdSetScale( mesh, newScale ) );
editor.execute( new SetScaleCommand( mesh, newScale ) );
/* full check */
......@@ -81,7 +81,7 @@ test( "Test nested Do's, Undo's and Redo's", function() {
editor.redo(); // translation redone
editor.redo(); // rotation redone
editor.execute( new CmdRemoveObject( mesh ) );
editor.execute( new RemoveObjectCommand( mesh ) );
ok( editor.scene.children.length == 0, "OK, object removal was successful" );
editor.undo(); // removal undone
......
......@@ -3,9 +3,9 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module( "CmdRemoveScript" );
module( "RemoveScriptCommand" );
test( "Test CmdRemoveScript (Undo and Redo)", function() {
test( "Test RemoveScriptCommand (Undo and Redo)", function() {
var editor = new Editor();
......@@ -21,7 +21,7 @@ test( "Test CmdRemoveScript (Undo and Redo)", function() {
// add objects to editor
objects.map( function( item ) {
editor.execute( new CmdAddObject( item ) );
editor.execute( new AddObjectCommand( item ) );
} );
ok( editor.scene.children.length == 2, "OK, the box and the sphere have been added" );
......@@ -29,7 +29,7 @@ test( "Test CmdRemoveScript (Undo and Redo)", function() {
// add scripts to the objects
for ( var i = 0; i < scripts.length; i ++ ) {
var cmd = new CmdAddScript( objects[ i ], scripts[ i ] );
var cmd = new AddScriptCommand( objects[ i ], scripts[ i ] );
cmd.updatable = false;
editor.execute( cmd );
......@@ -37,7 +37,7 @@ test( "Test CmdRemoveScript (Undo and Redo)", function() {
for ( var i = 0; i < scripts.length; i ++ ) {
var cmd = new CmdRemoveScript( objects[ i ], scripts[ i ] );
var cmd = new RemoveScriptCommand( objects[ i ], scripts[ i ] );
cmd.updatable = false;
editor.execute( cmd );
......
......@@ -25,7 +25,7 @@ test( "Test Serialization", function( assert ) {
var box = aBox( 'The Box' );
// Test Add
var cmd = new CmdAddObject( box );
var cmd = new AddObjectCommand( box );
cmd.updatable = false;
editor.execute( cmd );
......@@ -41,10 +41,10 @@ test( "Test Serialization", function( assert ) {
// Test Add
var cmd = new CmdAddObject( box );
var cmd = new AddObjectCommand( box );
editor.execute( cmd );
var cmd = new CmdAddScript( box, { "name": "test", "source": "console.log(\"hello world\");" } );
var cmd = new AddScriptCommand( box, { "name": "test", "source": "console.log(\"hello world\");" } );
cmd.updatable = false;
editor.execute( cmd );
......@@ -61,11 +61,11 @@ test( "Test Serialization", function( assert ) {
var anakinSkywalker = aSphere( anakinsName );
var lukeSkywalker = aBox( lukesName );
editor.execute( new CmdAddObject( anakinSkywalker ) );
editor.execute( new CmdAddObject( lukeSkywalker ) );
editor.execute( new AddObjectCommand( anakinSkywalker ) );
editor.execute( new AddObjectCommand( lukeSkywalker ) );
// Tell Luke, Anakin is his father
editor.execute( new CmdMoveObject( lukeSkywalker, anakinSkywalker ) );
editor.execute( new MoveObjectCommand( lukeSkywalker, anakinSkywalker ) );
return "moveObject";
......@@ -74,15 +74,15 @@ test( "Test Serialization", function( assert ) {
var removeScript = function () {
var box = aBox( 'Box with no script' );
editor.execute( new CmdAddObject( box ) );
editor.execute( new AddObjectCommand( box ) );
var script = { "name": "test", "source": "console.log(\"hello world\");" } ;
var cmd = new CmdAddScript( box, script );
var cmd = new AddScriptCommand( box, script );
cmd.updatable = false;
editor.execute( cmd );
cmd = new CmdRemoveScript( box, script );
cmd = new RemoveScriptCommand( box, script );
editor.execute( cmd );
return "removeScript";
......@@ -93,8 +93,8 @@ test( "Test Serialization", function( assert ) {
var pointLight = aPointlight( "The light Light" );
editor.execute( new CmdAddObject( pointLight ) );
var cmd = new CmdSetColor( pointLight, 'color', green );
editor.execute( new AddObjectCommand( pointLight ) );
var cmd = new SetColorCommand( pointLight, 'color', green );
cmd.updatable = false;
editor.execute( cmd );
......@@ -107,9 +107,9 @@ test( "Test Serialization", function( assert ) {
var box = aBox( 'Guinea Pig' ); // default ( 100, 100, 100, 1, 1, 1 )
var boxGeometry = { geometry: { parameters: { width: 200, height: 201, depth: 202, widthSegments: 2, heightSegments: 3, depthSegments: 4 } } };
editor.execute( new CmdAddObject( box ) );
editor.execute( new AddObjectCommand( box ) );
var cmd = new CmdSetGeometry( box, getGeometry( "BoxGeometry", boxGeometry ) );
var cmd = new SetGeometryCommand( box, getGeometry( "BoxGeometry", boxGeometry ) );
cmd.updatable = false;
editor.execute( cmd );
......@@ -120,9 +120,9 @@ test( "Test Serialization", function( assert ) {
var setGeometryValue = function() {
var box = aBox( 'Geometry Value Box' );
editor.execute( new CmdAddObject( box ) );
editor.execute( new AddObjectCommand( box ) );
cmd = new CmdSetGeometryValue( box, 'uuid', THREE.Math.generateUUID() );
cmd = new SetGeometryValueCommand( box, 'uuid', THREE.Math.generateUUID() );
cmd.updatable = false;
editor.execute( cmd );
......@@ -133,10 +133,10 @@ test( "Test Serialization", function( assert ) {
var setMaterial = function () {
var sphere = aSphere( 'The Sun' );
editor.execute( new CmdAddObject( sphere ) );
editor.execute( new AddObjectCommand( sphere ) );
var material = new THREE[ 'MeshPhongMaterial' ]();
var cmd = new CmdSetMaterial( sphere, material );
var cmd = new SetMaterialCommand( sphere, material );
cmd.updatable = false;
editor.execute( cmd );
......@@ -147,9 +147,9 @@ test( "Test Serialization", function( assert ) {
var setMaterialColor = function () {
var box = aBox( 'Box with colored material' );
editor.execute( new CmdAddObject( box ) );
editor.execute( new AddObjectCommand( box ) );
var cmd = new CmdSetMaterialColor( box, 'color', green );
var cmd = new SetMaterialColorCommand( box, 'color', green );
cmd.updatable = false;
editor.execute( cmd );
......@@ -160,7 +160,7 @@ test( "Test Serialization", function( assert ) {
var setMaterialMap = function () {
var sphere = aSphere( 'Sphere with texture' );
editor.execute( new CmdAddObject( sphere ) );
editor.execute( new AddObjectCommand( sphere ) );
// dirt.png
var data = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpDMjYxMEI4MzVENDMxMUU1OTdEQUY4QkNGNUVENjg4MyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpDMjYxMEI4NDVENDMxMUU1OTdEQUY4QkNGNUVENjg4MyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkMyNjEwQjgxNUQ0MzExRTU5N0RBRjhCQ0Y1RUQ2ODgzIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkMyNjEwQjgyNUQ0MzExRTU5N0RBRjhCQ0Y1RUQ2ODgzIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+txizaQAAABVQTFRFh4eHbGxsdFhEWT0puYVclmxKeVU6ppwr+AAAAHtJREFUeNosjgEWBCEIQplFuP+RB5h9lZn2EZxkLzC3D1YSgSlmk7i0ctzDZNBz/VSoX1KwjlFI8WmA2R7JqUa0LJJcd1rLNWRRaMyi+3Y16qMKHhdE48XLsDyHKJ0nSMazY1fxHyriXxV584tmEedcfGNrA/5cmK8AAwCT9ATehDDyzwAAAABJRU5ErkJggg==';
......@@ -170,7 +170,7 @@ test( "Test Serialization", function( assert ) {
var texture = new THREE.Texture( img, 'map' );
texture.sourceFile = 'dirt.png';
var cmd = new CmdSetMaterialMap( sphere, 'map', texture );
var cmd = new SetMaterialMapCommand( sphere, 'map', texture );
cmd.updatable = false;
editor.execute( cmd );
......@@ -181,9 +181,9 @@ test( "Test Serialization", function( assert ) {
var setMaterialValue = function () {
var box = aBox( 'Box with values' );
editor.execute( new CmdAddObject( box ) );
editor.execute( new AddObjectCommand( box ) );
var cmd = new CmdSetMaterialValue( box, 'name', 'Bravo' );
var cmd = new SetMaterialValueCommand( box, 'name', 'Bravo' );
cmd.updatable = false;
editor.execute( cmd );
......@@ -194,10 +194,10 @@ test( "Test Serialization", function( assert ) {
var setPosition = function () {
var sphere = aSphere( 'Sphere with position' );
editor.execute( new CmdAddObject( sphere ) );
editor.execute( new AddObjectCommand( sphere ) );
var newPosition = new THREE.Vector3( 101, 202, 303 );
var cmd = new CmdSetPosition( sphere, newPosition );
var cmd = new SetPositionCommand( sphere, newPosition );
cmd.updatable = false;
editor.execute( cmd );
......@@ -208,10 +208,10 @@ test( "Test Serialization", function( assert ) {
var setRotation = function () {
var box = aBox( 'Box with rotation' );
editor.execute( new CmdAddObject( box ) );
editor.execute( new AddObjectCommand( box ) );
var newRotation = new THREE.Euler( 0.3, - 1.7, 2 );
var cmd = new CmdSetRotation( box, newRotation );
var cmd = new SetRotationCommand( box, newRotation );
cmd.updatable = false;
editor.execute ( cmd );
......@@ -222,10 +222,10 @@ test( "Test Serialization", function( assert ) {
var setScale = function () {
var sphere = aSphere( 'Sphere with scale' );
editor.execute( new CmdAddObject( sphere ) );
editor.execute( new AddObjectCommand( sphere ) );
var newScale = new THREE.Vector3( 1.2, 3.3, 4.6 );
var cmd = new CmdSetScale( sphere, newScale );
var cmd = new SetScaleCommand( sphere, newScale );
cmd.updatable = false;
editor.execute( cmd );
......@@ -236,12 +236,12 @@ test( "Test Serialization", function( assert ) {
var setScriptValue = function () {
var box = aBox( 'Box with script' );
editor.execute( new CmdAddObject( box ) );
editor.execute( new AddObjectCommand( box ) );
var script = { name: "Alert", source: "alert( null );" };
editor.execute( new CmdAddScript( box, script ) );
editor.execute( new AddScriptCommand( box, script ) );
var newScript = { name: "Console", source: "console.log( null );" };
var cmd = new CmdSetScriptValue( box, script, 'source', newScript.source, 0 );
var cmd = new SetScriptValueCommand( box, script, 'source', newScript.source, 0 );
cmd.updatable = false;
editor.execute( cmd );
......@@ -252,9 +252,9 @@ test( "Test Serialization", function( assert ) {
var setUuid = function () {
var sphere = aSphere( 'Sphere with UUID' );
editor.execute( new CmdAddObject( sphere ) );
editor.execute( new AddObjectCommand( sphere ) );
var cmd = new CmdSetUuid( sphere, THREE.Math.generateUUID() );
var cmd = new SetUuidCommand( sphere, THREE.Math.generateUUID() );
cmd.updatable = false;
editor.execute( cmd );
......@@ -265,9 +265,9 @@ test( "Test Serialization", function( assert ) {
var setValue = function () {
var box = aBox( 'Box with value' );
editor.execute( new CmdAddObject( box ) );
editor.execute( new AddObjectCommand( box ) );
var cmd = new CmdSetValue( box, 'intensity', 2.3 );
var cmd = new SetValueCommand( box, 'intensity', 2.3 );
cmd.updatable = false;
editor.execute( cmd );
......
......@@ -3,13 +3,13 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module( "CmdSetColor" );
module( "SetColorCommand" );
test( "Test CmdSetColor (Undo and Redo)", function() {
test( "Test SetColorCommand (Undo and Redo)", function() {
var editor = new Editor();
var pointLight = aPointlight( "The light Light" );
editor.execute( new CmdAddObject( pointLight ) );
editor.execute( new AddObjectCommand( pointLight ) );
var green = 12581843; // bffbd3
var blue = 14152447; // d7f2ff
......@@ -19,7 +19,7 @@ test( "Test CmdSetColor (Undo and Redo)", function() {
colors.map( function( color ) {
var cmd = new CmdSetColor( pointLight, 'color', color );
var cmd = new SetColorCommand( pointLight, 'color', color );
cmd.updatable = false;
editor.execute( cmd );
......
......@@ -3,9 +3,9 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module( "CmdSetGeometry" );
module( "SetGeometryCommand" );
test( "Test CmdSetGeometry (Undo and Redo)", function() {
test( "Test SetGeometryCommand (Undo and Redo)", function() {
var editor = new Editor();
......@@ -17,13 +17,13 @@ test( "Test CmdSetGeometry (Undo and Redo)", function() {
// add the object
var cmd = new CmdAddObject( box );
var cmd = new AddObjectCommand( box );
cmd.updatable = false;
editor.execute( cmd );
for ( var i = 0; i < geometryParams.length; i ++ ) {
var cmd = new CmdSetGeometry( box, getGeometry( "BoxGeometry", geometryParams[ i ] ) );
var cmd = new SetGeometryCommand( box, getGeometry( "BoxGeometry", geometryParams[ i ] ) );
cmd.updatable = false;
editor.execute( cmd );
......
......@@ -3,14 +3,14 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module( "CmdSetGeometryValue" );
module( "SetGeometryValueCommand" );
test( "Test CmdSetGeometryValue (Undo and Redo)", function() {
test( "Test SetGeometryValueCommand (Undo and Redo)", function() {
var editor = new Editor();
var box = aBox( 'The Box' );
var cmd = new CmdAddObject( box );
var cmd = new AddObjectCommand( box );
cmd.updatable = false;
editor.execute( cmd );
......@@ -25,7 +25,7 @@ test( "Test CmdSetGeometryValue (Undo and Redo)", function() {
keys.map( function( key ) {
cmd = new CmdSetGeometryValue( box, key, testData[ i ][ key ] );
cmd = new SetGeometryValueCommand( box, key, testData[ i ][ key ] );
cmd.updatable = false;
editor.execute( cmd );
......
......@@ -3,14 +3,14 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module( "CmdSetMaterialColor" );
module( "SetMaterialColorCommand" );
test( "Test for CmdSetMaterialColor (Undo and Redo)", function() {
test( "Test for SetMaterialColorCommand (Undo and Redo)", function() {
// Setup scene
var editor = new Editor();
var box = aBox();
var cmd = new CmdAddObject( box );
var cmd = new AddObjectCommand( box );
cmd.updatable = false;
editor.execute( cmd );
......@@ -25,7 +25,7 @@ test( "Test for CmdSetMaterialColor (Undo and Redo)", function() {
colors.map( function ( color ) {
var cmd = new CmdSetMaterialColor( box, attributeName, color );
var cmd = new SetMaterialColorCommand( box, attributeName, color );
cmd.updatable = false;
editor.execute( cmd );
......
......@@ -3,14 +3,14 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module( "CmdSetMaterial" );
module( "SetMaterialCommand" );
test( "Test for CmdSetMaterial (Undo and Redo)", function() {
test( "Test for SetMaterialCommand (Undo and Redo)", function() {
// setup
var editor = new Editor();
var box = aBox( 'Material girl in a material world' );
var cmd = new CmdAddObject( box );
var cmd = new AddObjectCommand( box );
cmd.updatable = false;
editor.execute( cmd );
......@@ -31,7 +31,7 @@ test( "Test for CmdSetMaterial (Undo and Redo)", function() {
materialClasses.map( function( materialClass ) {
material = new THREE[ materialClass ]();
editor.execute( new CmdSetMaterial( box, material ) );
editor.execute( new SetMaterialCommand( box, material ) );
} );
......
......@@ -3,14 +3,14 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module( "CmdSetMaterialMap" );
module( "SetMaterialMapCommand" );
test( "Test for CmdSetMaterialMap (Undo and Redo)", function() {
test( "Test for SetMaterialMapCommand (Undo and Redo)", function() {
// setup
var editor = new Editor();
var box = aBox( 'Material mapped box' );
var cmd = new CmdAddObject( box );
var cmd = new AddObjectCommand( box );
cmd.updatable = false;
editor.execute( cmd );
......@@ -47,7 +47,7 @@ test( "Test for CmdSetMaterialMap (Undo and Redo)", function() {
// apply the textures
textures.map( function( texture ) {
var cmd = new CmdSetMaterialMap( box, mapName, texture );
var cmd = new SetMaterialMapCommand( box, mapName, texture );
cmd.updatable = false;
editor.execute( cmd );
......
......@@ -3,14 +3,14 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module( "CmdSetMaterialValue" );
module( "SetMaterialValueCommand" );
test( "Test for CmdSetMaterialValue (Undo and Redo)", function() {
test( "Test for SetMaterialValueCommand (Undo and Redo)", function() {
// setup scene
var editor = new Editor();
var box = aBox();
var cmd = new CmdAddObject( box );
var cmd = new AddObjectCommand( box );
cmd.updatable = false;
editor.execute( cmd );
......@@ -39,7 +39,7 @@ test( "Test for CmdSetMaterialValue (Undo and Redo)", function() {
testData[ attributeName ].map( function( value ) {
var cmd = new CmdSetMaterialValue( box, attributeName, value );
var cmd = new SetMaterialValueCommand( box, attributeName, value );
cmd.updatable = false;
editor.execute( cmd );
......
......@@ -3,13 +3,13 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module( "CmdSetPosition" );
module( "SetPositionCommand" );
test( "Test CmdSetPosition (Undo and Redo)", function() {
test( "Test SetPositionCommand (Undo and Redo)", function() {
var editor = new Editor();
var box = aBox();
var cmd = new CmdAddObject( box );
var cmd = new AddObjectCommand( box );
editor.execute( cmd );
var positions = [
......@@ -23,7 +23,7 @@ test( "Test CmdSetPosition (Undo and Redo)", function() {
positions.map( function( position ) {
var newPosition = new THREE.Vector3( position.x, position.y, position.z );
var cmd = new CmdSetPosition( box, newPosition );
var cmd = new SetPositionCommand( box, newPosition );
cmd.updatable = false;
editor.execute( cmd );
......
......@@ -3,14 +3,14 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module( "CmdSetRotation" );
module( "SetRotationCommand" );
test( "Test CmdSetRotation (Undo and Redo)", function() {
test( "Test SetRotationCommand (Undo and Redo)", function() {
// setup
var editor = new Editor();
var box = aBox();
editor.execute( new CmdAddObject( box ) );
editor.execute( new AddObjectCommand( box ) );
var rotations = [
......@@ -25,7 +25,7 @@ test( "Test CmdSetRotation (Undo and Redo)", function() {
rotations.map( function( rotation ) {
var newRotation = new THREE.Euler( rotation.x, rotation.y, rotation.z );
var cmd = new CmdSetRotation( box, newRotation );
var cmd = new SetRotationCommand( box, newRotation );
cmd.updatable = false;
editor.execute ( cmd );
......
......@@ -3,14 +3,14 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module( "CmdSetScale" );
module( "SetScaleCommand" );
test( "Test CmdSetScale (Undo and Redo)", function() {
test( "Test SetScaleCommand (Undo and Redo)", function() {
// setup
var editor = new Editor();
var box = aBox();
editor.execute( new CmdAddObject( box ) );
editor.execute( new AddObjectCommand( box ) );
// scales
......@@ -25,7 +25,7 @@ test( "Test CmdSetScale (Undo and Redo)", function() {
scales.map( function( scale ) {
var newScale = new THREE.Vector3( scale.x, scale.y, scale.z );
var cmd = new CmdSetScale( box, newScale );
var cmd = new SetScaleCommand( box, newScale );
cmd.updatable = false;
editor.execute( cmd );
......
......@@ -5,7 +5,7 @@
module( "TestCmdSetScene" );
test( "Test for CmdSetScene (Undo and Redo)", function() {
test( "Test for SetSceneCommand (Undo and Redo)", function() {
// setup
var editor = new Editor();
......@@ -16,7 +16,7 @@ test( "Test for CmdSetScene (Undo and Redo)", function() {
var scenes = objects.map( function( object ) {
editor = new Editor();
var cmd = new CmdAddObject( object );
var cmd = new AddObjectCommand( object );
cmd.updatable = false;
editor.execute( cmd );
return { obj: object, exportedData: exportScene( editor ) };
......@@ -29,7 +29,7 @@ test( "Test for CmdSetScene (Undo and Redo)", function() {
scenes.map( function( scene ) {
var importedScene = importScene( scene.exportedData );
var cmd = new CmdSetScene( importedScene );
var cmd = new SetSceneCommand( importedScene );
cmd.updatable = false;
editor.execute( cmd );
......
......@@ -3,20 +3,20 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module( "CmdSetScriptValue" );
module( "SetScriptValueCommand" );
test( "Test CmdSetScriptValue for source (Undo and Redo)", function() {
test( "Test SetScriptValueCommand for source (Undo and Redo)", function() {
// setup
var editor = new Editor();
var box = aBox( "The scripted box" );
var cmd = new CmdAddObject( box );
var cmd = new AddObjectCommand( box );
cmd.updatable = false;
editor.execute( cmd );
var translateScript = { name: "Translate", source: "function( update ) {}" };
cmd = new CmdAddScript( box, translateScript );
cmd = new AddScriptCommand( box, translateScript );
cmd.updatable = false;
editor.execute( cmd );
......@@ -34,7 +34,7 @@ test( "Test CmdSetScriptValue for source (Undo and Redo)", function() {
testSourceData.map( function( script ) {
var cmd = new CmdSetScriptValue( box, translateScript, 'source', script.source, 0 );
var cmd = new SetScriptValueCommand( box, translateScript, 'source', script.source, 0 );
cmd.updatable = false;
editor.execute( cmd );
......@@ -57,7 +57,7 @@ test( "Test CmdSetScriptValue for source (Undo and Redo)", function() {
names.map( function( name ) {
cmd = new CmdSetScriptValue( box, translateScript, 'name', name );
cmd = new SetScriptValueCommand( box, translateScript, 'name', name );
cmd.updatable = false;
editor.execute( cmd );
......
......@@ -3,20 +3,20 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module( "CmdSetUuid" );
module( "SetUuidCommand" );
test( "Test CmdSetUuid (Undo and Redo)", function() {
test( "Test SetUuidCommand (Undo and Redo)", function() {
var editor = new Editor();
var object = aBox( 'UUID test box' );
editor.execute( new CmdAddObject( object ) );
editor.execute( new AddObjectCommand( object ) );
var uuids = [ THREE.Math.generateUUID(), THREE.Math.generateUUID(), THREE.Math.generateUUID() ];
uuids.map( function( uuid ) {
var cmd = new CmdSetUuid( object, uuid );
var cmd = new SetUuidCommand( object, uuid );
cmd.updatable = false;
editor.execute( cmd );
......
......@@ -3,9 +3,9 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module( "CmdSetValue" );
module( "SetValueCommand" );
test( "Test CmdSetValue (Undo and Redo)", function() {
test( "Test SetValueCommand (Undo and Redo)", function() {
var editor = new Editor();
......@@ -18,7 +18,7 @@ test( "Test CmdSetValue (Undo and Redo)", function() {
[ box, light, cam ].map( function( object ) {
editor.execute( new CmdAddObject( object ) );
editor.execute( new AddObjectCommand( object ) );
ok( 0 == 0, "Testing object of type '" + object.type + "'" );
......@@ -26,12 +26,12 @@ test( "Test CmdSetValue (Undo and Redo)", function() {
if ( object[ item ] !== undefined ) {
var cmd = new CmdSetValue( object, item, valueBefore );
var cmd = new SetValueCommand( object, item, valueBefore );
cmd.updatable = false;
editor.execute( cmd );
ok( object[ item ] == valueBefore, " OK, the attribute '" + item + "' is correct after first execute (expected: '" + valueBefore + "', actual: '" + object[ item ] + "')" );
var cmd = new CmdSetValue( object, item, valueAfter );
var cmd = new SetValueCommand( object, item, valueAfter );
cmd.updatable = false;
editor.execute( cmd );
ok( object[ item ] == valueAfter, " OK, the attribute '" + item + "' is correct after second execute (expected: '" + valueAfter + "', actual: '" + object[ item ] + "')" );
......
......@@ -69,52 +69,52 @@
<script src="../../editor/js/History.js"></script>
<!-- command object classes -->
<script src="../../editor/js/Cmd.js"></script>
<script src="../../editor/js/CmdAddObject.js"></script>
<script src="../../editor/js/CmdAddScript.js"></script>
<script src="../../editor/js/CmdMoveObject.js"></script>
<script src="../../editor/js/CmdMultiCmds.js"></script>
<script src="../../editor/js/CmdRemoveObject.js"></script>
<script src="../../editor/js/CmdRemoveScript.js"></script>
<script src="../../editor/js/CmdSetColor.js"></script>
<script src="../../editor/js/CmdSetGeometry.js"></script>
<script src="../../editor/js/CmdSetGeometryValue.js"></script>
<script src="../../editor/js/CmdSetMaterial.js"></script>
<script src="../../editor/js/CmdSetMaterialColor.js"></script>
<script src="../../editor/js/CmdSetMaterialMap.js"></script>
<script src="../../editor/js/CmdSetMaterialValue.js"></script>
<script src="../../editor/js/CmdSetPosition.js"></script>
<script src="../../editor/js/CmdSetRotation.js"></script>
<script src="../../editor/js/CmdSetScale.js"></script>
<script src="../../editor/js/CmdSetScene.js"></script>
<script src="../../editor/js/CmdSetScriptValue.js"></script>
<script src="../../editor/js/CmdSetUuid.js"></script>
<script src="../../editor/js/CmdSetValue.js"></script>
<script src="../../editor/js/Command.js"></script>
<script src="../../editor/js/commands/AddObjectCommand.js"></script>
<script src="../../editor/js/commands/AddScriptCommand.js"></script>
<script src="../../editor/js/commands/MoveObjectCommand.js"></script>
<script src="../../editor/js/commands/MultiCmdsCommand.js"></script>
<script src="../../editor/js/commands/RemoveObjectCommand.js"></script>
<script src="../../editor/js/commands/RemoveScriptCommand.js"></script>
<script src="../../editor/js/commands/SetColorCommand.js"></script>
<script src="../../editor/js/commands/SetGeometryCommand.js"></script>
<script src="../../editor/js/commands/SetGeometryValueCommand.js"></script>
<script src="../../editor/js/commands/SetMaterialCommand.js"></script>
<script src="../../editor/js/commands/SetMaterialColorCommand.js"></script>
<script src="../../editor/js/commands/SetMaterialMapCommand.js"></script>
<script src="../../editor/js/commands/SetMaterialValueCommand.js"></script>
<script src="../../editor/js/commands/SetPositionCommand.js"></script>
<script src="../../editor/js/commands/SetRotationCommand.js"></script>
<script src="../../editor/js/commands/SetScaleCommand.js"></script>
<script src="../../editor/js/commands/SetSceneCommand.js"></script>
<script src="../../editor/js/commands/SetScriptValueCommand.js"></script>
<script src="../../editor/js/commands/SetUuidCommand.js"></script>
<script src="../../editor/js/commands/SetValueCommand.js"></script>
<!-- add class-based unit tests below -->
<script src="editor/CommonUtilities.js"></script>
<!-- Undo-Redo tests -->
<script src="editor/TestCmdAddObjectAndCmdRemoveObject.js"></script>
<script src="editor/TestCmdAddScript.js"></script>
<script src="editor/TestCmdMoveObject.js"></script>
<script src="editor/TestCmdMultiCmds.js"></script>
<script src="editor/TestCmdRemoveScript.js"></script>
<script src="editor/TestCmdSetColor.js"></script>
<script src="editor/TestCmdSetGeometry.js"></script>
<script src="editor/TestCmdSetGeometryValue.js"></script>
<script src="editor/TestCmdSetMaterial.js"></script>
<script src="editor/TestCmdSetMaterialColor.js"></script>
<script src="editor/TestCmdSetMaterialMap.js"></script>
<script src="editor/TestCmdSetMaterialValue.js"></script>
<script src="editor/TestCmdSetPosition.js"></script>
<script src="editor/TestCmdSetRotation.js"></script>
<script src="editor/TestCmdSetScale.js"></script>
<script src="editor/TestCmdSetScene.js"></script>
<script src="editor/TestCmdSetScriptValue.js"></script>
<script src="editor/TestCmdSetUuid.js"></script>
<script src="editor/TestCmdSetValue.js"></script>
<script src="editor/TestAddObjectCommandAndRemoveObjectCommand.js"></script>
<script src="editor/TestAddScriptCommand.js"></script>
<script src="editor/TestMoveObjectCommand.js"></script>
<script src="editor/TestMultiCmdsCommand.js"></script>
<script src="editor/TestRemoveScriptCommand.js"></script>
<script src="editor/TestSetColorCommand.js"></script>
<script src="editor/TestSetGeometryCommand.js"></script>
<script src="editor/TestSetGeometryValueCommand.js"></script>
<script src="editor/TestSetMaterialCommand.js"></script>
<script src="editor/TestSetMaterialColorCommand.js"></script>
<script src="editor/TestSetMaterialMapCommand.js"></script>
<script src="editor/TestSetMaterialValueCommand.js"></script>
<script src="editor/TestSetPositionCommand.js"></script>
<script src="editor/TestSetRotationCommand.js"></script>
<script src="editor/TestSetScaleCommand.js"></script>
<script src="editor/TestSetSceneCommand.js"></script>
<script src="editor/TestSetScriptValueCommand.js"></script>
<script src="editor/TestSetUuidCommand.js"></script>
<script src="editor/TestSetValueCommand.js"></script>
<script src="editor/TestNestedDoUndoRedo.js"></script>
<script src="editor/TestSerialization.js"></script>
<script src="editor/TestNegativeCases.js"></script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册