Skip to main content

OctreeNode

Basic node interacting with the octree. See Octree for usage.

local octree = Octree.new()
local node = octree:CreateNode(Vector3.zero, "A")
print(octree:RadiusSearch(Vector3.zero, 100)) --> { "A" }

node:Destroy() -- Remove node from octree

print(octree:RadiusSearch(Vector3.zero, 100)) --> { }

Functions

KNearestNeighborsSearch

OctreeNode:KNearestNeighborsSearch(
knumber,--

The number to retrieve

radiusnumber--

The radius to search in

) → (
{T},--

Objects found, including self

{number}--

Distances squared

)

Finds the nearest neighbors to this node within the radius

local octree = Octree.new()
local node = octree:CreateNode(Vector3.zero, "A")
octree:CreateNode(Vector3.new(0, 0, 5), "B")
print(octree:KNearestNeighborsSearch(10, 100)) --> { "A", "B" } { 0, 25 }

GetObject

OctreeNode:GetObject() → T

Returns the object stored in the octree

local octree = Octree.new()
local node = octree:CreateNode(Vector3.zero, "A")
print(octree:GetObject()) --> "A"

RadiusSearch

OctreeNode:RadiusSearch(
radiusnumber--

The radius to search in

) → (
{any},--

Objects found

{number}--

Distances squared

)

Finds the nearest neighbors to the octree node

GetPosition

OctreeNode:GetPosition() → Vector3

Retrieves the position

GetRawPosition

OctreeNode:GetRawPosition() → (
number,--

px

number,--

py

number--

pz

)

Retrieves the as px, py, pz

SetPosition

OctreeNode:SetPosition(positionVector3) → ()

Sets the position of the octree nodes and updates the octree accordingly

local octree = Octree.new()
local node = octree:CreateNode(Vector3.zero, "A")
print(octree:RadiusSearch(Vector3.zero, 100)) --> { "A" }

node:SetPosition(Vector3.new(1000, 0, 0))
print(octree:RadiusSearch(Vector3.zero, 100)) --> {}

Destroy

OctreeNode:Destroy() → ()

Removes the OctreeNode from the octree

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Creates a new for the given Octree with the object.\n\n:::warning\nUse Octree:CreateNode() for more consistent results. To use this object directly\nyou need to set the position before it's registered which may be unclean.\n:::",
            "params": [
                {
                    "name": "octree",
                    "desc": "",
                    "lua_type": "Octree"
                },
                {
                    "name": "object",
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "OctreeNode<T>"
                }
            ],
            "function_type": "static",
            "private": true,
            "source": {
                "line": 37,
                "path": "src/octree/src/Shared/OctreeNode.lua"
            }
        },
        {
            "name": "KNearestNeighborsSearch",
            "desc": "Finds the nearest neighbors to this node within the radius\n\n```lua\nlocal octree = Octree.new()\nlocal node = octree:CreateNode(Vector3.zero, \"A\")\noctree:CreateNode(Vector3.new(0, 0, 5), \"B\")\nprint(octree:KNearestNeighborsSearch(10, 100)) --> { \"A\", \"B\" } { 0, 25 }\n```",
            "params": [
                {
                    "name": "k",
                    "desc": "The number to retrieve",
                    "lua_type": "number"
                },
                {
                    "name": "radius",
                    "desc": "The radius to search in",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "Objects found, including self",
                    "lua_type": "{ T }"
                },
                {
                    "desc": "Distances squared",
                    "lua_type": "{ number }"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 64,
                "path": "src/octree/src/Shared/OctreeNode.lua"
            }
        },
        {
            "name": "GetObject",
            "desc": "Returns the object stored in the octree\n\n```lua\nlocal octree = Octree.new()\nlocal node = octree:CreateNode(Vector3.zero, \"A\")\nprint(octree:GetObject()) --> \"A\"\n```",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 79,
                "path": "src/octree/src/Shared/OctreeNode.lua"
            }
        },
        {
            "name": "RadiusSearch",
            "desc": "Finds the nearest neighbors to the octree node",
            "params": [
                {
                    "name": "radius",
                    "desc": "The radius to search in",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "Objects found",
                    "lua_type": "{ any }"
                },
                {
                    "desc": "Distances squared",
                    "lua_type": "{ number }"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 90,
                "path": "src/octree/src/Shared/OctreeNode.lua"
            }
        },
        {
            "name": "GetPosition",
            "desc": "Retrieves the position",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Vector3"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 99,
                "path": "src/octree/src/Shared/OctreeNode.lua"
            }
        },
        {
            "name": "GetRawPosition",
            "desc": "Retrieves the as px, py, pz",
            "params": [],
            "returns": [
                {
                    "desc": "px",
                    "lua_type": "number"
                },
                {
                    "desc": "py",
                    "lua_type": "number"
                },
                {
                    "desc": "pz",
                    "lua_type": "number"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 110,
                "path": "src/octree/src/Shared/OctreeNode.lua"
            }
        },
        {
            "name": "SetPosition",
            "desc": "Sets the position of the octree nodes and updates the octree accordingly\n\n```lua\nlocal octree = Octree.new()\nlocal node = octree:CreateNode(Vector3.zero, \"A\")\nprint(octree:RadiusSearch(Vector3.zero, 100)) --> { \"A\" }\n\nnode:SetPosition(Vector3.new(1000, 0, 0))\nprint(octree:RadiusSearch(Vector3.zero, 100)) --> {}\n```",
            "params": [
                {
                    "name": "position",
                    "desc": "",
                    "lua_type": "Vector3"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 128,
                "path": "src/octree/src/Shared/OctreeNode.lua"
            }
        },
        {
            "name": "Destroy",
            "desc": "Removes the OctreeNode from the octree",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 165,
                "path": "src/octree/src/Shared/OctreeNode.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "OctreeNode",
    "desc": "Basic node interacting with the octree. See [Octree](/api/Octree) for usage.\n\n```lua\nlocal octree = Octree.new()\nlocal node = octree:CreateNode(Vector3.zero, \"A\")\nprint(octree:RadiusSearch(Vector3.zero, 100)) --> { \"A\" }\n\nnode:Destroy() -- Remove node from octree\n\nprint(octree:RadiusSearch(Vector3.zero, 100)) --> { }\n```",
    "source": {
        "line": 15,
        "path": "src/octree/src/Shared/OctreeNode.lua"
    }
}