Color3 & Vector3 Lua Environment
Vector3
vector3.new(x, y, z)
vector3.new(x, y, z)Constructs a new Vector3.
Parameters:
x[float],y[float],z[float]Returns:
vector3
local vec = vector3.new(10, 5, 0);vector3.zero()
vector3.zero()Returns a zero vector (0, 0, 0).
Returns:
vector3
local origin = vector3.zero();vector3.one()
vector3.one()Returns a vector of ones (1, 1, 1).
Returns:
vector3
local scale = vector3.one();vector3.unit_x()
vector3.unit_x()Returns the X axis unit vector (1, 0, 0).
Returns:
vector3
vector3.unit_y()
vector3.unit_y()Returns the Y axis unit vector (0, 1, 0).
Returns:
vector3
vector3.unit_z()
vector3.unit_z()Returns the Z axis unit vector (0, 0, 1).
Returns:
vector3
vec.x, vec.y, vec.z
vec.x, vec.y, vec.zRead or write individual components.
Arithmetic Operations
Supports +, -, *, /, ==.
vec:length() / vec:magnitude()
vec:length() / vec:magnitude()Returns the length of the vector.
Returns:
float
vec:squared_magnitude()
vec:squared_magnitude()Returns the squared length (faster than length).
Returns:
float
vec:dot(other)
vec:dot(other)Calculates the dot product.
Parameters:
other[vector3]Returns:
float
vec:cross(other)
vec:cross(other)Calculates the cross product.
Parameters:
other[vector3]Returns:
vector3
vec:normalize()
vec:normalize()Returns the unit vector (length of 1).
Returns:
vector3
Color3
color3.new(r, g, b)
color3.new(r, g, b)Constructs a color from 0.0 to 1.0 floats.
Parameters:
r[float],g[float],b[float]Returns:
color3
color3.from_rgb(r, g, b)
color3.from_rgb(r, g, b)Constructs a color from 0 to 255 integers.
Parameters:
r[int],g[int],b[int]Returns:
color3
color3.from_hex(hex)
color3.from_hex(hex)Constructs a color from a hex integer (0xRRGGBB).
Parameters:
hex[uint32]Returns:
color3
color3.from_hsv(h, s, v)
color3.from_hsv(h, s, v)Constructs a color from Hue, Saturation, Value.
Parameters:
h[float],s[float],v[float]Returns:
color3
color3.random()
color3.random()Returns a completely random color.
Returns:
color3
color3.rainbow(hue)
color3.rainbow(hue)Returns a color from the rainbow spectrum based on hue.
Parameters:
hue[float]Returns:
color3
Static Presets
Common colors are available as functions.
color3.red(),color3.green(),color3.blue()color3.black(),color3.white(),color3.gray()color3.yellow(),color3.cyan(),color3.purple(),color3.orange()
col.r, col.g, col.b
col.r, col.g, col.bRead or write individual components.
Arithmetic Operations
Supports +, -, *, /, ==.
col:lerp(target, alpha)
col:lerp(target, alpha)Linearly interpolates between two colors.
Parameters:
target[color3],alpha[float]Returns:
color3
col:to_string()
col:to_string()Returns string representation.
Returns:
string
Last updated