Skip to content

Commit 487bf76

Browse files
committed
use skeleton scale when loading 'real' skeleton to edit. send skeleton scale to animation listing to use
1 parent 16873c6 commit 487bf76

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

src/lib/processes/animations-listing/StepAnimationsListing.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ export class StepAnimationsListing extends EventTarget {
2828
private current_playing_index: number = 0
2929
private skeleton_type: SkeletonType = SkeletonType.Human
3030

31+
// retrieved from load skeleton step
32+
// we will use this to scale all position animation keyframes (uniform scale)
33+
private skeleton_scale: number = 1.0
34+
3135
private _added_event_listeners: boolean = false
3236

3337
// Animation search functionality
@@ -82,7 +86,9 @@ export class StepAnimationsListing extends EventTarget {
8286
this.theme_manager = theme_manager
8387
}
8488

85-
public begin (skeleton_type: SkeletonType): void {
89+
public begin (skeleton_type: SkeletonType, skeleton_scale: number): void {
90+
this.skeleton_scale = skeleton_scale
91+
8692
if (this.ui.dom_current_step_index != null) {
8793
this.ui.dom_current_step_index.innerHTML = '4'
8894
}

src/lib/processes/load-skeleton/StepLoadSkeleton.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ export class StepLoadSkeleton extends EventTarget {
2525
return this.skeleton_file_path() // this is actually the type/filepath combo
2626
}
2727

28+
// The edit skeleton step will use this to scale the skeleton when loading editable skeleton
29+
// animations listing will use this to scale all position keyframes
30+
public skeleton_scale (): number {
31+
return this.skeleton_scale_percentage
32+
}
33+
2834
constructor (main_scene: Scene) {
2935
super()
3036
this._main_scene = main_scene
@@ -178,6 +184,9 @@ export class StepLoadSkeleton extends EventTarget {
178184
this.loaded_armature.position.set(0, 0, 0)
179185
this.loaded_armature.updateWorldMatrix(true, true)
180186

187+
// scale the armature to what we picked using the scale slider/preview
188+
this.loaded_armature.scale.set(this.skeleton_scale(), this.skeleton_scale(), this.skeleton_scale())
189+
181190
this.dispatchEvent(new CustomEvent('skeletonLoaded', { detail: this.loaded_armature }))
182191
})
183192
})

src/script.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export class Bootstrap {
292292
break
293293
case ProcessStep.AnimationsListing:
294294
this.process_step = ProcessStep.AnimationsListing
295-
this.animations_listing_step.begin(this.load_skeleton_step.skeleton_type())
295+
this.animations_listing_step.begin(this.load_skeleton_step.skeleton_type(), this.load_skeleton_step.skeleton_scale())
296296

297297
this.skeleton_helper?.setJointsVisible(false)
298298

0 commit comments

Comments
 (0)