Home » Javascript » Three.js How to add joints and create keyboard movements

Three.js How to add joints and create keyboard movements

Posted by: admin August 19, 2018 Leave a comment

Questions:

I need to create joints using 3dObject and add a keyboard movements to the frog. So far I have the function for joints:

function createJoint(){
var joint = new THREE.Object3D();
joint.name = 'joint';
return joint;
}

And this is the body and head of the frog:

//Pentagonbody
var pentagonbody = createPentagon();
scene.add(pentagonbody);

//Head
var head = squareBipyramid();
head.position.x = 0.8;
head.position.y = 0;
head.rotation.z = 0;
pentagonbody.add(head);

An example would be like pressing the left arrow key will turn the frog’s head to look left and right key would make it look to the right but the body won’t move.

I’m still new to three.js so I’m not too sure what to do at this point.

Any help is appreciated! Cheers

Answers: