Skip to content

GLTFPhysicsShape

Inherits: Resource < RefCounted < Object

Represents a glTF physics shape.

Represents a physics shape as defined by the OMI_physics_shape or OMI_collider glTF extensions. This class is an intermediary between the glTF data and Orblit’s nodes, and it’s abstracted in a way that allows adding support for different glTF physics extensions in the future.

Type Name Default
float height 2.0
ImporterMesh importer_mesh
bool is_trigger false
int mesh_index -1
float radius 0.5
String shape_type ""
Vector3 size Vector3(1, 1, 1)
Returns Method
GLTFPhysicsShape from_dictionary(dictionary: Dictionary) static
GLTFPhysicsShape from_node(shape_node: CollisionShape3D) static
GLTFPhysicsShape from_resource(shape_resource: Shape3D) static
Dictionary to_dictionary() const
CollisionShape3D to_node(cache_shapes: bool = false)
Shape3D to_resource(cache_shapes: bool = false)

height

float height = 2.0

The height of the shape, in meters. This is only used when the shape type is "capsule" or "cylinder". This value should not be negative, and for "capsule" it should be at least twice the radius.

importer_mesh

ImporterMesh importer_mesh

The ImporterMesh resource of the shape. This is only used when the shape type is "hull" (convex hull) or "trimesh" (concave trimesh).

is_trigger

bool is_trigger = false

If true, indicates that this shape is a trigger. For Orblit, this means that the shape should be a child of an Area3D node.

This is the only variable not used in the to_node() method, it’s intended to be used alongside when deciding where to add the generated node as a child.

mesh_index

int mesh_index = -1

The index of the shape’s mesh in the glTF file. This is only used when the shape type is "hull" (convex hull) or "trimesh" (concave trimesh).

radius

float radius = 0.5

The radius of the shape, in meters. This is only used when the shape type is "capsule", "cylinder", or "sphere". This value should not be negative.

shape_type

String shape_type = ""

The type of shape this shape represents. Valid values are "box", "capsule", "cylinder", "sphere", "hull", and "trimesh".

size

Vector3 size = Vector3(1, 1, 1)

The size of the shape, in meters. This is only used when the shape type is "box", and it represents the "diameter" of the box. This value should not be negative.

from_dictionary

GLTFPhysicsShape from_dictionary(dictionary: Dictionary) static

Creates a new GLTFPhysicsShape instance by parsing the given Dictionary.

from_node

GLTFPhysicsShape from_node(shape_node: CollisionShape3D) static

Creates a new GLTFPhysicsShape instance from the given Orblit CollisionShape3D node.

from_resource

GLTFPhysicsShape from_resource(shape_resource: Shape3D) static

Creates a new GLTFPhysicsShape instance from the given Orblit Shape3D resource.

to_dictionary

Dictionary to_dictionary() const

Serializes this GLTFPhysicsShape instance into a Dictionary in the format defined by OMI_physics_shape.

to_node

CollisionShape3D to_node(cache_shapes: bool = false)

Converts this GLTFPhysicsShape instance into a Orblit CollisionShape3D node.

to_resource

Shape3D to_resource(cache_shapes: bool = false)

Converts this GLTFPhysicsShape instance into a Orblit Shape3D resource.