Import a 3D Model and automatically assign and export animations
TypeScript
Only show head correction for human skeleton types
Scott Petrovic251be59f38b2
diff --git a/src/Mesh2MotionEngine.ts b/src/Mesh2MotionEngine.tsindex 6abe84f..ba424fd 100644--- a/src/Mesh2MotionEngine.ts+++ b/src/Mesh2MotionEngine.ts@@ -286,7 +286,7 @@ export class Mesh2MotionEngine {this.regenerate_skeleton_helper(this.edit_skeleton_step.skeleton())process_step = ProcessStep.EditSkeleton- this.edit_skeleton_step.begin(this.scene)+ this.edit_skeleton_step.begin(this.scene, this.load_skeleton_step.skeleton_type())this.transform_controls.enabled = truethis.transform_controls.setMode(this.transform_controls_type) // 'translate', 'rotate'diff --git a/src/create.html b/src/create.htmlindex 31b6488..a307dca 100644--- a/src/create.html+++ b/src/create.html@@ -265,7 +265,7 @@<hr /><!-- Preview plane controls -->- <div style="display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem;">+ <div id="use-head-weight-correction-container" style="display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem;"><div class="styled-checkbox"><input type="checkbox" id="preview-plane-checkbox" /><label for="preview-plane-checkbox">Use Head Weight Correction</label>@@ -277,16 +277,10 @@<input type="range" id="preview-plane-height-input" min="0.20" max="2.00" step="0.01" value="0.50" /><span id="preview-plane-height-label" style="width: 2rem;">0.50</span></div>- </div>- <hr />+ <hr />- <!-- add number input for changing scale of skeleton-->- <!-- <div style="display: flex; flex-direction: row; justify-content: space-evenly; align-items: center; gap: 0.4rem;">- <input type="number" id="scale-input" name="scale-input" value="-3" min="-90" max="90" step="1.0">- <span class="suffix-unit">%</span>- <button id="scale-skeleton-button" class="secondary-button" >Scale skeleton</button>- </div> -->+ </div><!-- option to change out skinning algorithm -->diff --git a/src/lib/UI.ts b/src/lib/UI.tsindex 83fc073..fc11e0b 100644--- a/src/lib/UI.ts+++ b/src/lib/UI.ts@@ -39,6 +39,7 @@ export class UI {dom_transform_space_radio_group: HTMLElement | null = null// preview plane controls+ dom_use_head_weight_correction_container: HTMLElement | null = nulldom_preview_plane_checkbox: HTMLInputElement | null = nulldom_preview_plane_height_input: HTMLInputElement | null = nulldom_preview_plane_height_label: HTMLElement | null = null@@ -123,6 +124,7 @@ export class UI {this.dom_transform_space_radio_group = document.querySelector('#transform-space-group')// preview plane controls+ this.dom_use_head_weight_correction_container = document.querySelector('#use-head-weight-correction-container')this.dom_preview_plane_checkbox = document.querySelector('#preview-plane-checkbox')this.dom_preview_plane_height_input = document.querySelector('#preview-plane-height-input')this.dom_preview_plane_height_label = document.querySelector('#preview-plane-height-label')diff --git a/src/lib/processes/edit-skeleton/StepEditSkeleton.ts b/src/lib/processes/edit-skeleton/StepEditSkeleton.tsindex bac64b0..5470d61 100644--- a/src/lib/processes/edit-skeleton/StepEditSkeleton.ts+++ b/src/lib/processes/edit-skeleton/StepEditSkeleton.ts@@ -18,6 +18,7 @@ import {type Camera} from 'three'import { SkinningFormula } from '../../enums/SkinningFormula.ts'+import { SkeletonType } from '../../enums/SkeletonType.ts'/** StepEditSkeleton@@ -96,7 +97,22 @@ export class StepEditSkeleton extends EventTarget {return result}- public begin (main_scene: Scene): void {+ private update_ui_options_on_begin(skeleton_type: SkeletonType): void {+ // keep track of skeleton type to show/hide certain UI elements+ // only human skeletons have the head weight correction option+ if (this.ui.dom_use_head_weight_correction_container != null) {+ if (skeleton_type === SkeletonType.Human) {+ this.ui.dom_use_head_weight_correction_container.style.display = 'block'+ } else {+ this.ui.dom_use_head_weight_correction_container.style.display = 'none'+ this.enable_head_weight_correction = false // force setting to false in case it was enabled before+ }+ }+ }++ public begin (main_scene: Scene, skeleton_type: SkeletonType): void {+ this.update_ui_options_on_begin(skeleton_type)+// show UI elemnents for editing meshif (this.ui.dom_current_step_index != null) {this.ui.dom_current_step_index.innerHTML = '3'