xxxxxxxxxx
69
/*
Reference: Dynamic tree
Author: Jason Labbe
Site: jasonlabbe3d.com
modified 29 May 2022
*/
let maxLevel = 7;
// The amount of nested branches it will subdivide to. More is slower.
let branchForce = 0.5;
// The branch's resistance against the hand movement. A lower value will make it feel sluggish, while a bigger value will make it spring-like.
let rootBranch = null;
let debug = false;
function setup() {
createCanvas(windowWidth, screen.availHeight);
colorMode(HSB, 255);
generateNewTree();
setupMoveNet();
}
function draw() {
updateMoveNet();
background(255);
drawMirroredCam(0, 0, width+200, screen.availHeight); // (x, y, w, h);
// since we changed the cam dimensions,
// the x and y position should be also mapped accordingly.
let x = map(pose.rightWrist.x, 0, cam.width, 0, width);
let y = map(pose.rightWrist.y, 0, cam.height, 0, height);
fill(255);
ellipse(x, y, 30, 30); // ***
push();
translate(width / 2, height - 20);
treeIterator(rootBranch, 0, 0, 0);
pop();
fill(0);
noStroke();
}
/*
Use one of the keypoints names after "pose."
i.e. pose.rightEye.x
pose.rightEye.y
Keypoints Names
Id Part
0 nose
1 leftEye
2 rightEye
3 leftEar
4 rightEar
5 leftShoulder
6 rightShoulder
7 leftElbow
8 rightElbow
9 leftWrist
10 rightWrist
11 leftHip
12 rightHip
13 leftKnee
14 rightKnee
15 leftAnkle
16 rightAnkle
*/