vector3
vector3
The vector3 class is the primary 3D coordinate type used across Stranded III for positions, rotations (Euler angles in degrees), velocities, and scales. Supports arithmetic metamethods (+, -, *).
Overview
Properties (3)
| Property | Type | Summary |
|---|---|---|
x
|
number
|
The X coordinate of the 3D vector. |
y
|
number
|
The Y coordinate of the 3D vector (height in Godot coordinates). |
z
|
number
|
The Z coordinate of the 3D vector. |
Methods (4)
| Method Signature | Returns | Summary |
|---|---|---|
vector3:dot(other)
|
number
|
Calculates the dot product with another 3D vector. |
vector3:length()
|
number
|
Calculates the length of the vector. |
vector3.new(x, y, z)
|
vector3
|
Constructs a new 3D vector. |
vector3:normalized()
|
vector3
|
Returns a normalized unit vector. |
Detailed Reference
vector3.xnumberThe X coordinate component.
Reads or writes the X component of the 3D vector.
vector3.ynumberThe Y coordinate component.
Reads or writes the Y component (height) of the 3D vector.
vector3.znumberThe Z coordinate component.
Reads or writes the Z component of the 3D vector.
vector3:dot(other)| Parameter | Type | Default | Description |
|---|---|---|---|
other | vector3 | The other 3D vector. |
numberThe scalar dot product.
Calculates x1 x2 + y1 y2 + z1 * z2.
vector3:length()numberEuclidean magnitude of the vector.
Calculates the Euclidean distance from the origin sqrt(x^2 + y^2 + z^2).
vector3.new(x, y, z)| Parameter | Type | Default | Description |
|---|---|---|---|
x | number | The X coordinate. | |
y | number | The Y coordinate. | |
z | number | The Z coordinate. |
vector3Newly constructed 3D vector.
Creates a new 3D vector with the specified coordinates.
local pos = vector3.new(100, 10, -50)vector3:normalized()vector3Unit vector with length 1.0.
Returns a scaled vector pointing in the same direction with length 1.0.