12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- module( "CmdSetRotation" );
- test( "Test CmdSetRotation (Undo and Redo)", function() {
- // setup
- var editor = new Editor();
- var box = aBox();
- editor.execute( new CmdAddObject( box ) );
- var rotations = [
- { x: 1.1, y: 0.4, z: -2.0 },
- { x: 2.2, y: -1.3, z: 1.3 },
- { x: 0.3, y: -0.1, z: -1.9 }
- ];
- rotations.map( function( rotation ) {
- var newRotation = new THREE.Euler( rotation.x, rotation.y, rotation.z );
- var cmd = new CmdSetRotation( box, newRotation );
- cmd.updatable = false;
- editor.execute ( cmd );
- });
- ok( box.rotation.x == rotations[ rotations.length - 1 ].x, "OK, changing X rotation was successful" );
- ok( box.rotation.y == rotations[ rotations.length - 1 ].y, "OK, changing Y rotation was successful" );
- ok( box.rotation.z == rotations[ rotations.length - 1 ].z, "OK, changing Z rotation was successful" );
- editor.undo();
- ok( box.rotation.x == rotations[ rotations.length - 2 ].x, "OK, changing X rotation was successful (after undo)" );
- ok( box.rotation.y == rotations[ rotations.length - 2 ].y, "OK, changing Y rotation was successful (after undo)" );
- ok( box.rotation.z == rotations[ rotations.length - 2 ].z, "OK, changing Z rotation was successful (after undo)" );
- editor.redo();
- ok( box.rotation.x == rotations[ rotations.length - 1 ].x, "OK, changing X rotation was successful (after redo)" );
- ok( box.rotation.y == rotations[ rotations.length - 1 ].y, "OK, changing Y rotation was successful (after redo)" );
- ok( box.rotation.z == rotations[ rotations.length - 1 ].z, "OK, changing Z rotation was successful (after redo)" );
- });
|