Import a 3D Model and automatically assign and export animations
TypeScript
Remove the manual UI buttons for moving camera
Scott Petrovicb324d2d0ada9
diff --git a/src/index.html b/src/index.htmlindex 80adb7a..bd72868 100644--- a/src/index.html+++ b/src/index.html@@ -214,18 +214,6 @@<label for="mirror-skeleton">Mirror Left/Right Joints</label></div>- <hr />--- <!-- change camera to orthographic views to help position skeleton-->- <div style="text-align: center; padding: 0">View</div>- <div id="view-buttons-container" style="display: flex; gap: 0px; padding-top: 0">- <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>--<hr /><!-- add number input for changing scale of skeleton-->@@ -235,10 +223,6 @@<button id="scale-skeleton-button" class="secondary-button" >Scale skeleton</button></div>- <!-- hide this move to origin for now as is it seems to cause more trouble than it helps -->- <!-- <button id="action_move_to_origin" class="secondary-button" >Move to origin</button> -->-- <!-- <hr /> --><!-- option to change out skinning algorithm --><label style="display: none" for="skinning-algorithm-options">Skinning algorithm:</label>@@ -248,15 +232,6 @@<option value="closest-bone-child">Closest Distance Child</option></select>- <!-- checkbox for enabling weight skin debug mode. -->- <!-- <div class="styled-checkbox">- <input type="checkbox" id="debug-skinning-checkbox" >- <label for="debug-skinning-checkbox">Visualize Weight Painting</label>- <div class="tooltip">- <span class="material-symbols-outlined" style="font-size: 16px;">help</span>- <span class="tooltiptext">Preview weight painted mesh</span>- </div>- </div> --><!-- back to load skeleton --><div class="display: flex; gap: 0.5rem;">diff --git a/src/lib/EventListeners.ts b/src/lib/EventListeners.tsindex c7c8db6..60a4441 100644--- a/src/lib/EventListeners.ts+++ b/src/lib/EventListeners.ts@@ -136,11 +136,6 @@ export class EventListeners {this.bootstrap.process_step = this.bootstrap.process_step_changed(ProcessStep.LoadModel)})- // change view event listeners when configuring skeleton- this.bootstrap.ui.dom_view_front_change?.addEventListener('click', () => { this.bootstrap.switchToView('front') })- this.bootstrap.ui.dom_view_side_change?.addEventListener('click', () => { this.bootstrap.switchToView('side') })- this.bootstrap.ui.dom_view_top_change?.addEventListener('click', () => { this.bootstrap.switchToView('top') })-this.bootstrap.ui.dom_transform_type_radio_group?.addEventListener('change', (event: Event) => {const radio_button_selected: string | null = event.target?.valuediff --git a/src/lib/UI.ts b/src/lib/UI.tsindex b268e19..d3f0d0c 100644--- a/src/lib/UI.ts+++ b/src/lib/UI.ts@@ -68,12 +68,7 @@ export class UI {dom_export_button_hidden_link: HTMLElement | null = nulldom_build_version: HTMLElement | null = null- // changing views buttons when editing skeleton- dom_view_front_change: HTMLButtonElement | null = null- dom_view_side_change: HTMLButtonElement | null = null- dom_view_top_change: HTMLButtonElement | null = null-- constructor () {+ constructor () {this.initialize_dom_elements()// AnimationSearch will be initialized when needed}@@ -118,11 +113,6 @@ export class UI {this.dom_mesh_preview_group = document.querySelector('#mesh-preview-group')- // UI controls for changing views- this.dom_view_front_change = document.querySelector('#front-view-button')- this.dom_view_side_change = document.querySelector('#side-view-button')- this.dom_view_top_change = document.querySelector('#top-view-button')-// UI controls for working with skinned meshthis.dom_skinned_mesh_tools = document.querySelector('#skinned-step-tools')this.dom_skinned_mesh_animation_tools = document.querySelector('#skinned-step-animation-export-options')diff --git a/src/script.ts b/src/script.tsindex be2984a..d4b6c59 100644--- a/src/script.ts+++ b/src/script.ts@@ -508,50 +508,6 @@ export class Bootstrap {return true}-- public switchToView (view: 'front' | 'side' | 'top'): void {- if (this.controls === undefined) {- console.log('switching to view failed: controls are undefined')- return- }-- const distance = 10- const target_position = new THREE.Vector3()- switch (view) {- case 'front':- target_position.set(0, 0, distance)- break- case 'side':- target_position.set(distance, 0, 0)- break- case 'top':- target_position.set(0, distance, 0)- break- }-- const bounding_box = this.load_model_step.model_meshes().children[0].geometry.boundingBox- const model_height = bounding_box.max.y - bounding_box.min.y- const target = new THREE.Vector3(0, model_height / 2, 0) // look at origin, adjusted for model height-- const start_position = this.camera.position.clone()- const start_time = performance.now()- const duration = 0.25 // seconds-- const animate = (current_time: number) => {- const elapsed_time = (current_time - start_time) / 1000- const t = Math.min(elapsed_time / duration, 1) // normalize time to [0, 1]-- this.camera.position.lerpVectors(start_position, target_position, t)- this.controls.target.lerp(target, t)- this.controls.update()-- if (t < 1) {- requestAnimationFrame(animate)- }- }-- requestAnimationFrame(animate)- }} // end Bootstrap class// Create an instance of the Bootstrap class when the script is loaded