Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

Improve UI for showing bones list by using standard tools panel like other pages

Scott Petrovic1f3041f16c6e
diff --git a/src/retarget/StepBoneMapping.ts b/src/retarget/StepBoneMapping.ts
index f1e26f0..83ea7b5 100644
--- a/src/retarget/StepBoneMapping.ts
+++ b/src/retarget/StepBoneMapping.ts
@@ -8,7 +8,6 @@ export class StepBoneMapping extends EventTarget {
private target_skeleton_type: SkeletonType = SkeletonType.None
// DOM references
- private bone_mapping_container: HTMLDivElement | null = null
private source_bones_list: HTMLDivElement | null = null
private target_bones_list: HTMLDivElement | null = null
@@ -19,13 +18,9 @@ export class StepBoneMapping extends EventTarget {
public begin (): void {
// Get DOM references
- this.bone_mapping_container = document.getElementById('bone-mapping-container') as HTMLDivElement
this.source_bones_list = document.getElementById('source-bones-list') as HTMLDivElement
this.target_bones_list = document.getElementById('target-bones-list') as HTMLDivElement
- // Show the bone mapping UI
- this.show_bone_mapping_ui()
-
// Populate the lists
this.update_bone_lists()
}
@@ -33,12 +28,14 @@ export class StepBoneMapping extends EventTarget {
public set_source_skeleton_data (skeleton_data: Group<Object3DEventMap>): void {
this.source_skeleton_data = skeleton_data
console.log('Source skeleton data set in bone mapping:', this.source_skeleton_data)
+ this.update_source_bones_list()
}
public set_target_skeleton_data (armature: Object3D, skeleton_type: SkeletonType): void {
this.target_armature = armature
this.target_skeleton_type = skeleton_type
console.log('Target skeleton data set in bone mapping:', this.target_armature, 'Type:', this.target_skeleton_type)
+ this.update_target_bones_list()
}
public has_source_skeleton (): boolean {
@@ -114,7 +111,7 @@ export class StepBoneMapping extends EventTarget {
const bone_names = this.get_source_bone_names()
if (bone_names.length === 0) {
- this.source_bones_list.innerHTML = '<p style="color: #888;">No source skeleton loaded</p>'
+ this.source_bones_list.innerHTML = '<em>No source skeleton loaded</em>'
return
}
@@ -133,7 +130,7 @@ export class StepBoneMapping extends EventTarget {
const bone_names = this.get_target_bone_names()
if (bone_names.length === 0) {
- this.target_bones_list.innerHTML = '<p style="color: #888;">No target skeleton loaded</p>'
+ this.target_bones_list.innerHTML = '<em>No target skeleton loaded</em>'
return
}
@@ -146,16 +143,4 @@ export class StepBoneMapping extends EventTarget {
this.target_bones_list?.appendChild(bone_item)
})
}
-
- private show_bone_mapping_ui (): void {
- if (this.bone_mapping_container !== null) {
- this.bone_mapping_container.style.display = 'block'
- }
- }
-
- private hide_bone_mapping_ui (): void {
- if (this.bone_mapping_container !== null) {
- this.bone_mapping_container.style.display = 'none'
- }
- }
}
diff --git a/src/retarget/index.html b/src/retarget/index.html
index 88b75b0..3fe7154 100644
--- a/src/retarget/index.html
+++ b/src/retarget/index.html
@@ -8,7 +8,7 @@
<!-- Stylesheets-->
<link href="../styles.css" rel="stylesheet" crossorigin="anonymous" />
- <link rel="stylesheet" href="./retarget/retarget.css" crossorigin="anonymous" />
+ <link rel="stylesheet" href="./retarget.css" crossorigin="anonymous" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" />
<link rel="stylesheet" href="../dialog.css" crossorigin="anonymous" />
@@ -37,44 +37,47 @@
</button>
</div>
</nav>
-
- <div style="padding: 2rem;">
- <!-- there are some issues going on with scaling the skeleton for FBX and other formats
- so we will start simple for now with just GLB files -->
- <input type="file" id="upload-file" accept=".glb" style="display: none;" />
- <label for="upload-file" class="button" id="load-model-button">Choose Skinned 3d Model File</label>
-
- <div id="skeleton-selection-container" >
- <label for="skeleton-type-select">Choose Target Skeleton:</label>
- <select id="skeleton-type-select" class="button">
- <option value="">-- Select Skeleton --</option>
- <option value="human">Human</option>
- <option value="quadraped">Quadruped (Fox)</option>
- <option value="bird">Bird</option>
- <option value="dragon">Dragon</option>
- </select>
- </div>
- <button class="button" id="bone-map-button" >Bone Map</button>
-
- <!-- Bone Mapping UI -->
- <div id="bone-mapping-container" style="display: none; margin-top: 2rem;">
- <h3>Bone Mapping</h3>
- <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 2rem;">
- <div>
- <h4>Source Skeleton Bones</h4>
- <div id="source-bones-list" style="max-height: 400px; overflow-y: auto; border: 1px solid #ccc; padding: 1rem;">
- <!-- Source bones will be populated here -->
- </div>
+ <!-- Tool Options Panel -->
+ <div id="tool-panel">
+ <h1>Bring your own rigged model</h1>
+
+ <p>Instructions and information go here with what this page is for</p>
+ <div style="display: flex; flex-direction: row; gap: 1rem; margin-top: 1rem;">
+ <!-- imported 3d skinned mesh and bones list-->
+ <div class="bone-map-section">
+ <p>Your 3d rigged mesh</p>
+ <!-- there are some issues going on with scaling the skeleton for FBX and other formats
+ so we will start simple for now with just GLB files -->
+ <input type="file" id="upload-file" accept=".glb" style="display: none;" />
+ <label for="upload-file" class="button" id="load-model-button">Upload Skinned Model</label>
+
+ <p>Bones List</p>
+ <div id="source-bones-list">
+ <p style="color: var(--text-secondary);">No source skeleton loaded</p>
+ </div>
+ </div>
+
+ <!-- target skeleton selection and bones list-->
+ <div class="bone-map-section">
+ <h2>Mesh2Motion Skeleton</h2>
+ <div id="skeleton-selection-container" >
+ <!-- <label for="skeleton-type-select">Choose Target Skeleton:</label> -->
+ <select id="skeleton-type-select" class="button">
+ <option value="">-- Select Skeleton --</option>
+ <option value="human">Human</option>
+ <option value="quadraped">Quadruped (Fox)</option>
+ <option value="bird">Bird</option>
+ <option value="dragon">Dragon</option>
+ </select>
</div>
- <div>
- <h4>Target Skeleton Bones</h4>
- <div id="target-bones-list" style="max-height: 400px; overflow-y: auto; border: 1px solid #ccc; padding: 1rem;">
- <!-- Target bones will be populated here -->
- </div>
+
+ <p>Bones List</p>
+ <div id="target-bones-list" >
+ <p style="color: var(--text-secondary);">No target skeleton loaded</p>
</div>
</div>
- </div>
+ </div>
</div>
<!-- 3d view controls shown on bottom right. This helps with click events -->
diff --git a/src/retarget/retarget.css b/src/retarget/retarget.css
index e69de29..6728dd0 100644
--- a/src/retarget/retarget.css
+++ b/src/retarget/retarget.css
@@ -0,0 +1,17 @@
+h1 {
+ font-size: 1.5rem;
+}
+
+.bone-map-section {
+ display: inline-flex;
+ flex-direction: column;
+ border: 1px solid var(--bg-tertiary);
+ padding: 1rem;
+}
+
+#source-bones-list, #target-bones-list {
+ max-height: calc(100vh - 400px);
+ overflow-y: auto;
+ background-color: var(--bg-alternate);
+ border-radius: 0.25rem;
+}
\ No newline at end of file
diff --git a/src/retarget/retarget.ts b/src/retarget/retarget.ts
index e380efb..79ed910 100644
--- a/src/retarget/retarget.ts
+++ b/src/retarget/retarget.ts
@@ -9,7 +9,6 @@ class RetargetModule {
private readonly mesh2motion_engine: Mesh2MotionEngine
private fileInput: HTMLInputElement | null = null
private load_model_button: HTMLLabelElement | null = null
- private bone_map_button: HTMLButtonElement | null = null
private readonly step_load_target_skeleton: StepLoadTargetSkeleton
private readonly step_bone_mapping: StepBoneMapping
@@ -29,13 +28,13 @@ class RetargetModule {
public init (): void {
this.add_event_listeners()
this.step_load_target_skeleton.begin()
+ this.step_bone_mapping.begin()
}
public add_event_listeners (): void {
// Get DOM elements
this.fileInput = document.getElementById('upload-file') as HTMLInputElement
this.load_model_button = document.getElementById('load-model-button') as HTMLLabelElement
- this.bone_map_button = document.getElementById('bone-map-button') as HTMLButtonElement
// Add event listener for file selection
this.fileInput.addEventListener('change', (event) => {
@@ -49,11 +48,6 @@ class RetargetModule {
const skeleton_type = this.step_load_target_skeleton.get_skeleton_type()
this.step_bone_mapping.set_target_skeleton_data(target_armature, skeleton_type)
})
-
- // Bone map button click listener
- this.bone_map_button?.addEventListener('click', () => {
- this.handle_bone_map_requested()
- })
}
private handleFileSelect (event: Event): void {
@@ -120,15 +114,6 @@ class RetargetModule {
}
})
}
-
- private handle_bone_map_requested (): void {
- console.log('Bone map requested - proceeding to bone mapping step')
- console.log('Target skeleton type:', this.step_load_target_skeleton.get_skeleton_type())
- console.log('Target armature:', this.step_load_target_skeleton.get_loaded_target_armature())
-
- // Begin the bone mapping step
- this.step_bone_mapping.begin()
- }
}
// Initialize when DOM is ready
@@ -138,3 +123,4 @@ document.addEventListener('DOMContentLoaded', () => {
const retarget_app = new RetargetModule()
+
diff --git a/src/styles.css b/src/styles.css
index d2dc4fb..46be741 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -347,7 +347,7 @@ option {
top: var(--navigation-height);
right: 0;
border-left: 1px solid var(--bg-tertiary);
- padding: 0.5rem;
+ padding: 1.0rem;
height: 100%;
overflow-y: auto;
overflow-x: hidden;