Posenet node sockets tree leaf interaction

hey! So I made a node app with posenet, and the aim is for an interactive web experience, where two people’s hands are needed to grow a tree. The first person who logs on will be the root of the tree, and the second person will be the leaves of the tree.

Right now, I got it so when someone logs on they are the tree, interacting with someone who is a leaf. However, I want it to be so the first person who logs on will be a tree, and the second will be a leaf. I store the people who log on in the world array. Right now, no matter who logs on first, you will be the tree in your browser. This is because my local data is

if (local.data.pose != null){
socket.emit(‘game-update’, local.data);

and world data is

for (var i = 0; i < world.length; i++) {
if (world[i].id == socket.id){ // if its you skip drawing it

if (world[i].data.pose != null){


How might I do it, so the first person who logs on is the tree, and the second is the leaf? The bulk of the code is in pose.js and client.js in https://glitch.com/edit/#!/tree-sockets-v5?path=public%2Fclient.js%3A78%3A1

If I am not wrong, do I need some web synchronisation thing where I need a data base to store the socket ids? Is it easier if I made it so a tree only grows if two player’s hands touch?

Thank you!

1 Like