Last year, I modified CloneTrooper1019’s Module3D to better handle distortion, and ended up running faster.
However, that modified version caused parts to shake when changing the camera angle. For the release of Ultimate Boxing, I wanted to fix that. Now I present Module3D V4, for lack of a better name.
Also did a stress test on it with 20 parts, and it is actually faster, again. Rather than doing a lot of screen position calls, the position is calculated once, and the angle needed to go against the Field Of View is calculated and applied.
So… What’s the purpose of this? Set a part to camera on a GUI? Also, that amount of math is not required to do this little. Also calling things like “GuiObj.AbsoluteSize.X” multiple times is very inefficient too. You could’ve also easily created a CFrame from a single out vector from camera. Also didn’t need to calculate the position every time, could’ve done it for when only the frame moved, stored the CFrame in object space and would just need to multiply that CFrame with camera CFrame. If you wanted to go to extreme efficiency, you could expand the CFrame*CFrame calculation and fit it all in with Lua to just update with a CFrame.new.
I couldn’t figure out a simpler method that allowed the front of the object to face the camera (for example, the sides are a lot more visible with the red parts than the blue parts)
Hmmm… I never actually thought of doing that. I may look into it again in the future if I feel the need for it to run faster, but I don’t know how to constantly check the AbsoluteSize and AbsolutePostiion without a loop, unless .Changed fires with it.
Not exactly something I am good with. I think I will leave it up to someone like AxisAngle to figure that out.
If anyone wants to rewrite it to be even more efficient, go ahead. This pretty much suits my needs as is… well, except if you play at an extreme aspect ratio, such as a 3 WQHD multi monitor setup.
You know what would be the most efficient? Just get a part which follows the exact camera CFrame and then weld those models to that part, make it all non-collide and that’s it. Roblox would handle it a thousand times faster than you ever could.