Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

use skeleton scale when loading 'real' skeleton to edit. send skeleton scale to animation listing to use

Scott Petrovic487bf76217d0
diff --git a/src/lib/processes/animations-listing/StepAnimationsListing.ts b/src/lib/processes/animations-listing/StepAnimationsListing.ts
index ec8db52..85da7c4 100644
--- a/src/lib/processes/animations-listing/StepAnimationsListing.ts
+++ b/src/lib/processes/animations-listing/StepAnimationsListing.ts
@@ -28,6 +28,10 @@ export class StepAnimationsListing extends EventTarget {
private current_playing_index: number = 0
private skeleton_type: SkeletonType = SkeletonType.Human
+ // retrieved from load skeleton step
+ // we will use this to scale all position animation keyframes (uniform scale)
+ private skeleton_scale: number = 1.0
+
private _added_event_listeners: boolean = false
// Animation search functionality
@@ -82,7 +86,9 @@ export class StepAnimationsListing extends EventTarget {
this.theme_manager = theme_manager
}
- public begin (skeleton_type: SkeletonType): void {
+ public begin (skeleton_type: SkeletonType, skeleton_scale: number): void {
+ this.skeleton_scale = skeleton_scale
+
if (this.ui.dom_current_step_index != null) {
this.ui.dom_current_step_index.innerHTML = '4'
}
diff --git a/src/lib/processes/load-skeleton/StepLoadSkeleton.ts b/src/lib/processes/load-skeleton/StepLoadSkeleton.ts
index f6c81ab..837b9b1 100644
--- a/src/lib/processes/load-skeleton/StepLoadSkeleton.ts
+++ b/src/lib/processes/load-skeleton/StepLoadSkeleton.ts
@@ -25,6 +25,12 @@ export class StepLoadSkeleton extends EventTarget {
return this.skeleton_file_path() // this is actually the type/filepath combo
}
+ // The edit skeleton step will use this to scale the skeleton when loading editable skeleton
+ // animations listing will use this to scale all position keyframes
+ public skeleton_scale (): number {
+ return this.skeleton_scale_percentage
+ }
+
constructor (main_scene: Scene) {
super()
this._main_scene = main_scene
@@ -178,6 +184,9 @@ export class StepLoadSkeleton extends EventTarget {
this.loaded_armature.position.set(0, 0, 0)
this.loaded_armature.updateWorldMatrix(true, true)
+ // scale the armature to what we picked using the scale slider/preview
+ this.loaded_armature.scale.set(this.skeleton_scale(), this.skeleton_scale(), this.skeleton_scale())
+
this.dispatchEvent(new CustomEvent('skeletonLoaded', { detail: this.loaded_armature }))
})
})
diff --git a/src/script.ts b/src/script.ts
index d5d5374..49b6698 100644
--- a/src/script.ts
+++ b/src/script.ts
@@ -292,7 +292,7 @@ export class Bootstrap {
break
case ProcessStep.AnimationsListing:
this.process_step = ProcessStep.AnimationsListing
- this.animations_listing_step.begin(this.load_skeleton_step.skeleton_type())
+ this.animations_listing_step.begin(this.load_skeleton_step.skeleton_type(), this.load_skeleton_step.skeleton_scale())
this.skeleton_helper?.setJointsVisible(false)