After completing some coding courses, I am now venturing into the world of WebGL using Three.js to enhance my programming skills.
I have been experimenting with a widely used function in examples on threes.org:
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
This function allows me to adjust the size and centering of my geometry based on the width and height of my browser window. However, I have encountered an issue when decreasing the width of the window where my geometry becomes cut off due to its centralized positioning without scaling down proportionally.
In an attempt to rectify this problem, I implemented object.scale.devideScalar(1.5);
within my onWindowResize()
function in this example: http://codepen.io/gnazoa/pen/BjoBZz. Unfortunately, this adjustment did not solve the issue.
The discrepancy between how the geometry appears on my desktop screen compared to on my iPhone illustrated the importance of finding a solution for this problem:
https://i.sstatic.net/AerXK.png
https://i.sstatic.net/nSrqN.png
If you have any suggestions or insight on resolving this dilemma, it would be greatly appreciated as I strive for an optimal user experience regardless of device.