Index · Object → Geometry3D

Geometry3D

Provides methods for some common 3D geometric operations.

Class Description

Provides a set of helper functions to create geometric shapes, compute intersections between shapes, and process various other geometric operations in 3D.

Methods

func build_box_planes(extents: Vector3) -> Plane[]

Returns an array with 6 Planes that describe the sides of a box centered at the origin. The box size is defined by extents, which represents one (positive) corner of the box (i.e. half its actual size).

func build_capsule_planes(radius: float, height: float, sides: int, lats: int, axis: Vector3.Axis = 2) -> Plane[]

Returns an array of Planes closely bounding a faceted capsule centered at the origin with radius radius and height height. The parameter sides defines how many planes will be generated for the side part of the capsule, whereas lats gives the number of latitudinal steps at the bottom and top of the capsule. The parameter axis describes the axis along which the capsule is oriented (0 for X, 1 for Y, 2 for Z).

func build_cylinder_planes(radius: float, height: float, sides: int, axis: Vector3.Axis = 2) -> Plane[]

Returns an array of Planes closely bounding a faceted cylinder centered at the origin with radius radius and height height. The parameter sides defines how many planes will be generated for the round part of the cylinder. The parameter axis describes the axis along which the cylinder is oriented (0 for X, 1 for Y, 2 for Z).

func clip_polygon(points: PackedVector3Array, plane: Plane) -> PackedVector3Array

Clips the polygon defined by the points in points against the plane and returns the points of the clipped polygon.

func compute_convex_mesh_points(planes: Plane[]) -> PackedVector3Array

Calculates and returns all the vertex points of a convex shape defined by an array of planes.

func get_closest_point_to_segment(point: Vector3, s1: Vector3, s2: Vector3) -> Vector3

Returns the 3D point on the 3D segment (s1, s2) that is closest to point. The returned point will always be inside the specified segment.

func get_closest_point_to_segment_uncapped(point: Vector3, s1: Vector3, s2: Vector3) -> Vector3

Returns the 3D point on the 3D line defined by (s1, s2) that is closest to point. The returned point can be inside the segment (s1, s2) or outside of it, i.e. somewhere on the line extending from the segment.

func get_closest_points_between_segments(p1: Vector3, p2: Vector3, q1: Vector3, q2: Vector3) -> PackedVector3Array

Given the two 3D segments (p1, p2) and (q1, q2), finds those two points on the two segments that are closest to each other. Returns a PackedVector3Array that contains this point on (p1, p2) as well the accompanying point on (q1, q2).

func get_triangle_barycentric_coords(point: Vector3, a: Vector3, b: Vector3, c: Vector3) -> Vector3

Returns a Vector3 containing weights based on how close a 3D position (point) is to a triangle's different vertices (a, b and c). This is useful for interpolating between the data of different vertices in a triangle. One example use case is using this to smoothly rotate over a mesh instead of relying solely on face normals.

Here is a more detailed explanation of barycentric coordinates.

func ray_intersects_triangle(from: Vector3, dir: Vector3, a: Vector3, b: Vector3, c: Vector3) -> Variant

Tests if the 3D ray starting at from with the direction of dir intersects the triangle specified by a, b and c. If yes, returns the point of intersection as Vector3. If no intersection takes place, returns null.

func segment_intersects_convex(from: Vector3, to: Vector3, planes: Plane[]) -> PackedVector3Array

Given a convex hull defined though the Planes in the array planes, tests if the segment (from, to) intersects with that hull. If an intersection is found, returns a PackedVector3Array containing the point the intersection and the hull's normal. Otherwise, returns an empty array.

func segment_intersects_cylinder(from: Vector3, to: Vector3, height: float, radius: float) -> PackedVector3Array

Checks if the segment (from, to) intersects the cylinder with height height that is centered at the origin and has radius radius. If no, returns an empty PackedVector3Array. If an intersection takes place, the returned array contains the point of intersection and the cylinder's normal at the point of intersection.

func segment_intersects_sphere(from: Vector3, to: Vector3, sphere_position: Vector3, sphere_radius: float) -> PackedVector3Array

Checks if the segment (from, to) intersects the sphere that is located at sphere_position and has radius sphere_radius. If no, returns an empty PackedVector3Array. If yes, returns a PackedVector3Array containing the point of intersection and the sphere's normal at the point of intersection.

func segment_intersects_triangle(from: Vector3, to: Vector3, a: Vector3, b: Vector3, c: Vector3) -> Variant

Tests if the segment (from, to) intersects the triangle a, b, c. If yes, returns the point of intersection as Vector3. If no intersection takes place, returns null.

func tetrahedralize_delaunay(points: PackedVector3Array) -> PackedInt32Array

Tetrahedralizes the volume specified by a discrete set of points in 3D space, ensuring that no point lies within the circumsphere of any resulting tetrahedron. The method returns a PackedInt32Array where each tetrahedron consists of four consecutive point indices into the points array (resulting in an array with n * 4 elements, where n is the number of tetrahedra found). If the tetrahedralization is unsuccessful, an empty PackedInt32Array is returned.

Inherited from Object (62)
func _get(property: StringName) -> Variant
func _get_property_list() -> Dictionary[]
func _init() -> void
func _iter_get(iter: Variant) -> Variant
func _iter_init(iter: Array) -> bool
func _iter_next(iter: Array) -> bool
func _notification(what: int) -> void
func _set(property: StringName, value: Variant) -> bool
func _to_string() -> String
func _validate_property(property: Dictionary) -> void
func add_user_signal(signal: String, arguments: Array = []) -> void
func call(method: StringName) -> Variant
func callv(method: StringName, arg_array: Array) -> Variant
func cancel_free() -> void
func connect(signal: StringName, callable: Callable, flags: int = 0) -> Error
func disconnect(signal: StringName, callable: Callable) -> void
func emit_signal(signal: StringName) -> Error
func free() -> void
func get(property: StringName) -> Variant
func get_class() -> String
func get_incoming_connections() -> Dictionary[]
func get_indexed(property_path: NodePath) -> Variant
func get_meta(name: StringName, default: Variant = null) -> Variant
func get_meta_list() -> StringName[]
func get_method_list() -> Dictionary[]
func get_property_list() -> Dictionary[]
func get_signal_connection_list(signal: StringName) -> Dictionary[]
func get_signal_list() -> Dictionary[]
func has_meta(name: StringName) -> bool
func has_method(method: StringName) -> bool
func has_signal(signal: StringName) -> bool
func is_class(class: StringName) -> bool
func is_connected(signal: StringName, callable: Callable) -> bool
func notification(what: int, reversed: bool = false) -> void
func remove_meta(name: StringName) -> void
func remove_user_signal(signal: StringName) -> void
func set(property: StringName, value: Variant) -> void
func set_block_signals(enable: bool) -> void
func set_deferred(property: StringName, value: Variant) -> void
func set_indexed(property_path: NodePath, value: Variant) -> void
func set_message_translation(enable: bool) -> void
func set_meta(name: StringName, value: Variant) -> void
func set_script(script: Variant) -> void
func set_translation_domain(domain: StringName) -> void
func to_string() -> String
func tr(message: StringName, context: StringName = &"") -> String
func tr_n(message: StringName, plural_message: StringName, n: int, context: StringName = &"") -> String

Signals

Inherited from Object (2)