Skip to main content

Vector3Utils

Utilities involving Vector3 objects in Roblox.

Functions

fromVector2XY

Vector3Utils.fromVector2XY(vector2Vector2) → Vector3

Creates a Vector3 from a Vector2 in the XY plane

fromVector2XZ

Vector3Utils.fromVector2XZ(vector2Vector2) → Vector3

Creates a Vector3 from a Vector2 in the XZ plane

getAngleRad

Vector3Utils.getAngleRad() → number?

Computes the angle between 2 vectors in radians

reflect

Vector3Utils.reflect(
vectorVector3,
unitNormalVector3
) → Vector3

Reflects a vector over a unit normal

angleBetweenVectors

Vector3Utils.angleBetweenVectors() → number

Computes the angle between 2 vectors in radians

slerp

Vector3Utils.slerp(
startVector3,
finishVector3,
tnumber--

Amount to slerp. 0 is start, 1 is finish. beyond that is extended as expected.

) → Vector3

Spherically lerps between start and finish

constrainToCone

Vector3Utils.constrainToCone(
directionVector3,--

The vector direction to constrain

coneDirectionVector3,--

The direction of the cone.

coneAngleRadnumber--

Angle of the cone

) → Vector3--

Constrained angle

Constrains a Vector3 into a cone.

round

Vector3Utils.round(
vector3Vector3,
amountnumber
) → Vector3

Rounds the vector to the nearest number

-- Snaps to a grid!
local snapped = Vector3Utils.round(position, 4)

areClose

Vector3Utils.areClose(
epsilonnumber
) → boolean

Checks if 2 Vector3 values are clsoe to each other

Show raw api
{
    "functions": [
        {
            "name": "fromVector2XY",
            "desc": "Creates a Vector3 from a Vector2 in the XY plane",
            "params": [
                {
                    "name": "vector2",
                    "desc": "",
                    "lua_type": "Vector2"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Vector3"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 18,
                "path": "src/vector3utils/src/Shared/Vector3Utils.lua"
            }
        },
        {
            "name": "fromVector2XZ",
            "desc": "Creates a Vector3 from a Vector2 in the XZ plane",
            "params": [
                {
                    "name": "vector2",
                    "desc": "",
                    "lua_type": "Vector2"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Vector3"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 28,
                "path": "src/vector3utils/src/Shared/Vector3Utils.lua"
            }
        },
        {
            "name": "getAngleRad",
            "desc": "Computes the angle between 2 vectors in radians",
            "params": [
                {
                    "name": "a",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "b",
                    "desc": "",
                    "lua_type": "Vector3"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 39,
                "path": "src/vector3utils/src/Shared/Vector3Utils.lua"
            }
        },
        {
            "name": "reflect",
            "desc": "Reflects a vector over a unit normal",
            "params": [
                {
                    "name": "vector",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "unitNormal",
                    "desc": "",
                    "lua_type": "Vector3"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Vector3"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 54,
                "path": "src/vector3utils/src/Shared/Vector3Utils.lua"
            }
        },
        {
            "name": "angleBetweenVectors",
            "desc": "Computes the angle between 2 vectors in radians",
            "params": [
                {
                    "name": "a",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "b",
                    "desc": "",
                    "lua_type": "Vector3"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 65,
                "path": "src/vector3utils/src/Shared/Vector3Utils.lua"
            }
        },
        {
            "name": "slerp",
            "desc": "Spherically lerps between start and finish",
            "params": [
                {
                    "name": "start",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "finish",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "t",
                    "desc": "Amount to slerp. 0 is start, 1 is finish. beyond that is extended as expected.",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Vector3"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 79,
                "path": "src/vector3utils/src/Shared/Vector3Utils.lua"
            }
        },
        {
            "name": "constrainToCone",
            "desc": "Constrains a Vector3 into a cone.",
            "params": [
                {
                    "name": "direction",
                    "desc": "The vector direction to constrain",
                    "lua_type": "Vector3"
                },
                {
                    "name": "coneDirection",
                    "desc": "The direction of the cone.",
                    "lua_type": "Vector3"
                },
                {
                    "name": "coneAngleRad",
                    "desc": "Angle of the cone",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "Constrained angle",
                    "lua_type": "Vector3"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 95,
                "path": "src/vector3utils/src/Shared/Vector3Utils.lua"
            }
        },
        {
            "name": "round",
            "desc": "Rounds the vector to the nearest number\n\n```lua\n-- Snaps to a grid!\nlocal snapped = Vector3Utils.round(position, 4)\n```",
            "params": [
                {
                    "name": "vector3",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "amount",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Vector3"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 119,
                "path": "src/vector3utils/src/Shared/Vector3Utils.lua"
            }
        },
        {
            "name": "areClose",
            "desc": "Checks if 2 Vector3 values are clsoe to each other",
            "params": [
                {
                    "name": "a",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "b",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "epsilon",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 131,
                "path": "src/vector3utils/src/Shared/Vector3Utils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Vector3Utils",
    "desc": "Utilities involving Vector3 objects in Roblox.",
    "source": {
        "line": 5,
        "path": "src/vector3utils/src/Shared/Vector3Utils.lua"
    }
}