Import a 3D Model and automatically assign and export animations
TypeScript
Add a select all toggle to include all animations
Scott Petrovic9ec7cde9283c
diff --git a/src/create.html b/src/create.htmlindex 1c4cb40..bc48786 100644--- a/src/create.html+++ b/src/create.html@@ -320,10 +320,15 @@<!-- Filter textbox for animations --><span style="position: relative; flex: 1;"><input type="text" id="animation-filter" placeholder="Filter">- <div id="animation-listing-count">0</div></span></div>+ <!-- Select all / Deselect all button and animation count -->+ <div id="toggle-select-all-container">+ <button id="toggle-select-all-animations" class="secondary-button">Select All</button>+ <div id="animation-listing-count" style="white-space: nowrap;">0 animations</div>+ </div>+<!-- loading progress when animations start getting larger. --><div id="animation-progress-loader-container" style="display: none">@@ -334,7 +339,7 @@<!-- javascript will populate this item with animationsthat we get from the animations file(s) -->- <div id="animations-items"></div>+ <div id="animations-items" class="create-page"></div><!-- slider to control arm extension (hide this feature until the base functionality is more stable) --><div id="arm-extension-options">diff --git a/src/index.html b/src/index.htmlindex 22a8f24..d6d020d 100644--- a/src/index.html+++ b/src/index.html@@ -123,10 +123,15 @@<!-- Filter textbox for animations --><span style="position: relative; flex: 1;"><input type="text" id="animation-filter" placeholder="Filter">- <div id="animation-listing-count">0</div></span></div>+ <!-- Select all / Deselect all button and animation count -->+ <div id="toggle-select-all-container">+ <button id="toggle-select-all-animations" class="secondary-button">Select All</button>+ <div id="animation-listing-count" style="white-space: nowrap;">0 animations</div>+ </div>+<!-- loading progress when animations start getting larger. --><div id="animation-progress-loader-container" style="display: none">diff --git a/src/lib/processes/animations-listing/AnimationSearch.ts b/src/lib/processes/animations-listing/AnimationSearch.tsindex ce6b7a6..c7ed221 100644--- a/src/lib/processes/animations-listing/AnimationSearch.ts+++ b/src/lib/processes/animations-listing/AnimationSearch.ts@@ -283,4 +283,42 @@ export class AnimationSearch extends EventTarget {this.render_filtered_animations('')}}++ public toggle_select_all_animations (): void {+ // Check if all animations are currently selected+ const all_selected = this.all_animations.every(animation => animation.isChecked === true)++ // Toggle the state: if all are selected, deselect all; otherwise, select all+ const new_state = !all_selected+ this.all_animations.forEach(animation => {+ animation.isChecked = new_state+ })++ // Update all checkboxes in the UI+ this.update_all_checkboxes_in_ui(new_state)++ // Save the checkbox states to ensure they're synced with the UI+ this.save_current_checkbox_states()++ // If in "selected only" mode, re-render to update the displayed animations+ if (this.show_selected_only) {+ const filter_text = this.filter_input?.value.toLowerCase() ?? ''+ this.render_filtered_animations(filter_text)+ }++ // Emit event to notify that export options have changed+ this.custom_event = new CustomEvent('export-options-changed', { detail: { selectedAnimations: this.get_selected_animation_indices() } })+ this.dispatchEvent(this.custom_event)+ }++ private update_all_checkboxes_in_ui (checked_state: boolean): void {+ if (this.animation_list_container === null) {+ return+ }++ const checkboxes = this.animation_list_container.querySelectorAll('input[type="checkbox"]')+ checkboxes.forEach((checkbox) => {+ (checkbox as HTMLInputElement).checked = checked_state+ })+ }}diff --git a/src/lib/processes/animations-listing/StepAnimationsListing.ts b/src/lib/processes/animations-listing/StepAnimationsListing.tsindex b34503d..40aa08f 100644--- a/src/lib/processes/animations-listing/StepAnimationsListing.ts+++ b/src/lib/processes/animations-listing/StepAnimationsListing.ts@@ -487,6 +487,13 @@ export class StepAnimationsListing extends EventTarget {})})+ // event listener for select all / deselect all button+ const toggle_select_all_button = document.querySelector('#toggle-select-all-animations')+ toggle_select_all_button?.addEventListener('click', () => {+ this.animation_search?.toggle_select_all_animations()+ this.update_download_button_enabled()+ })+// helps ensure we don't add event listeners multiple timesthis.has_added_event_listeners = true}diff --git a/src/marketing/marketing.css b/src/marketing/marketing.cssindex f1128bc..beb7f91 100644--- a/src/marketing/marketing.css+++ b/src/marketing/marketing.css@@ -35,11 +35,6 @@ button.active-button {background-color: var(--button-primary-bg);}-#animations-items {- max-height: calc(100vh - 19rem);-}--/* model switcher styles on the explore page */#model-variation-switcher {display: flex;diff --git a/src/retarget/RetargetAnimationListing.ts b/src/retarget/RetargetAnimationListing.tsindex 7498c74..f859ccd 100644--- a/src/retarget/RetargetAnimationListing.ts+++ b/src/retarget/RetargetAnimationListing.ts@@ -147,7 +147,7 @@ export class RetargetAnimationListing extends EventTarget {// Update animation listing count displayconst listing_count_element = document.getElementById('animation-listing-count')if (listing_count_element !== null) {- listing_count_element.textContent = this.animation_clips_loaded.length.toString() + 'animations'+ listing_count_element.textContent = this.animation_clips_loaded.length.toString() + ' animations'}// the export button enabled state relies on the animation search being initialized@@ -244,6 +244,24 @@ export class RetargetAnimationListing extends EventTarget {this.animation_search?.set_show_selected_only(show_selected_only)})})++ // event listener for select all / deselect all button+ const toggle_select_all_button = document.querySelector('#toggle-select-all-animations')+ toggle_select_all_button?.addEventListener('click', () => {+ this.animation_search?.toggle_select_all_animations()+ // Update the export button disabled state+ const animation_checkboxes = document.querySelectorAll('#animations-items input[type="checkbox"]')+ const is_any_checkbox_checked: boolean = Array.from(animation_checkboxes).some((checkbox) => {+ return (checkbox as HTMLInputElement).checked+ })+ if (this.export_button != null) {+ this.export_button.disabled = !is_any_checkbox_checked+ }+ // Update the count+ if (this.animation_count_element != null) {+ this.animation_count_element.textContent = this.get_selected_animation_indices().length.toString()+ }+ })}public get_animation_player (): AnimationPlayer {diff --git a/src/retarget/index.html b/src/retarget/index.htmlindex 0ab8dd1..325cde6 100644--- a/src/retarget/index.html+++ b/src/retarget/index.html@@ -162,11 +162,16 @@</div><!-- Filter textbox for animations -->- <span style="position: relative; flex: 1;">+ <span><input type="text" id="animation-filter" placeholder="Filter">- <div id="animation-listing-count">0</div></span></div>++ <!-- Select all / Deselect all button and animation count -->+ <div style="display: flex; gap: 1rem; align-items: center; margin-top: 0.5rem; justify-content: space-between;">+ <button id="toggle-select-all-animations" class="secondary-button">Select All</button>+ <div id="animation-listing-count" style="white-space: nowrap;">0 animations</div>+ </div><!-- loading progress when animations start getting larger. --><div id="animation-progress-loader-container" style="display: none">diff --git a/src/retarget/retarget.css b/src/retarget/retarget.cssindex 885dda8..f23b10e 100644--- a/src/retarget/retarget.css+++ b/src/retarget/retarget.css@@ -115,7 +115,7 @@ h1 {}#animations-items {- max-height: calc(100vh - 14rem);+ max-height: calc(100vh - 17rem);}#auto-bone-map-match {diff --git a/src/styles.css b/src/styles.cssindex 38668b3..554304a 100644--- a/src/styles.css+++ b/src/styles.css@@ -151,9 +151,6 @@ div, p {}#animation-listing-count {- position: absolute;- top: 0.3rem;- right: 1rem;color: var(--text-alternate)}@@ -483,11 +480,17 @@ option {background: var(--bg-primary);}-+#toggle-select-all-container {+ display: flex;+ gap: 1rem;+ align-items: center;+ justify-content: space-between;+ margin-bottom: 0.5rem;+}#animations-items{- max-height: calc(100vh - 27rem);+ max-height: calc(100vh - 22rem);display: inline-flex;overflow: auto;;flex-direction: row;@@ -500,6 +503,11 @@ option {width: 24rem; /* creates 3 column of animation items */}+#animations-items.create-page {+ /* create page has a tile at the top so we need this listing grid slightly smaller */+ max-height: calc(100vh - 30rem);+}+#animations-items div {display: inline-flex;padding: 0;