I have added 3 objects to my scene: a cube, a cuboid and a pyramid(cuboid is child of cube,but pyramid is not.). I want to move the pyramid on clicking the keyboard arrows.But all the 3 objects are moving,instead of pyramid alone. What could be the reason?
code snippet:
pyramid.name='fov';
scene.add(pyramid);
/*some codes in between*/
function movement(e){
var distance = 0.15;
var fov = scene.getObjectByName('fov');
if(e.keyCode =='37'){
fov.position.x += distance;
}
else if (e.keyCode == '38'){
fov.position.z += distance;
}
else if (e.keyCode == '39'){
fov.position.x += distance;
}
else if (e.keyCode == '40'){
fov.position.z += distance;
}