Import a 3D Model and automatically assign and export animations
TypeScript
Add animation listing HTML to retargeting area and add a continue button
Scott Petrovicbcb23f4ba087
diff --git a/src/retarget/index.html b/src/retarget/index.htmlindex b197eda..4d343f2 100644--- a/src/retarget/index.html+++ b/src/retarget/index.html@@ -91,6 +91,116 @@</div></div>+ <div style="display: flex; padding: 1rem; justify-content: flex-end;">+ <button id="continue-to-listing-button" style="display: none">Continue</button>+ </div>++ <!-- animation listings area -->++ <span id="skinned-step-animation-export-options">++ <div id="animations-listing">++ <!-- Filter textbox for animations -->+ <div id="animation-listing-count">0</div>+ <input type="text" id="animation-filter" placeholder="Filter animations...">++ <!-- loading progress when animations start getting larger. -->+ <div id="animation-progress-loader-container" style="display: none">+ <div id="loading-status-text">Loading animation data</div>+ <div id="loading-progress-bar"></div>+ <div id="current-file-progress-bar"></div>+ </div>+++ <!-- javascript will populate this item with animations+ that we get from the animations file(s) -->+ <div id="animations-items"> </div>+++ <!-- slider to control arm extension (hide this feature until the base functionality is more stable) -->+ <div id="a-pose-correction-options">+ <div style="+ display: flex;+ flex-direction: row;+ align-items: center;+ gap: 1rem;+ justify-content: center;+ ">+ <label style="display:inline-flex">A-Pose Correction - Open Arms</label>+ <span class="material-symbols-outlined" data-tippy-content="If your model uses an A-Pose, this will help expand/contract arms for all animations">help</span>++ <button class="secondary-button" id="reset-a-pose-button">+ <img src="images/icons/reset.svg" alt="Reset A-Pose" width="20" height="20" />+ </button>+ </div>++ <div style="display: flex; flex-direction: row; gap: 1rem; justify-content: flex-start; align-items: center;">+ <input type="number" id="extend-arm-numeric-input" name="arm-extend-input" value="0" min="-70" max="100" step="1">+ <span class="suffix-unit">%</span>+ <input id="extend-arm-range-input" style="flex-grow: 1;" type="range" min="-70" max="100" value="0" />+ </div>++ <hr />++ </div>+++ <div style="display: flex; gap: 0.5rem;">+ <button class="secondary-button" id="action_back_to_edit_skeleton" >‹ Back</button>++ <!-- testing the mirroring options -->+ <div class="styled-checkbox icon-toggle">+ <input type="checkbox" id="mirror-animations-checkbox" name="mirror-animations" value="true" style="display:none;">+ <label for="mirror-animations-checkbox" data-tippy-content="Mirror animations" tabindex="0">+ <img src="images/icons/mirror.svg" alt="Mirror animations" width="30" height="30" />+ </label>+ </div>+++ <!-- checkbox option to show skeleton -->+ <div class="styled-checkbox icon-toggle">+ <input type="checkbox" id="show-skeleton-checkbox" name="show-skeleton" value="show" style="display:none;">+ <label for="show-skeleton-checkbox" data-tippy-content="Show skeleton" tabindex="0">+ <img src="images/icons/bone-display.svg" width="30" height="30" alt="Show skeleton" />+ </label>+ </div>++ <button id="export-button" title="Export animations. Make sure to select the animations you want to export first.">+ <span class="button-icon-group">+ <span class="material-symbols-outlined">save_alt</span>+ <span>Download <span id="animation-selection-count">0</span></span>+ </span>+ </button>+ <a id="download-hidden-link" href="#" style="display:none"></a>++ </div>++++ </div>+++ </span>++ </div>++ <!-- Free-floating Animation Player -->+ <div id="animation-player">+ <div id="current-animation-container">+ <span id="current-animation-name">No animation selected</span>+ </div>+ <div id="play-controls">+ <button id="play-pause-button" class="animation-control-button" disabled>+ <span class="material-symbols-outlined">play_arrow</span>+ </button>+ <span>+ <span id="current-time">0f</span> /+ <span id="total-time">0f</span>+ </span>+ <input type="range" id="animation-scrubber" min="0" max="100" value="0" disabled>+ </div>+</div><!-- 3d view controls shown on bottom right. This helps with click events -->diff --git a/src/retarget/retarget.ts b/src/retarget/retarget.tsindex 6dc958f..44af72b 100644--- a/src/retarget/retarget.ts+++ b/src/retarget/retarget.ts@@ -12,33 +12,35 @@ class RetargetModule {private readonly step_bone_mapping: StepBoneMappingprivate readonly retarget_animation_preview: RetargetAnimationPreview+ private continue_button: HTMLButtonElement | null+constructor () {// Set up camera position similar to marketing bootstrapthis.mesh2motion_engine = new Mesh2MotionEngine()const camera_position = new Vector3().set(0, 1.7, 5)this.mesh2motion_engine.set_camera_position(camera_position)-+// Override zoom limits for retargeting to accommodate models of various sizes// Allow closer zoom for small details and farther zoom for large models// FBX are known to have units with 1 = 1 cm, so things like mixamo will import at 200 units// GLB seems to have gone with 1 = 1 meterthis.mesh2motion_engine.set_zoom_limits(0.1, 1000)-+// Initialize Mesh2Motion skeleton loading step (source)this.step_load_source_skeleton = new StepLoadSourceSkeleton(this.mesh2motion_engine.get_scene())-+// Initialize target model loading stepthis.step_load_target_model = new StepLoadTargetModel(this.mesh2motion_engine)-+// Initialize bone mapping stepthis.step_bone_mapping = new StepBoneMapping(this.mesh2motion_engine.get_scene())-+// Initialize animation previewthis.retarget_animation_preview = new RetargetAnimationPreview(this.mesh2motion_engine.get_scene(),this.step_bone_mapping)-+// Set up animation loop for preview updatesthis.setup_animation_loop()}@@ -59,15 +61,23 @@ class RetargetModule {this.step_bone_mapping.set_source_skeleton_data(source_armature, skeleton_type)this.try_start_preview()})-+// Listen for target model (user-uploaded) loadedthis.step_load_target_model.addEventListener('target-model-loaded', (event: Event) => {const custom_event = event as CustomEventconst retargetable_meshes = custom_event.detail.retargetable_meshes as Group<Object3DEventMap>-+// Set target skeleton data in bone mapping (uploaded mesh)this.step_bone_mapping.set_target_skeleton_data(retargetable_meshes)this.try_start_preview()++ // Show "Continue" button to proceed to animation listing+ this.continue_button = document.getElementById('continue-to-listing-button') as HTMLButtonElement+ this.continue_button.style.display = 'block'+ this.continue_button.onclick = () => {+ // TODO: Hide the bone mapping panel and show the animation listing panel+ console.log('Continue to animation listing clicked')+ }})}@@ -83,20 +93,21 @@ class RetargetModule {private setup_animation_loop (): void {let last_time = performance.now()-+const animate = (): void => {requestAnimationFrame(animate)-+const current_time = performance.now()const delta_time = (current_time - last_time) / 1000 // Convert to secondslast_time = current_time-+// Update animation previewthis.retarget_animation_preview.update(delta_time)}-+animate()- }}+ }+}// Initialize when DOM is readydocument.addEventListener('DOMContentLoaded', () => {@@ -104,5 +115,3 @@ document.addEventListener('DOMContentLoaded', () => {})const retarget_app = new RetargetModule()--