Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

allow m2m engine to use custom skeleton or normal one. show mouse controls on retarget page

Scott Petrovic14157d564360
diff --git a/src/Mesh2MotionEngine.ts b/src/Mesh2MotionEngine.ts
index bcac6c6..52033de 100644
--- a/src/Mesh2MotionEngine.ts
+++ b/src/Mesh2MotionEngine.ts
@@ -57,7 +57,8 @@ export class Mesh2MotionEngine {
// for looking at specific bones
public process_step: ProcessStep = ProcessStep.LoadModel
- public skeleton_helper: CustomSkeletonHelper | undefined = undefined
+ public skeleton_helper: CustomSkeletonHelper | THREE.SkeletonHelper | undefined = undefined
+ public use_custom_skeleton_helper: boolean = true // retargeting doesn't use this
public debugging_visual_object: Group = new Group()
// when editing the skeleton, what type of mesh will we see
@@ -135,6 +136,10 @@ export class Mesh2MotionEngine {
}
}
+ public set_custom_skeleton_helper_enabled (enabled: boolean): void {
+ this.use_custom_skeleton_helper = enabled
+ }
+
public set_fog_enabled (enabled: boolean): void {
if (enabled) {
// Determine fog color based on theme
@@ -221,7 +226,12 @@ export class Mesh2MotionEngine {
this.scene.remove(this.skeleton_helper)
}
- this.skeleton_helper = new CustomSkeletonHelper(new_skeleton.bones[0], { linewidth: 4, color: 0x4e7d58 })
+ if (this.use_custom_skeleton_helper) {
+ this.skeleton_helper = new CustomSkeletonHelper(new_skeleton.bones[0], { linewidth: 4, color: 0x4e7d58 })
+ } else {
+ this.skeleton_helper = new THREE.SkeletonHelper(new_skeleton.bones[0])
+ }
+
this.skeleton_helper.name = helper_name
this.scene.add(this.skeleton_helper)
}
diff --git a/src/retarget/index.html b/src/retarget/index.html
index 449781d..6b80d86 100644
--- a/src/retarget/index.html
+++ b/src/retarget/index.html
@@ -179,6 +179,22 @@
</div>
+
+ <!-- Top toolbar with mouse controls -->
+ <div id="header-ui">
+ <div>
+ <img src="/images/mouse-left.svg" height="30" width="30" style="vertical-align: middle;"/> Rotate
+ </div>
+
+ <div>
+ <img src="/images/mouse-right.svg" height="30" width="30" style="vertical-align: middle;"/> Pan
+ </div>
+ <div>
+ <img src="/images/mouse-middle.svg" height="30" width="30" style="vertical-align: middle;"/> Zoom
+ </div>
+ </div>
+
+
<!-- 3d view controls shown on bottom right. This helps with click events -->
<div id="view-control-hitbox"></div>
diff --git a/src/retarget/retarget.ts b/src/retarget/retarget.ts
index aa3c093..6041279 100644
--- a/src/retarget/retarget.ts
+++ b/src/retarget/retarget.ts
@@ -23,6 +23,7 @@ class RetargetModule {
this.mesh2motion_engine = new Mesh2MotionEngine()
const camera_position = new Vector3().set(3, 2, 15)
this.mesh2motion_engine.set_camera_position(camera_position)
+ this.mesh2motion_engine.set_custom_skeleton_helper_enabled(false)
// Override zoom limits for retargeting to accommodate models of various sizes
// Allow closer zoom for small details and farther zoom for large models