Import a 3D Model and automatically assign and export animations
TypeScript
store target mapping type to retargeting service
Scott Petrovic77d0e91f0684
diff --git a/src/retarget/AnimationRetargetService.ts b/src/retarget/AnimationRetargetService.tsindex b4abe91..eab9fb5 100644--- a/src/retarget/AnimationRetargetService.ts+++ b/src/retarget/AnimationRetargetService.ts@@ -23,7 +23,6 @@ export class AnimationRetargetService {* Get/set for the skeleton type. This will be the source of truth* for other classes to grab this data*/- private skeleton_type: SkeletonType = SkeletonType.Noneprivate source_armature: Group | null = nullpublic set_source_armature (armature: Group | null): void {this.source_armature = armature@@ -33,6 +32,7 @@ export class AnimationRetargetService {return this.source_armature}+ private skeleton_type: SkeletonType = SkeletonType.Nonepublic set_skeleton_type (type: SkeletonType): void {this.skeleton_type = type}@@ -62,10 +62,19 @@ export class AnimationRetargetService {* @returns A new animation clip retargeted for the target skeleton*/+ private target_mapping_type: TargetBoneMappingType = TargetBoneMappingType.None++ public set_target_mapping_type (type: TargetBoneMappingType): void {+ this.target_mapping_type = type+ }++ public get_target_mapping_type (): TargetBoneMappingType {+ return this.target_mapping_type+ }+public retarget_animation_clip (source_clip: AnimationClip,bone_mappings: Map<string, string>,- target_mapping_type: TargetBoneMappingType,target_skeleton_data: Scene | null = null,target_skinned_meshes: SkinnedMesh[] = []): AnimationClip {@@ -107,7 +116,7 @@ export class AnimationRetargetService {const retargeted_clip = new AnimationClip(`${source_clip.name}`, source_clip.duration, new_tracks)// Apply Mixamo-specific corrections if needed- if (target_mapping_type === TargetBoneMappingType.Mixamo) {+ if (this.target_mapping_type === TargetBoneMappingType.Mixamo) {this.apply_bone_rotation_correction(retargeted_clip,bone_mappings,diff --git a/src/retarget/RetargetAnimationPreview.ts b/src/retarget/RetargetAnimationPreview.tsindex 1480d9d..abd725b 100644--- a/src/retarget/RetargetAnimationPreview.ts+++ b/src/retarget/RetargetAnimationPreview.ts@@ -185,7 +185,6 @@ export class RetargetAnimationPreview extends EventTarget {this.retargeted_animation_clip = AnimationRetargetService.getInstance().retarget_animation_clip(this.current_animation_clip,bone_mappings,- this.step_bone_mapping.get_target_mapping_template(),this.step_bone_mapping.get_target_skeleton_data(),this.target_skinned_meshes)diff --git a/src/retarget/steps/StepExportRetargetedAnimations.ts b/src/retarget/steps/StepExportRetargetedAnimations.tsindex 2e4b176..95d042e 100644--- a/src/retarget/steps/StepExportRetargetedAnimations.ts+++ b/src/retarget/steps/StepExportRetargetedAnimations.ts@@ -8,15 +8,14 @@ export class StepExportRetargetedAnimations extends EventTarget {// Retargeting-related propertiesprivate bone_mapping = new Map<string, string>()- private target_mapping_type: TargetBoneMappingType = TargetBoneMappingType.None+ // target_mapping_type is now managed by AnimationRetargetService singletonprivate target_skeleton_data: Scene | null = nullprivate target_skinned_meshes: SkinnedMesh[] = []private target_rig_scene: Scene | null = nullpublic setup_retargeting (target_rig_scene: Scene, meshes: SkinnedMesh[], bone_mapping: Map<string, string>,- mapping_type: TargetBoneMappingType, skeleton_data: Scene | null): void {+ skeleton_data: Scene | null): void {this.bone_mapping = bone_mapping- this.target_mapping_type = mapping_typethis.target_skeleton_data = skeleton_datathis.target_skinned_meshes = meshesthis.target_rig_scene = target_rig_scene@@ -48,7 +47,6 @@ export class StepExportRetargetedAnimations extends EventTarget {AnimationRetargetService.getInstance().retarget_animation_clip(clip,this.bone_mapping,- this.target_mapping_type,this.target_skeleton_data,this.target_skinned_meshes // use the meshes being exported as the target)