Three.js screen width

I have code

let ADD = 0.01;

const animate = function () {
     requestAnimationFrame( animate );
     mesh.position.x += ADD;
         if (mesh.position.x <= -3 || mesh.position.x >= 3) {
          ADD *= -1;
     }
     renderer.render( scene, camera );
};

in this example my mesh moves to the left 3 and to the right 3 but i need move mesh to full width. if console.log(window.innerWidth) = 2560(my resolution)

How can i get screen width in space three.js ?

Thanks in advance for your help

Functions to calculate the visible width / height at a given z-depth from a perspective camera may help you.

1 Like

yes, thanks.
I attach the answer.

3 Likes