TestCmdSetRotation.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. module( "CmdSetRotation" );
  2. test( "Test CmdSetRotation (Undo and Redo)", function() {
  3. var editor = new Editor();
  4. var mesh = aBox();
  5. var initRotationX = 1.1 ;
  6. var initRotationY = 0.4 ;
  7. var initRotationZ = -2.0 ;
  8. mesh.rotation.x = initRotationX ;
  9. mesh.rotation.y = initRotationY ;
  10. mesh.rotation.z = initRotationZ ;
  11. editor.execute( new CmdAddObject( mesh ) );
  12. editor.select( mesh );
  13. // rotate the object
  14. var newRotationX = -3.2 ;
  15. var newRotationY = 0.8 ;
  16. var newRotationZ = 1.5 ;
  17. var newRotation = new THREE.Euler( newRotationX, newRotationY, newRotationZ );
  18. editor.execute ( new CmdSetRotation( mesh, newRotation ) );
  19. ok( mesh.rotation.x != initRotationX, "OK, changing X rotation was successful" );
  20. ok( mesh.rotation.y != initRotationY, "OK, changing Y rotation was successful" );
  21. ok( mesh.rotation.z != initRotationZ, "OK, changing Z rotation was successful" );
  22. editor.undo();
  23. ok( mesh.rotation.x == initRotationX, "OK, changing X rotation value is undone" );
  24. ok( mesh.rotation.y == initRotationY, "OK, changing Y rotation value is undone" );
  25. ok( mesh.rotation.z == initRotationZ, "OK, changing Z rotation value is undone" );
  26. editor.redo();
  27. ok( mesh.rotation.x == newRotationX, "OK, changing X rotation value is redone" );
  28. ok( mesh.rotation.y == newRotationY, "OK, changing Y rotation value is redone" );
  29. ok( mesh.rotation.z == newRotationZ, "OK, changing Z rotation value is redone" );
  30. });