logo
pub struct World { /* private fields */ }
Expand description

World implements the low-level entity API and the mesh API.

For ease of development, the wrappers (Entity, Environment etc) are recommended for entity management.

Implementations

Get the World singleton.

Get the World singleton.

Creates a world entity, from one of several templates (entity_type).

  • name: only relevant for keeping track of your object during development

  • entity_template: Chooses between one of a few “templates” (sets of precreated components):

    • EntityTemplate::Empty
    • EntityTemplate::Object
    • EntityTemplate::Environment
    • EntityTemplate::MeshStyle
    • EntityTemplate::Camera

Adds a component to an entity.

Removes a component from an entity.

Checks whether an entity has a component.

Destroys an entity. Attempting to access the entity after this is an error.

Clones an entity with all its components and returns the handle to the new entity.

Clones multiple entities with all their components and returns the handles to the new entities.

The name passed will be concatenated to the name of each source entity.

Copies a component from an entity to another. Creates the component if it doesn’t exists.

Lets you check whether an EntityHandle points to a valid entity.

If it has existed but been destroyed, the return value is false.

Sets the value of a property of a component belonging to an entity.

Gets the value of a property of a component belonging to an entity.

Retrieves values of the entities passed through the slice entities.

Careful attention that the out_data element size and layout matches the corresponding EntityValueType struct, should be taken.

Sets the values of the entities passed through the slice entities. The length of the out_data slice needs to be the same as entities or a single value in which case it will be applied to all entities.

Careful attention that the in_data element size and layout matches the corresponding EntityValueType struct, should be taken.

Sets the local transforms of the entities passed through the slice entities. The length of the input slice needs to be the same as entities or a single value in which case it will be applied to all entities.

Retrieves the local transforms of the entities passed through the slice entities.

Sets the world transforms of the entities passed through the slice entities. The length of the input slice needs to be the same as entities or a single value in which case it will be applied to all entities.

Retrieves the world transforms of the entities passed through the slice entities.

Retrieves the state of the local transforms of the entities passed through the slice entities.

It is useful to call this method before World::get_entity_local_transforms to figure out which entities actually have the value.

Sets the world transforms of the entities passed through the slice entities. The length of the input slice needs to be the same as entities or a single value in which case it will be applied to all entities.

Retrieves the world transforms of the entities passed through the slice entities.

Retrieves the local bounds of the entities passed through the slice entities.

Retrieves the physics velocities of the entities passed through the slice entities.

Sets the mesh style tints referenced from the entities passed through the slice entities. The length of the input slice needs to be the same as entities or a single value in which case it will be applied to all the entities.

Note: Will set the tint on the mesh style that is used by this entity. This assumes each entity uses its own MeshStyle.

Sets if rendering is enabled for the entities passed through the slice entities. The length of the input slice needs to be the same as entities or a single value in which case it will be applied to all the entities.

Creates a physics body in the middle of the frame

Takes parameters from the Physics component. Automatically used by the World API in enable_dynamic and similar functions.

Lets you query some properties of a raw mesh, including its bounding volume.

Lets you query the names of any morph targets associated with the mesh.

It is recommended to store the return value instead of calling it every frame.

Lets you check whether a DataHandle points to a valid mesh.

If it has existed but been destroyed, the return value is false.

Casts a ray through the world, returning the first hit.

You can also use this to do spherecasts (a.k.a sphere sweeps or “thick” raycasts) by setting RaycastQuery::spherecast_radius.

Casts multiple rays through the world, returning the first hit for each. This is faster than calling raycast multiple times.

You can also use this to do spherecasts (a.k.a sphere sweeps or “thick” raycasts) by setting RaycastQuery::spherecast_radius.

👎Deprecated:

Use raycast instead

Casts a ray through the world (SLOW!).

Reports the first hit or optionally any hit, which can be somewhat faster to compute, but which hit you get is not guaranteed in any way).

One entity can be excluded to avoid self-hits.

Sends multiple messages to an entity.

Retrieves a copy of the entity’s outbox as a Vec

Gets all components an entity has, returns the number of components.

Gets all components an entity has

Creates a new data object from a CreateDataType and slice of bytes.

Gets data from the data referenced by the handle. Always returns the number of bytes even if the output is empty (so you can allocate the right amount)

Retrieves data by this DataHandle and RetrieveDataType as a Vec of bytes.

Decreases the ref count of a data object. When ref count reaches zero it is destroyed. Attempting to access the data after this is an error.

Increases the ref count of a data object.

Lets you check whether a DataHandle points to a valid data object. If it has existed but been destroyed, the return value is false.

Sets a debug name of this data object. Useful for debugging memory usage and leaks.

Gets a debug name of this data object.

Sets debug options of this entity such as whether to enable physics shape debug rendering or not. An empty slice will mean to apply the options to all entities in the world.

Pass your world update function to this. Will make sure messages are received, sent and transient entities are destroyed in the right order.

Measures the layout size of a chunk of formatted text. Formatting is embedded directly into the string using a simple markup language, documented elsewhere.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.