Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions examples/jsm/loaders/usd/USDAParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,18 @@ class USDAParser {

}

if ( header.framesPerSecond !== undefined ) {

rootFields.framesPerSecond = parseFloat( header.framesPerSecond );

}

if ( header.timeCodesPerSecond !== undefined ) {

rootFields.timeCodesPerSecond = parseFloat( header.timeCodesPerSecond );

}

}

specsByPath[ '/' ] = { specType: SpecType.Prim, fields: rootFields };
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/loaders/usd/USDComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class USDComposer {
// Get FPS from root spec
const rootSpec = this.specsByPath[ '/' ];
const rootFields = rootSpec ? rootSpec.fields : {};
this.fps = rootFields.framesPerSecond || rootFields.timeCodesPerSecond || 30;
this.fps = rootFields.timeCodesPerSecond || rootFields.framesPerSecond || 24;

const group = new Group();
this._buildHierarchy( group, '/' );
Expand Down
52 changes: 52 additions & 0 deletions test/unit/addons/loaders/USDLoader.tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { USDLoader } from '../../../../examples/jsm/loaders/USDLoader.js';

export default QUnit.module( 'Addons', () => {

QUnit.module( 'Loaders', () => {

QUnit.module( 'USDLoader', () => {

QUnit.test( 'uses timeCodesPerSecond for USDA animation timing', ( assert ) => {

const usda = `#usda 1.0
(
defaultPrim = "Root"
framesPerSecond = 24
timeCodesPerSecond = 60
)

def Xform "Root"
{
def Xform "Animated"
{
float3 xformOp:translate = (0, 0, 0)
float3 xformOp:translate.timeSamples = {
0: (0, 0, 0),
60: (1, 0, 0),
}
uniform token[] xformOpOrder = ["xformOp:translate"]
}
}`;

const loader = new USDLoader();
const scene = loader.parse( usda );
const clip = scene.animations[ 0 ];
const track = clip.tracks[ 0 ];

assert.strictEqual( scene.animations.length, 1, 'One animation clip is created.' );
assert.strictEqual( clip.name, 'TransformAnimation', 'Transform animation is created.' );
assert.closeTo( clip.duration, 1, 0.000001, 'Animation duration uses timeCodesPerSecond.' );
assert.strictEqual( track.name, 'Animated.position', 'Track targets the animated Xform.' );
assert.deepEqual(
Array.from( track.times ),
[ 0, 1 ],
'Time samples are converted to seconds.'
);

} );

} );

} );

} );
1 change: 1 addition & 0 deletions test/unit/three.addons.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import './addons/utils/ColorUtils.tests.js';
import './addons/math/ColorSpaces.tests.js';
import './addons/curves/NURBSCurve.tests.js';
import './addons/loaders/HDRLoader.tests.js';
import './addons/loaders/USDLoader.tests.js';
import './addons/exporters/USDZExporter.tests.js';
Loading