Import a 3D Model and automatically assign and export animations
TypeScript
Better UX for retargeting to make sure at least one bone is mapped before continuing
Scott Petrovic56d77b3bcd7b
diff --git a/src/retarget/index.html b/src/retarget/index.htmlindex 273011d..728fe42 100644--- a/src/retarget/index.html+++ b/src/retarget/index.html@@ -130,8 +130,15 @@</div></div>- <div style="display: flex; padding: 1rem; justify-content: flex-end;">- <button id="continue-to-listing-button" style="display: none">Continue</button>+ <div style="display: flex; padding: 1rem; justify-content: flex-end; align-items: center; gap: 0.25rem;">+ <button id="continue-to-listing-button" disabled>Continue</button>+ <span id="continue-button-tooltip"+ data-tippy-content="Map at least one source bone to a target bone before continuing."+ aria-label="Continue requirements help"+ style="display: inline-flex; align-items: center; color: var(--text-secondary); cursor: help;"+ >+ <span class="material-symbols-outlined" style="font-size: 1.2rem;">help</span>+ </span></div></span>diff --git a/src/retarget/retarget.ts b/src/retarget/retarget.tsindex c54016f..5e6e2b6 100644--- a/src/retarget/retarget.ts+++ b/src/retarget/retarget.ts@@ -18,6 +18,7 @@ class RetargetModule {private animation_listing_step: RetargetAnimationListing | null = nullprivate back_to_bone_map_button: HTMLButtonElement | null = null+ private continue_to_listing_button: HTMLButtonElement | null = nullconstructor () {// Set up camera position similar to marketing bootstrap@@ -58,7 +59,9 @@ class RetargetModule {this.back_to_bone_map_button = document.getElementById('back_to_bone_map_button') as HTMLButtonElementconst bone_mapping_step = document.getElementById('bone-mapping-step')const animation_export_options = document.getElementById('skinned-step-animation-export-options')- const continue_button = document.getElementById('continue-to-listing-button') as HTMLButtonElement+ this.continue_to_listing_button = document.getElementById('continue-to-listing-button') as HTMLButtonElement++ this.update_continue_button_state()this.back_to_bone_map_button.onclick = () => {// Hide the skinned-step-animation-export-options ID and show the bone-mapping-step ID@@ -112,15 +115,18 @@ class RetargetModule {// hide the skeleton helper since we are on that stepthis.step_load_source_skeleton.show_skeleton_helper(false)-this.start_live_preview()- // Show "Continue" button to proceed to animation listing- continue_button.style.display = 'block'+ this.update_continue_button_state()+ })++ // listen for bone mapping update events to update continue button state+ this.step_bone_mapping.addEventListener('bone-mappings-changed', () => {+ this.update_continue_button_state()})// next button to go to the animation listing step- continue_button.onclick = () => {+ this.continue_to_listing_button.onclick = () => {// Hide the bone-mapping-step ID and show the skinned-step-animation-export-options IDif (bone_mapping_step !== null && animation_export_options !== null) {bone_mapping_step.style.display = 'none'@@ -145,14 +151,41 @@ class RetargetModule {}}- private check_for_mesh2motion_retarget (): void {- // if the source and target is identical, no need to do bone mapping step- const identical_bones: boolean = RetargetUtils.are_source_and_target_bones_identical(+ private update_continue_button_state (): void {+ if (this.continue_to_listing_button === null) {+ return+ }++ // variables that control if we enable the continue button and show the tooltip+ const identical_bones: boolean = this.is_source_and_target_rig_identical() // target rig is a M2M rig+ const tooltip_span: HTMLElement | null = document.querySelector('#continue-button-tooltip')+ const has_at_least_one_bone_mapping = this.step_bone_mapping.has_bone_mappings()++ // only show the tooltip if we dont' have any bone mappings to provide guidance to the user+ if (tooltip_span != null) {+ if (has_at_least_one_bone_mapping || identical_bones) {+ tooltip_span.style.display = 'none'+ } else {+ tooltip_span.style.display = 'inline-flex'+ }+ }++ // enable/disable the continue button+ this.continue_to_listing_button.disabled = !(identical_bones || has_at_least_one_bone_mapping)+ }++ // Helps us determine if we are uploading a Mesh2Motion rig+ // we don't need bone mapping for that, so this helps us catch that scenario+ private is_source_and_target_rig_identical (): boolean {+ return RetargetUtils.are_source_and_target_bones_identical(AnimationRetargetService.getInstance().get_source_armature(),AnimationRetargetService.getInstance().get_target_armature())+ }- console.log('Are source and target bones identical (no mapping needed)?', identical_bones)+ private check_for_mesh2motion_retarget (): void {+ // if the source and target is identical, no need to do bone mapping step+ const identical_bones: boolean = this.is_source_and_target_rig_identical()const target_bones_list_container = document.getElementById('target-bones-list-container')const no_bone_mapping_needed_message = document.getElementById('no-bone-mapping-needed-message')diff --git a/src/retarget/steps/StepBoneMapping.ts b/src/retarget/steps/StepBoneMapping.tsindex 65eebc7..571ed11 100644--- a/src/retarget/steps/StepBoneMapping.ts+++ b/src/retarget/steps/StepBoneMapping.ts@@ -297,14 +297,6 @@ export class StepBoneMapping extends EventTarget {this.update_target_bones_list()this.update_clear_button_visibility()- // Dispatch event to notify of mapping change- this.dispatchEvent(new CustomEvent('bone-mapping-updated', {- detail: {- target_bone: target_bone_name,- source_bone: source_bone_name- }- }))-// Dispatch event to notify about mapping state changethis.dispatchEvent(new CustomEvent('bone-mappings-changed'))}