Import a 3D Model and automatically assign and export animations
TypeScript
make bone toggle visible/invisible depending on process step
Scott Petrovic3af2d7866ad6
diff --git a/src/lib/UI.ts b/src/lib/UI.tsindex a1d7f9a..11396a0 100644--- a/src/lib/UI.ts+++ b/src/lib/UI.ts@@ -8,6 +8,10 @@ export class UI {dom_load_model_button: HTMLButtonElement | null = nulldom_load_model_debug_checkbox: HTMLInputElement | null = null+ // toggle for showing/hiding skeleton in the 3D view+ dom_show_skeleton_container: HTMLElement | null = null+ dom_show_skeleton_checkbox: HTMLInputElement | null = null+// load skeleton UIdom_rotate_model_x_button: HTMLButtonElement | null = nulldom_rotate_model_y_button: HTMLButtonElement | null = null@@ -48,7 +52,6 @@ export class UI {dom_skinned_mesh_tools: HTMLElement | null = nulldom_skinned_mesh_animation_tools: HTMLElement | null = null- dom_show_skeleton_checkbox: HTMLInputElement | null = nulldom_back_to_edit_skeleton_button: HTMLButtonElement | null = nulldom_back_to_load_skeleton_button: HTMLButtonElement | null = nulldom_back_to_load_model_button: HTMLButtonElement | null = null@@ -105,6 +108,10 @@ export class UI {this.dom_current_step_index = document.querySelector('#current-step-index')this.dom_current_step_element = document.querySelector('#current-step-label')+ // skeleton toggle on UI viewport+ this.dom_show_skeleton_container = document.querySelector('#skeleton-toggle')+ this.dom_show_skeleton_checkbox = document.querySelector('#show-skeleton-checkbox')+// UI controls for loading the modelthis.dom_load_model_tools = document.querySelector('#load-model-tools')this.dom_upload_model_button = document.querySelector('#model-upload')@@ -157,7 +164,7 @@ export class UI {// UI controls for working with skinned meshthis.dom_skinned_mesh_tools = document.querySelector('#skinned-step-tools')this.dom_skinned_mesh_animation_tools = document.querySelector('#skinned-step-animation-export-options')- this.dom_show_skeleton_checkbox = document.querySelector('#show-skeleton-checkbox')+this.dom_back_to_edit_skeleton_button = document.querySelector('#action_back_to_edit_skeleton')this.dom_back_to_load_skeleton_button = document.querySelector('#action_back_to_load_skeleton')this.dom_back_to_load_model_button = document.querySelector('#action_back_to_load_model')@@ -216,5 +223,8 @@ export class UI {if (this.dom_skinned_mesh_animation_tools != null) {this.dom_skinned_mesh_animation_tools.style.display = 'none'}+ if (this.dom_show_skeleton_container != null) {+ this.dom_show_skeleton_container.style.display = 'none'+ }}}diff --git a/src/lib/processes/animations-listing/StepAnimationsListing.ts b/src/lib/processes/animations-listing/StepAnimationsListing.tsindex 3581c3f..3df3a2b 100644--- a/src/lib/processes/animations-listing/StepAnimationsListing.ts+++ b/src/lib/processes/animations-listing/StepAnimationsListing.ts@@ -100,6 +100,12 @@ export class StepAnimationsListing extends EventTarget {this.ui.dom_skinned_mesh_animation_tools.style.display = 'flex'}+ // bone display toggle only works in animation preview since+ // everything is setup by now+ if (this.ui.dom_show_skeleton_container != null) {+ this.ui.dom_show_skeleton_container.style.display = 'inline-flex'+ }+this.reset_step_data()this.custom_animation_importer.set_enabled(!this.is_loading_default_animations)diff --git a/src/retarget/RetargetAnimationListing.ts b/src/retarget/RetargetAnimationListing.tsindex 231d2d1..e6c9c5c 100644--- a/src/retarget/RetargetAnimationListing.ts+++ b/src/retarget/RetargetAnimationListing.ts@@ -6,6 +6,7 @@ import type { ThemeManager } from '../lib/ThemeManager.ts'import { type TransformedAnimationClipPair } from '../lib/processes/animations-listing/interfaces/TransformedAnimationClipPair.ts'import { AnimationRetargetService } from './AnimationRetargetService.ts'import { StepExportRetargetedAnimations } from './steps/StepExportRetargetedAnimations.ts'+import { UI } from '../lib/UI.ts'/*** RetargetAnimationListing - Handles animation listing and playback specifically for retargeting workflow@@ -18,6 +19,7 @@ export class RetargetAnimationListing extends EventTarget {private readonly step_export_retargeted_animations: StepExportRetargetedAnimations = new StepExportRetargetedAnimations()private animation_clips_loaded: TransformedAnimationClipPair[] = []private animation_mixer: AnimationMixer = new AnimationMixer(new Object3D())+ private readonly ui: UI = UI.getInstance()private _added_event_listeners: boolean = false@@ -40,6 +42,19 @@ export class RetargetAnimationListing extends EventTarget {this.add_event_listeners()this._added_event_listeners = true}++ this.show_bone_toggle_button(true)+ }++ public end (): void {+ this.show_bone_toggle_button(false) // cannot toggle bone display in configuration area+ this.stop_preview() // stop any playing animations in the listing+ }++ private show_bone_toggle_button (show: boolean): void {+ if (this.ui.dom_show_skeleton_container != null) {+ this.ui.dom_show_skeleton_container.style.display = show ? 'inline-flex' : 'none'+ }}public reset_step_data (): void {diff --git a/src/retarget/retarget.ts b/src/retarget/retarget.tsindex 5e6e2b6..3fbb1a6 100644--- a/src/retarget/retarget.ts+++ b/src/retarget/retarget.ts@@ -8,6 +8,7 @@ import { RetargetAnimationListing } from './RetargetAnimationListing.ts'import { AnimationRetargetService } from './AnimationRetargetService'import { type SkeletonType } from '../lib/enums/SkeletonType.ts'import { RetargetUtils } from './RetargetUtils.ts'+import { UI } from '../lib/UI.ts'class RetargetModule {private readonly mesh2motion_engine: Mesh2MotionEngine@@ -19,6 +20,7 @@ class RetargetModule {private back_to_bone_map_button: HTMLButtonElement | null = nullprivate continue_to_listing_button: HTMLButtonElement | null = null+ private readonly ui: UI = UI.getInstance()constructor () {// Set up camera position similar to marketing bootstrap@@ -72,11 +74,11 @@ class RetargetModule {// stop the animation listing stepif (this.animation_listing_step !== null) {- this.animation_listing_step.stop_preview()+ this.animation_listing_step.end() // any clean up needed to reset animation listing state}// start the live preview again and hide the animation player- this.start_live_preview()+ this.attempt_start_live_preview()this.mesh2motion_engine.show_animation_player(false)}@@ -115,7 +117,7 @@ class RetargetModule {// hide the skeleton helper since we are on that stepthis.step_load_source_skeleton.show_skeleton_helper(false)- this.start_live_preview()+ this.attempt_start_live_preview()this.update_continue_button_state()})@@ -204,12 +206,11 @@ class RetargetModule {}}- private start_live_preview (): void {- // Start preview when both skeletons are loaded+ private attempt_start_live_preview (): void {+ // Only start preview when both skeletons are loadedif (this.step_bone_mapping.has_both_skeletons()) {- console.log('Both skeletons loaded, starting animation preview...')-this.retarget_animation_preview.start_preview().catch((error) => {+ // maybe useful if errors happen in the future for debuggingconsole.error('Failed to start preview:', error)})}