Skip to content

Commit 524d6ec

Browse files
committed
Fix case where animation listing is getting triggered twice
1 parent 24e0515 commit 524d6ec

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

src/script.ts

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ export class Bootstrap {
250250

251251
/**********
252252
* MAIN PROCESS FLOW LOGIC
253+
* I am doing else if here since the bindpose step changes the step at the end
254+
* we don't want to trigger the animation listing too early since it is the case after
253255
*********/
254256
if (this.process_step === ProcessStep.LoadModel) {
255257
// reset the state in the case of coming back to this step
@@ -262,8 +264,7 @@ export class Bootstrap {
262264

263265
this.load_model_step.begin()
264266
}
265-
266-
if (this.process_step === ProcessStep.LoadSkeleton) {
267+
else if (this.process_step === ProcessStep.LoadSkeleton) {
267268
// add event listener. TODO: put this in the load skeleton process step
268269
this.load_skeleton_step.addEventListener('skeletonLoaded', () => {
269270
this.edit_skeleton_step.load_original_armature_from_model(this.load_skeleton_step.armature())
@@ -290,8 +291,7 @@ export class Bootstrap {
290291
// this needs to happen at the end since it is expecting the mesh data
291292
this.load_skeleton_step.begin()
292293
}
293-
294-
if (this.process_step === ProcessStep.EditSkeleton) {
294+
else if (this.process_step === ProcessStep.EditSkeleton) {
295295
this.load_skeleton_step?.dispose()
296296

297297
this.regenerate_skeleton_helper(this.edit_skeleton_step.skeleton())
@@ -306,16 +306,14 @@ export class Bootstrap {
306306
this.mesh_preview_display_type = ModelPreviewDisplay.WeightPainted
307307
this.changed_model_preview_display(this.mesh_preview_display_type) // show weight painted mesh by default
308308
}
309-
310-
if (this.process_step === ProcessStep.BindPose) {
309+
else if (this.process_step === ProcessStep.BindPose) {
311310
this.transform_controls.enabled = false // shouldn't be editing bones
312311
this.calculate_skin_weighting_for_models()
313312
this.scene.add(...this.weight_skin_step.final_skinned_meshes()) // add final skinned mesh to scene
314313
this.weight_skin_step.weight_painted_mesh_group().visible = false // hide weight painted mesh
315314
this.process_step_changed(ProcessStep.AnimationsListing)
316315
}
317-
318-
if (this.process_step === ProcessStep.AnimationsListing) {
316+
else if (this.process_step === ProcessStep.AnimationsListing) {
319317
this.process_step = ProcessStep.AnimationsListing
320318
this.animations_listing_step.begin(this.load_skeleton_step.skeleton_type(), this.load_skeleton_step.skeleton_scale())
321319

@@ -485,27 +483,14 @@ export class Bootstrap {
485483
// when we have are in the "Weight Painted" display mode
486484
this.weight_skin_step.calculate_weights_for_all_mesh_data(true)
487485

488-
// TODO: maybe way to update references instead of removing and adding?
489-
// this.remove_skinned_meshes_from_scene() // clear any existing skinned meshes in the scene
490-
// this.scene.add(...this.weight_skin_step.final_skinned_meshes())
491-
492486
// remember our skeleton position before we do the skinning process
493487
// that way if we revert to try again...we will have the original positions/rotations
494488
this.load_model_step.model_meshes().visible = false // hide our unskinned mesh after we have done the skinning process
495489

496490
// re-define skeleton helper to use the skinned mesh)
497491
if (this.weight_skin_step.skeleton() === undefined) {
498492
console.warn('Tried to regenerate skeleton helper, but skeleton is undefined!')
499-
return
500-
}
501-
502-
// we might want to test out the binding algorithm to see various hitboxes
503-
// if we are doing debugging, go to that view, if no debugging, go straight to thd animation listing step
504-
if (this.edit_skeleton_step.show_debugging()) {
505-
return
506493
}
507-
508-
console.log('What does our scene look like after we are done skinning:', this.scene)
509494
}
510495

511496
public test_bone_weighting_success (): boolean {

0 commit comments

Comments
 (0)