Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

Fix copying data to objects to get applyChain working

Scott Petrovic2f805531e1c0
diff --git a/src/retarget/human-retargeting/Quat.ts b/src/retarget/human-retargeting/Quat.ts
index 38780cb..e477e16 100644
--- a/src/retarget/human-retargeting/Quat.ts
+++ b/src/retarget/human-retargeting/Quat.ts
@@ -52,6 +52,15 @@ export default class Quat extends Array {
return this
}
+ // copyObj...but just pass in the individual components
+ xyzw (x: number, y: number, z: number, w: number): this {
+ this[0] = x
+ this[1] = y
+ this[2] = z
+ this[3] = w
+ return this
+ }
+
// object needs to contain x,y,z,w keys. Ok to have other properties since
// we only care about these four.
copyObj (o: { x: number, y: number, z: number, w: number, [key: string]: unknown }): this {
diff --git a/src/retarget/human-retargeting/Retargeter.ts b/src/retarget/human-retargeting/Retargeter.ts
index 70c9bca..a2723b1 100644
--- a/src/retarget/human-retargeting/Retargeter.ts
+++ b/src/retarget/human-retargeting/Retargeter.ts
@@ -40,24 +40,24 @@ export class Retargeter {
// Compute vectors from animation source
// then align target joints to it
- this.applyScaledTranslation('pelvis')
- this.applyEndInterp('spine')
- this.applyEndInterp('head')
- this.applyEndInterp('armL')
- this.applyEndInterp('armR')
- this.applyEndInterp('legL')
- this.applyEndInterp('legR')
+ // this.applyScaledTranslation('pelvis')
+ // this.applyEndInterp('spine')
+ // 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.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')
+ this.applyChain('armL')
+ this.applyChain('armR')
+ this.applyChain('legL')
+ this.applyChain('legR')
// Run Additives if any exist
for (const i of this.additives) {
@@ -228,8 +228,8 @@ export class Retargeter {
bone = this.srcRig.skel.bones[src[i].idx]
bone.getWorldPosition(vec)
bone.getWorldQuaternion(quat)
- source_position.copyTo(new Vec3(vec.x, vec.y, vec.z))
- source_rotation.copyTo(new Quat(quat.x, quat.y, quat.z, quat.w))
+ source_position.xyz(vec.x, vec.y, vec.z)
+ source_rotation.xyzw(quat.x, quat.y, quat.z, quat.w)
source_swing.fromQuat(source_rotation, src[i].swing)
source_twist.fromQuat(source_rotation, src[i].twist)