Figuring out how much of the side of a cube is visible
I have a simple Three.js scene with a camera that orbits around a cube,
always looking directly at it. I need to figure out the percentage of the
side that is currently most visible by the camera as it orbits around the
cube.
So if I'm looking straight on then side 1 (the "front") can be seeing 100%
and all other 5 sides are at 0%. If I rotate the camera slightly to the
right right then part of side 2 (the "right side") can now be seen --
perhaps 20%, while side one can now be seen at %80. If I then rotate
slightly up then perhaps side 3 (the top) is 10% visible, etc.
How can I go about figuring this out? Remember, the cube itself does not
rotate -- only the camera. Three.js or JavaScript would be great, but I
can deal with pretty much any programming language. I'm mostly interested
in ideas for how to achieve this.
No comments:
Post a Comment