Region3: Difference between revisions
>NXTBoy The example made no sense. @SDuke: Can you confirm that the coordinates of the second point must be larger? |
No edit summary |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{NonStandard|reason=Region3 was added in April 2011.}} | |||
A Region3 is used to represent a size and a location in 3D space. | A Region3 is used to represent a size and a location in 3D space. | ||
Line 27: | Line 29: | ||
5, 5, 5, 1, 0, 0, 0, 1, 0, 0, 0, 1; 3, 3, 3 | 5, 5, 5, 1, 0, 0, 0, 1, 0, 0, 0, 1; 3, 3, 3 | ||
== | ==Constructors== | ||
{| | {| class="wikitable" | ||
! Constructor !! Description | ! Constructor !! Description | ||
|- | |- | ||
Line 38: | Line 40: | ||
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. | 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. | ||
{| | {| class="wikitable" | ||
!Property !! Type !! Description | !Property !! Type !! Description | ||
|- | |- |
Latest revision as of 19:51, 18 November 2023
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 |