Closed EddyVerbruggen closed 4 years ago
Here's a nice demo of how this can be used.
just out of curiosity, what happens if an object is directly behind you (and the camera)? -- with apologies since i could check myself...
Ok, I checked... items directly behind you also have onscreen x, y coordinates (which is what I thought would happen).
You're right. That makes it a bit harder to do what I wanted to achieve, but I've found a satisfactory way around it. Will test on Android tomorrow a little and update the repo.
Btw - There is a Dot product rule to test if an object is in front or behind
Dot product of: direction vector (camera to object), and camera look direction vector
It would also be cool (feature) if there was a way to expose hit testing/raytracing
That sounds like a much better approach, but I need this feature for a presentation I'm doing soon so I'll stick to the half-baked solution I have now. Sounds like a great plan though, to add a node.isInFrontOfCamera()
function to the plugin. Or maybe even something like node.getPositionRelativeToCamera()
.
It would be helpful to fi. programmatically know if an object is in a certain place (x/y) on the screen. So fi. when a sphere/model is in or near the center of the screen we can consider the user looking at it.