Region3

Constructors

NameDescription
new(min: Vector3,max: Vector3)Returns a new Region3 given the Vector3 bounds of the rectangular prism volume. The order of the bounds matters - swapping them flips the polarity of the size components and can produce a Region3 with negative volume.

Code Snippet

local region = Region3.new(Vector3.new(-10, 0, -10), Vector3.new(10, 20, 10))
local alignedRegion = region:ExpandToGrid(4)

local parts = workspace:GetPartBoundsInBox(alignedRegion.CFrame, alignedRegion.Size)
print(#parts, "parts found in region")

Properties

NameTypeDescription
CFrameCFrameThe CFrame representing the center position and orientation of the Region3. Computed as the midpoint of the min and max vectors passed to Region3.new(). Always has an identity rotation, since a Region3 is axis-aligned. Read-only.
SizeVector3The size of the Region3 as a Vector3, equal to max - min from the constructor arguments. Individual components may be negative if the corresponding component of min is greater than max. Read-only.

Methods

NameParametersReturnsDescription
ExpandToGrid(resolution: number):Region3resolution: numberRegion3Expands the Region3 based on the provided resolution and returns the expanded Region3 aligned to the Terrain voxel grid. resolution must be a positive number, given in studs.