How do you use an argument value to set up the position of a cube?

The reason why I’m asking this is because in the render function of my cube, I cannot use arguments as variables to set the position of my cube. For example, here is a snippet of my code that won’t work:

function render(xPos, yPos, zPos) {
                x = xPos;
                y = yPos;
                z = zPos;
                cube.rotation.x = 10;
                cube.position.set(x, y, z);
                renderer.render(scene, camera);

Can anybody please provide some suggestions on how to fix this problem?!?! Thanks!

this part calls render with unrelated arguments, but you could do

requestAnimationFrame(function(){ render(xPos, yPos, zPos); });

(warning: this will lock you with the same values forever)

tbh, you just need to do cube.position.set(x, y, z); elsewhere

1 Like

Hi there!
Thanks for the advice, which had worked, but what is a method that I can use that is more flexible?!?!?! Thanks for the help!