Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

Show hide download button options based on skeleton type

Scott Petrovic214ab251cb70
diff --git a/src/Mesh2MotionEngine.ts b/src/Mesh2MotionEngine.ts
index e643fb2..e599dc4 100644
--- a/src/Mesh2MotionEngine.ts
+++ b/src/Mesh2MotionEngine.ts
@@ -421,7 +421,13 @@ export class Mesh2MotionEngine {
}
else if (this.process_step === ProcessStep.AnimationsListing) {
this.process_step = ProcessStep.AnimationsListing
- this.animations_listing_step.begin(this.load_skeleton_step.skeleton_type(), this.load_skeleton_step.skeleton_scale())
+
+ const active_skeleton_type: SkeletonType = this.load_skeleton_step.skeleton_type()
+ this.animations_listing_step.begin(active_skeleton_type, this.load_skeleton_step.skeleton_scale())
+
+ // download options for export currently will only work for humanoid skeletons
+ // since we will give options to change the bone names to other standard formats.
+ this.download_settings.update_download_settings_ui_visibility(active_skeleton_type)
// update reference of skeleton helper to use the final skinned mesh
this.regenerate_skeleton_helper(this.weight_skin_step.skeleton())
diff --git a/src/lib/processes/export-to-file/DownloadSettings.ts b/src/lib/processes/export-to-file/DownloadSettings.ts
index 36a061f..a87c0f7 100644
--- a/src/lib/processes/export-to-file/DownloadSettings.ts
+++ b/src/lib/processes/export-to-file/DownloadSettings.ts
@@ -1,3 +1,5 @@
+import { SkeletonType } from '../../enums/SkeletonType.ts'
+
export enum BoneNamingStructure {
Default = 'default',
Mixamo = 'mixamo'
@@ -20,6 +22,21 @@ export class DownloadSettings extends EventTarget {
return this.selected_bone_naming_structure
}
+ // Download options currently only apply to human skeleton, so this will
+ // show/hide the DOM download settings options on UI based on that.
+ public update_download_settings_ui_visibility (skeleton_type: SkeletonType): void {
+ const is_human_skeleton = skeleton_type === SkeletonType.Human
+
+ if (this.dom_download_settings_popup !== null) {
+ this.dom_download_settings_popup.style.display = is_human_skeleton ? 'inline-flex' : 'none'
+ this.dom_download_settings_popup.setAttribute('aria-hidden', is_human_skeleton ? 'false' : 'true')
+ }
+
+ if (!is_human_skeleton) {
+ this.set_popup_visibility(false)
+ }
+ }
+
private initialize_dom_elements (): void {
this.dom_download_settings_popup = document.querySelector('#download-settings-popup')
this.dom_download_settings_toggle = document.querySelector('#download-settings-toggle')