USDLoader.tests.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { USDLoader } from '../../../../examples/jsm/loaders/USDLoader.js';
  2. export default QUnit.module( 'Addons', () => {
  3. QUnit.module( 'Loaders', () => {
  4. QUnit.module( 'USDLoader', () => {
  5. QUnit.test( 'uses timeCodesPerSecond for USDA animation timing', ( assert ) => {
  6. const usda = `#usda 1.0
  7. (
  8. defaultPrim = "Root"
  9. framesPerSecond = 24
  10. timeCodesPerSecond = 60
  11. )
  12. def Xform "Root"
  13. {
  14. def Xform "Animated"
  15. {
  16. float3 xformOp:translate = (0, 0, 0)
  17. float3 xformOp:translate.timeSamples = {
  18. 0: (0, 0, 0),
  19. 60: (1, 0, 0),
  20. }
  21. uniform token[] xformOpOrder = ["xformOp:translate"]
  22. }
  23. }`;
  24. const loader = new USDLoader();
  25. const scene = loader.parse( usda );
  26. const clip = scene.animations[ 0 ];
  27. const track = clip.tracks[ 0 ];
  28. assert.strictEqual( scene.animations.length, 1, 'One animation clip is created.' );
  29. assert.strictEqual( clip.name, 'TransformAnimation', 'Transform animation is created.' );
  30. assert.closeTo( clip.duration, 1, 0.000001, 'Animation duration uses timeCodesPerSecond.' );
  31. assert.strictEqual( track.name, 'Animated.position', 'Track targets the animated Xform.' );
  32. assert.deepEqual(
  33. Array.from( track.times ),
  34. [ 0, 1 ],
  35. 'Time samples are converted to seconds.'
  36. );
  37. } );
  38. } );
  39. } );
  40. } );
粤ICP备19079148号