Geometry3D
Hereda: Object
Proporciona métodos para algunas operaciones geométricas 3D comunes.
Descripción
Proporciona un conjunto de funciones de ayuda para crear formas geométricas, calcular intersecciones entre formas y procesar varias otras operaciones geométricas en 3D.
Métodos
Descripciones de Métodos
Array[Plane] build_box_planes(extents: Vector3) 🔗
Devuelve un array con 6 Planes que describen los lados de una caja centrada en el origen. El tamaño de la caja está definido por extents, que representa una esquina (positiva) de la caja (es decir, la mitad de su tamaño real).
Array[Plane] build_capsule_planes(radius: float, height: float, sides: int, lats: int, axis: Axis = 2) 🔗
Devuelve un array de Planes que delimitan estrechamente una cápsula facetada centrada en el origen con radio radius y altura height. El parámetro sides define cuántos planos se generarán para la parte lateral de la cápsula, mientras que lats da el número de pasos latitudinales en la parte inferior y superior de la cápsula. El parámetro axis describe el eje a lo largo del cual se orienta la cápsula (0 para X, 1 para Y, 2 para Z).
Array[Plane] build_cylinder_planes(radius: float, height: float, sides: int, axis: Axis = 2) 🔗
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).
PackedVector3Array clip_polygon(points: PackedVector3Array, plane: Plane) 🔗
Recorta el polígono definido por los puntos en points contra el plane y devuelve los puntos del polígono recortado.
PackedVector3Array compute_convex_mesh_points(planes: Array[Plane]) 🔗
Calcula y devuelve todos los puntos de los vértices de una forma convexa definida por un array de planes.
Vector3 get_closest_point_to_segment(point: Vector3, s1: Vector3, s2: Vector3) 🔗
Devuelve el punto 3D en el segmento 3D (s1, s2) que está más cerca de point. El punto devuelto siempre estará dentro del segmento especificado.
Vector3 get_closest_point_to_segment_uncapped(point: Vector3, s1: Vector3, s2: Vector3) 🔗
Devuelve el punto 3D en la línea 3D definida por (s1, s2) que está más cerca de point. El punto devuelto puede estar dentro del segmento (s1, s2) o fuera de él, es decir, en algún lugar de la línea que se extiende desde el segmento.
PackedVector3Array get_closest_points_between_segments(p1: Vector3, p2: Vector3, q1: Vector3, q2: Vector3) 🔗
Dados los dos segmentos 3D (p1, p2) y (q1, q2), encuentra esos dos puntos en los dos segmentos que están más cerca uno del otro. Devuelve un PackedVector3Array que contiene este punto en (p1, p2) así como el punto acompañante en (q1, q2).
Vector3 get_triangle_barycentric_coords(point: Vector3, a: Vector3, b: Vector3, c: Vector3) 🔗
Devuelve un Vector3 que contiene pesos basados en la cercanía de una posición 3D (point) a los diferentes vértices de un triángulo (a, b y c). Esto es útil para interpolar entre los datos de los diferentes vértices de un triángulo. Un caso de uso de ejemplo es utilizar esto para rotar suavemente sobre una malla en lugar de depender únicamente de las normales de la cara.
Aquí hay una explicación más detallada de las coordenadas baricéntricas.
Variant ray_intersects_triangle(from: Vector3, dir: Vector3, a: Vector3, b: Vector3, c: Vector3) 🔗
Comprueba si el rayo 3D que comienza en from con la dirección de dir interseca el triángulo especificado por a, b y c. Si es así, devuelve el punto de intersección como Vector3. Si no hay intersección, devuelve null.
PackedVector3Array segment_intersects_convex(from: Vector3, to: Vector3, planes: Array[Plane]) 🔗
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.
PackedVector3Array segment_intersects_cylinder(from: Vector3, to: Vector3, height: float, radius: float) 🔗
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.
PackedVector3Array segment_intersects_sphere(from: Vector3, to: Vector3, sphere_position: Vector3, sphere_radius: float) 🔗
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.
Variant segment_intersects_triangle(from: Vector3, to: Vector3, a: Vector3, b: Vector3, c: Vector3) 🔗
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.
PackedInt32Array tetrahedralize_delaunay(points: PackedVector3Array) 🔗
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.