Calculate possible size of decal


I am trying to calculate the size of the intersection between the cone and the boxes that’s created on clicked. Basically I am trying to determine the possible size of the decals on certain positions on the mesh. Any ideas ?

I guess you would need to raycast the 4 corners of the decal to the mesh but then depending on the mesh shape it might be a really difficult task also do you want the projected area on the surface or a “squared” approximating one ?

I actually just want the width of the mesh at a specific height (Y)

To illustrate this, i have used clipplanes. I want the width of the visible part of mesh on mousedown

what do you mean by the width ?

  • the full perimeter (if so at the middle top or bottom) ?
  • the radius (if so at the middle top or bottom) ?
  • the diameter (if so at the middle top or bottom) ?

Is the mesh always a cone with the top angle known ?

The length of these two lines along the x axis.

The mesh is different designs in my use case, the cone is just for illustrative purposes

on a random mesh you would need:

  1. raycast on the clicked position to the mesh
  2. project the point to a central mesh vertical axis
  3. “raycast” from this point to both opposite directions which are along the 3rd axis of the orthonormal space defined by the ray in 1, the mesh vertical axis and the result of their cross products.
  4. compute the length between both newfound points.