Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

Use applyEndInterp() for now since that works (even though it gives not great results)

Scott Petrovic51e2d38c19f6
diff --git a/src/retarget/human-retargeting/Retargeter.ts b/src/retarget/human-retargeting/Retargeter.ts
index 91c9a45..70c9bca 100644
--- a/src/retarget/human-retargeting/Retargeter.ts
+++ b/src/retarget/human-retargeting/Retargeter.ts
@@ -40,15 +40,24 @@ export class Retargeter {
// Compute vectors from animation source
// then align target joints to it
- this.applyScaledTranslation('pelvis') // apply position scaling for hips
- this.applyChain('pelvis')
+ this.applyScaledTranslation('pelvis')
this.applyEndInterp('spine')
- this.applyChain('head')
-
- this.applyChain('armL')
- this.applyChain('armR')
- this.applyChain('legL')
- this.applyChain('legR')
+ this.applyEndInterp('head')
+ this.applyEndInterp('armL')
+ this.applyEndInterp('armR')
+ this.applyEndInterp('legL')
+ this.applyEndInterp('legR')
+
+ // TODO: Figure out why the applyChain() version is doing nothing
+ // this.applyScaledTranslation('pelvis') // apply position scaling for hips
+ // this.applyChain('pelvis')
+ // this.applyEndInterp('spine')
+ // this.applyChain('head')
+
+ // this.applyChain('armL')
+ // this.applyChain('armR')
+ // this.applyChain('legL')
+ // this.applyChain('legR')
// Run Additives if any exist
for (const i of this.additives) {
@@ -155,14 +164,17 @@ export class Retargeter {
)
tracks.push(quat_track)
- // TODO: Add this logic later to include root motion if correct bone
- // Create position track
- // const pos_track = new THREE.VectorKeyframeTrack(
- // `${bone_name}.position`,
- // data.times,
- // data.positions
- // )
- // tracks.push(pos_track)
+ // add root motion track
+ // TODO: this needs to be a bit smarter to know which track
+ // has the root bone (hard-coding where Mixamo stores root motion)
+ if (bone_name.toLowerCase().trim().includes('hips')) {
+ const pos_track = new THREE.VectorKeyframeTrack(
+ `${bone_name}.position`,
+ data.times,
+ data.positions
+ )
+ tracks.push(pos_track)
+ }
})
console.log(`Baked ${frame_count} frames for ${this.tarRig.skel.bones.length} bones (${tracks.length} tracks)`)