TestCmdSetGeometry.js 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. module( "CmdSetGeometry" );
  2. test( "Test CmdSetGeometry", function() {
  3. var editor = new Editor();
  4. // initialize objects and geometries
  5. var box = aBox( 'Guinea Pig' ); // default ( 100, 100, 100, 1, 1, 1 )
  6. var boxGeometry1 = { width: 200, height: 201, depth: 202, widthSegments: 2, heightSegments: 3, depthSegments: 4 };
  7. var boxGeometry2 = { width: 50, height: 51, depth: 52, widthSegments: 7, heightSegments: 8, depthSegments: 9 };
  8. var geometryParams = [ boxGeometry1, boxGeometry2 ];
  9. // add the object
  10. var cmd = new CmdAddObject( box );
  11. cmd.updatable = false;
  12. editor.execute( cmd );
  13. for ( var i = 0; i < geometryParams.length; i++ ) {
  14. var cmd = new CmdSetGeometry( box, new THREE.BoxGeometry(
  15. geometryParams[i]['width'],
  16. geometryParams[i]['height'],
  17. geometryParams[i]['depth'],
  18. geometryParams[i]['widthSegments'],
  19. geometryParams[i]['heightSegments'],
  20. geometryParams[i]['depthSegments']
  21. ) );
  22. cmd.updatable = false;
  23. editor.execute( cmd );
  24. var params = box.geometry.parameters;
  25. ok( params.width == geometryParams[i]['width'], "OK, box width matches the corresponding value from boxGeometry" + ( i + 1 ) );
  26. ok( params.height == geometryParams[i]['height'], "OK, box height matches the corresponding value from boxGeometry" + ( i + 1 ) );
  27. ok( params.depth == geometryParams[i]['depth'], "OK, box depth matches the corresponding value from boxGeometry" + ( i + 1 ) );
  28. ok( params.widthSegments == geometryParams[i]['widthSegments'], "OK, box widthSegments matches the corresponding value from boxGeometry" + ( i + 1 ) );
  29. ok( params.heightSegments == geometryParams[i]['heightSegments'], "OK, box heightSegments matches the corresponding value from boxGeometry" + ( i + 1 ) );
  30. ok( params.depthSegments == geometryParams[i]['depthSegments'], "OK, box depthSegments matches the corresponding value from boxGeometry" + ( i + 1 ) );
  31. }
  32. editor.undo();
  33. var params = box.geometry.parameters;
  34. ok( params.width == geometryParams[0]['width'], "OK, box width matches the corresponding value from boxGeometry1 (after undo)");
  35. ok( params.height == geometryParams[0]['height'], "OK, box height matches the corresponding value from boxGeometry1 (after undo)");
  36. ok( params.depth == geometryParams[0]['depth'], "OK, box depth matches the corresponding value from boxGeometry1 (after undo)");
  37. ok( params.widthSegments == geometryParams[0]['widthSegments'], "OK, box widthSegments matches the corresponding value from boxGeometry1 (after undo)");
  38. ok( params.heightSegments == geometryParams[0]['heightSegments'], "OK, box heightSegments matches the corresponding value from boxGeometry1 (after undo)");
  39. ok( params.depthSegments == geometryParams[0]['depthSegments'], "OK, box depthSegments matches the corresponding value from boxGeometry1 (after undo)");
  40. editor.redo();
  41. var params = box.geometry.parameters;
  42. ok( params.width == geometryParams[1]['width'], "OK, box width matches the corresponding value from boxGeometry2 (after redo)");
  43. ok( params.height == geometryParams[1]['height'], "OK, box height matches the corresponding value from boxGeometry2 (after redo)");
  44. ok( params.depth == geometryParams[1]['depth'], "OK, box depth matches the corresponding value from boxGeometry2 (after redo)");
  45. ok( params.widthSegments == geometryParams[1]['widthSegments'], "OK, box widthSegments matches the corresponding value from boxGeometry2 (after redo)");
  46. ok( params.heightSegments == geometryParams[1]['heightSegments'], "OK, box heightSegments matches the corresponding value from boxGeometry2 (after redo)");
  47. ok( params.depthSegments == geometryParams[1]['depthSegments'], "OK, box depthSegments matches the corresponding value from boxGeometry2 (after redo)");
  48. });
粤ICP备19079148号