three-mediapipe-rig 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,16 +1,18 @@
1
1
 
2
2
  ![cover](cover.jpg)
3
3
 
4
- # three-mediapipe-rig
4
+ # Control a skeleton with the webcam
5
5
 
6
- Integrate [Google MediaPipe](https://ai.google.dev/edge/mediapipe/solutions/guide)'s **webcam motion tracking** with [Three.js](https://threejs.org/) skeletal rigs. Load a GLTF/GLB character, bind it, and drive its body, hands, and face from a webcam or video — in just a few lines of code.
6
+ Integrate [Google MediaPipe](https://ai.google.dev/edge/mediapipe/solutions/guide)'s **webcam motion tracking** with [Three.js](https://threejs.org/) skeletal rigs.
7
7
 
8
- Use your webcam ( or a video ) to drive a skeleton.
8
+ The motion from the webcam will be applied to a skeleton. Angle based so it works with any size skeleton.
9
9
 
10
10
  This will run 3 models: face, body, hands. So expect a FPS drop.
11
11
 
12
- LIVE EXAMPLE: https://bandinopla.github.io/three-mediapipe-rig/
13
-
12
+ Expolore the demos:
13
+ - [Characters](https://bandinopla.github.io/three-mediapipe-rig)
14
+ - [Hands Demo](https://bandinopla.github.io/three-mediapipe-rig/?demo=hands)
15
+ - [Video to Face Geometry](https://bandinopla.github.io/three-mediapipe-rig/?demo=face-uv-demo)
14
16
  ---
15
17
 
16
18
  ## Table of Contents
@@ -26,6 +28,7 @@ LIVE EXAMPLE: https://bandinopla.github.io/three-mediapipe-rig/
26
28
  - [Bone Naming](#bone-naming)
27
29
  - [Default bone names](#default-bone-names)
28
30
  - [Custom bone map example](#custom-bone-map-example)
31
+ - [Video -> Facial Geometry](#video-to-facial-geometry)
29
32
  - [Multiple Characters](#multiple-characters)
30
33
  - [Debugging with Video](#debugging-with-video)
31
34
  - [Recording](#recording)
@@ -52,41 +55,32 @@ npm install three-mediapipe-rig
52
55
 
53
56
  ## Quick Start
54
57
 
55
- ```ts
56
- // 1. Create your renderer
57
- const renderer = new THREE.WebGPURenderer({ antialias: true });
58
- renderer.setSize(window.innerWidth, window.innerHeight);
59
- document.body.appendChild(renderer.domElement);
58
+ ```ts
60
59
 
61
- // 2. Initialize the tracker (loads MediaPipe models)
60
+ // 1. Initialize the tracker (loads MediaPipe models)
62
61
  await setupTracker({ ...config... })
63
62
 
64
63
  const rig = scene.getObjectByName("rig")!;
65
64
 
66
- // 3. Bind the rig to the tracker
65
+ // 2. Bind the rig to the tracker
67
66
  const binding = tracker.bind(rig);
68
67
 
69
68
 
70
- // 4. Start the webcam ( must be initialized by a user triggered event like a click )
71
- tracker.start();
72
-
73
- // 5. Update in your render loop
74
- const clock = new THREE.Timer();
75
- renderer.setAnimationLoop((time: number) => {
76
- const delta = clock.update(time).getDelta();
69
+ // 3. Start the webcam ( must be initialized by a user triggered event like a click )
70
+ button.addEventListener('click', () => {
71
+ tracker.start(); //<-- will ask webcam access!
72
+ })
77
73
 
78
- // 6. update the skeleton...
79
- binding?.update(delta);
80
74
 
81
- renderer.render(scene, camera);
82
- });
75
+ // 4. Update the rig in your render loop ( this keels the skeleton in-sync)
76
+ binding?.update(delta);
83
77
  ```
84
78
 
85
79
  ### Skeleton
86
- You can use the skeleton provided in `rig.blend` or use your own and provide a bone name mapping so we know where the bones are in the second argument for the `.bind` method. But pay attention to the bone role of the provided skeleton, as it is the one expected by this module.
80
+ You can use the skeleton provided in `rig.blend` or use your own and provide a bone name mapping so we know where the bones are in the second argument for the `.bind` method. But pay attention to the [**bone roll**](https://docs.blender.org/manual/en/latest/animation/armatures/bones/editing/bone_roll.html) of the provided skeleton, as it is the one expected by this module.
87
81
 
88
82
  ### Facial Animation
89
- Media Pipe provides blend shape keys for the face ( estimated from the webcam ). The face it is expected to be a separated mesh, just the face, with blend shape keys named as the ones provided by Media Pipe. See [Blend Shape Keys reference](/face-blendshapekeys.md) You don't have to have all of them, if they are not found, they will be ignored.
83
+ Media Pipe provides blend shape keys for the face ( estimated from the webcam ). The face it is expected to be a separated mesh with a name that starts with "face", with blend shape keys named as the ones provided by Media Pipe. See [Blend Shape Keys reference](/face-blendshapekeys.md) You don't have to have all of them, if they are not found, they will be ignored.
90
84
 
91
85
 
92
86
  ## API
@@ -230,11 +224,18 @@ const myBoneMap: BoneMap = {
230
224
  index3L: "LeftHandIndex3",
231
225
  // (continue for all fingers)
232
226
  };
233
-
234
- const binding = tracker.bind(rig, myBoneMap);
235
227
  ```
228
+
236
229
 
237
- ---
230
+ ## Video to Facial Geometry
231
+ Media Pipe's facial tracking also provides a facial mesh, if you [download the face mesh object](https://github.com/google-ai-edge/mediapipe/tree/master/mediapipe/modules/face_geometry) you can also make it deform and be textured using the webcam data. This will texture the mesh with the feed from the camera and also will move the vertices to adjust to the facial expressions:
232
+
233
+ ```js
234
+ const face = tracker.faceTracker.bindGeometry( faceMesh );
235
+
236
+ //... and in your loop
237
+ face.update(delta)
238
+ ```
238
239
 
239
240
  ## Multiple Characters
240
241