Clientx and window.innerWidth Question:

IMO using window.innerWidth / window.innerHeight pretty much anywhere is an antipattern since it comes with the hidden assumption that the canvas is full screen. As soon as you make a canvas that is not fullscreen/centered then you’ll run into issues like this.

The three.js examples are guilty of this and people copy the code so it gets propagated everywhere. It would be better if something like container.clientWidth / container.clientHeight was used instead (or canvas instead of container).

2 Likes