Table of Contents

Class GBPositioning3DUtils

Namespace
GridPlacement.GDScript
Assembly
MoonBark.GridPlacement.GDScript.dll

GBPositioning3DUtils Static utility functions for 3D grid-based positioning and tile movement operations.\n\n6.0.0-3D-Surface (Wave B1.1): 3D mirror of [GBPositioning2DUtils]. Covers the math the [GridPositioner3D] needs; the 2D viewport-center + screen-to-world helpers are NOT mirrored because 3D uses [Camera3D] ray-casts (via [GridPositioner3DSpike]'s math) instead of 2D's [Camera2D] canvas-transform projection.\n\nDifferences from 2D: - [Vector2] / [Vector2i] → [Vector3] / [Vector3i] - [Node2D] / [TileMapLayer] → [Node3D] / [GridMap] - [Rect2i] (map bounds) → [AABB] (GridMap does not expose Rect2i; the 3D utils use [method GridMap.get_used_cells] to derive bounds when needed, or callers pass a precomputed bounds) - No 8-direction tile delta: 3D is 6-direction (or 26-direction with diagonals); the 3D manipulation service provides direction-to-tile mapping in Wave B2.\n\nThe data layer ([PlacementContainer], [PlacementSession], [PlacementRule] base, [ValidationResults]) is already dimension-agnostic; this file is the engine-facing math layer.

class GBPositioning3DUtils extends RefCounted
GBPositioning3DUtils

Properties

map_position

var map_position = grid.to_local(global_position)

tile_center_local

var tile_center_local = grid.map_to_local(tile)

tile_center_global

var tile_center_global = grid.to_global(tile_center_local)

local

var local = grid.map_to_local(cell)

current_tile

var current_tile: Vector3i = get_tile_from_node_position(node, grid)

new_tile

var new_tile: Vector3i = current_tile + p_tile_delta

cells

var cells: Array[Vector3i] = grid.get_used_cells()

cell_size

var cell_size: Vector3 = grid.cell_size

min_pos

var min_pos: Vector3 = grid.map_to_local(cells[0])

max_pos

var max_pos: Vector3 = min_pos

local

var local = grid.map_to_local(cell)

cells

var cells: Array[Vector3i] = grid.get_used_cells()

min_tile

var min_tile: Vector3i = cells[0]

max_tile

var max_tile: Vector3i = cells[0]

n

var n = direction.normalized()

sx

var sx = 0

sy

var sy = 0

sz

var sz = 0

Methods

get_tile_from_global_position

static func get_tile_from_global_position(global_position: Vector3, grid: GridMap) -> Vector3i:

Parameters

global_position
grid

Returns

move_to_tile_center

static func move_to_tile_center(node: Node3D, tile: Vector3i, grid: GridMap) -> Vector3i:

Parameters

node
tile
grid

Returns

get_tile_from_node_position

static func get_tile_from_node_position(node: Node3D, grid: GridMap) -> Vector3i:

Parameters

node
grid

Returns

move_node_by_tiles

static func move_node_by_tiles(node: Node3D, p_tile_delta: Vector3i, grid: GridMap) -> Vector3i:

Parameters

node
p_tile_delta
grid

Returns

get_tile_world_center

static func get_tile_world_center(tile: Vector3i, grid: GridMap) -> Vector3:

Parameters

tile
grid

Returns

get_used_bounds

static func get_used_bounds(grid: GridMap) -> AABB:

Parameters

grid

Returns

snap_tile_to_bounds

static func snap_tile_to_bounds(tile: Vector3i, grid: GridMap) -> Vector3i:

Parameters

tile
grid

Returns

direction_to_tile_delta

static func direction_to_tile_delta(direction: Vector3, threshold: float = 0.33) -> Vector3i:

Parameters

direction
threshold

Returns