Vector API
LuaVec3i (Vec3i wrapper) is used for integer grid coordinates such as block/sector/system positions.
LuaVec3f (Vec3f wrapper) is used for world-space positions with fractional precision.
LuaVec3i Reference
Reference
getX()/getY()/getZ()Returns the corresponding integer component.setX(x: Integer)/setY(y: Integer)/setZ(z: Integer)Sets the corresponding component.add(vec: LuaVec3i)Addsveccomponent-wise. Mutates and returnsself.sub(vec: LuaVec3i)Subtractsveccomponent-wise. Mutates and returnsself.mul(vec: LuaVec3i)Multiplies component-wise byvec. Mutates and returnsself.div(vec: LuaVec3i)Divides component-wise byvec. Mutates and returnsself.scale(factor: Number)Multiplies all components byfactor. Mutates and returnsself.absolute()Makes all components non-negative. Mutates and returnsself.negate()Negates all components. Mutates and returnsself.size()Returns the Euclidean length as aDouble.toVec3f()Creates aLuaVec3fcopy of the vector.
LuaVec3f Reference
getX()/getY()/getZ()Returns the corresponding float component.setX(x: Number)/setY(y: Number)/setZ(z: Number)Sets the corresponding component.add(vec: LuaVec3f)Addsveccomponent-wise. Mutates and returnsself.sub(vec: LuaVec3f)Subtractsveccomponent-wise. Mutates and returnsself.mul(vec: LuaVec3f)Multiplies component-wise byvec. Mutates and returnsself.div(vec: LuaVec3f)Divides component-wise byvec. Mutates and returnsself.scale(factor: Number)Multiplies all components byfactor. Mutates and returnsself.absolute()Makes all components non-negative. Mutates and returnsself.negate()Negates all components. Mutates and returnsself.size()Returns the Euclidean length as aDouble.toVec3i()Creates aLuaVec3icopy of the vector by truncating each component toward zero.floorToVec3i()Creates aLuaVec3icopy by flooring each component.roundToVec3i()Creates aLuaVec3icopy by rounding each component to the nearest integer.
Notes
All math operations mutate the vector in place and return
selffor chaining.Use
vec3i(x, y, z)to construct a new vector.Use
vec3f(x, y, z)for world-space vectors.LuaVec3ican also be converted toLuaVec3fwithtoVec3f().LuaVec3fcan also be converted toLuaVec3iwithtoVec3i().Use
floorToVec3i()when world coordinates need stable block-grid conversion for negative values.Use
roundToVec3i()when nearest-block behavior is more appropriate.