Import a 3D Model and automatically assign and export animations
TypeScript
Add back A-Pose fix to open arms. clean up button styles a bit. Add arrows for back/next buttons
Scott Petrovic4c2afdfb5427
diff --git a/src/index.html b/src/index.htmlindex 5f6cdac..af84d43 100644--- a/src/index.html+++ b/src/index.html@@ -38,7 +38,7 @@<div id="load-model-tools">- <p class="step-instructions">Supports GLTF or GLB files. Models must be in T-Pose. A-Pose has issues for now.</p>+ <p class="step-instructions">Supports GLTF or GLB files. Models must be in T-Pose.</p><label for="model-upload" class="button" ><span class="button-icon-group">@@ -68,7 +68,7 @@<div class="tooltip"><span class="material-symbols-outlined" style="font-size: 16px;">help</span>- <span class="tooltiptext">Replaces all materials with normal shaders for debugging</span>+ <span class="tooltiptext">Replaces all materials with a 'normal' shader for debugging</span></div></div>@@ -91,15 +91,15 @@<span><span>Rotate Model to face front</span><div style="display: flex; flex-direction: row">- <button id="rotate-model-x-button">X</button>- <button id="rotate-model-y-button">Y</button>- <button id="rotate-model-z-button">Z</button>+ <button class="secondary-button" id="rotate-model-x-button">X</button>+ <button class="secondary-button" id="rotate-model-y-button">Y</button>+ <button class="secondary-button" id="rotate-model-z-button">Z</button></div></span><hr />- <button id="load-skeleton-button">Load Skeleton</button>+ <button id="load-skeleton-button">Load Skeleton ›</button></div>@@ -122,9 +122,9 @@<div style="display: flex; flex-direction: row; align-items: center; column-gap: 5px; "><span>View:</span><div id="view-buttons-container" style="display: flex; gap: 5px;">- <button id="front-view-button">Front</button>- <button id="side-view-button">Side</button>- <button id="top-view-button">Top</button>+ <button class="secondary-button" id="front-view-button">Front</button>+ <button class="secondary-button" id="side-view-button">Side</button>+ <button class="secondary-button" id="top-view-button">Top</button></div></div>@@ -168,7 +168,7 @@<p class="step-instructions">Select animations you want to export by checking them by animation</p>- <button id="action_back_to_edit_skeleton" >Back to edit skeleton</button>+ <button id="action_back_to_edit_skeleton" >‹ Back to edit skeleton</button><!-- checkbox option to show skeleton --><div class="styled-checkbox">@@ -193,11 +193,19 @@<!-- slider to control arm extension (hide this feature until the base functionality is more stable) -->- <!-- <div style="display: flex; flex-direction: row; justify-content: space-evenly; align-items: center;">+ <div style="display: flex; flex-direction: row; align-items: center;">+ <label style="display:inline-flex">A-Pose Correction</label>+ <span class="tooltip">+ <span class="material-symbols-outlined" style="font-size: 16px;">help</span>+ <span class="tooltiptext">If your model uses an A-Pose, this will help expand/contract arms for all animations</span>+ </span>+ </div>++ <div style="display: flex; flex-direction: row; gap: 1rem; justify-content: flex-start; align-items: center;"><input type="number" id="extend-arm-input" name="arm-extend-input" value="3" min="-25" max="25" step="1"><span class="suffix-unit">%</span><button id="extend-arm-button" class="secondary-button" >Open Arms</button>- </div> -->+ </div><hr />diff --git a/src/lib/processes/StepAnimationsListing.ts b/src/lib/processes/StepAnimationsListing.tsindex 09a1515..2d34fff 100644--- a/src/lib/processes/StepAnimationsListing.ts+++ b/src/lib/processes/StepAnimationsListing.ts@@ -171,6 +171,7 @@ export class StepAnimationsListing extends EventTarget {}private extend_arm_animations_by_percentage (percentage: number): void {+// loop through each animation clip to update the tracksthis.animation_clips_loaded.forEach((animation_clip: AnimationClip) => {animation_clip.tracks.forEach((track: KeyframeTrack) => {@@ -183,8 +184,10 @@ export class StepAnimationsListing extends EventTarget {const quaterion_track: QuaternionKeyframeTrack = track// if the track is an upper arm bone, then modify that- const track_name_to_match: string = '_Arm' // for simplified human skeleton- if (quaterion_track.name.indexOf(track_name_to_match) > -1) {+ const is_right_arm_track_match: boolean = quaterion_track.name.indexOf('upper_armR') > -1+ const is_left_arm_track_match: boolean = quaterion_track.name.indexOf('upper_armL') > -1++ if (is_right_arm_track_match || is_left_arm_track_match) {const new_track_values: Float32Array = quaterion_track.values.slice() // clone arrayconst track_count: number = quaterion_track.times.length@@ -192,7 +195,14 @@ export class StepAnimationsListing extends EventTarget {// get correct value since it is a quaternionconst units_in_quaternions: number = 4const quaternion: Quaternion = new Quaternion()- quaternion.setFromAxisAngle(new Vector3(1, 0, 0), percentage / 100)++ // rotate the upper arms in opposite directions to rise/lower arms+ if (is_right_arm_track_match) {+ quaternion.setFromAxisAngle(new Vector3(0, 0, -1), percentage / 100)+ }+ if (is_left_arm_track_match) {+ quaternion.setFromAxisAngle(new Vector3(0, 0, 1), percentage / 100)+ }// get the existing quaternionconst existing_quaternion: Quaternion = new Quaternion(diff --git a/src/lib/processes/StepEditSkeleton.ts b/src/lib/processes/StepEditSkeleton.tsindex fa4c88b..387d900 100644--- a/src/lib/processes/StepEditSkeleton.ts+++ b/src/lib/processes/StepEditSkeleton.ts@@ -68,7 +68,7 @@ export class StepEditSkeleton extends EventTarget {}if (this.ui.dom_bind_pose_button !== null) {- this.ui.dom_bind_pose_button.innerHTML = 'Skin Model'+ this.ui.dom_bind_pose_button.innerHTML = 'Skin Model ›'}}diff --git a/src/styles.css b/src/styles.cssindex 1fed019..72dea63 100644--- a/src/styles.css+++ b/src/styles.css@@ -26,7 +26,7 @@hr {border:1px solid #1f405a;width: 100%;- margin: 0.3rem 0rem;+ margin: 1rem 0rem;}li{@@ -232,9 +232,9 @@ option {/* width */-::-webkit-scrollbar {+/* ::-webkit-scrollbar {width: 14px;- }+ } *//* Track */::-webkit-scrollbar-track {@@ -352,7 +352,7 @@ input[type="file"] {.tooltip {position: relative;display: inline-block;- margin-left: 4px;+}@@ -392,7 +392,7 @@ input[type="file"] {.styled-checkbox {display: flex;align-items: center;- gap: 0.5rem; /* Space between checkbox and label */+ gap: 0; /* Space between checkbox and label */}.styled-checkbox input[type="checkbox"] {