How to get viewport (camera) topLeft, topRight, bottomLeft, bottomRight position
How to apply static fixed sprite to these positions
How to get viewport (camera) topLeft, topRight, bottomLeft, bottomRight position
How to apply static fixed sprite to these positions
One way through position center
And using center and half of window.innerWidth
Does this demo give a hint for your case?
There expected to be something in math books that cover the case
The Math is straightforward – you only do two matrix multiplications (with the inverse of the projection matrix and then with the global matrix). This is effectively what Vector3.unproject() does.
objs[0].position.set( -1, -1, 0.5 ).unproject( camera );
objs[1].position.set( -1, +1, 0.5 ).unproject( camera );
objs[2].position.set( +1, -1, 0.5 ).unproject( camera );
objs[3].position.set( +1, +1, 0.5 ).unproject( camera );
In this demo there are 4 objects in the 4 corners.
Thanks
I luckly did it with
function pixelsToWorld(pixels, distance) {
const visibleHeight =
2 * Math.tan(THREE.MathUtils.degToRad(camera.fov / 2)) * distance;
const visibleWidth = visibleHeight * camera.aspect;
return pixels * visibleWidth / window.innerWidth;
}
I am using PerspectiveCamera and there exists OrthographicCamera what i didnt used earlier