PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

Region3

Region3

See also

  • articles/Scripting Terrain, an article describing how to generate terrain of different sizes and shapes using voxel-based code

Constructors

Region3.new ( Vector3 min, Vector3 max )

Creates a new Region3 out of two Vector3 values.

Properties

CFrame Region3.CFrame

The center location and rotation of the Region3

Vector3 Region3.Size

The 3D size of the Region3

Functions

Region3 Region3:ExpandToGrid ( int Region )

A function that expands the Region3 so that it is aligned with a voxel grid based on the provided resolution and returns the expanded Region3.

All you need to do is perform the method on the Region3 you have defined, providing a resolution. Then, the function will align the region so that it is compatible with the Terrain grid.


Expanding a Region3 to a Grid

This code sample creates a Region3 at Vector3.new(0, 0, -3) with a size of Vector3.new(4, 4, 4). It then expands the region with a resolution of 4 to align it with a voxel grid using DataType/Region3/ExpandToGrid. Once the region is compatible with the terrain grid, it fills the region with water terrain using Terrain/FillRegion.

local region = Region3.new(Vector3.new(0, 0, -3), Vector3.new(4, 4, 4))
local res = 4
region = region:ExpandToGrid(res)

local terrain = game:WaitForChild("Terrain")
terrain:FillRegion(region, 4, Enum.Material.Water)