Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

Remove skeleton hover sphere when not in edit skeleton step

Scott Petrovic201f0605a141
diff --git a/src/lib/processes/StepEditSkeleton.ts b/src/lib/processes/StepEditSkeleton.ts
index bf4f6c7..e235962 100644
--- a/src/lib/processes/StepEditSkeleton.ts
+++ b/src/lib/processes/StepEditSkeleton.ts
@@ -110,6 +110,8 @@ export class StepEditSkeleton extends EventTarget {
return this.mirror_mode_enabled
}
+
+
public algorithm (): string {
return this.skinning_algorithm
}
@@ -160,7 +162,7 @@ export class StepEditSkeleton extends EventTarget {
return SkinningFormula.Distance // default if other two don't match
}
- public remove_event_listeners (): void {
+ private remove_event_listeners (): void {
if (this.ui.dom_move_to_origin_button !== null) {
this.ui.dom_move_to_origin_button.removeEventListener('click', () => {})
}
@@ -182,6 +184,12 @@ export class StepEditSkeleton extends EventTarget {
}
}
+ public cleanup_on_exit_step (): void {
+ this.remove_event_listeners()
+ this.clear_hover_point_if_exists()
+ }
+
+
/*
* Take original armature that we are editing and create a skeleton that Three.js can use
*/
@@ -278,6 +286,16 @@ export class StepEditSkeleton extends EventTarget {
this.update_bone_hover_point_position(closest_bone)
}
+ /**
+ * Remove the hover point. This is important when we change steps
+ */
+ private clear_hover_point_if_exists (): void {
+ if (this.joint_hover_point !== null) {
+ this._main_scene_ref?.remove(this.joint_hover_point)
+ this.joint_hover_point = null
+ }
+ }
+
/**
* Create a hover effect for the bone that would be selected for bone editing
* @param bone
@@ -316,4 +334,6 @@ export class StepEditSkeleton extends EventTarget {
this.joint_hover_point = null
}
}
+
+
}
diff --git a/src/script.ts b/src/script.ts
index d66fe0f..56bd6c2 100644
--- a/src/script.ts
+++ b/src/script.ts
@@ -150,8 +150,8 @@ export class Bootstrap {
// we will have the current step turn on the UI elements it needs
this.ui.hide_all_elements()
- // clean up any event listeners from the previous steps
- this.edit_skeleton_step.remove_event_listeners()
+ // clean up things related to edit step in case we are leaving it
+ this.edit_skeleton_step.cleanup_on_exit_step()
// hide the info container by default
if (this.ui.dom_info_container !== null) {