:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/Geometry3D.xml. .. _class_Geometry3D: Geometry3D ========== **Inherits:** :ref:`Object` Provides methods for some common 3D geometric operations. .. rst-class:: classref-introduction-group Description ----------- Provides a set of helper functions to create geometric shapes, compute intersections between shapes, and process various other geometric operations in 3D. .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +--------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array`\[:ref:`Plane`\] | :ref:`build_box_planes`\ (\ extents\: :ref:`Vector3`\ ) | +--------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array`\[:ref:`Plane`\] | :ref:`build_capsule_planes`\ (\ radius\: :ref:`float`, height\: :ref:`float`, sides\: :ref:`int`, lats\: :ref:`int`, axis\: :ref:`Axis` = 2\ ) | +--------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array`\[:ref:`Plane`\] | :ref:`build_cylinder_planes`\ (\ radius\: :ref:`float`, height\: :ref:`float`, sides\: :ref:`int`, axis\: :ref:`Axis` = 2\ ) | +--------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedVector3Array` | :ref:`clip_polygon`\ (\ points\: :ref:`PackedVector3Array`, plane\: :ref:`Plane`\ ) | +--------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedVector3Array` | :ref:`compute_convex_mesh_points`\ (\ planes\: :ref:`Array`\[:ref:`Plane`\]\ ) | +--------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector3` | :ref:`get_closest_point_to_segment`\ (\ point\: :ref:`Vector3`, s1\: :ref:`Vector3`, s2\: :ref:`Vector3`\ ) | +--------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector3` | :ref:`get_closest_point_to_segment_uncapped`\ (\ point\: :ref:`Vector3`, s1\: :ref:`Vector3`, s2\: :ref:`Vector3`\ ) | +--------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedVector3Array` | :ref:`get_closest_points_between_segments`\ (\ p1\: :ref:`Vector3`, p2\: :ref:`Vector3`, q1\: :ref:`Vector3`, q2\: :ref:`Vector3`\ ) | +--------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector3` | :ref:`get_triangle_barycentric_coords`\ (\ point\: :ref:`Vector3`, a\: :ref:`Vector3`, b\: :ref:`Vector3`, c\: :ref:`Vector3`\ ) | +--------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Variant` | :ref:`ray_intersects_triangle`\ (\ from\: :ref:`Vector3`, dir\: :ref:`Vector3`, a\: :ref:`Vector3`, b\: :ref:`Vector3`, c\: :ref:`Vector3`\ ) | +--------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedVector3Array` | :ref:`segment_intersects_convex`\ (\ from\: :ref:`Vector3`, to\: :ref:`Vector3`, planes\: :ref:`Array`\[:ref:`Plane`\]\ ) | +--------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedVector3Array` | :ref:`segment_intersects_cylinder`\ (\ from\: :ref:`Vector3`, to\: :ref:`Vector3`, height\: :ref:`float`, radius\: :ref:`float`\ ) | +--------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedVector3Array` | :ref:`segment_intersects_sphere`\ (\ from\: :ref:`Vector3`, to\: :ref:`Vector3`, sphere_position\: :ref:`Vector3`, sphere_radius\: :ref:`float`\ ) | +--------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Variant` | :ref:`segment_intersects_triangle`\ (\ from\: :ref:`Vector3`, to\: :ref:`Vector3`, a\: :ref:`Vector3`, b\: :ref:`Vector3`, c\: :ref:`Vector3`\ ) | +--------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedInt32Array` | :ref:`tetrahedralize_delaunay`\ (\ points\: :ref:`PackedVector3Array`\ ) | +--------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_Geometry3D_method_build_box_planes: .. rst-class:: classref-method :ref:`Array`\[:ref:`Plane`\] **build_box_planes**\ (\ extents\: :ref:`Vector3`\ ) :ref:`🔗` Returns an array with 6 :ref:`Plane`\ s 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). .. rst-class:: classref-item-separator ---- .. _class_Geometry3D_method_build_capsule_planes: .. rst-class:: classref-method :ref:`Array`\[:ref:`Plane`\] **build_capsule_planes**\ (\ radius\: :ref:`float`, height\: :ref:`float`, sides\: :ref:`int`, lats\: :ref:`int`, axis\: :ref:`Axis` = 2\ ) :ref:`🔗` Returns an array of :ref:`Plane`\ s 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). .. rst-class:: classref-item-separator ---- .. _class_Geometry3D_method_build_cylinder_planes: .. rst-class:: classref-method :ref:`Array`\[:ref:`Plane`\] **build_cylinder_planes**\ (\ radius\: :ref:`float`, height\: :ref:`float`, sides\: :ref:`int`, axis\: :ref:`Axis` = 2\ ) :ref:`🔗` Returns an array of :ref:`Plane`\ s 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). .. rst-class:: classref-item-separator ---- .. _class_Geometry3D_method_clip_polygon: .. rst-class:: classref-method :ref:`PackedVector3Array` **clip_polygon**\ (\ points\: :ref:`PackedVector3Array`, plane\: :ref:`Plane`\ ) :ref:`🔗` Clips the polygon defined by the points in ``points`` against the ``plane`` and returns the points of the clipped polygon. .. rst-class:: classref-item-separator ---- .. _class_Geometry3D_method_compute_convex_mesh_points: .. rst-class:: classref-method :ref:`PackedVector3Array` **compute_convex_mesh_points**\ (\ planes\: :ref:`Array`\[:ref:`Plane`\]\ ) :ref:`🔗` Calculates and returns all the vertex points of a convex shape defined by an array of ``planes``. .. rst-class:: classref-item-separator ---- .. _class_Geometry3D_method_get_closest_point_to_segment: .. rst-class:: classref-method :ref:`Vector3` **get_closest_point_to_segment**\ (\ point\: :ref:`Vector3`, s1\: :ref:`Vector3`, s2\: :ref:`Vector3`\ ) :ref:`🔗` 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. .. rst-class:: classref-item-separator ---- .. _class_Geometry3D_method_get_closest_point_to_segment_uncapped: .. rst-class:: classref-method :ref:`Vector3` **get_closest_point_to_segment_uncapped**\ (\ point\: :ref:`Vector3`, s1\: :ref:`Vector3`, s2\: :ref:`Vector3`\ ) :ref:`🔗` 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. .. rst-class:: classref-item-separator ---- .. _class_Geometry3D_method_get_closest_points_between_segments: .. rst-class:: classref-method :ref:`PackedVector3Array` **get_closest_points_between_segments**\ (\ p1\: :ref:`Vector3`, p2\: :ref:`Vector3`, q1\: :ref:`Vector3`, q2\: :ref:`Vector3`\ ) :ref:`🔗` 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 :ref:`PackedVector3Array` that contains this point on (``p1``, ``p2``) as well the accompanying point on (``q1``, ``q2``). .. rst-class:: classref-item-separator ---- .. _class_Geometry3D_method_get_triangle_barycentric_coords: .. rst-class:: classref-method :ref:`Vector3` **get_triangle_barycentric_coords**\ (\ point\: :ref:`Vector3`, a\: :ref:`Vector3`, b\: :ref:`Vector3`, c\: :ref:`Vector3`\ ) :ref:`🔗` Returns a :ref:`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. `__ .. rst-class:: classref-item-separator ---- .. _class_Geometry3D_method_ray_intersects_triangle: .. rst-class:: classref-method :ref:`Variant` **ray_intersects_triangle**\ (\ from\: :ref:`Vector3`, dir\: :ref:`Vector3`, a\: :ref:`Vector3`, b\: :ref:`Vector3`, c\: :ref:`Vector3`\ ) :ref:`🔗` 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 :ref:`Vector3`. If no intersection takes place, returns ``null``. .. rst-class:: classref-item-separator ---- .. _class_Geometry3D_method_segment_intersects_convex: .. rst-class:: classref-method :ref:`PackedVector3Array` **segment_intersects_convex**\ (\ from\: :ref:`Vector3`, to\: :ref:`Vector3`, planes\: :ref:`Array`\[:ref:`Plane`\]\ ) :ref:`🔗` Given a convex hull defined though the :ref:`Plane`\ s in the array ``planes``, tests if the segment (``from``, ``to``) intersects with that hull. If an intersection is found, returns a :ref:`PackedVector3Array` containing the point the intersection and the hull's normal. Otherwise, returns an empty array. .. rst-class:: classref-item-separator ---- .. _class_Geometry3D_method_segment_intersects_cylinder: .. rst-class:: classref-method :ref:`PackedVector3Array` **segment_intersects_cylinder**\ (\ from\: :ref:`Vector3`, to\: :ref:`Vector3`, height\: :ref:`float`, radius\: :ref:`float`\ ) :ref:`🔗` 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 :ref:`PackedVector3Array`. If an intersection takes place, the returned array contains the point of intersection and the cylinder's normal at the point of intersection. .. rst-class:: classref-item-separator ---- .. _class_Geometry3D_method_segment_intersects_sphere: .. rst-class:: classref-method :ref:`PackedVector3Array` **segment_intersects_sphere**\ (\ from\: :ref:`Vector3`, to\: :ref:`Vector3`, sphere_position\: :ref:`Vector3`, sphere_radius\: :ref:`float`\ ) :ref:`🔗` 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 :ref:`PackedVector3Array`. If yes, returns a :ref:`PackedVector3Array` containing the point of intersection and the sphere's normal at the point of intersection. .. rst-class:: classref-item-separator ---- .. _class_Geometry3D_method_segment_intersects_triangle: .. rst-class:: classref-method :ref:`Variant` **segment_intersects_triangle**\ (\ from\: :ref:`Vector3`, to\: :ref:`Vector3`, a\: :ref:`Vector3`, b\: :ref:`Vector3`, c\: :ref:`Vector3`\ ) :ref:`🔗` Tests if the segment (``from``, ``to``) intersects the triangle ``a``, ``b``, ``c``. If yes, returns the point of intersection as :ref:`Vector3`. If no intersection takes place, returns ``null``. .. rst-class:: classref-item-separator ---- .. _class_Geometry3D_method_tetrahedralize_delaunay: .. rst-class:: classref-method :ref:`PackedInt32Array` **tetrahedralize_delaunay**\ (\ points\: :ref:`PackedVector3Array`\ ) :ref:`🔗` 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 :ref:`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 :ref:`PackedInt32Array` is returned. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`