Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

Limit zooming in and out. Hide skeleton when entering animations preview

Scott Petrovic3194a69da66f
diff --git a/src/index.html b/src/index.html
index 12ed7fc..544dcdd 100644
--- a/src/index.html
+++ b/src/index.html
@@ -306,7 +306,7 @@
<!-- checkbox option to show skeleton -->
<div class="styled-checkbox">
- <input type="checkbox" id="show-skeleton-checkbox" name="show-skeleton" value="show" checked>
+ <input type="checkbox" id="show-skeleton-checkbox" name="show-skeleton" value="show">
<label for="show-skeleton-checkbox">Show skeleton</label>
</div>
diff --git a/src/lib/CustomSkeletonHelper.ts b/src/lib/CustomSkeletonHelper.ts
index 676e467..eaa39c3 100644
--- a/src/lib/CustomSkeletonHelper.ts
+++ b/src/lib/CustomSkeletonHelper.ts
@@ -121,6 +121,14 @@ class CustomSkeletonHelper extends Line2 {
this.joint_points.geometry.dispose()
this.joint_points.material.dispose()
}
+
+ public show(): void {
+ this.visible = true
+ }
+
+ public hide(): void {
+ this.visible = false
+ }
}
function getBoneList (object: any): any[] {
diff --git a/src/script.ts b/src/script.ts
index 2a45abb..bf3c60c 100644
--- a/src/script.ts
+++ b/src/script.ts
@@ -110,6 +110,11 @@ export class Bootstrap {
// center orbit controls around mid-section area with target change
this.controls = new OrbitControls(this.camera, this.renderer.domElement)
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.maxDistance = 30 // Maximum zoom (farthest from model)
+
this.controls.update()
this.scene.add(this.transform_controls.getHelper())
@@ -271,6 +276,11 @@ export class Bootstrap {
this.animations_listing_step.load_and_apply_default_animation_to_skinned_mesh(this.weight_skin_step.final_skinned_meshes(),
this.load_skeleton_step.skeleton_type())
+
+ if (this.skeleton_helper !== undefined) {
+ this.skeleton_helper.hide() // hide skeleton helper in animations listing step
+ }
+
break
}