Writing a Region3 yourself?

Hello, I would like to write a rotating region3 but alone and without the help of plugins or videos (I don’t understand English videos). I know it is possible, and I tried to watch a video of Egomoose, but I don’t understand anything. So I asked myself, what do I have to use? Matrix or Vector3? I also know that the constructor of Region3 uses vectors, but these do not bear position, but a direction and length, so I think it uses matrix, but again I am unsure. For those who didn’t understand my question: how does Roblox do region 3?


Is there any particular reason you have to write it yourself? I have a released and documented module you can use.

1 Like

I can’t believe it, the great egomoose! I’ve already looked at it, and thanks for the link, but I understand things better when I write them myself, and I’m curious to see how Roblox does it.

Ah, well we’ll never know exactly how Roblox does it unless they show us their source code. Mine takes advantage of GJK collision detection (for the rotation). Maybe you can read up on that in your native language.


Thanks, you’re the best! So I’m going to try to achieve it on my own terms.

A Region3 is probably stored as a table containing the two Vector3s you inputed in the first place

{Vector3.new(x,y,z), Vector3.new(x,y,z)}

And using these two pieces of informations, roblox can calculate other stuff like the Size priority (which is essentially the volume of that area, thus it’s just simple physics). In the source code it might be written this way, where v1 is the first vector and v2 is second vector

size = v1.magnitude * v2.magnitude * v1.Y

And the CFrame property is basically just the center.

It’s easy to break down what’s going on, a Ray for example is just stored as two Vector3s aswell, first vector being the origin, 2nd is the direction, and to prove that this is how the RayValue object makes the ray look like
It doesn’t need 3D visualising, that’s the engines job, it can be expressed mathematically, using two vectors, instead of an image of the actual region.

1 Like

It just uses the spacial hash + part AABBs, that is, it doesn’t do collisions at all. You can get rotated parts in a FindPartsInRegion3 result which are entirely outside the region in question (where their AABBs touch the region but their actual geometry doesn’t).