Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

hide skeleton joints on animation listing since they don't do anything. Fix state with show skeleton

Scott Petrovicd2ec4406c68e
diff --git a/src/lib/CustomSkeletonHelper.ts b/src/lib/CustomSkeletonHelper.ts
index eaa39c3..3585fc2 100644
--- a/src/lib/CustomSkeletonHelper.ts
+++ b/src/lib/CustomSkeletonHelper.ts
@@ -129,6 +129,10 @@ class CustomSkeletonHelper extends Line2 {
public hide(): void {
this.visible = false
}
+
+ public setJointsVisible (visible: boolean): void {
+ this.joint_points.visible = visible
+ }
}
function getBoneList (object: any): any[] {
diff --git a/src/lib/Generators.ts b/src/lib/Generators.ts
index d37779a..4222709 100644
--- a/src/lib/Generators.ts
+++ b/src/lib/Generators.ts
@@ -6,8 +6,6 @@ import {
Group, Line, LineBasicMaterial, BufferAttribute, Vector2
} from 'three'
-import { CustomSkeletonHelper } from './CustomSkeletonHelper'
-
import { Utility } from './Utilities'
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
@@ -80,11 +78,6 @@ export class Generators {
return skeleton
}
- static create_skeleton_helper (skeleton: Skeleton): CustomSkeletonHelper {
- const skeleton_helper = new CustomSkeletonHelper(skeleton.bones[0], { lineWidth: 5, dashed: true })
- return skeleton_helper
- }
-
// create x markers at a location in space
static create_x_markers (points: Vector3[], size = 0.1, color = 0xff0000, name = ''): Group {
const group = new Group()
diff --git a/src/lib/UI.ts b/src/lib/UI.ts
index 5f84c06..b268e19 100644
--- a/src/lib/UI.ts
+++ b/src/lib/UI.ts
@@ -41,7 +41,7 @@ export class UI {
dom_skinning_algorithm_selection: HTMLElement | null = null
dom_skinned_mesh_tools: HTMLElement | null = null
dom_skinned_mesh_animation_tools: HTMLElement | null = null
- dom_show_skeleton_checkbox: HTMLElement | null = null
+ dom_show_skeleton_checkbox: HTMLInputElement | null = null
dom_back_to_edit_skeleton_button: HTMLButtonElement | null = null
dom_back_to_load_skeleton_button: HTMLButtonElement | null = null
dom_back_to_load_model_button: HTMLButtonElement | null = null
diff --git a/src/script.ts b/src/script.ts
index c27908b..75f2392 100644
--- a/src/script.ts
+++ b/src/script.ts
@@ -117,7 +117,7 @@ export class Bootstrap {
this.controls.target.set(0, 0.9, 0)
// Set zoom limits to prevent excessive zooming in or out
- this.controls.minDistance = 5 // Minimum zoom (closest to model)
+ this.controls.minDistance = 2 // Minimum zoom (closest to model)
this.controls.maxDistance = 30 // Maximum zoom (farthest from model)
this.controls.update()
@@ -247,6 +247,8 @@ export class Bootstrap {
this.transform_controls.enabled = true
this.transform_controls.setMode(this.transform_controls_type) // 'translate', 'rotate'
+ this.skeleton_helper?.setJointsVisible(true)
+
this.mesh_preview_display_type = ModelPreviewDisplay.WeightPainted
this.changed_model_preview_display(this.mesh_preview_display_type) // show weight painted mesh by default
break
@@ -263,6 +265,13 @@ export class Bootstrap {
this.process_step = ProcessStep.AnimationsListing
this.animations_listing_step.begin()
+ this.skeleton_helper?.setJointsVisible(false)
+
+ // hide skeleton by default in animations listing step
+ if (this.ui.dom_show_skeleton_checkbox !== null) {
+ this.ui.dom_show_skeleton_checkbox.checked = false
+ }
+
// Show/hide A-Pose correction options based on skeleton type
this.update_a_pose_options_visibility()