Jump to content

Detecting the points visible through an element


bviale
 Share

Recommended Posts

Hello :)

I'm trying to cover the visible area of an element through another.

The camera is behind a rectangle, and at the bottom of the scene there is a picture. I'm trying to cover the area of the picture visible through the rectangle with a plane just like this : 

image.png.f880ea28c859d47712563267bc1783ae.png

I've set up the scene with my elements but I have troubles to detect which part of the picture is visible through the rectangle.

Maybe I can use BABYLON.Vector3.Project to have a projection of the picture in the rectangle ? That's my only lead at the moment to obtain a point based on the camera position.

Do you guys have any idea of how I can achieve this ? 

Here is my playground so far : https://playground.babylonjs.com/indexstable#QQNCWU

 

Thank you :)

Link to comment
Share on other sites

My first instinct would be using Rays to all four corners of the transparent rectangle. 

Check when those rays intersect with the video, and then you have the position in which they intersect on the video mesh itself. Afterwards, it is only a matter of understanding how you need to rescale, but (without really thinking it through) it seems relatively trivial, since you know which corner intersects with it.

Of course, I assume that you are always looking from the front of the transparent rectangle.

Note - the position from which the ray will be sent should also be calculated. I need to think about this one a bit more ;)

Edit 1 - 

4 Rays from the four corners of the transparent in using the camera's direction variable will do the trick.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...