Region3
Ouch! |
A Region3 is used to represent a size and a location in 3D space.
A Region3 can be created with the Region3.new constructor, which receives two Vector3 values:
Region3.new( Vector3.new(1, 1, 1), Vector3.new(9, 9, 9) ) -- a Region3 with a size of (8, 8, 8) and a position at (5, 5, 5)
This constructor can only create a bounding box. That is, you can't create a rotated Region3, because you can only define two corners of the bounding box. The first argument is the lower corner of the bounding box, while the second argument is the upper corner. Note that this means the X,Y and Z for the second argument should all be larger than the first one. Example :
local start_point = Vector3.new(5, 8, 5) local end_point = Vector3.new(8, 5, 8) Region3.new( Vector3.new( math.min(start_point.X, end_point.X), math.min(start_point.Y, end_point.Y), math.min(start_point.Z, end_point.Z) ), Vector3.new( math.max(start_point.X, end_point.X), math.max(start_point.Y, end_point.Y), math.max(start_point.Z, end_point.Z) ) )
The above example returns a Region3 with a size of (3, 3, 3) and a position of (5, 5, 5).
When printed, the Region3's CFrame and Size are displayed:
5, 5, 5, 1, 0, 0, 0, 1, 0, 0, 0, 1; 3, 3, 3
Constructors
Constructor | Description |
---|---|
Region3.new(Vector3, Vector3) | Creates a new Region3 out of two Vector3 values. |
Properties
All the of a properties Region3 userdata are read-only and cannot be set or edited directly. You must create a new Region3 using Region3.new() to make the properties change.
Property | Type | Description |
---|---|---|
Region3.CFrame | CFrame | The center location and rotation of the the Region3 |
Region3.Size | Vector3 | The 3D size of the Region3 |