Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

Disable export GLB button if no animations selected to export.

Scott Petrovice0b317b81691
diff --git a/src/index.html b/src/index.html
index e537e33..96ae209 100644
--- a/src/index.html
+++ b/src/index.html
@@ -245,7 +245,7 @@
</label>
<input id="import-animations-button" type="file" name="animation-upload" accept=".glb, .gltf, .fbx, .bvh" /> -->
- <button id="export-button">
+ <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 GLB</span>
diff --git a/src/lib/processes/StepAnimationsListing.ts b/src/lib/processes/StepAnimationsListing.ts
index b8c0d6c..1b63c7a 100644
--- a/src/lib/processes/StepAnimationsListing.ts
+++ b/src/lib/processes/StepAnimationsListing.ts
@@ -79,6 +79,7 @@ export class StepAnimationsListing extends EventTarget {
}
this.add_event_listeners()
+ this.update_download_button_enabled()
}
public mixer (): AnimationMixer {
@@ -224,6 +225,15 @@ export class StepAnimationsListing extends EventTarget {
})
}
+ private update_download_button_enabled (): void {
+ // see if any of the "export" checkboxes are active. if not we need to disable the "Download" button
+ const animation_checkboxes = this.ui.get_animated_selected_elements()
+ const is_any_checkbox_checked: boolean = Array.from(animation_checkboxes).some((checkbox) => {
+ return checkbox.checked === true
+ })
+ this.ui.dom_export_button.disabled = !is_any_checkbox_checked
+ }
+
private add_event_listeners (): void {
if (this.has_added_event_listeners) {
return
@@ -232,6 +242,8 @@ export class StepAnimationsListing extends EventTarget {
// event listener for animation clip list with changing the current animation
if (this.ui.dom_animation_clip_list != null) {
this.ui.dom_animation_clip_list.addEventListener('click', (event) => {
+ this.update_download_button_enabled()
+
if ((event.target != null) && event.target.tagName === 'BUTTON') {
const animation_index: number = event.target.getAttribute('data-index')
this.play_animation(animation_index)
diff --git a/src/styles.css b/src/styles.css
index b17ebe5..994047e 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -97,6 +97,13 @@ button:active, .button:active {
transform: scale(0.98);
}
+button:disabled {
+ background: #2b3d4a;
+ opacity: 0.5;
+ cursor: not-allowed;
+ border: none;
+}
+
.button-icon-group {