So it’s mostly just a matter of calculating the intersection of the mouse ray (camera to mouse) and the plane at z=-100.
So the long way of calculating the mouse ray would be to consider the mouse position on a 2d layer and make a vector from the center of the screen and camera eye distance ( can be calculated from screen size and fov) to the mouse position. Then you’d need to rotate that by the camera’s orientation matrix and adding the camera position.
The simpler way to get the mouse ray could be to leverage existing c3 features. If you get the mouse position on a 3d layer it will give you the xy of the mouse projected on the z=0 plane. So the ray would be from the camera to that.
So, anyways the generic formulas for a line and plane are:
P=p1+u*(p2-p1)
N dot (P-p3)=0
And the intersection can be found by combining the two formulas and solving for u:
U= (N dot (p3-p1))/(N dot (p2-p1))
And finally plugging that back into the line equation to get the actual point.
However in your case it all can be simplified at lot.
P1 = camera.pos
P2 = vec(mouse.x, mouse.y, 0)
P3 = vec(0,0,-100)
N = vec(0,0,1)
So barring any errors the final equations should be:
PlaneZ =-100
X = lerp(camera.x, mouse.x, -planeZ/camera.z+1)
y = lerp(camera.y, mouse.y, -planeZ/camera.z+1)
Z = planeZ
Just make sure the mouse coordinates are from a 3d layer. You can specify the layer you get the mouse coordinates from with mouse.X(layer)