Installation

Cargo

First you need to install the crate by adding this entry to your Cargo.toml dependencies list:

bevy_mod_scripting = { version = "0.9.0", features = ["lua54"]}

Choose the language features you wish enabled and add them to the features block.

Bevy Plugin

The next step is to add the BMS plugin to your application.

app.add_plugins(BMSPlugin);

You can modify each of the plugins contained within the plugin group using set(MySubPlugin).

Language Features

Each language supported by BMS can be switched-on via feature flag as below:

LanguageFeature Flag
Lua51lua51
Lua52lua54
Lua53lua53
Lua54lua54
Luajitluajit
Luajit52luajit52
Luauluau
Rhairhai
Runerune

Extra Features

In order to fit as many use cases as possible, BMS allows you to disable a lot of its functionality.

By default all of the useful features are enabled, but you may disable them if you wish if you are only needing BMS for script lifecycle management, and want to populate the bindings yourself.

FeatureDescription
core_functionsIf enabled, will enable all core functions, i.e. bevy integrations which let you interact with Bevy via reflection
bevy_core_bindingsEnables bindings for the bevy_core module
bevy_ecs_bindingsEnables bindings for the bevy_ecs module
bevy_hierarchy_bindingsEnables bindings for the bevy_hierarchy module
bevy_input_bindingsEnables bindings for the bevy_input module
bevy_math_bindingsEnables bindings for the bevy_math module
bevy_reflect_bindingsEnables bindings for the bevy_reflect module
bevy_time_bindingsEnables bindings for the bevy_time module
bevy_transform_bindingsEnables bindings for the bevy_transform module
mlua_asyncEnables mlua/async
mlua_serializeEnables mlua/serialize
mlua_macrosEnables mlua/macros
unsafe_lua_modulesAllows loading unsafe modules via require in lua

Managing Scripts

Scripts live in the standard bevy assets directory. Loading a script means:

  • Parsing the script body
  • Creating or updating the resources which store script state
  • Assigning a name/id to the script so it can be referred to by the rest of the application.

Loading

BMS listens to ScriptAsset events and reacts accordingly. In order to load a script, all you need to do is request a handle to it via the asset server and store it somewhere.

Below is an example system which loads a script called assets/my_script.lua and stores the handle in a local system parameter:

fn load_script(server: Res<AssetServer>, mut handle: Local<Handle<ScriptAsset>>) {
    let handle_ = server.load::<ScriptAsset>("my_script.lua");
    *handle = handle_;
}

In practice you will likely store this handle in a resource or component, when your load all the scripts necessary for your application.

Unloading

Scripts are automatically unloaded when the asset is dropped. This means that if you have a handle to a script and it goes out of scope, the script will be unloaded.

This will delete references to the script and remove any internal handles to the asset. You will also need to clean up any handles to the asset you hold in your application in order for the asset to be unloaded.

Hot-loading scripts

To enable hot-loading of assets, you need to enable the necessary bevy features as normal see the bevy cheatbook for instructions.

Assuming that hot-reloading is enabled for your app, any changes to script assets will automatically be picked up and the scripts re-loaded.

File Extensions

Normally the set of supported extensions is pre-decided by each language plugin.

I.e. Lua supports ".lua" extensions and Rhai supports ".rhai" extensions.

Scripts are mapped to the corresponding language plugin based on these and so it's important to use them correctly.

If you would like to add more extensions you need to populate them via app.add_supported_script_extensions.

Advanced

Normally not necessary, but knowing these exist could be useful for more advanced use cases.

Manually (re)loading scripts

In order to manually re-load or load a script you can issue the CreateOrUpdateScript command:

CreateOrUpdateScript::<LuaScriptingPlugin>::new("my_script.lua".into(), "print(\"hello world from new script body\")".into(), asset_handle)

replace LuaScriptingPlugin with the scripting plugin you are using.

Manually Deleting scripts

In order to delete a previously loaded script, you will need to issue a DeleteScript command like so:

DeleteScript::<LuaScriptingPlugin>::new("my_script.lua".into())

replace LuaScriptingPlugin with the scripting plugin you are using.

Loading/Unloading timeframe

Scripts asset events are processed within the same frame they are issued. This means the moment an asset is loaded, it should be loaded and ready to use in the Update schedule. Similarly, the moment an asset is deleted, it should be unloaded and no longer usable in the Update schedule.

Attaching Scripts

Once you have scripts discovered and loaded, you'll want to run them.

At the moment BMS supports three methods of making scripts runnable:

  • Attaching them to entities via ScriptComponent's
  • Adding static scripts
  • Creating dynamic systems ⚗️ (see the script systems section)

And then sending script event's which trigger callbacks on the scripts.

Attaching scripts to entities

In order to attach a script and make it runnable simply add a ScriptComponent to an entity

    commands.entity(my_entity).insert(ScriptComponent::new(vec!["my_script.lua", "my_other_script.lua"]));

When this script is run the entity global will represent the entity the script is attached to. This allows you to interact with the entity in your script easilly.

Be wary of path separators, by default script ID's are derived from asset paths, which are platform dependent. Make sure to use `std::path::PathBuf` if you are targetting multiple platforms.

Making static scripts runnable

Some scripts do not require attaching to an entity. You can run these scripts by loading them first as you would with any other script, then either adding them at app level via add_static_script or by issuing a AddStaticScript command like so:

    commands.queue(AddStaticScript::new("my_static_script.lua"));

The script will then be run as any other script but without being attached to any entity. and as such the entity global will always represent an invalid entity.

Note: Internally these scripts are attached to a dummy entity and as such you can think of them as being attached to an entity with an id of 0.

Running Scripts

Scripts can run logic either when loaded or when triggered by an event. For example the script:

print("hello from load time")
function on_event(arg1)
    print("hello from event time")
    print(arg1)
end

Will print "hello from load time" when the script is loaded, and "hello from event time" when the script receives an event targeting the on_event callback with a receiver list including this script or entity.

In order to trigger on_event you need to first define a label, then send an event containing the label:


#[derive(Reflect)]
pub struct MyReflectType;

// define the label, you can define as many as you like here
callback_labels!(OnEvent => "on_event");

// trigger the event
fn send_event(mut writer: EventWriter<ScriptCallbackEvent>, mut allocator: ResMut<AppReflectAllocator>) {

    let allocator = allocator.write();
    let my_reflect_payload = ReflectReference::new_allocated(MyReflectType, &mut allocator);

    writer.send(ScriptCallbackEvent::new_for_all(
        OnEvent,
        vec![my_reflect_payload.into()],
    ));
}

Note the second argument is the payload we are sending with the event, in this case we are sending an arbitrary reflect type MyReflectType. This can be any type you like, as long as it implements Reflect.

Other variants of the ScriptValue enum are available for sending different types of data, such as ScriptValue::Integer for primtive, types.

Event Handlers

In order for the events you send to actually be picked up, you need to inject special systems into your application. These systems will listen for the events and trigger the appropriate callbacks on the scripts:

app.add_systems(Update, event_handler::<OnEvent, LuaScriptingPlugin>);

Note the system is parameterized by the label we defined earlier, and the scripting plugin we are using. You can add as many of these systems as you like.

The event handler will catch all events with the label OnEvent and trigger the on_event callback on all targeted scripts which have that callback defined.

In order to handle events in the same frame and not accidentally have events "spill over" into the next frame, you should make sure to order any systems which produce these events before the event handler systems.

Controlling Script Bindings

In this book we refer to anything accessible by a script, which allows it to communicate with your Rust code a binding (which in previous versions was more generically referred to as a script API).

The "binding" here being used as in: binding script code to rust code.

Namespaces

Namespaces are a way to group functions together, and are used to prevent naming conflicts. You can have multiple namespaces, and each namespace can have multiple functions.

Language implementations will also look for specific functions registered on your type first before looking at the generic ReflectReference namespace.

Dynamic Functions

Everything callable by scripts must first be registered in the dynamic function registry. Notably we do not make use of the normal bevy function registry to improve performance and usability. This means you cannot call just any function.

In order for a function to be callable by a script it must adhere to a few requirements:

  • Each argument must implement FromScript.
  • Each return type must implement IntoScript.
  • Each argument must also implement GetTypeDependencies
  • Each return type must also implement GetTypeDependencies

The into/from requirements allow us to convert these types to ScriptValue's, and each supported scripting language can then marshall these into the script.

Note these types are implemented for primitives, but if you want to interact with one of your Reflect implementing types, you will need to use one of Ref<T>, Mut<T> or Val<T> wrappers in place of &T, &mut T and T respectively.

These wrappers enable us to safely interact with bevy, and claim any necessary mutex'es on Resources, Components or Allocations.

The GetTypeDependencies, trait is simply a local trait alias for GetTypeRegistration with less strict type requirements. It allows us to register all the types necessary for the function calls, so that you don't have to register anything manually. If your type implements GetTypeRegistration you should not face any issues on this front.

Registering Script Functions

Registering functions can be done via the NamespaceBuilder like below:

    NamespaceBuilder::<ReflectReference>::new(&mut world)
        .register(
            "hello_world",
            |s: String| {
                println!(s)
            },
        );

    NamespaceBuilder::<GlobalNamespace>::new_unregistered(&mut world)
        .register(
            "hello_world2",
            |s: String| {
                println!(s)
            },
        );

This will allow you to call this function within lua like so:

some_type:hello_world("hi from method!");
hello_world2("hi from global!");

Note the new_unregistered call instead of new, this is because GlobalNamespace is not a Reflect type, and the new call also automatically registers the type in the reflection registry.

Macros

The above is a bit tedious, so instead you can use the script_bindings macro, which applies to impl blocks like so:

#[script_bindings("test_fn")]
impl TestStruct {
    /// My docs !!
    /// 
    /// Arguments:
    /// * `_self` - the first argument
    /// * `arg1` - the second argument
    /// Returns:
    /// * `return` - nothing
    fn test_fn(_self: Ref<TestStruct>, mut arg1: usize) {}
}


pub fn main() {
    let mut app = App::new();
    register_test_fn(app.world_mut())
}

Note the documentation will automatically be picked up and stored for the purposes of reflection and documentation generation, including argument/return type specific docs.

Context Arguments

Each script function call always receives an additional context argument: FunctionCallContext. You can opt-in to receive this argument in your own function definitions by adding it as the first argument.

The context contains requests from the caller to your function, such as "I am calling you from a 1-indexed array system, please convert the index first", This argument is only relevant if you're targeting multiple languages.

It also allows you to retrieve the world via FunctionCallContext::world().

You can use this as follows:

    NamespaceBuilder::<ReflectReference>::new(&mut world)
        .register(
            "hello_world",
            |ctx: FunctionCallContext, s: String| {
                let world = ctx.world()?;
                let should_use_0_indexing = ctx.convert_to_0_indexed;
                println!(should_use_0_indexing);
                println!(s)
                Ok(())
            },
        );

Generic Arguments

Sometimes you might want to be generic over the type of argument you're accepting, you can do so by accepting ScriptValue arguments like so:

    NamespaceBuilder::<ReflectReference>::new(&mut world)
        .register(
            "is_integer",
            |s: ScriptValue| {
                match s {
                    ScriptValue::Integer(i) => true,
                    _ => false
                }
            },
        );

You can treat return values similarly.

Fallible functions

Your script functions can return errors either by:

  • Returning Result<T: IntoScript, InteropError>
  • Returning ScriptValue and manually creating the ScriptValue::Error(into_interop_erorr.into()) variant.

Reserved Functions

There are a few reserved functions that you can override by registering them on a specific type:

Function NameDescriptionOverridable?Has Default Implementation?
geta getter function, used for indexing into a type
seta setter function, used for setting a value on a type
suba subtraction function, used for subtracting two values
addan addition function, used for adding two values
mula multiplication function, used for multiplying two values
diva division function, used for dividing two values
rema remainder function, used for getting the remainder of two values
nega negation function, used for negating a value
powa power function, used for raising a value to a power
eqan equality function, used for checking if two values are equal
lta less than function, used for checking if a value is less than another
iteran iterator function, used for iterating over a value
display_refa display function, used for displaying a reference to a value
display_valuea display function, used for displaying a mutable reference to a value

In this context overridable indicates whether language implementations will look for a specific function on your type before looking at the generic ReflectReference namespace. You can still remove the existing registration for these functions on the ReflectReference namespace if you want to replace them with your own implementation.

Note the ReflectReference namespace is special, in that functions defined on it, act like a fallback and hence apply to ALL references.

Globals

By default, each type registered with the type registry, has the following set:

  • a static reference in the global namespace, i.e.: Vec3, Mat3
  • an entry in the types global type cache, i.e.: types.Vec3, types.Mat3

You can filter the types included by customising the CoreScriptGlobalsPlugin

Modifying Script Contexts

You should be able to achieve what you need by registering script functions in most cases. However sometimes you might want to override the way contexts are loaded, or how the runtime is initialized.

This is possible using Context Initializers and Context Pre Handling Initializers as well as Runtime Initializers.

It is however always reccomened to use the dynamic script function registry whenever possible, as it is more flexible and easier to use. It also allows you to introspect available functions easier.

Context Initializers

For example, let's say you want to set a dynamic amount of globals in your script, depending on some setting in your app.

You could do this by customizing the scripting plugin:

let plugin = LuaScriptingPlugin::default().add_context_initializer(|script_id: &str, context: &mut Lua| {
    let globals = context.globals();
    for i in 0..10 {
        globals.set(i, i);
    }
    Ok(())
});

app.add_plugins(plugin)

The above will run every time the script is loaded or re-loaded and before it handles any callbacks.

Context Pre Handling Initializers

If you want to customize your context before every time it's about to handle events (and when it's loaded + reloaded), you can use Context Pre Handling Initializers:

let plugin = LuaScriptingPlugin::default().add_context_pre_handling_initializer(|script_id: &str, entity: Entity, context: &mut Lua| {
    let globals = context.globals();
    globals.set("script_name", script_id.to_owned());
    Ok(())
});

Runtime Initializers

Some scripting languages, have the concept of a runtime. This is a global object which is shared between all contexts. You can customize this object using Runtime Initializers:

let plugin = SomeScriptingPlugin::default().add_runtime_initializer(|runtime: &mut Runtime| {
    runtime.set_max_stack_size(1000);
    Ok(())
});

In the case of Lua, the runtime type is () i.e. This is because mlua does not have a separate runtime concept.

Accessing the World in Initializers

You can access the world in these initializers by using the thread local: ThreadWorldContainer:


let plugin = LuaScriptingPlugin::default();
plugin.add_context_initializer(|script_id: &str, context: &mut Lua| {
    let world = ThreadWorldContainer.try_get_world().unwrap();
    world.with_resource::<MyResource>(|res| println!("My resource: {:?}", res));
    Ok(())
});

Shared Contexts

By default BMS will create an individual script context, or sandbox, for each script that is run. This means that each script will have its own set of global variables and functions that are isolated from other scripts. However, sometimes this might not be desirable, if you aren't worried about scripts interfering with each other, or if you want to easilly share data between scripts. In these cases, you can use shared contexts.

Enabling Shared Contexts

You can enable shared contexts by configuring the relevant scripting plugin like so:

let mut plugin = LuaScriptingPlugin::default().enable_context_sharing();

app.add_plugins(plugin);

Context Loading Settings

All context loading settings are stored in a separate resource per scripting plugin namely: ContextLoadingSettings<Plugin>.

The settings are as follows:

  • loader - the load and unload strategy for contexts. Each scripting plugin will have a load and unload function which is hooked up through here
  • assigner - the strategy for assigning/unassigning contexts to scripts. This is used to determine how to assign a context to a script when it is run, and what to do with the context when the script is finished.
  • context_initializers - stores all context initializers for the plugin
  • context_pre_handling_initializers - stores all context pre-handling initializers for the plugin

More advanced applications might want to customize these settings to suit their needs.

Script ID mapping

Every script is currently identified by a unique ID.

ID's are derived from the script asset path for scripts loaded via the asset system.

By default this is an identity mapping, but you can override this by modifying the AssetPathToScriptIdMapper inside the ScriptAssetSettings resource before loading the script.

Be wary of path separators, by default script ID's are derived from asset paths, which are platform dependent. Make sure to use `std::path::PathBuf` if you are targetting multiple platforms.

Script Systems

Script systems are an experimental feature

It's possible within BMS to inject new systems from within scripts themselves.

Systems introduced by scripts can run in parallel to other systems, and can be freely inserted between any other system, including other script systems.

BMS also provides utilities for visualising schedules using dot graphs, allowing low-effort modding frameworks for game authors.

Schedules

Bevy doesn't support reflecting schedules, so BMS rolls it's own schedule registry resource: AppScheduleRegistry, which can be used to add any custom schedules you want to interact with. The default Bevy schedules will be pre-populated for you.

Once you've registered your schedule you will be able to interact with it in scripts like below:

local update_schedule = world.get_schedule_by_name("Update")
local systems = update:systems()
local system_with_name = update:get_system_by_name("my_system")

Inserting Systems

To insert a system you will need to use the system_builder global function like below:

local system = system_builder("my_system", script_id)
    :exclusive()
    :after(some_other_system)
    :before(another_system)

This will let you call world.add_system like so:

world.add_system(update_schedule,system)

If your event handler running the script is running in a certain schedule, that schedule will be temporarilly removed by Bevy. Meaning you won't be able to modify it from within the script in-flight.

Parameters

The system builder allows script authors to parameterise systems, using resource and query functions. The order in which those functions are called, will define the order in which arguments will be provided to the specified script callback.

For example:

system_builder("my_system")
    :query(
        world.query()
            :component(ComponentA)
            :component(ComponentB)
            :with(ComponentC)
            :without(ComponentD)
    )
    :resource(ResourceA)

will create a system which calls the specified callback my_system with 2 arguments:

  • The ScriptQueryResult for the first query
    • With components access to ComponentA and ComponentB
  • The ReflectReference to ResourceA

Exclusive systems

An exclusive system can be created using the exclusive function call on the system builder.

This allows the system to access everything as in a normal event handler.

Non-exclusive systems, will only be able to access the set of components and resources as parameterized when building the system. This is why we can run the system in parallel to other non-overlapping systems.

Exclusive systems on the other hand, cannot run in parallel.

Callback

The system injected will be similar to an event handler, however it will only trigger the specified script, and without any entity, in the first example you'd see the following lua callback:

function my_system()
    print("I am a dynamic system")
end

get triggered every update.

Examples

In the future we hope to embedd live WASM code examples into the documentation, for now the best source of example scripts will be our regression test suite available in all supported languages in our github repository.

For rust examples see this folder.

Scripting Reference

This part of the book covers the user-facing API of the scripting languages supported by BMS. This will be where you will want to forward your script users to get started with scripting in BMS.

If you are a modder, welcome! 👋, apologies for the rust-centricity of this guide, we are working on it!

Globals

Scripts will have access to a few global variables in most callbacks:

  • world: a static reference to the world, with all sorts of functions available
  • entity: the entity the script is attached to, not available on load/unload callbacks, and in dynamic system callbacks.
  • script_id: the ID of the current script

Constructing Arbitrary Types

When interfacing with bevy, we do this via reflection. While the generated bindings do not cover constructors for every single type that bevy or other libraries provide, reflection allows us to construct some (not all types implement FromReflect) types from dynamic structs.

BMS exposes this ability to all script writers via the construct global function.

Structs

The following struct:

pub struct MyStruct {
    pub my_field: String
}

can be constructed from lua like so:

local MyStruct = types.MyStruct
local concrete_my_struct = construct(MyStruct, {
    my_field = "hello"
})

Tuple Structs

The following tuple struct:


pub struct MyTupleStruct(pub String);

can be constructed like so:


local MyTupleStruct = types.MyTupleStruct
local concrete_my_tuple_struct = construct(MyTupleStruct, {
    _1 = "hello"
})

Enums

The following enum:

pub enum MyEnum {
    VariantA {
        field: String
    },
    VariantB
}

can be constructed like so:


local MyEnum = types.MyEnum
local variantA = construct(MyEnum, {
    variant = "VariantA",
    field = "hello"
})
local variantB = construct(MyEnum, {
    variant = "VariantB"
})

When working with enums you can also figure out the variant at runtime using variant_name:

if my_enum:variant_name() == "VariantA" then
    print(my_enum.field)
end

Core Bindings

Contents

This is an automatically generated file, you'll find links to the contents below

Globals

Global Values

Global values that are accessible anywhere inside scripts. You should avoid naming conflicts with these and trying to overwrite or edit them.

Instances

Instances containing actual accessible values.

Static Instances

Static type references, existing for the purpose of typed static function calls.

InstanceType
ThreadedAnimationGraphsThreadedAnimationGraphs
WindowClosingWindowClosing
WindowRefWindowRef
DQuatDQuat
UiBoxShadowSamplesUiBoxShadowSamples
GizmoConfigGizmoConfig
HierarchyEventHierarchyEvent
PickingInteractionPickingInteraction
PanGesturePanGesture
CascadesVisibleEntitiesCascadesVisibleEntities
CircularSegmentCircularSegment
WindowClosedWindowClosed
AccumulatedMouseMotionAccumulatedMouseMotion
ImageNodeImageNode
AtomicUsizeAtomicUsize
GltfMaterialExtrasGltfMaterialExtras
CursorIconCursorIcon
GridAutoFlowGridAutoFlow
Dir2Dir2
CameraRenderGraphCameraRenderGraph
LightGizmoColorLightGizmoColor
ArcArc
AnimationGraphHandleAnimationGraphHandle
ShadowFilteringMethodShadowFilteringMethod
NativeKeyNativeKey
InternalWindowStateInternalWindowState
GlyphAtlasLocationGlyphAtlasLocation
NodeImageModeNodeImageMode
i8i8
WindowMovedWindowMoved
TonemappingTonemapping
RenderLayersRenderLayers
TextLayoutInfoTextLayoutInfo
AnimationTargetAnimationTarget
TransformTransform
WindowCloseRequestedWindowCloseRequested
RemovedComponentEntityRemovedComponentEntity
GizmoLineStyleGizmoLineStyle
GridTrackGridTrack
ButtonAxisSettingsButtonAxisSettings
DynamicScriptFunctionMutDynamicFunctionMut
SmolStrSmolStr
NonZeroI16NonZeroI16
OverflowOverflow
TextBoundsTextBounds
LchaLcha
JustifyContentJustifyContent
RectangleRectangle
VisibilityVisibility
UuidUuid
TextColorTextColor
CascadesFrustaCascadesFrusta
TypeIdTypeId
FogFalloffFogFalloff
PresentModePresentMode
u16u16
AmbientLightAmbientLight
DMat3DMat3
ScriptResourceRegistrationScriptResourceRegistration
RenderTargetRenderTarget
BoundingCircleBoundingCircle
ContentSizeContentSize
LabelLabel
DVec2DVec2
GamepadButtonChangedEventGamepadButtonChangedEvent
NodeNode
AnnulusAnnulus
MouseButtonInputMouseButtonInput
SphereSphere
ParentParent
RectRect
CompassQuadrantCompassQuadrant
AtomicI32AtomicI32
Ray3dRay3d
AssetPathAssetPath
StringString
EaseFunctionEaseFunction
ScriptTypeRegistrationScriptTypeRegistration
Camera2dCamera2d
Mesh2dMesh2d
IntervalInterval
AppLifecycleAppLifecycle
AspectRatioAspectRatio
TimerModeTimerMode
ScriptComponentRegistrationScriptComponentRegistration
charchar
QuatQuat
PointerLocationPointerLocation
MouseButtonMouseButton
GamepadConnectionEventGamepadConnectionEvent
TouchPhaseTouchPhase
GamepadEventGamepadEvent
Plane3dPlane3d
WindowResolutionWindowResolution
NonZeroU32NonZeroU32
WindowThemeChangedWindowThemeChanged
Arc2dArc2d
ComputedTextBlockComputedTextBlock
GamepadButtonStateChangedEventGamepadButtonStateChangedEvent
MeshMorphWeightsMeshMorphWeights
DirectionalLightDirectionalLight
BloomBloom
GlobalsUniformGlobalsUniform
Vec2Vec2
OpaqueRendererMethodOpaqueRendererMethod
ReflectSystemReflectSystem
PointerPressPointerPress
VisibleMeshEntitiesVisibleMeshEntities
PointLightShadowMapPointLightShadowMap
Line3dLine3d
Camera3dCamera3d
ScreenSpaceTransmissionQualityScreenSpaceTransmissionQuality
RayIdRayId
VolumetricFogVolumetricFog
RelativeCursorPositionRelativeCursorPosition
CircularSectorCircularSector
Isometry3dIsometry3d
ComponentIdComponentId
TextFontTextFont
Triangle3dTriangle3d
UiScaleUiScale
SmaaPresetSmaaPreset
DepthOfFieldModeDepthOfFieldMode
BoundingCircleCastBoundingCircleCast
u128u128
WindowLevelWindowLevel
Dir3Dir3
MaxTrackSizingFunctionMaxTrackSizingFunction
u64u64
ScreenshotCapturedScreenshotCaptured
WindowCreatedWindowCreated
AtomicU32AtomicU32
U64Vec3U64Vec3
DepthPrepassDepthPrepass
GlyphAtlasInfoGlyphAtlasInfo
SpatialListenerSpatialListener
ViewportViewport
RawGamepadButtonChangedEventRawGamepadButtonChangedEvent
PointerInteractionPointerInteraction
Capsule2dCapsule2d
GamepadRumbleIntensityGamepadRumbleIntensity
AabbGizmoConfigGroupAabbGizmoConfigGroup
Capsule3dCapsule3d
Affine3Affine3
DefaultSpatialScaleDefaultSpatialScale
BVec3BVec3
AtomicU16AtomicU16
BloomPrefilterBloomPrefilter
CuboidCuboid
GltfSceneExtrasGltfSceneExtras
Mesh3dMesh3d
TemporalJitterTemporalJitter
Vec3AVec3A
ActiveAnimationActiveAnimation
AnimationEventAnimationEvent
AccumulatedMouseScrollAccumulatedMouseScroll
TimerTimer
BorderRectBorderRect
SensitivitySensitivity
CompositeAlphaModeCompositeAlphaMode
AabbCast3dAabbCast3d
WindowOccludedWindowOccluded
ScreenSpaceReflectionsScreenSpaceReflections
SpatialScaleSpatialScale
FocusPolicyFocusPolicy
FlexDirectionFlexDirection
Mat3AMat3A
CubemapVisibleEntitiesCubemapVisibleEntities
Segment3dSegment3d
U64Vec4U64Vec4
AlignContentAlignContent
BackgroundColorBackgroundColor
SmaaSmaa
ButtonSettingsButtonSettings
NonZeroU16NonZeroU16
BVec3ABVec3A
AtomicIsizeAtomicIsize
PathBufPathBuf
Affine3AAffine3A
CalculatedClipCalculatedClip
DurationDuration
NoFrustumCullingNoFrustumCulling
AnimationTargetIdAnimationTargetId
RotationGestureRotationGesture
MouseWheelMouseWheel
AabbAabb
RenderAssetUsagesRenderAssetUsages
DistanceFogDistanceFog
SliceScaleModeSliceScaleMode
GamepadButtonGamepadButton
AlignSelfAlignSelf
AnimationTransitionsAnimationTransitions
i128i128
ScreenSpaceAmbientOcclusionQualityLevelScreenSpaceAmbientOcclusionQualityLevel
KeyCodeKeyCode
GizmoLineJointGizmoLineJoint
Mat2Mat2
JustifyTextJustifyText
IVec2IVec2
CylinderCylinder
Mat4Mat4
isizeisize
EllipseEllipse
ScreenSpaceAmbientOcclusionScreenSpaceAmbientOcclusion
EulerRotEulerRot
ThreadedAnimationGraphThreadedAnimationGraph
CascadeShadowConfigCascadeShadowConfig
I64Vec4I64Vec4
ImeIme
PrimaryWindowPrimaryWindow
ChromaticAberrationChromaticAberration
FunctionReturnInfoFunctionReturnInfo
RawGamepadAxisChangedEventRawGamepadAxisChangedEvent
CascadesCascades
LinearRgbaLinearRgba
ReflectReferenceReflectReference
OrthographicProjectionOrthographicProjection
MonitorMonitor
FunctionCallContextFunctionCallContext
ScriptQueryResultScriptQueryResult
ClearColorClearColor
SpriteSourceSpriteSource
IVec3IVec3
DepthOfFieldDepthOfField
ColorColor
ComponentTicksComponentTicks
ConeCone
Vec4Vec4
OutlineOutline
NodeIndexNodeIndex
DynamicSceneRootDynamicSceneRoot
ScriptSystemBuilderScriptSystemBuilder
GamepadAxisGamepadAxis
ColorGradingGlobalColorGradingGlobal
i32i32
VideoModeVideoMode
XyzaXyza
WindowThemeWindowTheme
DAffine3DAffine3
TextLayoutTextLayout
AtomicBoolAtomicBool
BVec4ABVec4A
ImageNodeSizeImageNodeSize
DoubleTapGestureDoubleTapGesture
AnimationEventTargetAnimationEventTarget
ReflectScheduleReflectSchedule
FileDragAndDropFileDragAndDrop
BoundingSphereCastBoundingSphereCast
GlobalVolumeGlobalVolume
I64Vec3I64Vec3
DeferredPrepassDeferredPrepass
TargetCameraTargetCamera
AlphaModeAlphaMode
KeyKey
CompassOctantCompassOctant
GamepadSettingsGamepadSettings
UiRectUiRect
NameName
ColorGradingColorGrading
NotShadowReceiverNotShadowReceiver
TetrahedronTetrahedron
ClusterConfigClusterConfig
IVec4IVec4
TimedAnimationEventTimedAnimationEvent
CursorOptionsCursorOptions
ClusterFarZModeClusterFarZMode
RequestRedrawRequestRedraw
GamepadGamepad
Mat3Mat3
Affine2Affine2
LineBreakLineBreak
AlignItemsAlignItems
LabaLaba
CameraCamera
ParallaxMappingMethodParallaxMappingMethod
GltfMeshExtrasGltfMeshExtras
GizmoConfigStoreGizmoConfigStore
Camera3dDepthTextureUsageCamera3dDepthTextureUsage
SubCameraViewSubCameraView
ColorMaterialColorMaterial
ForceTouchForceTouch
FxaaFxaa
f64f64
WindowEventWindowEvent
StopwatchStopwatch
PickingPluginPickingPlugin
PointerIdPointerId
WindowBackendScaleFactorChangedWindowBackendScaleFactorChanged
ComputedNodeComputedNode
CameraMainTextureUsagesCameraMainTextureUsages
AtomicU8AtomicU8
UVec3UVec3
PickingBehaviorPickingBehavior
AlphaMode2dAlphaMode2d
usizeusize
BorderColorBorderColor
RepeatAnimationRepeatAnimation
RegularPolygonRegularPolygon
UVec2UVec2
SyncToRenderWorldSyncToRenderWorld
SpriteSprite
VisibilityRangeVisibilityRange
CowCow
FrustumFrustum
CursorMovedCursorMoved
DMat4DMat4
RayCast2dRayCast2d
ResolvedBorderRadiusResolvedBorderRadius
boolbool
ClusterZConfigClusterZConfig
IdentifierIdentifier
OklabaOklaba
TextureAtlasLayoutTextureAtlasLayout
ConicalFrustumConicalFrustum
ViewVisibilityViewVisibility
InfinitePlane3dInfinitePlane3d
CursorGrabModeCursorGrabMode
ClearColorConfigClearColorConfig
u8u8
VisibleEntitiesVisibleEntities
TextSpanTextSpan
DirectionalLightShadowMapDirectionalLightShadowMap
InheritedVisibilityInheritedVisibility
WindowPositionWindowPosition
OverflowClipMarginOverflowClipMargin
AtomicU64AtomicU64
PlaybackSettingsPlaybackSettings
DAffine2DAffine2
PerspectiveProjectionPerspectiveProjection
BVec4BVec4
ZIndexZIndex
BoundingSphereBoundingSphere
f32f32
JustifyItemsJustifyItems
TextText
DMat2DMat2
PointerInputPluginPointerInputPlugin
DisplayDisplay
GridPlacementGridPlacement
ManualTextureViewHandleManualTextureViewHandle
PositionedGlyphPositionedGlyph
VirtualVirtual
UiAntiAliasUiAntiAlias
Triangle2dTriangle2d
CursorLeftCursorLeft
CustomCursorCustomCursor
WindowFocusedWindowFocused
TextureAtlasTextureAtlas
MouseMotionMouseMotion
CursorEnteredCursorEntered
ButtonStateButtonState
Isometry2dIsometry2d
OnReplaceOnReplace
PositionTypePositionType
AnimationTransitionAnimationTransition
FontSmoothingFontSmoothing
GamepadRumbleRequestGamepadRumbleRequest
GamepadInputGamepadInput
MouseScrollUnitMouseScrollUnit
SrgbaSrgba
UvChannelUvChannel
ExposureExposure
AnimationGraphAnimationGraph
MeshMesh
Dir3ADir3A
FunctionInfoFunctionInfo
DVec3DVec3
InteropErrorInteropError
RangeFullRangeFull
InteractionInteraction
DiGraphDiGraph
BVec2BVec2
I64Vec2I64Vec2
TextNodeFlagsTextNodeFlags
NamespaceNamespace
EnabledButtonsEnabledButtons
WindowDestroyedWindowDestroyed
Aabb2dAabb2d
HsvaHsva
StandardMaterialStandardMaterial
SystemIdMarkerSystemIdMarker
WindowResizeConstraintsWindowResizeConstraints
DefaultOpaqueRendererMethodDefaultOpaqueRendererMethod
FlexWrapFlexWrap
OnRemoveOnRemove
PlaybackModePlaybackMode
PinchGesturePinchGesture
MorphWeightsMorphWeights
ValVal
RhombusRhombus
GltfExtrasGltfExtras
ScalingModeScalingMode
AssetIndexAssetIndex
MipBiasMipBias
OnAddOnAdd
BloomCompositeModeBloomCompositeMode
SkinnedMeshSkinnedMesh
InstantInstant
GlobalTransformGlobalTransform
Vec3Vec3
MotionVectorPrepassMotionVectorPrepass
NativeKeyCodeNativeKeyCode
AtomicI16AtomicI16
RangeRange
IRectIRect
RealReal
EnvironmentMapLightEnvironmentMapLight
SpriteImageModeSpriteImageMode
GridTrackRepetitionGridTrackRepetition
NormalPrepassNormalPrepass
AnimationClipAnimationClip
SystemCursorIconSystemCursorIcon
u32u32
TorusTorus
IrradianceVolumeIrradianceVolume
OnInsertOnInsert
AnimationPlayerAnimationPlayer
OverflowAxisOverflowAxis
MinTrackSizingFunctionMinTrackSizingFunction
WindowModeWindowMode
TextureSlicerTextureSlicer
MsaaMsaa
URectURect
U64Vec2U64Vec2
ShaderStorageBufferShaderStorageBuffer
Segment2dSegment2d
LightGizmoConfigGroupLightGizmoConfigGroup
AnchorAnchor
ReflectableScheduleLabelReflectableScheduleLabel
WindowScaleFactorChangedWindowScaleFactorChanged
OklchaOklcha
UVec4UVec4
RayCast3dRayCast3d
ScreenshotScreenshot
NotShadowCasterNotShadowCaster
SceneRootSceneRoot
ColorGradingSectionColorGradingSection
CircleCircle
HslaHsla
Aabb3dAabb3d
EntityHashEntityHash
WindowResizedWindowResized
DebandDitherDebandDither
FocusFocus
GltfMaterialNameGltfMaterialName
AabbCast2dAabbCast2d
OrderIndependentTransparencySettingsOrderIndependentTransparencySettings
TouchInputTouchInput
ScriptQueryBuilderScriptQueryBuilder
i64i64
GamepadConnectionGamepadConnection
TextEntityTextEntity
AtomicI8AtomicI8
Rot2Rot2
MonitorSelectionMonitorSelection
CubemapFrustaCubemapFrusta
Plane2dPlane2d
FunctionArgInfoFunctionArgInfo
HwbaHwba
DVec4DVec4
JustifySelfJustifySelf
Line2dLine2d
KeyboardFocusLostKeyboardFocusLost
SpotLightSpotLight
ScriptValueScriptValue
ContrastAdaptiveSharpeningContrastAdaptiveSharpening
AtomicI64AtomicI64
GamepadAxisChangedEventGamepadAxisChangedEvent
AxisSettingsAxisSettings
FloatOrdFloatOrd
i16i16
CascadeCascade
RepeatedGridTrackRepeatedGridTrack
VolumetricLightVolumetricLight
ScrollPositionScrollPosition
BorderRadiusBorderRadius
ButtonButton
FixedFixed
Camera3dDepthLoadOpCamera3dDepthLoadOp
VolumeVolume
WindowWindow
LightProbeLightProbe
KeyboardInputKeyboardInput
EntityEntity
TickTick
HitDataHitData
ProjectionProjection
Text2dText2d
ChildrenChildren
PointLightPointLight
ImageImage
IndicesIndices
Ray2dRay2d
RawGamepadEventRawGamepadEvent
OverflowClipBoxOverflowClipBox

Functions

Non-Associated Functions

Global functions that are not associated with any type and callable from anywhere in the script.

For function details and documentation, click on the function link.

FunctionSummary
constructAttempts to construct the given type, given an arbitrary map of values.
system_builderCreates a new script system builder, which can be used to add new systems to the world.

construct

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Attempts to construct the given type, given an arbitrary map of values.

Arguments

NameTypeDocumentation
registrationScriptTypeRegistration | ScriptComponentRegistration | ScriptResourceRegistrationThe type to construct.
payloadHashMap<String, ScriptValue>The values to use to construct the type.

Returns

NameTypeDocumentation
referenceReflectReferenceThe constructed type.

system_builder

Creates a new script system builder, which can be used to add new systems to the world.

Arguments

NameTypeDocumentation
callbackStringThe function name in the script this system should call when run.
script_idStringThe id of the script this system will execute when run.

Returns

NameTypeDocumentation
builderScriptSystemBuilderThe system builder

Types

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
WorldThe ECS world containing all Components, Resources and Systems. Main point of interaction with a Bev...
ReflectReferenceA reference to an arbitrary reflected instance. The reference can point to either the ECS, or to ...
ScriptComponentRegistrationA reference to a component type's reflection registration. In general think of this as a handle t...
ScriptQueryBuilderThe query builder is used to build ECS queries which retrieve spefific components filtered by speci...
ScriptQueryResultA result from a query.
ScriptResourceRegistrationA reference to a resource type's reflection registration. In general think of this as a handle to...
ScriptTypeRegistrationA reference to a type which is not a `Resource` or `Component`. In general think of this as a han...
ScriptSystemBuilderA builder for systems living in scripts
ReflectScheduleA reflectable schedule.
ReflectSystemA reflectable system.
NameComponent used to identify an entity. Stores a hash for faster comparisons. The hash is eagerly r...
ComponentIdA value which uniquely identifies the type of a [`Component`] or [`Resource`] within a [`World`]. Each time a new `Component` type is registered within a `World` using e.g. [`World::register_component`]...
ComponentTicksRecords when a component or resource was added and when it was last mutably dereferenced (or added)...
TickA value that tracks when a system ran relative to other systems. This is used to power change dete...
EntityLightweight identifier of an [entity](crate::entity). The identifier is implemented using a [gene...
EntityHashA [`BuildHasher`] that results in a [`EntityHasher`].
IdentifierA unified identifier for all entity and similar IDs. Has the same size as a `u64` integer, but th...
RemovedComponentEntityWrapper around [`Entity`] for [`RemovedComponents`]. Internally, `RemovedComponents` uses these as...
ChildrenContains references to the child entities of this entity. Each child must contain a [`Parent`] component that points back to this entity. This component rarely needs to be created manually, consider using higher level utilities like [`BuildChildren::with_children`]...
ParentHolds a reference to the parent entity of this entity. This component should only be present on en...
HierarchyEventAn [`Event`] that is fired whenever there is a change in the world's hierarchy. [`Event`]: bevy_ecs::event::Event
ButtonStateThe current "press" state of an element
AxisSettingsSettings for a [`GamepadAxis`]. It is used inside the [`GamepadSettings`] to define the sensitivi...
ButtonAxisSettingsSettings for a [`GamepadButton`]. It is used inside the [`GamepadSettings`] to define the sensiti...
ButtonSettingsManages settings for gamepad buttons. It is used inside [`GamepadSettings`] to define the threshold for a [`GamepadButton`]...
GamepadStores a connected gamepad's metadata such as the name and its [`GamepadButton`] and [`GamepadAxis`...
GamepadAxisRepresents gamepad input types that are mapped in the range [-1.0, 1.0] ## Usage This is used to determine which axis has changed its value when receiving a gamepad axis event. It is also used in the [`Gamepad`]...
GamepadAxisChangedEvent[`GamepadAxis`] event triggered by an analog state change
GamepadButtonRepresents gamepad input types that are mapped in the range [0.0, 1.0]. ## Usage This is used to determine which button has changed its value when receiving gamepad button events It is also used in the [`Gamepad`]...
GamepadButtonChangedEvent[`GamepadButton`] event triggered by an analog state change
GamepadButtonStateChangedEvent[`GamepadButton`] event triggered by a digital state change
GamepadConnectionThe connection status of a gamepad.
GamepadConnectionEventA Gamepad connection event. Created when a connection to a gamepad is established and when a gamep...
GamepadEventA gamepad event. This event type is used over the [`GamepadConnectionEvent`], [`GamepadButtonChangedEvent`...
GamepadInputEncapsulation over [`GamepadAxis`] and [`GamepadButton`]
GamepadRumbleIntensityThe intensity at which a gamepad's force-feedback motors may rumble.
GamepadRumbleRequestAn event that controls force-feedback rumbling of a [`Gamepad`] [`entity`](Entity). # Notes Doe...
GamepadSettingsGamepad settings component. ## Usage It is used to create a `bevy` component that stores the se...
RawGamepadAxisChangedEvent[`GamepadAxis`] changed event unfiltered by [`GamepadSettings`]
RawGamepadButtonChangedEvent[`GamepadButton`] changed event unfiltered by [`GamepadSettings`]
RawGamepadEventA raw gamepad event. This event type is used over the [`GamepadConnectionEvent`], [`RawGamepadButtonChangedEvent`...
DoubleTapGestureDouble tap gesture. ## Platform-specific - Only available on **`macOS`** and **`iOS`**. - On *...
PanGesturePan gesture. ## Platform-specific - On **`iOS`**, must be enabled first
PinchGestureTwo-finger pinch gesture, often used for magnifications. Positive delta values indicate magnifica...
RotationGestureTwo-finger rotation gesture. Positive delta values indicate rotation counterclockwise and negati...
KeyThe logical key code of a [`KeyboardInput`]. ## Technical Its values map 1 to 1 to winit's Key.
KeyCodeThe key code of a [`KeyboardInput`]. ## Usage It is used as the generic `T` value of an [`ButtonInput`...
KeyboardFocusLostGets generated from `bevy_winit::winit_runner` Used for clearing all cached states to avoid havin...
KeyboardInputA keyboard input event. This event is the translated version of the `WindowEvent::KeyboardInput` ...
NativeKeyContains the platform-native logical key identifier, known as keysym. Exactly what that means dif...
NativeKeyCodeContains the platform-native physical key identifier The exact values vary from platform to platf...
AccumulatedMouseMotionTracks how much the mouse has moved every frame. This resource is reset to zero every frame. Th...
AccumulatedMouseScrollTracks how much the mouse has scrolled every frame. This resource is reset to zero every frame. ...
MouseButtonA button on a mouse device. ## Usage It is used as the generic `T` value of an [`ButtonInput`] to create a `bevy` resource. ## Updating The resource is updated inside of the [`mouse_button_input_system`]...
MouseButtonInputA mouse button input event. This event is the translated version of the `WindowEvent::MouseInput`...
MouseMotionAn event reporting the change in physical position of a pointing device. This represents raw, unf...
MouseScrollUnitThe scroll unit. Describes how a value of a [`MouseWheel`] event has to be interpreted. The value of the event can either be interpreted as the amount of lines or the amount of pixels to scroll.
MouseWheelA mouse wheel event. This event is the translated version of the `WindowEvent::MouseWheel` from t...
ForceTouchA force description of a [`Touch`] input.
TouchInputA touch input event. ## Logic Every time the user touches the screen, a new [`TouchPhase::Started`]...
TouchPhaseA phase of a [`TouchInput`]. ## Usage It is used to describe the phase of the touch input that is currently active. This includes a phase that indicates that a touch input has started or ended, or that a finger has moved. There is also a canceled phase that indicates that the system canceled the tracking of the finger.
AspectRatioAn `AspectRatio` is the ratio of width to height.
Aabb2dA 2D axis-aligned bounding box, or bounding rectangle
BoundingCircleA bounding circle
Aabb3dA 3D axis-aligned bounding box
BoundingSphereA bounding sphere
AabbCast2dAn intersection test that casts an [`Aabb2d`] along a ray.
BoundingCircleCastAn intersection test that casts a [`BoundingCircle`] along a ray.
RayCast2dA raycast intersection test for 2D bounding volumes
AabbCast3dAn intersection test that casts an [`Aabb3d`] along a ray.
BoundingSphereCastAn intersection test that casts a [`BoundingSphere`] along a ray.
RayCast3dA raycast intersection test for 3D bounding volumes
CompassOctantA compass enum with 8 directions. ```text N (North) ▲ NW │ NE ╲ │ ╱ W (West) ┼─────► E (East) ╱ │ ╲ SW │ SE ▼ S (South) `...
CompassQuadrantA compass enum with 4 directions. ```text N (North) ▲ │ │ W (West) ┼─────► E (East) │ │ ▼ S (South) `...
EaseFunctionCurve functions over the [unit interval], commonly used for easing transitions. [unit interval]: `Interval::UNIT`...
IntervalA nonempty closed interval, possibly unbounded in either direction. In other words, the interval ...
Dir2A normalized vector pointing in a direction in 2D space
Dir3A normalized vector pointing in a direction in 3D space
Dir3AA normalized SIMD vector pointing in a direction in 3D space. This type stores a 16 byte aligned [`Vec3A`]...
FloatOrdA wrapper for floats that implements [`Ord`], [`Eq`], and [`Hash`] traits. This is a work around for the fact that the IEEE 754-2008 standard, implemented by Rust's [`f32`]...
Isometry2dAn isometry in two dimensions, representing a rotation followed by a translation. This can often b...
Isometry3dAn isometry in three dimensions, representing a rotation followed by a translation. This can often...
AnnulusA primitive shape formed by the region between two circles, also known as a ring.
Arc2dA primitive representing an arc between two points on a circle. An arc has no area. If you want ...
Capsule2dA 2D capsule primitive, also known as a stadium or pill shape. A two-dimensional capsule is defin...
CircleA circle primitive, representing the set of points some distance from the origin
CircularSectorA primitive representing a circular sector: a pie slice of a circle. The segment is positioned so...
CircularSegmentA primitive representing a circular segment: the area enclosed by the arc of a circle and its chor...
EllipseAn ellipse primitive, which is like a circle, but the width and height can be different
Line2dAn infinite line going through the origin along a direction in 2D space. For a finite line: [`Segment2d`]...
Plane2dAn unbounded plane in 2D space. It forms a separating surface through the origin, stretching infin...
RectangleA rectangle primitive, which is like a square, except that the width and height can be different
RegularPolygonA polygon centered on the origin where all vertices lie on a circle, equally far apart.
RhombusA rhombus primitive, also known as a diamond shape. A four sided polygon, centered on the origin, ...
Segment2dA segment of a line going through the origin along a direction in 2D space.
Triangle2dA triangle in 2D space
Capsule3dA 3D capsule primitive centered on the origin A three-dimensional capsule is defined as a surface ...
ConeA cone primitive centered on the midpoint between the tip of the cone and the center of its base. ...
ConicalFrustumA conical frustum primitive. A conical frustum can be created by slicing off a section of a cone.
CuboidA cuboid primitive, which is like a cube, except that the x, y, and z dimensions are not required ...
CylinderA cylinder primitive centered on the origin
InfinitePlane3dAn unbounded plane in 3D space. It forms a separating surface through the origin, stretching infin...
Line3dAn infinite line going through the origin along a direction in 3D space. For a finite line: [`Segment3d`]...
Plane3dA bounded plane in 3D space. It forms a surface starting from the origin with a defined height and ...
Segment3dA segment of a line going through the origin along a direction in 3D space.
SphereA sphere primitive, representing the set of all points some distance from the origin
TetrahedronA tetrahedron primitive.
TorusA torus primitive, often representing a ring or donut shape The set of points some distance from a...
Triangle3dA 3D triangle primitive.
Ray2dAn infinite half-line starting at `origin` and going in `direction` in 2D space.
Ray3dAn infinite half-line starting at `origin` and going in `direction` in 3D space.
IRectA rectangle defined by two opposite corners. The rectangle is axis aligned, and defined by its mi...
RectA rectangle defined by two opposite corners. The rectangle is axis aligned, and defined by its mi...
URectA rectangle defined by two opposite corners. The rectangle is axis aligned, and defined by its mi...
Rot2A counterclockwise 2D rotation. # Example ``` # use approx::assert_relative_eq; # use bevy_math::{Rot2, Vec2}; use std::f32::consts::PI; // Create rotations from radians or degrees let rotation1 = Rot2::radians(PI / 2.0); let rotation2 = Rot2::degrees(45.0); // Get the angle back as radians or degrees assert_eq!(rotation1.as_degrees(), 90.0); assert_eq!(rotation2.as_radians(), PI / 4.0); // "Add" rotations together using `*` assert_relative_eq!(rotation1 * rotation2, Rot2::degrees(135.0)); // Rotate vectors assert_...
FixedThe fixed timestep game clock following virtual time. A specialization of the [`Time`] structure. **For method documentation, see [`Time#impl-Time`]...
RealReal time clock representing elapsed wall clock time. A specialization of the [`Time`] structure. **For method documentation, see [`Time#impl-Time`]...
StopwatchA Stopwatch is a struct that tracks elapsed time when started. Note that in order to advance the ...
TimerTracks elapsed time. Enters the finished state once `duration` is reached. Non repeating timers w...
TimerModeSpecifies [`Timer`] behavior.
VirtualThe virtual game clock representing game time. A specialization of the [`Time`] structure. **For method documentation, see [`Time#impl-Time`].**...
GlobalTransform[`GlobalTransform`] is an affine transformation from entity-local coordinates to worldspace coordinates. You cannot directly mutate [`GlobalTransform`]...
TransformDescribe the position of an entity. If the entity has a parent, the position is relative to its pa...
DurationNo Documentation 🚧
InstantNo Documentation 🚧
RangeFullNo Documentation 🚧
AtomicBoolNo Documentation 🚧
AtomicI16No Documentation 🚧
AtomicI32No Documentation 🚧
AtomicI64No Documentation 🚧
AtomicI8No Documentation 🚧
AtomicIsizeNo Documentation 🚧
AtomicU16No Documentation 🚧
AtomicU32No Documentation 🚧
AtomicU64No Documentation 🚧
AtomicU8No Documentation 🚧
AtomicUsizeNo Documentation 🚧
Affine2No Documentation 🚧
Affine3ANo Documentation 🚧
BVec2No Documentation 🚧
BVec3No Documentation 🚧
BVec3ANo Documentation 🚧
BVec4No Documentation 🚧
BVec4ANo Documentation 🚧
DAffine2No Documentation 🚧
DAffine3No Documentation 🚧
DMat2No Documentation 🚧
DMat3No Documentation 🚧
DMat4No Documentation 🚧
DQuatNo Documentation 🚧
DVec2No Documentation 🚧
DVec3No Documentation 🚧
DVec4No Documentation 🚧
EulerRotNo Documentation 🚧
I64Vec2No Documentation 🚧
I64Vec3No Documentation 🚧
I64Vec4No Documentation 🚧
IVec2No Documentation 🚧
IVec3No Documentation 🚧
IVec4No Documentation 🚧
Mat2No Documentation 🚧
Mat3No Documentation 🚧
Mat3ANo Documentation 🚧
Mat4No Documentation 🚧
QuatNo Documentation 🚧
U64Vec2No Documentation 🚧
U64Vec3No Documentation 🚧
U64Vec4No Documentation 🚧
UVec2No Documentation 🚧
UVec3No Documentation 🚧
UVec4No Documentation 🚧
Vec2No Documentation 🚧
Vec3No Documentation 🚧
Vec3ANo Documentation 🚧
Vec4No Documentation 🚧
SmolStrNo Documentation 🚧
UuidNo Documentation 🚧
DynamicFunctionMutA dynamic mutable script function.
FunctionCallContextThe caller context when calling a script function. Functions can choose to react to caller prefere...
PathBufA heap allocated file path
StringA heap allocated string
FocusResource representing which entity has keyboard focus, if any.
ActiveAnimationAn animation that an [`AnimationPlayer`] is currently either playing or was playing, but is presently paused. An stopped animation is considered no longer active.
AnimationClipA list of [`VariableCurve`]s and the [`AnimationTargetId`]s to which they apply. Because animati...
AnimationEventNo Documentation 🚧
AnimationEventTargetNo Documentation 🚧
AnimationPlayerAnimation controls. Automatically added to any root animations of a scene when it is spawned.
AnimationTargetAn entity that can be animated by an [`AnimationPlayer`]. These are frequently referred to as *bones* or *joints*, because they often refer to individually-animatable parts of an armature. Asset loaders for armatures are responsible for adding these as necessary. Typically, they're generated from hashed versions of the entire name path from the root of the armature to the bone. See the [`AnimationTargetId`]...
AnimationTargetIdA unique [UUID] for an animation target (e.g. bone in a skinned mesh). The [`AnimationClip`] asse...
RepeatAnimationRepetition behavior of an animation.
TimedAnimationEventNo Documentation 🚧
AnimationGraphA graph structure that describes how animation clips are to be blended together. Applications fr...
AnimationGraphHandleA [`Handle`] to the [`AnimationGraph`] to be used by the [`AnimationPlayer`](crate::AnimationPlayer) on the same entity.
ThreadedAnimationGraphAn acceleration structure for an animation graph that allows Bevy to evaluate it quickly. This i...
ThreadedAnimationGraphsAcceleration structures for animation graphs that allows Bevy to evaluate them quickly. These ar...
AnimationTransitionAn animation that is being faded out as part of a transition
AnimationTransitionsManages fade-out of animation blend factors, allowing for smooth transitions between animations. ...
AssetIndexA generational runtime-only identifier for a specific [`Asset`] stored in [`Assets`]. This is optim...
AssetPathRepresents a path to an asset in a "virtual filesystem". Asset paths consist of three main parts:...
RenderAssetUsagesDefines where the asset will be used. If an asset is set to the `RENDER_WORLD` but not the `MAIN_WORLD`...
DefaultSpatialScaleThe default scale factor applied to the positions of audio sources and listeners for spatial audio...
GlobalVolumeUse this [`Resource`] to control the global volume of all audio. Note: changing this value will not affect already playing audio.
PlaybackModeThe way Bevy manages the sound playback.
PlaybackSettingsInitial settings to be used when audio starts playing. If you would like to control the audio whi...
SpatialListenerSettings for the listener for spatial audio sources. This must be accompanied by `Transform` and `GlobalTransform`...
SpatialScaleA scale factor applied to the positions of audio sources and listeners for spatial audio. Defaul...
VolumeA volume level equivalent to a non-negative float.
ColorAn enumerated type that can represent any of the color types in this crate. This is useful when y...
HslaColor in Hue-Saturation-Lightness (HSL) color space with alpha. Further information on this color ...
HsvaColor in Hue-Saturation-Value (HSV) color space with alpha. Further information on this color mode...
HwbaColor in Hue-Whiteness-Blackness (HWB) color space with alpha. Further information on this color m...
LabaColor in LAB color space, with alpha
LchaColor in LCH color space, with alpha
LinearRgbaLinear RGB color with alpha.
OklabaColor in Oklab color space, with alpha
OklchaColor in Oklch color space, with alpha
SrgbaNon-linear standard RGB with alpha.
Xyza[CIE 1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space, also known as XYZ, with an alpha channel.
BloomApplies a bloom effect to an HDR-enabled 2d or 3d camera. Bloom emulates an effect found in real ...
BloomCompositeModeNo Documentation 🚧
BloomPrefilterApplies a threshold filter to the input image to extract the brightest regions before blurring the...
ContrastAdaptiveSharpeningApplies a contrast adaptive sharpening (CAS) filter to the camera. CAS is usually used in combina...
Camera2dA 2D camera component. Enables the 2D render graph for a [`Camera`].
Camera3dA 3D camera component. Enables the main 3D render graph for a [`Camera`]. The camera coordinate space is right-handed X-right, Y-up, Z-back. This means "forward" is -Z.
Camera3dDepthLoadOpThe depth clear operation to perform for the main 3d pass.
Camera3dDepthTextureUsageNo Documentation 🚧
ScreenSpaceTransmissionQualityThe quality of the screen space transmission blur effect, applied to whatever's “behind” transm...
DepthOfFieldA component that enables a [depth of field] postprocessing effect when attached to a [`Camera3d`], ...
DepthOfFieldModeControls the appearance of the effect.
FxaaA component for enabling Fast Approximate Anti-Aliasing (FXAA) for a [`bevy_render::camera::Camera`].
SensitivityNo Documentation 🚧
OrderIndependentTransparencySettingsUsed to identify which camera will use OIT to render transparent meshes and to configure OIT.
ChromaticAberrationAdds colored fringes to the edges of objects in the scene. [Chromatic aberration] simulates the effect when lenses fail to focus all colors of light toward a single point. It causes rainbow-colored streaks to appear, which are especially apparent on the edges of objects. Chromatic aberration is commonly used for collision effects, especially in horror games. Bevy's implementation is based on that of *Inside* ([Gjøl & Svendsen 2016]...
DeferredPrepassIf added to a [`crate::prelude::Camera3d`] then deferred materials will be rendered to the deferred gbuffer texture and will be available to subsequent passes. Note the default deferred lighting plugin also requires `DepthPrepass` to work correctly.
DepthPrepassIf added to a [`crate::prelude::Camera3d`] then depth values will be copied to a separate texture available to the main pass.
MotionVectorPrepassIf added to a [`crate::prelude::Camera3d`] then screen space motion vectors will be copied to a separate texture available to the main pass.
NormalPrepassIf added to a [`crate::prelude::Camera3d`] then vertex world normals will be copied to a separate texture available to the main pass. Normals will have normal map textures already applied.
SmaaA component for enabling Subpixel Morphological Anti-Aliasing (SMAA) for a [`bevy_render::camera::Camera`].
SmaaPresetA preset quality level for SMAA. Higher values are slower but result in a higher-quality image. ...
DebandDitherEnables a debanding shader that applies dithering to mitigate color banding in the final image for ...
TonemappingOptionally enables a tonemapping shader that attempts to map linear input stimulus into a perceptua...
SystemIdMarkerMarker [`Component`](bevy_ecs::component::Component) for identifying [`SystemId`] [`Entity`]s.
OnAddTrigger emitted when a component is added to an entity. See [`crate::component::ComponentHooks::on_add`] for more information.
OnInsertTrigger emitted when a component is inserted onto an entity. See [`crate::component::ComponentHooks::on_insert`] for more information.
OnRemoveTrigger emitted when a component is removed from an entity. See [`crate::component::ComponentHooks::on_remove`] for more information.
OnReplaceTrigger emitted when a component is replaced on an entity. See [`crate::component::ComponentHooks::on_replace`] for more information.
AabbGizmoConfigGroupThe [`GizmoConfigGroup`] used for debug visualizations of [`Aabb`] components on entities
GizmoConfigA struct that stores configuration for gizmos.
GizmoConfigStoreA [`Resource`] storing [`GizmoConfig`] and [`GizmoConfigGroup`] structs Use `app.init_gizmo_group::()` to register a custom config group.
GizmoLineJointAn enum configuring how line joints will be drawn.
GizmoLineStyleAn enum used to configure the style of gizmo lines, similar to CSS line-style
LightGizmoColorConfigures how a color is attributed to a light gizmo.
LightGizmoConfigGroupThe [`GizmoConfigGroup`] used to configure the visualization of lights.
GltfExtrasAdditional untyped data that can be present on most glTF types at the primitive level. See [the relevant glTF specification section](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#reference-extras)...
GltfMaterialExtrasAdditional untyped data that can be present on most glTF types at the material level. See [the relevant glTF specification section](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#reference-extras)...
GltfMaterialNameThe material name of a glTF primitive. See [the relevant glTF specification section](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#reference-material).
GltfMeshExtrasAdditional untyped data that can be present on most glTF types at the mesh level. See [the relevant glTF specification section](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#reference-extras)...
GltfSceneExtrasAdditional untyped data that can be present on most glTF types at the scene level. See [the relevant glTF specification section](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#reference-extras)...
ImageNo Documentation 🚧
Affine3Reduced-size version of `glam::Affine3A` for use when storage has significant performance impact. ...
IndicesAn array of indices into the [`VertexAttributeValues`](super::VertexAttributeValues) for a mesh. It describes the order in which the vertex attributes should be joined into faces.
MeshA 3D object made out of vertices representing triangles, lines, or points, with "attribute" values...
MeshMorphWeightsControl a specific [`Mesh`] instance's [morph targets]. These control the weights of specific "mes...
MorphWeightsControls the [morph targets] for all child `Mesh3d` entities. In most cases, [`MorphWeights`] shoul...
SkinnedMeshNo Documentation 🚧
NamespaceA namespace for functions
ScriptValueAn abstraction of values that can be passed to and from scripts. This allows us to re-use logic be...
FunctionArgInfoInformation about a function argument.
FunctionInfoInformation about a function.
FunctionReturnInfoInformation about a function return value.
InteropErrorAn error thrown when interoperating with scripting languages.
CascadesVisibleEntitiesNo Documentation 🚧
CubemapVisibleEntitiesNo Documentation 🚧
VisibleMeshEntitiesCollection of mesh entities visible for 3D lighting. This component contains all mesh entities vi...
ClusterConfigConfiguration of the clustering strategy for clustered forward rendering
ClusterFarZModeConfigure the far z-plane mode used for the furthest depth slice for clustered forward rendering
ClusterZConfigConfigure the depth-slicing strategy for clustered forward rendering
DistanceFogConfigures the “classic” computer graphics [distance fog](https://en.wikipedia.org/wiki/Distance_fog) effect, in which objects appear progressively more covered in atmospheric haze the further away they are from the camera. Affects meshes rendered via the PBR [`StandardMaterial`](crate::StandardMaterial)...
FogFalloffAllows switching between different fog falloff modes, and configuring their parameters. ## Conven...
CascadeNo Documentation 🚧
CascadeShadowConfigControls how cascaded shadow mapping works. Prefer using [`CascadeShadowConfigBuilder`] to construct an instance. ``` # use bevy_pbr::CascadeShadowConfig; # use bevy_pbr::CascadeShadowConfigBuilder; # use bevy_utils::default; # let config: CascadeShadowConfig = CascadeShadowConfigBuilder { maximum_distance: 100.0, ..default() }.into(); ```
CascadesNo Documentation 🚧
DirectionalLightShadowMapControls the resolution of [`DirectionalLight`] shadow maps.
NotShadowCasterAdd this component to make a [`Mesh3d`] not cast shadows.
NotShadowReceiverAdd this component to make a [`Mesh3d`] not receive shadows. **Note:** If you're using diffuse transmission, setting [`NotShadowReceiver`]...
PointLightShadowMapNo Documentation 🚧
ShadowFilteringMethodAdd this component to a [`Camera3d`](bevy_core_pipeline::core_3d::Camera3d) to control how to anti-alias shadow edges. The different modes use different approaches to [Percentage Closer Filtering](https://developer.nvidia.com/gpugems/gpugems/part-ii-lighting-and-shadows/chapter-11-shadow-map-antialiasing).
AmbientLightAn ambient light, which lights the entire scene equally. This resource is inserted by the [`PbrPlugin`]...
DirectionalLightA Directional light. Directional lights don't exist in reality but they are a good approximation...
PointLightA light that emits light in all directions from a central point. Real-world values for `intensity...
SpotLightA light that emits light in a given direction from a central point. Behaves like a point light in...
LightProbeA marker component for a light probe, which is a cuboid region that provides global illumination t...
EnvironmentMapLightA pair of cubemap textures that represent the surroundings of a specific area in space. See [`crate::environment_map`] for detailed information.
IrradianceVolumeThe component that defines an irradiance volume. See [`crate::irradiance_volume`] for detailed information.
DefaultOpaqueRendererMethodDefault render method used for opaque materials.
OpaqueRendererMethodRender method used for opaque materials. The forward rendering main pass draws each mesh entity a...
ParallaxMappingMethodThe [parallax mapping] method to use to compute depth based on the material's [`depth_map`]. Parallax Mapping uses a depth map texture to give the illusion of depth variation on a mesh surface that is geometrically flat. See the `parallax_...
StandardMaterialA material with "standard" properties used in PBR lighting Standard property values with pictures ...
UvChannelAn enum to define which UV attribute to use for a texture. It is used for every texture in the [`StandardMaterial`]...
ScreenSpaceAmbientOcclusionComponent to apply screen space ambient occlusion to a 3d camera. Screen space ambient occlusion ...
ScreenSpaceAmbientOcclusionQualityLevelNo Documentation 🚧
ScreenSpaceReflectionsAdd this component to a camera to enable *screen-space reflections* (SSR). Screen-space reflectio...
VolumetricFogWhen placed on a [`bevy_core_pipeline::core_3d::Camera3d`], enables volumetric fog and volumetric lighting, also known as light shafts or god rays.
VolumetricLightAdd this component to a [`DirectionalLight`](crate::DirectionalLight) with a shadow map (`shadows_enabled: true`) to make volumetric fog interact with it. This allows the light to generate light shafts/god rays.
PickingBehaviorAn optional component that overrides default picking behavior for an entity, allowing you to make ...
PickingPluginThis plugin sets up the core picking infrastructure. It receives input events, and provides the sha...
HitDataHolds data from a successful pointer hit test. See [`HitData::depth`] for important details.
RayIdIdentifies a ray constructed from some (pointer, camera) combination. A pointer can be over multip...
PickingInteractionA component that aggregates picking interaction state of this entity across all pointers. Unlike ...
PointerInputPluginAdds mouse and touch inputs for picking pointers to your app. This is a default input plugin, that...
PointerIdIdentifies a unique pointer entity. `Mouse` and `Touch` pointers are automatically spawned. This ...
PointerInteractionHolds a list of entities this pointer is currently interacting with, sorted from nearest to farthe...
PointerLocationComponent that tracks a pointer's current [`Location`].
PointerPressTracks the state of the pointer's buttons in response to [`PointerInput`] events.
AlphaModeSets how a material's base color alpha channel is used for transparency.
CameraThe defining [`Component`] for camera entities, storing information about how and what to render through this camera. The [`Camera`]...
CameraMainTextureUsagesThis component lets you control the [`TextureUsages`] field of the main texture generated for the camera
CameraRenderGraphConfigures the [`RenderGraph`](crate::render_graph::RenderGraph) name assigned to be run for a given [`Camera`] entity.
ExposureHow much energy a `Camera3d` absorbs from incoming light. https://en\.wikipedia\.org/wiki/Exposure\_\(photography\)
MipBiasCamera component specifying a mip bias to apply when sampling from material textures. Often used ...
RenderTargetThe "target" that a [`Camera`] will render to. For example, this could be a [`Window`] swapchain o...
SubCameraViewSettings to define a camera sub view. When [`Camera::sub_camera_view`] is `Some`, only the sub-section of the image defined by `size` and `offset` (relative to the `full_size` of the whole image) is projected to the cameras viewport. Take the example of the following multi-monitor setup: ```css ┌───┬───┐ │ A │ B │ ├───┼───┤ │ C │ D │ └───┴───┘ ``` If each monitor is 1920x1080, the whole image will have a resolution of 3840x2160. For each monitor we can use a single camera with a viewport of the same size as the monitor it corresponds to. To ensure that the image is cohesive, we can use a different sub view on each camera: - Camera A: `full_size` = 3840x2160, `size` = 1920x1080, `offset` = 0,0 - Camera B: `full_size` = 3840x2160, `size` = 1920x1080, `offset` = 1920,0 - Camera C: `full_size` = 3840x2160, `size` = 1920x1080, `offset` = 0,1080 - Camera D: `full_size` = 3840x2160, `size` = 1920x1080, `offset` = 1920,1080 However since only the ratio between the values is important, they could all be divided by 120 and still produce the same image. Camera D would for example have the following values: `full_size` = 32x18, `size` = 16x9, `offset` = 16,9
TemporalJitterA subpixel offset to jitter a perspective camera's frustum by. Useful for temporal rendering tech...
ViewportRender viewport configuration for the [`Camera`] component. The viewport defines the area on the render target to which the camera renders its image. You can overlay multiple cameras in a single window using viewports to create effects like split screen, minimaps, and character viewers.
ClearColorA [`Resource`] that stores the color that is used to clear the screen between frames. This color appears as the "background" color for simple apps, when there are portions of the screen with nothing rendered.
ClearColorConfigFor a camera, specifies the color used to clear the viewport before rendering.
ManualTextureViewHandleA unique id that corresponds to a specific [`ManualTextureView`] in the [`ManualTextureViews`] coll...
OrthographicProjectionProject a 3D space onto a 2D surface using parallel lines, i.e., unlike [`PerspectiveProjection`], the size of objects remains the same regardless of their distance to the camera. The volume contained in the projection is called the *view frustum*. Since the viewport is rectangular and projection lines are parallel, the view frustum takes the shape of a cuboid. Note that the scale of the projection and the apparent size of objects are inversely proportional. As the size of the projection increases, the size of objects decreases. # Examples Configure the orthographic projection to one world unit per 100 window pixels: ``` # use bevy_render::camera::{OrthographicProjection, Projection, ScalingMode}; let projection = Projection::Orthographic(OrthographicProjection { scaling_mode: ScalingMode::WindowSize, scale: 0.01, ..OrthographicProjection::default_2d() }); ```
PerspectiveProjectionA 3D camera projection in which distant objects appear smaller than close objects.
ProjectionA configurable [`CameraProjection`] that can select its projection type at runtime.
ScalingModeScaling mode for [`OrthographicProjection`]. The effect of these scaling modes are combined with the [`OrthographicProjection::scale`]...
GlobalsUniformContains global values useful when writing shaders. Currently only contains values related to time...
Mesh2dA component for 2D meshes. Requires a [`MeshMaterial2d`] to be rendered, commonly using a [`ColorMaterial`...
Mesh3dA component for 3D meshes. Requires a [`MeshMaterial3d`] to be rendered, commonly using a [`StandardMaterial`...
AabbAn axis-aligned bounding box, defined by: - a center, - the distances from the center to each fac...
CascadesFrustaNo Documentation 🚧
CubemapFrustaNo Documentation 🚧
FrustumA region of 3D space defined by the intersection of 6 [`HalfSpace`]s. Frustums are typically an apex-truncated square pyramid (a pyramid without the top) or a cuboid. Half spaces are ordered left, right, top, bottom, near, far. The normal vectors of the half-spaces point towards the interior of the frustum. A frustum component is used on an entity with a [`Camera`]...
ShaderStorageBufferA storage buffer that is prepared as a [`RenderAsset`] and uploaded to the GPU.
SyncToRenderWorldMarker component that indicates that its entity needs to be synchronized to the render world. Thi...
ColorGradingConfigures filmic color grading parameters to adjust the image appearance. Color grading is appli...
ColorGradingGlobalFilmic color grading values applied to the image as a whole (as opposed to individual sections, li...
ColorGradingSectionA section of color grading values that can be selectively applied to shadows, midtones, and highli...
MsaaComponent for configuring the number of samples for [Multi-Sample Anti-Aliasing](https://en.wikipedia.org/wiki/Multisample_anti-aliasing) for a [`Camera`](crate::camera::Camera)...
InheritedVisibilityWhether or not an entity is visible in the hierarchy. This will not be accurate until [`VisibilityPropagate`]...
NoFrustumCullingUse this component to opt-out of built-in frustum culling for entities, see [`Frustum`]. It can be used for example: - when a [`Mesh`]...
ViewVisibilityAlgorithmically-computed indication of whether an entity is visible and should be extracted for ren...
VisibilityUser indication of whether an entity is visible. Propagates down the entity hierarchy. If an enti...
VisibleEntitiesCollection of entities visible from the current view. This component contains all entities which ...
VisibilityRangeSpecifies the range of distances that this entity must be from the camera in order to be rendered....
RenderLayersDescribes which rendering layers an entity belongs to. Cameras with this component will only rend...
ScreenshotA component that signals to the renderer to capture a screenshot this frame. This component shoul...
ScreenshotCapturedNo Documentation 🚧
DynamicSceneRootAdding this component will spawn the scene as a child of that entity. Once it's spawned, the entit...
SceneRootAdding this component will spawn the scene as a child of that entity. Once it's spawned, the entit...
SpriteSourceA component that marks entities that aren't themselves sprites but become sprites during rendering...
ColorMaterialA [2d material](Material2d) that renders [2d meshes](crate::Mesh2d) with a texture tinted by a unif...
AlphaMode2dSets how a 2d material's base color alpha channel is used for transparency. Currently, this only w...
AnchorHow a sprite is positioned relative to its [`Transform`]. It defaults to `Anchor::Center`.
SpriteDescribes a sprite to be rendered to a 2D camera
SpriteImageModeControls how the image is altered when scaled.
TextureAtlasAn index into a [`TextureAtlasLayout`], which corresponds to a specific section of a texture. It stores a handle to [`TextureAtlasLayout`]...
TextureAtlasLayoutStores a map used to lookup the position of a texture in a [`TextureAtlas`]. This can be used to either use and look up a specific section of a texture, or animate frame-by-frame as a sprite sheet. Optionally it can store a mapping from sub texture handles to the related area index (see [`TextureAtlasBuilder`]...
BorderRectStruct defining a [`Sprite`](crate::Sprite) border with padding values
SliceScaleModeDefines how a texture slice scales when resized
TextureSlicerSlices a texture using the **9-slicing** technique. This allows to reuse an image at various sizes ...
ReflectableScheduleLabelNo Documentation 🚧
TextBoundsThe maximum width and height of text. The text will wrap according to the specified size. Charact...
GlyphAtlasInfoInformation about a glyph in an atlas. Rasterized glyphs are stored as rectangles in one or more...
GlyphAtlasLocationThe location of a glyph in an atlas, and how it should be positioned when placed. Used in [`GlyphAtlasInfo`]...
PositionedGlyphA glyph of a font, typically representing a single character, positioned in screen space. Contain...
TextLayoutInfoRender information for a corresponding text block. Contains scaled glyphs and their size. Generat...
Text2dThe top-level 2D text component. Adding `Text2d` to an entity will pull in required components fo...
ComputedTextBlockComputed information for a text block. See [`TextLayout`]. Automatically updated by 2d and UI text systems.
FontSmoothingDetermines which antialiasing method to use when rendering text. By default, text is rendered with...
JustifyTextDescribes the horizontal alignment of multiple lines of text relative to each other. This only af...
LineBreakDetermines how lines will be broken when preventing text from running out of bounds.
TextColorThe color of the text for this section.
TextEntityA sub-entity of a [`ComputedTextBlock`]. Returned by [`ComputedTextBlock::entities`].
TextFont`TextFont` determines the style of a text span within a [`ComputedTextBlock`], specifically the font face, the font size, and the color.
TextLayoutComponent with text format settings for a block of text. A block of text is composed of text span...
TextSpanA span of UI text in a tree of spans under an entity with [`TextLayout`] and `Text` or `Text2d`. Spans are collected in hierarchy traversal order into a [`ComputedTextBlock`]...
UiScaleThe current scale of the UI. A multiplier to fixed-sized ui values. **Note:** This will only aff...
FocusPolicyDescribes whether the node should block interactions with lower nodes
InteractionDescribes what type of input interaction has occurred for a UI node. This is commonly queried wit...
RelativeCursorPositionA component storing the position of the mouse relative to the node, (0., 0.) being the top-left cor...
UiRectA type which is commonly used to define margins, paddings and borders. # Examples ## Margin A...
ValRepresents the possible value types for layout properties. This enum allows specifying values for...
ContentSizeA node with a `ContentSize` component is a node where its size is based on its content.
AlignContentUsed to control how items are distributed. - For Flexbox containers, controls alignment of lines i...
AlignItemsUsed to control how each individual item is aligned by default within the space they're given. - F...
AlignSelfUsed to control how the specified item is aligned within the space it's given. - For Flexbox items...
BackgroundColorThe background color of the node This serves as the "fill" color.
BorderColorThe border color of the UI node.
BorderRadiusUsed to add rounded corners to a UI node. You can set a UI node to have uniformly rounded corners ...
CalculatedClipThe calculated clip of the node
ComputedNodeProvides the computed size and layout properties of the node.
DisplayDefines the layout model used by this node. Part of the [`Node`] component.
FlexDirectionDefines how flexbox items are ordered within a flexbox
FlexWrapDefines if flexbox items appear on a single line or on multiple lines
GridAutoFlowControls whether grid items are placed row-wise or column-wise as well as whether the sparse or den...
GridPlacementRepresents the position of a grid item in a single axis. There are 3 fields which may be set: ...
GridTrackA [`GridTrack`] is a Row or Column of a CSS Grid. This struct specifies what size the track should be. See below for the different "track sizing functions" you can specify.
GridTrackRepetitionHow many times to repeat a repeated grid track <https://developer.mozilla.org/en-US/docs/Web/CSS/...
JustifyContentUsed to control how items are distributed. - For Flexbox containers, controls alignment of items i...
JustifyItemsUsed to control how each individual item is aligned by default within the space they're given. - F...
JustifySelfUsed to control how the specified item is aligned within the space it's given. - For Flexbox items...
MaxTrackSizingFunctionNo Documentation 🚧
MinTrackSizingFunctionNo Documentation 🚧
NodeThe base component for UI entities. It describes UI layout and style properties. When defining ne...
OutlineThe [`Outline`] component adds an outline outside the edge of a UI node. Outlines do not take up space in the layout. To add an [`Outline`]...
OverflowWhether to show or hide overflowing items
OverflowAxisWhether to show or hide overflowing items
OverflowClipBoxUsed to determine the bounds of the visible area when a UI node is clipped.
OverflowClipMarginThe bounds of the visible area when a UI node is clipped.
PositionTypeThe strategy used to position this node
RepeatedGridTrackRepresents a *possibly* repeated [`GridTrack`]. The repetition parameter can either be: - The integer `1`, in which case the track is non-repeated. - a `u16` count to repeat the track N times. - A `GridTrackRepetition::AutoFit` or `GridTrackRepetition::AutoFill`. Note: that in the common case you want a non-repeating track (repetition count 1), you may use the constructor methods on [`GridTrack`]...
ResolvedBorderRadiusRepresents the resolved border radius values for a UI node. The values are in physical pixels.
ScrollPositionThe scroll position of the node. Updating the values of `ScrollPosition` will reposition the chil...
TargetCameraIndicates that this root [`Node`] entity should be rendered to a specific camera. UI then will be laid out respecting the camera's viewport and scale factor, and rendered to this camera's [`bevy_render::camera::RenderTarget`]...
UiAntiAliasMarker for controlling whether Ui is rendered with or without anti-aliasing in a camera. By defaul...
UiBoxShadowSamplesNumber of shadow samples. A larger value will result in higher quality shadows. Default is 4, val...
ZIndexIndicates that this [`Node`] entity's front-to-back ordering is not controlled solely by its location in the UI hierarchy. A node with a higher z-index will appear on top of sibling nodes with a lower z-index. UI nodes that have the same z-index will appear according to the order in which they appear in the UI hierarchy. In such a case, the last node to be added to its parent will appear in front of its siblings. Nodes without this component will be treated as if they had a value of [`ZIndex(0)`]...
ButtonMarker struct for buttons
ImageNodeA UI Node that renders an image.
ImageNodeSizeThe size of the image's texture This component is updated automatically by [`update_image_content_size_system`]...
NodeImageModeControls how the image is altered to fit within the layout and how the layout algorithm determines ...
LabelMarker struct for labels
TextThe top-level UI text component. Adding [`Text`] to an entity will pull in required components for setting up a UI text node. The string in this component is the first 'text span' in a hierarchy of text spans that are collected into a [`ComputedTextBlock`]...
TextNodeFlagsUI text system flags. Used internally by [`measure_text_system`] and [`text_system`] to schedule text for processing.
AppLifecycleApplication lifetime events
CursorEnteredAn event that is sent whenever the user's cursor enters a window.
CursorLeftAn event that is sent whenever the user's cursor leaves a window.
CursorMovedAn event reporting that the mouse cursor has moved inside a window. The event is sent only if the...
FileDragAndDropEvents related to files being dragged and dropped on a window.
ImeA Input Method Editor event. This event is the translated version of the `WindowEvent::Ime` from ...
RequestRedrawAn event that indicates all of the application's windows should be redrawn, even if their control ...
WindowBackendScaleFactorChangedAn event that indicates a window's OS-reported scale factor has changed.
WindowCloseRequestedAn event that is sent whenever the operating systems requests that a window be closed. This will b...
WindowClosedAn event that is sent whenever a window is closed. This will be sent when the window entity loses ...
WindowClosingAn event that is sent whenever a window is closing. This will be sent when after a [`WindowCloseRequested`]...
WindowCreatedAn event that is sent whenever a new window is created. To create a new window, spawn an entity w...
WindowDestroyedAn event that is sent whenever a window is destroyed by the underlying window system. Note that i...
WindowEventWraps all `bevy_window` and `bevy_input` events in a common enum. Read these events with `EventReader`...
WindowFocusedAn event that indicates a window has received or lost focus.
WindowMovedAn event that is sent when a window is repositioned in physical pixels.
WindowOccludedThe window has been occluded (completely hidden from view). This is different to window visibilit...
WindowResizedA window event that is sent whenever a window's logical size has changed.
WindowScaleFactorChangedAn event that indicates a window's scale factor has changed.
WindowThemeChangedAn event sent when the system theme changes for a window. This event is only sent when the window...
MonitorRepresents an available monitor as reported by the user's operating system, which can be used to q...
VideoModeRepresents a video mode that a monitor supports
SystemCursorIconThe icon to display for a window. Examples of all of these cursors can be found [here](https://www.w3schools.com/cssref/playit.php?filename=playcss_cursor&preval=crosshair). This `enum` is simply a copy of a similar `enum` found in [`winit`](https://docs.rs/winit/latest/winit/window/enum.CursorIcon.html)...
CompositeAlphaModeSpecifies how the alpha channel of the textures should be handled during compositing, for a [`Window`]...
CursorGrabModeDefines if and how the cursor is grabbed by a [`Window`]. ## Platform-specific - **`Windows`** doesn't support [`CursorGrabMode::Locked`]...
CursorOptionsCursor data for a [`Window`].
EnabledButtonsSpecifies which [`Window`] control buttons should be enabled. ## Platform-specific **`iOS`**, **`Android`**, and the **`Web`** do not have window control buttons. On some **`Linux`** environments these values have no effect.
InternalWindowStateStores internal [`Window`] state that isn't directly accessible.
MonitorSelectionReferences a screen monitor. Used when centering a [`Window`] on a monitor.
PresentModePresentation mode for a [`Window`]. The presentation mode specifies when a frame is presented to the window. The [`Fifo`]...
PrimaryWindowMarker [`Component`] for the window considered the primary window. Currently this is assumed to only exist on 1 entity at a time. [`WindowPlugin`](crate::WindowPlugin)...
WindowThe defining [`Component`] for window entities, storing information about how it should appear and behave. Each window corresponds to an entity, and is uniquely identified by the value of their [`Entity`]...
WindowLevelSpecifies where a [`Window`] should appear relative to other overlapping windows (on top or under) . Levels are groups of windows with respect to their z-position. The relative ordering between windows in different window levels is fixed. The z-order of windows within the same window level may change dynamically on user interaction. ## Platform-specific - **iOS / Android / Web / Wayland:** Unsupported.
WindowModeDefines the way a [`Window`] is displayed.
WindowPositionDefines where a [`Window`] should be placed on the screen.
WindowRefReference to a [`Window`], whether it be a direct link to a specific entity or a more vague defaulting choice.
WindowResizeConstraintsThe size limits on a [`Window`]. These values are measured in logical pixels (see [`WindowResolution`...
WindowResolutionControls the size of a [`Window`] ## Physical, logical and requested sizes There are three sizes associated with a window: - the physical size, which represents the actual height and width in physical pixels the window occupies on the monitor, - the logical size, which represents the size that should be used to scale elements inside the window, measured in logical pixels, - the requested size, measured in logical pixels, which is the value submitted to the API when creating the window, or requesting that it be resized. ## Scale factor The reason logical size and physical size are separated and can be different is to account for the cases where: - several monitors have different pixel densities, - the user has set up a pixel density preference in its operating system, - the Bevy `App` has specified a specific scale factor between both. The factor between physical size and logical size can be retrieved with [`WindowResolution::scale_factor`]...
WindowThemeThe [`Window`] theme variant to use.
CursorIconInsert into a window entity to set the cursor for that window.
CustomCursorCustom cursor image data.
boolA boolean value
charAn 8-bit character
TypeIdNo Documentation 🚧
NonZeroI16No Documentation 🚧
NonZeroU16No Documentation 🚧
NonZeroU32No Documentation 🚧
f32A 32-bit floating point number
f64A 64-bit floating point number
i128A signed 128-bit integer
i16A signed 16-bit integer
i32A signed 32-bit integer
i64A signed 64-bit integer
i8A signed 8-bit integer
isizeA signed pointer-sized integer
NodeIndexNo Documentation 🚧
u128An unsigned 128-bit integer
u16An unsigned 16-bit integer
u32An unsigned 32-bit integer
u64An unsigned 64-bit integer
u8An unsigned 8-bit integer
usizeAn unsigned pointer-sized integer
CowNo Documentation 🚧
ArcNo Documentation 🚧
Vec<String>No Documentation 🚧
Vec<TimedAnimationEvent>No Documentation 🚧
Vec<AnimationTransition>No Documentation 🚧
Vec<Entity>No Documentation 🚧
Vec<URect>No Documentation 🚧
Vec<ScriptQueryResult>No Documentation 🚧
Vec<ReflectReference>No Documentation 🚧
Vec<FunctionArgInfo>No Documentation 🚧
Vec<FunctionInfo>No Documentation 🚧
Vec<Cascade>No Documentation 🚧
Vec<ReflectSystem>No Documentation 🚧
Vec<PositionedGlyph>No Documentation 🚧
Vec<GridTrack>No Documentation 🚧
Vec<RepeatedGridTrack>No Documentation 🚧
Vec<VideoMode>No Documentation 🚧
Vec<f32>No Documentation 🚧
Vec<NodeIndex>No Documentation 🚧
Vec<u16>No Documentation 🚧
Vec<u32>No Documentation 🚧
Vec<u64>No Documentation 🚧
Handle<Unknown>A strong or weak handle to a specific [`Asset`]. If a [`Handle`] is [`Handle::Strong`], the [`Asset...
Handle<AnimationClip>A strong or weak handle to a specific [`Asset`]. If a [`Handle`] is [`Handle::Strong`], the [`Asset...
Handle<AnimationGraph>A strong or weak handle to a specific [`Asset`]. If a [`Handle`] is [`Handle::Strong`], the [`Asset...
Handle<Image>A strong or weak handle to a specific [`Asset`]. If a [`Handle`] is [`Handle::Strong`], the [`Asset...
Handle<Mesh>A strong or weak handle to a specific [`Asset`]. If a [`Handle`] is [`Handle::Strong`], the [`Asset...
Handle<StandardMaterial>A strong or weak handle to a specific [`Asset`]. If a [`Handle`] is [`Handle::Strong`], the [`Asset...
Handle<ShaderStorageBuffer>A strong or weak handle to a specific [`Asset`]. If a [`Handle`] is [`Handle::Strong`], the [`Asset...
Handle<ColorMaterial>A strong or weak handle to a specific [`Asset`]. If a [`Handle`] is [`Handle::Strong`], the [`Asset...
Handle<TextureAtlasLayout>A strong or weak handle to a specific [`Asset`]. If a [`Handle`] is [`Handle::Strong`], the [`Asset...
AssetId<Unknown>A unique runtime-only identifier for an [`Asset`]. This is cheap to [`Copy`]/[`Clone`] and is not directly tied to the lifetime of the Asset. This means it _can_ point to an [`Asset`]...
AssetId<AnimationClip>A unique runtime-only identifier for an [`Asset`]. This is cheap to [`Copy`]/[`Clone`] and is not directly tied to the lifetime of the Asset. This means it _can_ point to an [`Asset`]...
AssetId<AnimationGraph>A unique runtime-only identifier for an [`Asset`]. This is cheap to [`Copy`]/[`Clone`] and is not directly tied to the lifetime of the Asset. This means it _can_ point to an [`Asset`]...
AssetId<Image>A unique runtime-only identifier for an [`Asset`]. This is cheap to [`Copy`]/[`Clone`] and is not directly tied to the lifetime of the Asset. This means it _can_ point to an [`Asset`]...
AssetId<Mesh>A unique runtime-only identifier for an [`Asset`]. This is cheap to [`Copy`]/[`Clone`] and is not directly tied to the lifetime of the Asset. This means it _can_ point to an [`Asset`]...
AssetId<StandardMaterial>A unique runtime-only identifier for an [`Asset`]. This is cheap to [`Copy`]/[`Clone`] and is not directly tied to the lifetime of the Asset. This means it _can_ point to an [`Asset`]...
AssetId<ShaderStorageBuffer>A unique runtime-only identifier for an [`Asset`]. This is cheap to [`Copy`]/[`Clone`] and is not directly tied to the lifetime of the Asset. This means it _can_ point to an [`Asset`]...
AssetId<ColorMaterial>A unique runtime-only identifier for an [`Asset`]. This is cheap to [`Copy`]/[`Clone`] and is not directly tied to the lifetime of the Asset. This means it _can_ point to an [`Asset`]...
AssetId<TextureAtlasLayout>A unique runtime-only identifier for an [`Asset`]. This is cheap to [`Copy`]/[`Clone`] and is not directly tied to the lifetime of the Asset. This means it _can_ point to an [`Asset`]...
Axis<GamepadInput>Stores the position data of the input devices of type `T`. The values are stored as `f32`s, using...
ButtonInput<GamepadButton>A "press-able" input of type `T`. ## Usage This type can be used as a resource to keep the curr...
MeshMaterial3d<StandardMaterial>A [material](Material) used for rendering a [`Mesh3d`]. See [`Material`] for general information about 3D materials and how to implement your own materials. [`Mesh3d`]...
MeshMaterial2d<ColorMaterial>A [material](Material2d) used for rendering a [`Mesh2d`]. See [`Material2d`] for general information about 2D materials and how to implement your own materials. # Example ``` # use bevy_sprite::{ColorMaterial, MeshMaterial2d}; # use bevy_ecs::prelude::*; # use bevy_render::mesh::{Mesh, Mesh2d}; # use bevy_color::palettes::basic::RED; # use bevy_asset::Assets; # use bevy_math::primitives::Circle; # // Spawn an entity with a mesh using `ColorMaterial`. fn setup( mut commands: Commands, mut meshes: ResMut<Assets>, mut materials: ResMut<Assets>, ) { commands.spawn(( Mesh2d(meshes.add(Circle::new(50.0))), MeshMaterial2d(materials.add(ColorMaterial::from_color(RED))), )); } ``` [`MeshMaterial2d`]...
Time<Unknown>A generic clock resource that tracks how much it has advanced since its previous update and since ...
Time<Fixed>A generic clock resource that tracks how much it has advanced since its previous update and since ...
Time<Real>A generic clock resource that tracks how much it has advanced since its previous update and since ...
Time<Virtual>A generic clock resource that tracks how much it has advanced since its previous update and since ...
RangeNo Documentation 🚧
RangeNo Documentation 🚧
Option<Unknown>No Documentation 🚧
Option<String>No Documentation 🚧
Option<SpatialScale>No Documentation 🚧
Option<Color>No Documentation 🚧
Option<Entity>No Documentation 🚧
Option<ForceTouch>No Documentation 🚧
Option<CompassOctant>No Documentation 🚧
Option<Rect>No Documentation 🚧
Option<Indices>No Documentation 🚧
Option<ReflectReference>No Documentation 🚧
Option<ScriptValue>No Documentation 🚧
Option<SubCameraView>No Documentation 🚧
Option<Viewport>No Documentation 🚧
Option<TextureAtlas>No Documentation 🚧
Option<ReflectSchedule>No Documentation 🚧
Option<ReflectSystem>No Documentation 🚧
Option<Instant>No Documentation 🚧
Option<WindowTheme>No Documentation 🚧
Option<bool>No Documentation 🚧
Option<char>No Documentation 🚧
Option<NonZeroI16>No Documentation 🚧
Option<NonZeroU16>No Documentation 🚧
Option<NonZeroU32>No Documentation 🚧
Option<f32>No Documentation 🚧
Option<f64>No Documentation 🚧
Option<DVec2>No Documentation 🚧
Option<Vec2>No Documentation 🚧
Option<Vec3>No Documentation 🚧
Option<NodeIndex>No Documentation 🚧
Option<u16>No Documentation 🚧
Option<u32>No Documentation 🚧
Option<usize>No Documentation 🚧
SmallVec<Unknown>No Documentation 🚧
SmallVec<Unknown>No Documentation 🚧
SmallVec<Unknown>No Documentation 🚧
SmallVec<Unknown>No Documentation 🚧
Vec<Unknown>No Documentation 🚧
Vec<Range>No Documentation 🚧
HashSet<GamepadButton>No Documentation 🚧
Option<Unknown>No Documentation 🚧
Option<Unknown>No Documentation 🚧
Option<Cow>No Documentation 🚧
Option<Vec<String>>No Documentation 🚧
Option<Handle<Image>>No Documentation 🚧
Option<Handle<Mesh>>No Documentation 🚧
Result<Unknown, InteropError>No Documentation 🚧
Result<String, InteropError>No Documentation 🚧
Result<Entity, InteropError>No Documentation 🚧
Result<DynamicFunctionMut, InteropError>No Documentation 🚧
Result<ScriptComponentRegistration, ScriptResourceRegistration>No Documentation 🚧
Result<ScriptComponentRegistration, InteropError>No Documentation 🚧
Result<ScriptQueryBuilder, InteropError>No Documentation 🚧
Result<ReflectReference, InteropError>No Documentation 🚧
Result<ScriptSystemBuilder, InteropError>No Documentation 🚧
Result<ScriptValue, InteropError>No Documentation 🚧
Result<ReflectSystem, InteropError>No Documentation 🚧
Result<bool, InteropError>No Documentation 🚧
HashMap<AnimationTargetId, u64>No Documentation 🚧
HashMap<GamepadAxis, AxisSettings>No Documentation 🚧
HashMap<GamepadButton, ButtonAxisSettings>No Documentation 🚧
HashMap<GamepadButton, ButtonSettings>No Documentation 🚧
HashMap<GamepadInput, f32>No Documentation 🚧
HashMap<NodeIndex, ActiveAnimation>No Documentation 🚧
HashMap<NodeIndex, f32>No Documentation 🚧
Result<Vec<Entity>, InteropError>No Documentation 🚧
Result<Vec<ScriptQueryResult>, InteropError>No Documentation 🚧
Result<Vec<FunctionInfo>, InteropError>No Documentation 🚧
Result<Vec<ReflectSystem>, InteropError>No Documentation 🚧
Result<Option<String>, InteropError>No Documentation 🚧
Result<Option<Entity>, InteropError>No Documentation 🚧
Result<Option<ReflectReference>, InteropError>No Documentation 🚧
Result<Option<ScriptValue>, InteropError>No Documentation 🚧
Result<Option<ReflectSchedule>, InteropError>No Documentation 🚧
Result<Option<ReflectSystem>, InteropError>No Documentation 🚧
Result<Option<usize>, InteropError>No Documentation 🚧
DiGraphNo Documentation 🚧
HashMap<String, ScriptValue>No Documentation 🚧
HashMap<AnimationEventTarget, Vec<TimedAnimationEvent>>No Documentation 🚧
HashMap<AssetId<AnimationGraph>, ThreadedAnimationGraph>No Documentation 🚧
HashMap<Entity, Vec<Cascade>>No Documentation 🚧
Result<ScriptTypeRegistration, Result<ScriptComponentRegistration, ScriptResourceRegistration>>No Documentation 🚧
Option<Result<ScriptTypeRegistration, Result<ScriptComponentRegistration, ScriptResourceRegistration>>>No Documentation 🚧
Result<Option<Result<ScriptTypeRegistration, Result<ScriptComponentRegistration, ScriptResourceRegistration>>>, InteropError>No Documentation 🚧

World

Opaque Type. 🔒

Description

The ECS world containing all Components, Resources and Systems. Main point of interaction with a Bevy App.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
add_systemAdds the given system to the world.
despawnDespawns the given entity.
has_resourceChecks if the world has the given resource.
exitQuits the program.
despawn_recursiveDespawns the entity and all its descendants.
remove_componentRemoves the given component from the entity.
push_childrenPushes the given children entities into the provided parent entity.
has_entityChecks if the given entity exists.
get_type_by_nameReturns either a `ScriptComponentRegistration` or `ScriptResourceRegistration` depending on the type...
spawnSpawns a new entity and returns it
add_default_componentAdds the given resource to the world.
get_componentTries to retrieve the given component type on an entity.
get_parentRetrieves the parent of the given entity.
insert_childrenInserts the given children entities into the provided parent entity.
queryCreates a new `ScriptQueryBuilder` which can be used to query the ECS. Returns: * `query`: The new query builder.
remove_resourceRemoves the given resource from the world.
register_new_componentRegisters a new component type with the world. The component will behave like any other native comp...
insert_componentInserts the given component value into the provided entity
get_resourceRetrieves the resource with the given registration.
has_componentChecks if the given entity has the given component.
get_childrenRetrieves the children of the given entity.
despawn_descendantsDespawn the descendants of the given entity.
get_schedule_by_nameRetrieves the schedule with the given name, Also ensures the schedule is initialized before returnin...

add_system

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Adds the given system to the world.

Arguments

NameTypeDocumentation
scheduleReflectScheduleThe schedule to add the system to.
builderScriptSystemBuilderThe system builder specifying the system and its dependencies.

Returns

NameTypeDocumentation
systemReflectSystemThe system that was added.

despawn

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Despawns the given entity.

Arguments

NameTypeDocumentation
entityEntityThe entity to despawn.

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

has_resource

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Checks if the world has the given resource.

Arguments

NameTypeDocumentation
registrationScriptResourceRegistrationThe registration of the resource to check for.

Returns

NameTypeDocumentation
has_resourceboolWhether the world has the resource.

exit

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Quits the program.

Arguments

Returns

NameTypeDocumentation
result()Nothing if the program was exited successfully.

despawn_recursive

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Despawns the entity and all its descendants.

Arguments

NameTypeDocumentation
entityEntityThe entity to despawn recursively.

Returns

NameTypeDocumentation
result()Nothing if the entity and its descendants were despawned successfully.

remove_component

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Removes the given component from the entity.

Arguments

NameTypeDocumentation
entityEntityThe entity to remove the component from.
registrationScriptComponentRegistrationThe component to remove.

Returns

NameTypeDocumentation
result()Nothing if the component was removed successfully or didn't exist in the first place.

push_children

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Pushes the given children entities into the provided parent entity.

Arguments

NameTypeDocumentation
entityEntityThe parent entity to receive children
childrenVec<Entity>The children entities to push

Returns

NameTypeDocumentation
result()Nothing if the children were pushed successfully.

has_entity

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Checks if the given entity exists.

Arguments

NameTypeDocumentation
eEntityNo Documentation 🚧

Returns

NameTypeDocumentation
has_entityboolWhether the entity exists.

get_type_by_name

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Returns either a ScriptComponentRegistration or ScriptResourceRegistration depending on the type of the type requested. If the type is neither returns a ScriptTypeRegistration.

Arguments

NameTypeDocumentation
type_nameStringThe name of the type to retrieve.

Returns

NameTypeDocumentation
typeOptional<ScriptTypeRegistration | ScriptComponentRegistration | ScriptResourceRegistration>The registration of the type, if it exists.

spawn

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Spawns a new entity and returns it

Arguments

Returns

NameTypeDocumentation
entityEntityThe newly spawned entity

add_default_component

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Adds the given resource to the world.

Arguments

NameTypeDocumentation
entityEntityNo Documentation 🚧
registrationScriptComponentRegistrationThe resource to add.

Returns

NameTypeDocumentation
result()Nothing if the resource was added successfully.

get_component

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Tries to retrieve the given component type on an entity.

Arguments

NameTypeDocumentation
entityEntityThe entity to retrieve the component from.
registrationScriptComponentRegistrationThe component to retrieve.

Returns

NameTypeDocumentation
componentOptional<ReflectReference>The component on the entity, if it exists.

get_parent

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Retrieves the parent of the given entity.

Arguments

NameTypeDocumentation
entityEntityThe entity to retrieve the parent of.

Returns

NameTypeDocumentation
parentOptional<Entity>The parent of the entity

insert_children

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Inserts the given children entities into the provided parent entity.

Arguments

NameTypeDocumentation
entityEntityThe parent entity to receive children
indexusizeThe index to insert the children at
childrenVec<Entity>The children entities to insert

Returns

NameTypeDocumentation
result()Nothing if the children were inserted successfully.

query

Creates a new ScriptQueryBuilder which can be used to query the ECS.

Returns:

  • query: The new query builder.

Arguments

Returns

NameTypeDocumentation
arg0ScriptQueryBuilderNo Documentation 🚧

remove_resource

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Removes the given resource from the world.

Arguments

NameTypeDocumentation
registrationScriptResourceRegistrationThe resource to remove.

Returns

NameTypeDocumentation
result()Nothing if the resource was removed successfully or didn't exist in the first place.

register_new_component

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Registers a new component type with the world.

The component will behave like any other native component for all intents and purposes. The type that will be instantiated to back this component will be DynamicComponent which contains just one field:

  • data

This field can be set to any value and modified freely.

Arguments

NameTypeDocumentation
nameStringThe name of the component type

Returns

NameTypeDocumentation
registrationScriptComponentRegistrationThe registration of the new component type if successful.

insert_component

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Inserts the given component value into the provided entity

Arguments

NameTypeDocumentation
entityEntityThe entity to insert the component into.
registrationScriptComponentRegistrationThe component registration of the component to insert.
valueReflectReferenceThe value of the component to insert. Can be constructed using construct

Returns

NameTypeDocumentation
result()Nothing if the component was inserted successfully.

get_resource

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Retrieves the resource with the given registration.

Arguments

NameTypeDocumentation
registrationScriptResourceRegistrationThe registration of the resource to retrieve.

Returns

NameTypeDocumentation
resourceOptional<ReflectReference>The resource, if it exists.

has_component

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Checks if the given entity has the given component.

Arguments

NameTypeDocumentation
entityEntityThe entity to check.
registrationScriptComponentRegistrationThe component to check for.

Returns

NameTypeDocumentation
has_componentboolWhether the entity has the component.

get_children

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Retrieves the children of the given entity.

Arguments

NameTypeDocumentation
entityEntityThe entity to retrieve the children of.

Returns

NameTypeDocumentation
childrenVec<Entity>The children of the entity.

despawn_descendants

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Despawn the descendants of the given entity.

Arguments

NameTypeDocumentation
entityEntityThe entity to despawn the descendants of.

Returns

NameTypeDocumentation
result()Nothing if the descendants were despawned successfully.

get_schedule_by_name

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Retrieves the schedule with the given name, Also ensures the schedule is initialized before returning it.

Schedules in bevy are "containers" for systems, each schedule runs separately and contains different systems.

By default among others bevy contains the following schedules:

  • Update: Runs every frame.
  • PostUpdate: Runs after the Update schedule.
  • FixedUpdate: Runs at a fixed rate.

Arguments

NameTypeDocumentation
nameStringThe name of the schedule to retrieve.

Returns

NameTypeDocumentation
scheduleOptional<ReflectSchedule>The schedule with the given name, if it exists

ReflectReference

Opaque Type. 🔒

Description

A reference to an arbitrary reflected instance.

The reference can point to either the ECS, or to the allocator.

References are composed of two parts:

  • The base kind, which specifies where the reference points to
  • The path, which specifies how to access the value from the base.

Bindings defined on this type, apply to ALL references.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
iterIterates over the reference, if the reference is an appropriate container type. Returns an "next" i...
removeRemoves the value at the specified key from the reference, if the reference is an appropriate contai...
insertInserts the value into the reference at the specified index, if the reference is an appropriate cont...
functionsLists the functions available on the reference.
variant_nameIf this type is an enum, will return the name of the variant it represents on the type.
popPops the value from the reference, if the reference is an appropriate container type.
lenRetrieves the length of the reference, if the reference is an appropriate container type.
display_valueDisplays the "value" of this reference This is useful for debugging and logging.
clearClears the container, if the reference is an appropriate container type.
display_refDisplays this reference without printing the exact contents. This is useful for debugging and loggi...
pushPushes the value into the reference, if the reference is an appropriate container type.
map_getGets and clones the value under the specified key if the underlying type is a map type.

iter

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Iterates over the reference, if the reference is an appropriate container type.

Returns an "next" iterator function.

The iterator function should be called until it returns nil to signal the end of the iteration.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to iterate over.

Returns

NameTypeDocumentation
iterDynamicFunctionMutThe iterator function.

remove

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Removes the value at the specified key from the reference, if the reference is an appropriate container type.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to remove the value from.
keyScriptValueThe key to remove the value at.

Returns

NameTypeDocumentation
resultScriptValueThe removed value if any

insert

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Inserts the value into the reference at the specified index, if the reference is an appropriate container type.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to insert the value into.
keyScriptValueThe index to insert the value at.
valueScriptValueThe value to insert.

Returns

NameTypeDocumentation
result()Nothing if the value was inserted successfully.

functions

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Lists the functions available on the reference.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to list the functions of.

Returns

NameTypeDocumentation
functionsVec<FunctionInfo>The functions available on the reference.

variant_name

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

If this type is an enum, will return the name of the variant it represents on the type.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to get the variant name of.

Returns

NameTypeDocumentation
variant_nameOptional<String>The name of the variant, if the reference is an enum.

pop

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Pops the value from the reference, if the reference is an appropriate container type.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to pop the value from.

Returns

NameTypeDocumentation
valueScriptValueThe value that was popped, if the reference supports popping.

len

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Retrieves the length of the reference, if the reference is an appropriate container type.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to get the length of.

Returns

NameTypeDocumentation
lenOptional<usize>The length of the reference, if the reference is a container.

display_value

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Displays the "value" of this reference

This is useful for debugging and logging.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to display.

Returns

NameTypeDocumentation
displayStringThe display string.

clear

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Clears the container, if the reference is an appropriate container type.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to clear.

Returns

NameTypeDocumentation
result()Nothing if the reference was cleared

display_ref

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Displays this reference without printing the exact contents.

This is useful for debugging and logging.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to display.

Returns

NameTypeDocumentation
displayStringThe display string.

push

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Pushes the value into the reference, if the reference is an appropriate container type.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to push the value into.
valueScriptValueThe value to push.

Returns

NameTypeDocumentation
result()Nothing if the value was pushed successfully.

map_get

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Gets and clones the value under the specified key if the underlying type is a map type.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to index into.
keyScriptValueThe key to index with.

Returns

NameTypeDocumentation
valueOptional<ScriptValue>The value at the key, if the reference is a map.

ScriptComponentRegistration

ScriptComponentRegistration

  • registration:bevy_mod_scripting_core::bindings::query::ScriptTypeRegistration
  • component_id:bevy_ecs::component::ComponentId
  • is_dynamic_script_component:bool

Description

A reference to a component type's reflection registration.

In general think of this as a handle to a type.

Not to be confused with script registered dynamic components, although this can point to a script registered component.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
short_nameRetrieves the short name of the type. The short name is a more human-readable version of the type na...
type_nameRetrieves the name of the type.

short_name

Retrieves the short name of the type. The short name is a more human-readable version of the type name.

Arguments

NameTypeDocumentation
registrationScriptComponentRegistrationThe type registration.

Returns

NameTypeDocumentation
short_namestrThe short name of the

type_name

Retrieves the name of the type.

Arguments

NameTypeDocumentation
registrationScriptComponentRegistrationThe type registration.

Returns

NameTypeDocumentation
type_namestrThe name of the type.

ScriptQueryBuilder

Opaque Type. 🔒

Description

The query builder is used to build ECS queries which retrieve spefific components filtered by specific conditions.

For example:

builder.component(componentA)
    .component(componentB)
    .with(componentC)
    .without(componentD)  

Will retrieve entities which:

  • Have componentA
  • Have componentB
  • Have componentC
  • Do not have componentD

As well as references to components:

  • componentA
  • componentB

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
withoutAdds a component to filter the query by. This component will NOT be retrieved.
withAdds a component to filter the query by. This component will NOT be retrieved.
buildBuilds the query and retrieves the entities and component references.
componentAdds a component to be retrieved by the query

without

Adds a component to filter the query by. This component will NOT be retrieved.

Arguments

NameTypeDocumentation
queryScriptQueryBuilderThe query to add the component to
withoutScriptComponentRegistrationNo Documentation 🚧

Returns

NameTypeDocumentation
queryScriptQueryBuilderThe query with the component added

with

Adds a component to filter the query by. This component will NOT be retrieved.

Arguments

NameTypeDocumentation
queryScriptQueryBuilderThe query to add the component to
withScriptComponentRegistrationNo Documentation 🚧

Returns

NameTypeDocumentation
queryScriptQueryBuilderThe query with the component added

build

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Builds the query and retrieves the entities and component references.

Arguments

NameTypeDocumentation
queryScriptQueryBuilderThe query to build.

Returns

NameTypeDocumentation
resultVec<ScriptQueryResult>The entities and component references that match the query.

component

Adds a component to be retrieved by the query

Arguments

NameTypeDocumentation
queryScriptQueryBuilderThe query to add the component to
componentsScriptComponentRegistrationNo Documentation 🚧

Returns

NameTypeDocumentation
queryScriptQueryBuilderThe query with the component added

ScriptQueryResult

Opaque Type. 🔒

Description

A result from a query.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
entityRetrieves the entity from the query result.
componentsRetrieves the components from the query result. These are ordered by the order they were added to t...

entity

Retrieves the entity from the query result.

Arguments

NameTypeDocumentation
queryScriptQueryResultThe query result to retrieve the entity from.

Returns

NameTypeDocumentation
entityEntityThe entity from the query result.

components

Retrieves the components from the query result.

These are ordered by the order they were added to the query.

Arguments

NameTypeDocumentation
queryScriptQueryResultThe query result to retrieve the components from.

Returns

NameTypeDocumentation
componentsVec<ReflectReference>The components from the query result.

ScriptResourceRegistration

ScriptResourceRegistration

  • registration:bevy_mod_scripting_core::bindings::query::ScriptTypeRegistration
  • resource_id:bevy_ecs::component::ComponentId

Description

A reference to a resource type's reflection registration.

In general think of this as a handle to a type.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
short_nameRetrieves the short name of the type. The short name is a more human-readable version of the type na...
type_nameRetrieves the name of the type.

short_name

Retrieves the short name of the type. The short name is a more human-readable version of the type name.

Arguments

NameTypeDocumentation
registrationScriptResourceRegistrationThe type registration.

Returns

NameTypeDocumentation
short_namestrThe short name of the

type_name

Retrieves the name of the type.

Arguments

NameTypeDocumentation
registrationScriptResourceRegistrationThe type registration.

Returns

NameTypeDocumentation
type_namestrThe name of the type.

ScriptTypeRegistration

Opaque Type. 🔒

Description

A reference to a type which is not a Resource or Component.

In general think of this as a handle to a type.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
short_nameRetrieves the short name of the type. The short name is a more human-readable version of the type na...
type_nameRetrieves the name of the type.

short_name

Retrieves the short name of the type. The short name is a more human-readable version of the type name.

Arguments

NameTypeDocumentation
registrationScriptTypeRegistrationThe type registration.

Returns

NameTypeDocumentation
short_nameStringThe short name of the

type_name

Retrieves the name of the type.

Arguments

NameTypeDocumentation
registrationScriptTypeRegistrationThe type registration.

Returns

NameTypeDocumentation
type_nameStringThe name of the type.

ScriptSystemBuilder

Opaque Type. 🔒

Description

A builder for systems living in scripts

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
afterSpecifies the system is to run *after* the given system Note: this is an experimental feature, and ...
queryAdds a query to the system builder.
resourceRequests the system have access to the given resource. The resource will be added to the list of arg...
beforeSpecifies the system is to run *before* the given system. Note: this is an experimental feature, an...
exclusiveSpecifies the system is to run exclusively, meaning it can access anything, but will not run in para...

after

Specifies the system is to run after the given system

Note: this is an experimental feature, and the ordering might not work correctly for script initialized systems

Arguments

NameTypeDocumentation
builderScriptSystemBuilderThe system builder to add the dependency to.
systemReflectSystemThe system to run after.

Returns

NameTypeDocumentation
builderScriptSystemBuilderThe system builder with the dependency added.

query

Adds a query to the system builder.

Arguments

NameTypeDocumentation
builderScriptSystemBuilderThe system builder to add the query to.
queryScriptQueryBuilderThe query to add.

Returns

NameTypeDocumentation
builderScriptSystemBuilderThe system builder with the query added.

resource

Requests the system have access to the given resource. The resource will be added to the list of arguments of the callback in the order they're provided.

Arguments

NameTypeDocumentation
builderScriptSystemBuilderThe system builder to add the resource to.
resourceScriptResourceRegistrationThe resource to add.

Returns

NameTypeDocumentation
builderScriptSystemBuilderThe system builder with the resource added.

before

Specifies the system is to run before the given system.

Note: this is an experimental feature, and the ordering might not work correctly for script initialized systems

Arguments

NameTypeDocumentation
builderScriptSystemBuilderThe system builder to add the dependency to.
systemReflectSystemThe system to run before.

Returns

NameTypeDocumentation
builderScriptSystemBuilderThe system builder with the dependency added.

exclusive

Specifies the system is to run exclusively, meaning it can access anything, but will not run in parallel with other systems.

Arguments

NameTypeDocumentation
builderScriptSystemBuilderThe system builder to make exclusive.

Returns

NameTypeDocumentation
builderScriptSystemBuilderThe system builder that is now exclusive.

ReflectSchedule

ReflectSchedule

  • type_path:str
  • label:bevy_system_reflection::ReflectableScheduleLabel

Description

A reflectable schedule.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
get_system_by_nameRetrieves the system with the given name in the schedule
systemsRetrieves all the systems in the schedule.
render_dotRenders the schedule as a dot graph string. Useful for debugging scheduling.

get_system_by_name

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Retrieves the system with the given name in the schedule

Arguments

NameTypeDocumentation
scheduleReflectScheduleThe schedule to retrieve the system from.
nameStringThe identifier or full path of the system to retrieve.

Returns

NameTypeDocumentation
systemOptional<ReflectSystem>The system with the given name, if it exists.

systems

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Retrieves all the systems in the schedule.

Arguments

NameTypeDocumentation
scheduleReflectScheduleThe schedule to retrieve the systems from.

Returns

NameTypeDocumentation
systemsVec<ReflectSystem>The systems in the schedule.

render_dot

This function is impure, it might potentially try to access anything in the world. If you are using it in the context of a script system, it might cause access errors.

Renders the schedule as a dot graph string.

Useful for debugging scheduling.

Arguments

NameTypeDocumentation
scheduleReflectScheduleThe schedule to render.

Returns

NameTypeDocumentation
dotStringThe dot graph string.

ReflectSystem

Opaque Type. 🔒

Description

A reflectable system.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
pathRetrieves the full path of the system
identifierRetrieves the identifier of the system

path

Retrieves the full path of the system

Arguments

NameTypeDocumentation
systemReflectSystemThe system to retrieve the path from.

Returns

NameTypeDocumentation
pathStringThe full path of the system, e.g. my_crate::systems::my_system<T>

identifier

Retrieves the identifier of the system

Arguments

NameTypeDocumentation
systemReflectSystemThe system to retrieve the identifier from.

Returns

NameTypeDocumentation
identifierStringThe identifier of the system, e.g. my_system

Name

Name

  • hash:u64
  • name:alloc::borrow::Cow

Description

Component used to identify an entity. Stores a hash for faster comparisons.

The hash is eagerly re-computed upon each update to the name.

[Name] should not be treated as a globally unique identifier for entities, as multiple entities can have the same name. [Entity] should be used instead as the default unique identifier.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqNo Documentation 🚧
cloneNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfNameNo Documentation 🚧
otherNameNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfNameNo Documentation 🚧

Returns

NameTypeDocumentation
arg0NameNo Documentation 🚧

ComponentId

ComponentId

  1. usize

Description

A value which uniquely identifies the type of a [Component] or [Resource] within a [World].

Each time a new Component type is registered within a World using e.g. [World::register_component] or [World::register_component_with_descriptor] or a Resource with e.g. [World::init_resource], a corresponding ComponentId is created to track it.

While the distinction between ComponentId and [TypeId] may seem superficial, breaking them into two separate but related concepts allows components to exist outside of Rust's type system. Each Rust type registered as a Component will have a corresponding ComponentId, but additional ComponentIds may exist in a World to track components which cannot be represented as Rust types for scripting or other advanced use-cases.

A ComponentId is tightly coupled to its parent World. Attempting to use a ComponentId from one World to access the metadata of a Component in a different World is undefined behavior and must not be attempted.

Given a type T which implements [Component], the ComponentId for T can be retrieved from a World using [World::component_id()] or via [Components::component_id()]. Access to the ComponentId for a [Resource] is available via [Components::resource_id()].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
indexReturns the index of the current component.
eqNo Documentation 🚧
newCreates a new [`ComponentId`]. The `index` is a unique value associated with each type of component in a given world. Usually, this value is taken from a counter incremented for each type of component registered with the world.
assert_receiver_is_total_eqNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfComponentIdNo Documentation 🚧

Returns

NameTypeDocumentation
arg0ComponentIdNo Documentation 🚧

index

Returns the index of the current component.

Arguments

NameTypeDocumentation
_selfComponentIdNo Documentation 🚧

Returns

NameTypeDocumentation
arg0usizeNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfComponentIdNo Documentation 🚧
otherComponentIdNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

new

Creates a new [ComponentId]. The index is a unique value associated with each type of component in a given world. Usually, this value is taken from a counter incremented for each type of component registered with the world.

Arguments

NameTypeDocumentation
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0ComponentIdNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfComponentIdNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

ComponentTicks

ComponentTicks

  • added:bevy_ecs::component::Tick
  • changed:bevy_ecs::component::Tick

Description

Records when a component or resource was added and when it was last mutably dereferenced (or added).

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
is_changedReturns `true` if the component or resource was added or mutably dereferenced after the system last...
is_addedReturns `true` if the component or resource was added after the system last ran (or the system is ...
set_changedManually sets the change tick. This is normally done automatically via the [`DerefMut`](std::ops::DerefMut) implementation on [`Mut`](crate::change_detection::Mut)...
newCreates a new instance with the same change tick for `added` and `changed`.

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfComponentTicksNo Documentation 🚧

Returns

NameTypeDocumentation
arg0ComponentTicksNo Documentation 🚧

is_changed

Returns true if the component or resource was added or mutably dereferenced after the system last ran (or the system is running for the first time).

Arguments

NameTypeDocumentation
_selfComponentTicksNo Documentation 🚧
last_runTickNo Documentation 🚧
this_runTickNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_added

Returns true if the component or resource was added after the system last ran (or the system is running for the first time).

Arguments

NameTypeDocumentation
_selfComponentTicksNo Documentation 🚧
last_runTickNo Documentation 🚧
this_runTickNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

set_changed

Manually sets the change tick. This is normally done automatically via the DerefMut implementation on Mut<T>, ResMut<T>, etc. However, components and resources that make use of interior mutability might require manual updates.

Example

# use bevy_ecs::{world::World, component::ComponentTicks};
let world: World = unimplemented!();
let component_ticks: ComponentTicks = unimplemented!();
component_ticks.set_changed(world.read_change_tick());

Arguments

NameTypeDocumentation
_selfComponentTicksNo Documentation 🚧
change_tickTickNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

new

Creates a new instance with the same change tick for added and changed.

Arguments

NameTypeDocumentation
change_tickTickNo Documentation 🚧

Returns

NameTypeDocumentation
arg0ComponentTicksNo Documentation 🚧

Tick

Tick

  • tick:u32

Description

A value that tracks when a system ran relative to other systems. This is used to power change detection.

Note that a system that hasn't been run yet has a Tick of 0.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
getGets the value of this change tick.
assert_receiver_is_total_eqNo Documentation 🚧
cloneNo Documentation 🚧
newCreates a new [`Tick`] wrapping the given value.
is_newer_thanReturns `true` if this `Tick` occurred since the system's `last_run`. `this_run` is the current ti...
setSets the value of this change tick.
eqNo Documentation 🚧

get

Gets the value of this change tick.

Arguments

NameTypeDocumentation
_selfTickNo Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTickNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTickNo Documentation 🚧

Returns

NameTypeDocumentation
arg0TickNo Documentation 🚧

new

Creates a new [Tick] wrapping the given value.

Arguments

NameTypeDocumentation
ticku32No Documentation 🚧

Returns

NameTypeDocumentation
arg0TickNo Documentation 🚧

is_newer_than

Returns true if this Tick occurred since the system's last_run. this_run is the current tick of the system, used as a reference to help deal with wraparound.

Arguments

NameTypeDocumentation
_selfTickNo Documentation 🚧
last_runTickNo Documentation 🚧
this_runTickNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

set

Sets the value of this change tick.

Arguments

NameTypeDocumentation
_selfTickNo Documentation 🚧
ticku32No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTickNo Documentation 🚧
otherTickNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

Entity

Opaque Type. 🔒

Description

Lightweight identifier of an entity.

The identifier is implemented using a generational index: a combination of an index and a generation. This allows fast insertion after data removal in an array while minimizing loss of spatial locality.

These identifiers are only valid on the World it's sourced from. Attempting to use an Entity to fetch entity components or metadata from a different world will either fail or return unexpected results.

Stability warning

For all intents and purposes, Entity should be treated as an opaque identifier. The internal bit representation is liable to change from release to release as are the behaviors or performance characteristics of any of its trait implementations (i.e. Ord, Hash, etc.). This means that changes in Entity's representation, though made readable through various functions on the type, are not considered breaking changes under SemVer.

In particular, directly serializing with Serialize and Deserialize make zero guarantee of long term wire format compatibility. Changes in behavior will cause serialized Entity values persisted to long term storage (i.e. disk, databases, etc.) will fail to deserialize upon being updated.

Usage

This data type is returned by iterating a Query that has Entity as part of its query fetch type parameter (learn more). It can also be obtained by calling EntityCommands::id or EntityWorldMut::id.

# use bevy_ecs::prelude::*;
# #[derive(Component)]
# struct SomeComponent;
fn setup(mut commands: Commands) {
    // Calling `spawn` returns `EntityCommands`.
    let entity = commands.spawn(SomeComponent).id();
}

fn exclusive_system(world: &mut World) {
    // Calling `spawn` returns `EntityWorldMut`.
    let entity = world.spawn(SomeComponent).id();
}
#
# bevy_ecs::system::assert_is_system(setup);
# bevy_ecs::system::assert_is_system(exclusive_system);

It can be used to refer to a specific entity to apply EntityCommands, or to call Query::get (or similar methods) to access its components.

# use bevy_ecs::prelude::*;
#
# #[derive(Component)]
# struct Expired;
#
fn dispose_expired_food(mut commands: Commands, query: Query<Entity, With<Expired>>) {
    for food_entity in &query {
        commands.entity(food_entity).despawn();
    }
}
#
# bevy_ecs::system::assert_is_system(dispose_expired_food);

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
to_bitsConvert to a form convenient for passing outside of rust. Only useful for identifying entities wit...
from_bitsReconstruct an `Entity` previously destructured with [`Entity::to_bits`]. Only useful when applied to results from `to_bits` in the same instance of an application. # Panics This method will likely panic if given `u64` values that did not come from [`Entity::to_bits`]...
eqNo Documentation 🚧
cloneNo Documentation 🚧
generationReturns the generation of this Entity's index. The generation is incremented each time an entity w...
indexReturn a transiently unique identifier. No two simultaneously-live entities share the same index, ...
from_rawCreates a new entity ID with the specified `index` and a generation of 1. # Note Spawning a speci...

to_bits

Convert to a form convenient for passing outside of rust. Only useful for identifying entities within the same instance of an application. Do not use for serialization between runs. No particular structure is guaranteed for the returned bits.

Arguments

NameTypeDocumentation
_selfEntityNo Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

from_bits

Reconstruct an Entity previously destructured with [Entity::to_bits]. Only useful when applied to results from to_bits in the same instance of an application.

Panics

This method will likely panic if given u64 values that did not come from [Entity::to_bits].

Arguments

NameTypeDocumentation
bitsu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0EntityNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfEntityNo Documentation 🚧
otherEntityNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfEntityNo Documentation 🚧

Returns

NameTypeDocumentation
arg0EntityNo Documentation 🚧

generation

Returns the generation of this Entity's index. The generation is incremented each time an entity with a given index is despawned. This serves as a "count" of the number of times a given index has been reused (index, generation) pairs uniquely identify a given Entity.

Arguments

NameTypeDocumentation
_selfEntityNo Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

index

Return a transiently unique identifier. No two simultaneously-live entities share the same index, but dead entities' indices may collide with both live and dead entities. Useful for compactly representing entities within a specific snapshot of the world, such as when serializing.

Arguments

NameTypeDocumentation
_selfEntityNo Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

from_raw

Creates a new entity ID with the specified index and a generation of 1.

Note

Spawning a specific entity value is rarely the right choice. Most apps should favor Commands::spawn. This method should generally only be used for sharing entities across apps, and only when they have a scheme worked out to share an index space (which doesn't happen by default). In general, one should not try to synchronize the ECS by attempting to ensure that Entity lines up between instances, but instead insert a secondary identifier as a component.

Arguments

NameTypeDocumentation
indexu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0EntityNo Documentation 🚧

EntityHash

EntityHash

Description

A [BuildHasher] that results in a [EntityHasher].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfEntityHashNo Documentation 🚧

Returns

NameTypeDocumentation
arg0EntityHashNo Documentation 🚧

Identifier

Opaque Type. 🔒

Description

A unified identifier for all entity and similar IDs.

Has the same size as a u64 integer, but the layout is split between a 32-bit low segment, a 31-bit high segment, and the significant bit reserved as type flags to denote entity kinds.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_bitsConvert a `u64` into an [`Identifier`]. # Panics This method will likely panic if given `u64` values that did not come from [`Identifier::to_bits`]...
eqNo Documentation 🚧
masked_highReturns the masked value of the high segment of the [`Identifier`]. Does not include the flag bits.
cloneNo Documentation 🚧
lowReturns the value of the low segment of the [`Identifier`].
to_bitsConvert the [`Identifier`] into a `u64`.

from_bits

Convert a u64 into an [Identifier].

Panics

This method will likely panic if given u64 values that did not come from [Identifier::to_bits].

Arguments

NameTypeDocumentation
valueu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0IdentifierNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIdentifierNo Documentation 🚧
otherIdentifierNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

masked_high

Returns the masked value of the high segment of the [Identifier]. Does not include the flag bits.

Arguments

NameTypeDocumentation
_selfIdentifierNo Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIdentifierNo Documentation 🚧

Returns

NameTypeDocumentation
arg0IdentifierNo Documentation 🚧

low

Returns the value of the low segment of the [Identifier].

Arguments

NameTypeDocumentation
_selfIdentifierNo Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

to_bits

Convert the [Identifier] into a u64.

Arguments

NameTypeDocumentation
_selfIdentifierNo Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

RemovedComponentEntity

RemovedComponentEntity

  1. bevy_ecs::entity::Entity

Description

Wrapper around [Entity] for [RemovedComponents]. Internally, RemovedComponents uses these as an Events<RemovedComponentEntity>.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRemovedComponentEntityNo Documentation 🚧

Returns

NameTypeDocumentation
arg0RemovedComponentEntityNo Documentation 🚧

Children

Children

  1. smallvec::SmallVec<[bevy_ecs::entity::Entity; 8]>

Description

Contains references to the child entities of this entity.

Each child must contain a Parent component that points back to this entity. This component rarely needs to be created manually, consider using higher level utilities like BuildChildren::with_children which are safer and easier to use.

See HierarchyQueryExt for hierarchy related methods on Query.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
swapSwaps the child at `a_index` with the child at `b_index`.

swap

Swaps the child at a_index with the child at b_index.

Arguments

NameTypeDocumentation
_selfChildrenNo Documentation 🚧
a_indexusizeNo Documentation 🚧
b_indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

Parent

Parent

  1. bevy_ecs::entity::Entity

Description

Holds a reference to the parent entity of this entity. This component should only be present on entities that actually have a parent entity.

Parent entity must have this entity stored in its Children component. It is hard to set up parent/child relationships manually, consider using higher level utilities like BuildChildren::with_children.

See HierarchyQueryExt for hierarchy related methods on Query.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
getGets the [`Entity`] ID of the parent.
assert_receiver_is_total_eqNo Documentation 🚧
eqNo Documentation 🚧

get

Gets the [Entity] ID of the parent.

Arguments

NameTypeDocumentation
_selfParentNo Documentation 🚧

Returns

NameTypeDocumentation
arg0EntityNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfParentNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfParentNo Documentation 🚧
otherParentNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

HierarchyEvent

ChildAdded

  • child:bevy_ecs::entity::Entity
  • parent:bevy_ecs::entity::Entity

ChildRemoved

  • child:bevy_ecs::entity::Entity
  • parent:bevy_ecs::entity::Entity

ChildMoved

  • child:bevy_ecs::entity::Entity
  • previous_parent:bevy_ecs::entity::Entity
  • new_parent:bevy_ecs::entity::Entity

Description

An Event that is fired whenever there is a change in the world's hierarchy.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
assert_receiver_is_total_eqNo Documentation 🚧
eqNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfHierarchyEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0HierarchyEventNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfHierarchyEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfHierarchyEventNo Documentation 🚧
otherHierarchyEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

ButtonState

Pressed

Released

Description

The current "press" state of an element

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
is_pressedIs this button pressed?
assert_receiver_is_total_eqNo Documentation 🚧
eqNo Documentation 🚧
cloneNo Documentation 🚧

is_pressed

Is this button pressed?

Arguments

NameTypeDocumentation
_selfButtonStateNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfButtonStateNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfButtonStateNo Documentation 🚧
otherButtonStateNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfButtonStateNo Documentation 🚧

Returns

NameTypeDocumentation
arg0ButtonStateNo Documentation 🚧

AxisSettings

AxisSettings

  • livezone_upperbound:f32
  • deadzone_upperbound:f32
  • deadzone_lowerbound:f32
  • livezone_lowerbound:f32
  • threshold:f32

Description

Settings for a [GamepadAxis].

It is used inside the [GamepadSettings] to define the sensitivity range and threshold for an axis. Values that are higher than livezone_upperbound will be rounded up to 1.0. Values that are lower than livezone_lowerbound will be rounded down to -1.0. Values that are in-between deadzone_lowerbound and deadzone_upperbound will be rounded to 0.0. Otherwise, values will not be rounded.

The valid range is [-1.0, 1.0].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
thresholdGet the minimum value by which input must change before the change is registered.
livezone_lowerboundGet the value below which negative inputs will be rounded down to -1.0.
deadzone_lowerboundGet the value above which inputs will be rounded up to 0.0.
set_livezone_lowerboundTry to set the value below which negative inputs will be rounded down to -1.0. If the value passed...
cloneNo Documentation 🚧
set_deadzone_lowerboundTry to set the value above which inputs will be rounded up to 0.0. If the value passed is less tha...
set_thresholdTry to set the minimum value by which input must change before the changes will be applied. If the...
set_livezone_upperboundTry to set the value above which inputs will be rounded up to 1.0. If the value passed is negative...
set_deadzone_upperboundTry to set the value below which positive inputs will be rounded down to 0.0. If the value passed ...
filterFilters the `new_value` based on the `old_value`, according to the [`AxisSettings`]. Returns the clamped `new_value` if the change exceeds the settings threshold, and `None` otherwise.
livezone_upperboundGet the value above which inputs will be rounded up to 1.0.
clampClamps the `raw_value` according to the `AxisSettings`.
eqNo Documentation 🚧
deadzone_upperboundGet the value below which positive inputs will be rounded down to 0.0.

threshold

Get the minimum value by which input must change before the change is registered.

Arguments

NameTypeDocumentation
_selfAxisSettingsNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

livezone_lowerbound

Get the value below which negative inputs will be rounded down to -1.0.

Arguments

NameTypeDocumentation
_selfAxisSettingsNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

deadzone_lowerbound

Get the value above which inputs will be rounded up to 0.0.

Arguments

NameTypeDocumentation
_selfAxisSettingsNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

set_livezone_lowerbound

Try to set the value below which negative inputs will be rounded down to -1.0. If the value passed is positive or greater than deadzone_lowerbound, the value will not be changed. Returns the new value of livezone_lowerbound.

Arguments

NameTypeDocumentation
_selfAxisSettingsNo Documentation 🚧
valuef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAxisSettingsNo Documentation 🚧

Returns

NameTypeDocumentation
arg0AxisSettingsNo Documentation 🚧

set_deadzone_lowerbound

Try to set the value above which inputs will be rounded up to 0.0. If the value passed is less than -1.0 or less than livezone_lowerbound, the value will not be changed. Returns the new value of deadzone_lowerbound.

Arguments

NameTypeDocumentation
_selfAxisSettingsNo Documentation 🚧
valuef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

set_threshold

Try to set the minimum value by which input must change before the changes will be applied. If the value passed is not within [0.0..=2.0], the value will not be changed. Returns the new value of threshold.

Arguments

NameTypeDocumentation
_selfAxisSettingsNo Documentation 🚧
valuef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

set_livezone_upperbound

Try to set the value above which inputs will be rounded up to 1.0. If the value passed is negative or less than deadzone_upperbound, the value will not be changed. Returns the new value of livezone_upperbound.

Arguments

NameTypeDocumentation
_selfAxisSettingsNo Documentation 🚧
valuef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

set_deadzone_upperbound

Try to set the value below which positive inputs will be rounded down to 0.0. If the value passed is negative or greater than livezone_upperbound, the value will not be changed. Returns the new value of deadzone_upperbound.

Arguments

NameTypeDocumentation
_selfAxisSettingsNo Documentation 🚧
valuef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

filter

Filters the new_value based on the old_value, according to the [AxisSettings]. Returns the clamped new_value if the change exceeds the settings threshold, and None otherwise.

Arguments

NameTypeDocumentation
_selfAxisSettingsNo Documentation 🚧
new_valuef32No Documentation 🚧
old_valueOptional<f32>No Documentation 🚧

Returns

NameTypeDocumentation
arg0Optional<f32>No Documentation 🚧

livezone_upperbound

Get the value above which inputs will be rounded up to 1.0.

Arguments

NameTypeDocumentation
_selfAxisSettingsNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

clamp

Clamps the raw_value according to the AxisSettings.

Arguments

NameTypeDocumentation
_selfAxisSettingsNo Documentation 🚧
new_valuef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAxisSettingsNo Documentation 🚧
otherAxisSettingsNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

deadzone_upperbound

Get the value below which positive inputs will be rounded down to 0.0.

Arguments

NameTypeDocumentation
_selfAxisSettingsNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

ButtonAxisSettings

ButtonAxisSettings

  • high:f32
  • low:f32
  • threshold:f32

Description

Settings for a [GamepadButton].

It is used inside the [GamepadSettings] to define the sensitivity range and threshold for a button axis.

Logic

  • Values that are higher than or equal to high will be rounded to 1.0.
  • Values that are lower than or equal to low will be rounded to 0.0.
  • Otherwise, values will not be rounded.

The valid range is from 0.0 to 1.0, inclusive.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
filterFilters the `new_value` based on the `old_value`, according to the [`ButtonAxisSettings`]. Returns the clamped `new_value`, according to the [`ButtonAxisSettings`]...

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfButtonAxisSettingsNo Documentation 🚧

Returns

NameTypeDocumentation
arg0ButtonAxisSettingsNo Documentation 🚧

filter

Filters the new_value based on the old_value, according to the [ButtonAxisSettings]. Returns the clamped new_value, according to the [ButtonAxisSettings], if the change exceeds the settings threshold, and None otherwise.

Arguments

NameTypeDocumentation
_selfButtonAxisSettingsNo Documentation 🚧
new_valuef32No Documentation 🚧
old_valueOptional<f32>No Documentation 🚧

Returns

NameTypeDocumentation
arg0Optional<f32>No Documentation 🚧

ButtonSettings

ButtonSettings

  • press_threshold:f32
  • release_threshold:f32

Description

Manages settings for gamepad buttons.

It is used inside [GamepadSettings] to define the threshold for a [GamepadButton] to be considered pressed or released. A button is considered pressed if the press_threshold value is surpassed and released if the release_threshold value is undercut.

Allowed values: 0.0 <= ``release_threshold`` <= ``press_threshold`` <= 1.0

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
press_thresholdGet the button input threshold above which the button is considered pressed.
eqNo Documentation 🚧
is_releasedReturns `true` if the button is released. A button is considered released if the `value` passed is...
is_pressedReturns `true` if the button is pressed. A button is considered pressed if the `value` passed is g...
release_thresholdGet the button input threshold below which the button is considered released.
set_press_thresholdTry to set the button input threshold above which the button is considered pressed. If the value p...
set_release_thresholdTry to set the button input threshold below which the button is considered released. If the value ...

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfButtonSettingsNo Documentation 🚧

Returns

NameTypeDocumentation
arg0ButtonSettingsNo Documentation 🚧

press_threshold

Get the button input threshold above which the button is considered pressed.

Arguments

NameTypeDocumentation
_selfButtonSettingsNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfButtonSettingsNo Documentation 🚧
otherButtonSettingsNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_released

Returns true if the button is released. A button is considered released if the value passed is lower than or equal to the release threshold.

Arguments

NameTypeDocumentation
_selfButtonSettingsNo Documentation 🚧
valuef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_pressed

Returns true if the button is pressed. A button is considered pressed if the value passed is greater than or equal to the press threshold.

Arguments

NameTypeDocumentation
_selfButtonSettingsNo Documentation 🚧
valuef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

release_threshold

Get the button input threshold below which the button is considered released.

Arguments

NameTypeDocumentation
_selfButtonSettingsNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

set_press_threshold

Try to set the button input threshold above which the button is considered pressed. If the value passed is outside the range [release threshold..=1.0], the value will not be changed. Returns the new value of the press threshold.

Arguments

NameTypeDocumentation
_selfButtonSettingsNo Documentation 🚧
valuef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

set_release_threshold

Try to set the button input threshold below which the button is considered released. If the value passed is outside the range [0.0..=press threshold], the value will not be changed. Returns the new value of the release threshold.

Arguments

NameTypeDocumentation
_selfButtonSettingsNo Documentation 🚧
valuef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

Gamepad

Gamepad

  • vendor_id:core::option::Option
  • product_id:core::option::Option
  • digital:bevy_input::button_input::ButtonInput<bevy_input::gamepad::GamepadButton>
  • analog:bevy_input::axis::Axis<bevy_input::gamepad::GamepadInput>

Description

Stores a connected gamepad's metadata such as the name and its [GamepadButton] and [GamepadAxis].

An entity with this component is spawned automatically after [GamepadConnectionEvent] and updated by [gamepad_event_processing_system].

See also [GamepadSettings] for configuration.

Examples

# use bevy_input::gamepad::{Gamepad, GamepadAxis, GamepadButton};
# use bevy_ecs::system::Query;
# use bevy_core::Name;
#
fn gamepad_usage_system(gamepads: Query<(&Name, &Gamepad)>) {
    for (name, gamepad) in &gamepads {
        println!("{name}");

        if gamepad.just_pressed(GamepadButton::North) {
            println!("{} just pressed North", name)
        }

        if let Some(left_stick_x) = gamepad.get(GamepadAxis::LeftStickX)  {
            println!("left stick X: {}", left_stick_x)
        }
    }
}

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
product_idReturns the USB product ID as assigned by the [vendor], if available. [vendor]: Self::vendor_id
just_pressedReturns `true` if the [`GamepadButton`] has been pressed during the current frame. Note: This function does not imply information regarding the current state of [`ButtonInput::pressed`]...
just_releasedReturns `true` if the [`GamepadButton`] has been released during the current frame. Note: This function does not imply information regarding the current state of [`ButtonInput::pressed`]...
dpadReturns the directional pad as a [`Vec2`]
right_stickReturns the right stick as a [`Vec2`]
pressedReturns `true` if the [`GamepadButton`] has been pressed.
left_stickReturns the left stick as a [`Vec2`]
vendor_idReturns the USB vendor ID as assigned by the USB-IF, if available.

product_id

Returns the USB product ID as assigned by the [vendor], if available. [vendor]: Self::vendor_id

Arguments

NameTypeDocumentation
_selfGamepadNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Optional<u16>No Documentation 🚧

just_pressed

Returns true if the [GamepadButton] has been pressed during the current frame. Note: This function does not imply information regarding the current state of [ButtonInput::pressed] or [ButtonInput::just_released].

Arguments

NameTypeDocumentation
_selfGamepadNo Documentation 🚧
button_typeGamepadButtonNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

just_released

Returns true if the [GamepadButton] has been released during the current frame. Note: This function does not imply information regarding the current state of [ButtonInput::pressed] or [ButtonInput::just_pressed].

Arguments

NameTypeDocumentation
_selfGamepadNo Documentation 🚧
button_typeGamepadButtonNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

dpad

Returns the directional pad as a [Vec2]

Arguments

NameTypeDocumentation
_selfGamepadNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

right_stick

Returns the right stick as a [Vec2]

Arguments

NameTypeDocumentation
_selfGamepadNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

pressed

Returns true if the [GamepadButton] has been pressed.

Arguments

NameTypeDocumentation
_selfGamepadNo Documentation 🚧
button_typeGamepadButtonNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

left_stick

Returns the left stick as a [Vec2]

Arguments

NameTypeDocumentation
_selfGamepadNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

vendor_id

Returns the USB vendor ID as assigned by the USB-IF, if available.

Arguments

NameTypeDocumentation
_selfGamepadNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Optional<u16>No Documentation 🚧

GamepadAxis

LeftStickX

LeftStickY

LeftZ

RightStickX

RightStickY

RightZ

Other

  1. u8

Description

Represents gamepad input types that are mapped in the range [-1.0, 1.0]

Usage

This is used to determine which axis has changed its value when receiving a gamepad axis event. It is also used in the [Gamepad] component.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
assert_receiver_is_total_eqNo Documentation 🚧
eqNo Documentation 🚧
cloneNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadAxisNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadAxisNo Documentation 🚧
otherGamepadAxisNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadAxisNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GamepadAxisNo Documentation 🚧

GamepadAxisChangedEvent

GamepadAxisChangedEvent

  • entity:bevy_ecs::entity::Entity
  • axis:bevy_input::gamepad::GamepadAxis
  • value:f32

Description

[GamepadAxis] event triggered by an analog state change

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
eqNo Documentation 🚧
newCreates a new [`GamepadAxisChangedEvent`]

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadAxisChangedEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GamepadAxisChangedEventNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadAxisChangedEventNo Documentation 🚧
otherGamepadAxisChangedEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

new

Creates a new [GamepadAxisChangedEvent]

Arguments

NameTypeDocumentation
entityEntityNo Documentation 🚧
axisGamepadAxisNo Documentation 🚧
valuef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0GamepadAxisChangedEventNo Documentation 🚧

GamepadButton

South

East

North

West

C

Z

LeftTrigger

LeftTrigger2

RightTrigger

RightTrigger2

Select

Start

Mode

LeftThumb

RightThumb

DPadUp

DPadDown

DPadLeft

DPadRight

Other

  1. u8

Description

Represents gamepad input types that are mapped in the range [0.0, 1.0].

Usage

This is used to determine which button has changed its value when receiving gamepad button events It is also used in the [Gamepad] component.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
assert_receiver_is_total_eqNo Documentation 🚧
eqNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadButtonNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GamepadButtonNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadButtonNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadButtonNo Documentation 🚧
otherGamepadButtonNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

GamepadButtonChangedEvent

GamepadButtonChangedEvent

  • entity:bevy_ecs::entity::Entity
  • button:bevy_input::gamepad::GamepadButton
  • state:bevy_input::ButtonState
  • value:f32

Description

[GamepadButton] event triggered by an analog state change

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
eqNo Documentation 🚧
newCreates a new [`GamepadButtonChangedEvent`]

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadButtonChangedEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GamepadButtonChangedEventNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadButtonChangedEventNo Documentation 🚧
otherGamepadButtonChangedEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

new

Creates a new [GamepadButtonChangedEvent]

Arguments

NameTypeDocumentation
entityEntityNo Documentation 🚧
buttonGamepadButtonNo Documentation 🚧
stateButtonStateNo Documentation 🚧
valuef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0GamepadButtonChangedEventNo Documentation 🚧

GamepadButtonStateChangedEvent

GamepadButtonStateChangedEvent

  • entity:bevy_ecs::entity::Entity
  • button:bevy_input::gamepad::GamepadButton
  • state:bevy_input::ButtonState

Description

[GamepadButton] event triggered by a digital state change

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newCreates a new [`GamepadButtonStateChangedEvent`]
eqNo Documentation 🚧
cloneNo Documentation 🚧
assert_receiver_is_total_eqNo Documentation 🚧

new

Creates a new [GamepadButtonStateChangedEvent]

Arguments

NameTypeDocumentation
entityEntityNo Documentation 🚧
buttonGamepadButtonNo Documentation 🚧
stateButtonStateNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GamepadButtonStateChangedEventNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadButtonStateChangedEventNo Documentation 🚧
otherGamepadButtonStateChangedEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadButtonStateChangedEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GamepadButtonStateChangedEventNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadButtonStateChangedEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

GamepadConnection

Connected

  • name:String
  • vendor_id:core::option::Option
  • product_id:core::option::Option

Disconnected

Description

The connection status of a gamepad.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqNo Documentation 🚧
cloneNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadConnectionNo Documentation 🚧
otherGamepadConnectionNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadConnectionNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GamepadConnectionNo Documentation 🚧

GamepadConnectionEvent

GamepadConnectionEvent

  • gamepad:bevy_ecs::entity::Entity
  • connection:bevy_input::gamepad::GamepadConnection

Description

A Gamepad connection event. Created when a connection to a gamepad is established and when a gamepad is disconnected.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqNo Documentation 🚧
connectedIs the gamepad connected?
newCreates a [`GamepadConnectionEvent`].
disconnectedIs the gamepad disconnected?
cloneNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadConnectionEventNo Documentation 🚧
otherGamepadConnectionEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

connected

Is the gamepad connected?

Arguments

NameTypeDocumentation
_selfGamepadConnectionEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

new

Creates a [GamepadConnectionEvent].

Arguments

NameTypeDocumentation
gamepadEntityNo Documentation 🚧
connectionGamepadConnectionNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GamepadConnectionEventNo Documentation 🚧

disconnected

Is the gamepad disconnected?

Arguments

NameTypeDocumentation
_selfGamepadConnectionEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadConnectionEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GamepadConnectionEventNo Documentation 🚧

GamepadEvent

Connection

  1. bevy_input::gamepad::GamepadConnectionEvent

Button

  1. bevy_input::gamepad::GamepadButtonChangedEvent

Axis

  1. bevy_input::gamepad::GamepadAxisChangedEvent

Description

A gamepad event.

This event type is used over the [GamepadConnectionEvent], [GamepadButtonChangedEvent] and [GamepadAxisChangedEvent] when the in-frame relative ordering of events is important.

This event is produced by bevy_input

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqNo Documentation 🚧
cloneNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadEventNo Documentation 🚧
otherGamepadEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GamepadEventNo Documentation 🚧

GamepadInput

Axis

  1. bevy_input::gamepad::GamepadAxis

Button

  1. bevy_input::gamepad::GamepadButton

Description

Encapsulation over [GamepadAxis] and [GamepadButton]

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
assert_receiver_is_total_eqNo Documentation 🚧
eqNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadInputNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GamepadInputNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadInputNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadInputNo Documentation 🚧
otherGamepadInputNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

GamepadRumbleIntensity

GamepadRumbleIntensity

  • strong_motor:f32
  • weak_motor:f32

Description

The intensity at which a gamepad's force-feedback motors may rumble.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
weak_motorCreates a new rumble intensity with weak motor intensity set to the given value. Clamped within th...
strong_motorCreates a new rumble intensity with strong motor intensity set to the given value. Clamped within ...
eqNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadRumbleIntensityNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GamepadRumbleIntensityNo Documentation 🚧

weak_motor

Creates a new rumble intensity with weak motor intensity set to the given value. Clamped within the 0.0 to 1.0 range.

Arguments

NameTypeDocumentation
intensityf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0GamepadRumbleIntensityNo Documentation 🚧

strong_motor

Creates a new rumble intensity with strong motor intensity set to the given value. Clamped within the 0.0 to 1.0 range.

Arguments

NameTypeDocumentation
intensityf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0GamepadRumbleIntensityNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadRumbleIntensityNo Documentation 🚧
otherGamepadRumbleIntensityNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

GamepadRumbleRequest

Add

  • duration:bevy_utils::Duration
  • intensity:bevy_input::gamepad::GamepadRumbleIntensity
  • gamepad:bevy_ecs::entity::Entity

Stop

  • gamepad:bevy_ecs::entity::Entity

Description

An event that controls force-feedback rumbling of a [Gamepad] entity.

Notes

Does nothing if the gamepad or platform does not support rumble.

Example

# use bevy_input::gamepad::{Gamepad, GamepadRumbleRequest, GamepadRumbleIntensity};
# use bevy_ecs::prelude::{EventWriter, Res, Query, Entity, With};
# use bevy_utils::Duration;
fn rumble_gamepad_system(
    mut rumble_requests: EventWriter<GamepadRumbleRequest>,
    gamepads: Query<Entity, With<Gamepad>>,
) {
    for entity in gamepads.iter() {
        rumble_requests.send(GamepadRumbleRequest::Add {
            gamepad: entity,
            intensity: GamepadRumbleIntensity::MAX,
            duration: Duration::from_secs_f32(0.5),
        });
    }
}

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
gamepadGet the [`Entity`] associated with this request.

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadRumbleRequestNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GamepadRumbleRequestNo Documentation 🚧

gamepad

Get the [Entity] associated with this request.

Arguments

NameTypeDocumentation
_selfGamepadRumbleRequestNo Documentation 🚧

Returns

NameTypeDocumentation
arg0EntityNo Documentation 🚧

GamepadSettings

GamepadSettings

  • default_button_settings:bevy_input::gamepad::ButtonSettings
  • default_axis_settings:bevy_input::gamepad::AxisSettings
  • default_button_axis_settings:bevy_input::gamepad::ButtonAxisSettings
  • button_settings:bevy_utils::hashbrown::HashMap<bevy_input::gamepad::GamepadButton, bevy_input::gamepad::ButtonSettings, bevy_utils::hashbrown::hash_map::DefaultHashBuilder>
  • axis_settings:bevy_utils::hashbrown::HashMap<bevy_input::gamepad::GamepadAxis, bevy_input::gamepad::AxisSettings, bevy_utils::hashbrown::hash_map::DefaultHashBuilder>
  • button_axis_settings:bevy_utils::hashbrown::HashMap<bevy_input::gamepad::GamepadButton, bevy_input::gamepad::ButtonAxisSettings, bevy_utils::hashbrown::hash_map::DefaultHashBuilder>

Description

Gamepad settings component.

Usage

It is used to create a bevy component that stores the settings of [GamepadButton] and [GamepadAxis] in [Gamepad]. If no user defined [ButtonSettings], [AxisSettings], or [ButtonAxisSettings] are defined, the default settings of each are used as a fallback accordingly.

Note

The [GamepadSettings] are used to determine when raw gamepad events should register. Events that don't meet the change thresholds defined in [GamepadSettings] will not register. To modify these settings, mutate the corresponding component.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGamepadSettingsNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GamepadSettingsNo Documentation 🚧

RawGamepadAxisChangedEvent

RawGamepadAxisChangedEvent

  • gamepad:bevy_ecs::entity::Entity
  • axis:bevy_input::gamepad::GamepadAxis
  • value:f32

Description

[GamepadAxis] changed event unfiltered by [GamepadSettings]

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqNo Documentation 🚧
cloneNo Documentation 🚧
newCreates a [`RawGamepadAxisChangedEvent`].

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRawGamepadAxisChangedEventNo Documentation 🚧
otherRawGamepadAxisChangedEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRawGamepadAxisChangedEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0RawGamepadAxisChangedEventNo Documentation 🚧

new

Creates a [RawGamepadAxisChangedEvent].

Arguments

NameTypeDocumentation
gamepadEntityNo Documentation 🚧
axis_typeGamepadAxisNo Documentation 🚧
valuef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0RawGamepadAxisChangedEventNo Documentation 🚧

RawGamepadButtonChangedEvent

RawGamepadButtonChangedEvent

  • gamepad:bevy_ecs::entity::Entity
  • button:bevy_input::gamepad::GamepadButton
  • value:f32

Description

[GamepadButton] changed event unfiltered by [GamepadSettings]

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newCreates a [`RawGamepadButtonChangedEvent`].
eqNo Documentation 🚧
cloneNo Documentation 🚧

new

Creates a [RawGamepadButtonChangedEvent].

Arguments

NameTypeDocumentation
gamepadEntityNo Documentation 🚧
button_typeGamepadButtonNo Documentation 🚧
valuef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0RawGamepadButtonChangedEventNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRawGamepadButtonChangedEventNo Documentation 🚧
otherRawGamepadButtonChangedEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRawGamepadButtonChangedEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0RawGamepadButtonChangedEventNo Documentation 🚧

RawGamepadEvent

Connection

  1. bevy_input::gamepad::GamepadConnectionEvent

Button

  1. bevy_input::gamepad::RawGamepadButtonChangedEvent

Axis

  1. bevy_input::gamepad::RawGamepadAxisChangedEvent

Description

A raw gamepad event.

This event type is used over the [GamepadConnectionEvent], [RawGamepadButtonChangedEvent] and [RawGamepadAxisChangedEvent] when the in-frame relative ordering of events is important.

This event type is used by bevy_input to feed its components.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
eqNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRawGamepadEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0RawGamepadEventNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRawGamepadEventNo Documentation 🚧
otherRawGamepadEventNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

DoubleTapGesture

DoubleTapGesture

Description

Double tap gesture.

Platform-specific

  • Only available on macOS and iOS.
  • On iOS, must be enabled first

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqNo Documentation 🚧
cloneNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDoubleTapGestureNo Documentation 🚧
otherDoubleTapGestureNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDoubleTapGestureNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DoubleTapGestureNo Documentation 🚧

PanGesture

PanGesture

  1. glam::Vec2

Description

Pan gesture.

Platform-specific

  • On iOS, must be enabled first

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqNo Documentation 🚧
cloneNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfPanGestureNo Documentation 🚧
otherPanGestureNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfPanGestureNo Documentation 🚧

Returns

NameTypeDocumentation
arg0PanGestureNo Documentation 🚧

PinchGesture

PinchGesture

  1. f32

Description

Two-finger pinch gesture, often used for magnifications.

Positive delta values indicate magnification (zooming in) and negative delta values indicate shrinking (zooming out).

Platform-specific

  • Only available on macOS and iOS.
  • On iOS, must be enabled first

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqNo Documentation 🚧
cloneNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfPinchGestureNo Documentation 🚧
otherPinchGestureNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfPinchGestureNo Documentation 🚧

Returns

NameTypeDocumentation
arg0PinchGestureNo Documentation 🚧

RotationGesture

RotationGesture

  1. f32

Description

Two-finger rotation gesture.

Positive delta values indicate rotation counterclockwise and negative delta values indicate rotation clockwise.

Platform-specific

  • Only available on macOS and iOS.
  • On iOS, must be enabled first

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
eqNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRotationGestureNo Documentation 🚧

Returns

NameTypeDocumentation
arg0RotationGestureNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRotationGestureNo Documentation 🚧
otherRotationGestureNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

Key

Character

  1. smol_str::SmolStr

Unidentified

  1. bevy_input::keyboard::NativeKey

Dead

  1. core::option::Option

Alt

AltGraph

CapsLock

Control

Fn

FnLock

NumLock

ScrollLock

Shift

Symbol

SymbolLock

Meta

Hyper

Super

Enter

Tab

Space

ArrowDown

ArrowLeft

ArrowRight

ArrowUp

End

Home

PageDown

PageUp

Backspace

Clear

Copy

CrSel

Cut

Delete

EraseEof

ExSel

Insert

Paste

Redo

Undo

Accept

Again

Attn

Cancel

ContextMenu

Escape

Execute

Find

Help

Pause

Play

Props

Select

ZoomIn

ZoomOut

BrightnessDown

BrightnessUp

Eject

LogOff

Power

PowerOff

PrintScreen

Hibernate

Standby

WakeUp

AllCandidates

Alphanumeric

CodeInput

Compose

Convert

FinalMode

GroupFirst

GroupLast

GroupNext

GroupPrevious

ModeChange

NextCandidate

NonConvert

PreviousCandidate

Process

SingleCandidate

HangulMode

HanjaMode

JunjaMode

Eisu

Hankaku

Hiragana

HiraganaKatakana

KanaMode

KanjiMode

Katakana

Romaji

Zenkaku

ZenkakuHankaku

Soft1

Soft2

Soft3

Soft4

ChannelDown

ChannelUp

Close

MailForward

MailReply

MailSend

MediaClose

MediaFastForward

MediaPause

MediaPlay

MediaPlayPause

MediaRecord

MediaRewind

MediaStop

MediaTrackNext

MediaTrackPrevious

New

Open

Print

Save

SpellCheck

Key11

Key12

AudioBalanceLeft

AudioBalanceRight

AudioBassBoostDown

AudioBassBoostToggle

AudioBassBoostUp

AudioFaderFront

AudioFaderRear

AudioSurroundModeNext

AudioTrebleDown

AudioTrebleUp

AudioVolumeDown

AudioVolumeUp

AudioVolumeMute

MicrophoneToggle

MicrophoneVolumeDown

MicrophoneVolumeUp

MicrophoneVolumeMute

SpeechCorrectionList

SpeechInputToggle

LaunchApplication1

LaunchApplication2

LaunchCalendar

LaunchContacts

LaunchMail

LaunchMediaPlayer

LaunchMusicPlayer

LaunchPhone

LaunchScreenSaver

LaunchSpreadsheet

LaunchWebBrowser

LaunchWebCam

LaunchWordProcessor

BrowserBack

BrowserFavorites

BrowserForward

BrowserHome

BrowserRefresh

BrowserSearch

BrowserStop

AppSwitch

Call

Camera

CameraFocus

EndCall

GoBack

GoHome

HeadsetHook

LastNumberRedial

Notification

MannerMode

VoiceDial

TV

TV3DMode

TVAntennaCable

TVAudioDescription

TVAudioDescriptionMixDown

TVAudioDescriptionMixUp

TVContentsMenu

TVDataService

TVInput

TVInputComponent1

TVInputComponent2

TVInputComposite1

TVInputComposite2

TVInputHDMI1

TVInputHDMI2

TVInputHDMI3

TVInputHDMI4

TVInputVGA1

TVMediaContext

TVNetwork

TVNumberEntry

TVPower

TVRadioService

TVSatellite

TVSatelliteBS

TVSatelliteCS

TVSatelliteToggle

TVTerrestrialAnalog

TVTerrestrialDigital

TVTimer

AVRInput

AVRPower

ColorF0Red

ColorF1Green

ColorF2Yellow

ColorF3Blue

ColorF4Grey

ColorF5Brown

ClosedCaptionToggle

Dimmer

DisplaySwap

DVR

Exit

FavoriteClear0

FavoriteClear1

FavoriteClear2

FavoriteClear3

FavoriteRecall0

FavoriteRecall1

FavoriteRecall2

FavoriteRecall3

FavoriteStore0

FavoriteStore1

FavoriteStore2

FavoriteStore3

Guide

GuideNextDay

GuidePreviousDay

Info

InstantReplay

ListProgram

LiveContent

Lock

MediaApps

MediaAudioTrack

MediaLast

MediaSkipBackward

MediaSkipForward

MediaStepBackward

MediaStepForward

MediaTopMenu

NextFavoriteChannel

NextUserProfile

OnDemand

Pairing

PinPDown

PinPMove

PinPToggle

PinPUp

PlaySpeedDown

PlaySpeedReset

PlaySpeedUp

RandomToggle

RcLowBattery

RecordSpeedNext

RfBypass

ScanChannelsToggle

ScreenModeNext

Settings

SplitScreenToggle

STBInput

STBPower

Subtitle

Teletext

VideoModeNext

Wink

ZoomToggle

F1

F2

F3

F4

F5

F6

F7

F8

F9

F10

F11

F12

F13

F14

F15

F16

F17

F18

F19

F20

F21

F22

F23

F24

F25

F26

F27

F28

F29

F30

F31

F32

F33

F34

F35

Description

The logical key code of a [KeyboardInput].

Technical

Its values map 1 to 1 to winit's Key.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
assert_receiver_is_total_eqNo Documentation 🚧
eqNo Documentation 🚧
cloneNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfKeyNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfKeyNo Documentation 🚧
otherKeyNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfKeyNo Documentation 🚧

Returns

NameTypeDocumentation
arg0KeyNo Documentation 🚧

KeyCode

Unidentified

  1. bevy_input::keyboard::NativeKeyCode

Backquote

Backslash

BracketLeft

BracketRight

Comma

Digit0

Digit1

Digit2

Digit3

Digit4

Digit5

Digit6

Digit7

Digit8

Digit9

Equal

IntlBackslash

IntlRo

IntlYen

KeyA

KeyB

KeyC

KeyD

KeyE

KeyF

KeyG

KeyH

KeyI

KeyJ

KeyK

KeyL

KeyM

KeyN

KeyO

KeyP

KeyQ

KeyR

KeyS

KeyT

KeyU

KeyV

KeyW

KeyX

KeyY

KeyZ

Minus

Period

Quote

Semicolon

Slash

AltLeft

AltRight

Backspace

CapsLock

ContextMenu

ControlLeft

ControlRight

Enter

SuperLeft

SuperRight

ShiftLeft

ShiftRight

Space

Tab

Convert

KanaMode

Lang1

Lang2

Lang3

Lang4

Lang5

NonConvert

Delete

End

Help

Home

Insert

PageDown

PageUp

ArrowDown

ArrowLeft

ArrowRight

ArrowUp

NumLock

Numpad0

Numpad1

Numpad2

Numpad3

Numpad4

Numpad5

Numpad6

Numpad7

Numpad8

Numpad9

NumpadAdd

NumpadBackspace

NumpadClear

NumpadClearEntry

NumpadComma

NumpadDecimal

NumpadDivide

NumpadEnter

NumpadEqual

NumpadHash

NumpadMemoryAdd

NumpadMemoryClear

NumpadMemoryRecall

NumpadMemoryStore

NumpadMemorySubtract

NumpadMultiply

NumpadParenLeft

NumpadParenRight

NumpadStar

NumpadSubtract

Escape

Fn

FnLock

PrintScreen

ScrollLock

Pause

BrowserBack

BrowserFavorites

BrowserForward

BrowserHome

BrowserRefresh

BrowserSearch

BrowserStop

Eject

LaunchApp1

LaunchApp2

LaunchMail

MediaPlayPause

MediaSelect

MediaStop

MediaTrackNext

MediaTrackPrevious

Power

Sleep

AudioVolumeDown

AudioVolumeMute

AudioVolumeUp

WakeUp

Meta

Hyper

Turbo

Abort

Resume

Suspend

Again

Copy

Cut

Find

Open

Paste

Props

Select

Undo

Hiragana

Katakana

F1

F2

F3

F4

F5

F6

F7

F8

F9

F10

F11

F12

F13

F14

F15

F16

F17

F18

F19

F20

F21

F22

F23

F24

F25

F26

F27

F28

F29

F30

F31

F32

F33

F34

F35

Description

The key code of a [KeyboardInput].

Usage

It is used as the generic T value of an [ButtonInput] to create a Res<ButtonInput<KeyCode>>.

Code representing the location of a physical key This mostly conforms to the UI Events Specification's KeyboardEvent.code with a few exceptions:

  • The keys that the specification calls MetaLeft and MetaRight are named SuperLeft and SuperRight here.
  • The key that the specification calls "Super" is reported as Unidentified here.

Updating

The resource is updated inside of the [keyboard_input_system].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqNo Documentation 🚧
cloneNo Documentation 🚧
assert_receiver_is_total_eqNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfKeyCodeNo Documentation 🚧
otherKeyCodeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfKeyCodeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0KeyCodeNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfKeyCodeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

KeyboardFocusLost

KeyboardFocusLost

Description

Gets generated from bevy_winit::winit_runner

Used for clearing all cached states to avoid having 'stuck' key presses when, for example, switching between windows with 'Alt-Tab' or using any other OS specific key combination that leads to Bevy window losing focus and not receiving any input events

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
assert_receiver_is_total_eqNo Documentation 🚧
eqNo Documentation 🚧
cloneNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfKeyboardFocusLostNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfKeyboardFocusLostNo Documentation 🚧
otherKeyboardFocusLostNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfKeyboardFocusLostNo Documentation 🚧

Returns

NameTypeDocumentation
arg0KeyboardFocusLostNo Documentation 🚧

KeyboardInput

KeyboardInput

  • key_code:bevy_input::keyboard::KeyCode
  • logical_key:bevy_input::keyboard::Key
  • state:bevy_input::ButtonState
  • repeat:bool
  • window:bevy_ecs::entity::Entity

Description

A keyboard input event.

This event is the translated version of the WindowEvent::KeyboardInput from the winit crate. It is available to the end user and can be used for game logic.

Usage

The event is consumed inside of the [keyboard_input_system] to update the ButtonInput<KeyCode> resource.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
assert_receiver_is_total_eqNo Documentation 🚧
eqNo Documentation 🚧
cloneNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfKeyboardInputNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfKeyboardInputNo Documentation 🚧
otherKeyboardInputNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfKeyboardInputNo Documentation 🚧

Returns

NameTypeDocumentation
arg0KeyboardInputNo Documentation 🚧

NativeKey

Unidentified

Android

  1. u32

MacOS

  1. u16

Windows

  1. u16

Xkb

  1. u32

Web

  1. smol_str::SmolStr

Description

Contains the platform-native logical key identifier, known as keysym.

Exactly what that means differs from platform to platform, but the values are to some degree tied to the currently active keyboard layout. The same key on the same keyboard may also report different values on different platforms, which is one of the reasons this is a per-platform enum.

This enum is primarily used to store raw keysym when Winit doesn't map a given native logical key identifier to a meaningful [Key] variant. This lets you use [Key], and let the user define keybinds which work in the presence of identifiers we haven't mapped for you yet.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
eqNo Documentation 🚧
assert_receiver_is_total_eqNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfNativeKeyNo Documentation 🚧

Returns

NameTypeDocumentation
arg0NativeKeyNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfNativeKeyNo Documentation 🚧
otherNativeKeyNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfNativeKeyNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

NativeKeyCode

Unidentified

Android

  1. u32

MacOS

  1. u16

Windows

  1. u16

Xkb

  1. u32

Description

Contains the platform-native physical key identifier

The exact values vary from platform to platform (which is part of why this is a per-platform enum), but the values are primarily tied to the key's physical location on the keyboard.

This enum is primarily used to store raw keycodes when Winit doesn't map a given native physical key identifier to a meaningful [KeyCode] variant. In the presence of identifiers we haven't mapped for you yet, this lets you use [KeyCode] to:

  • Correctly match key press and release events.
  • On non-web platforms, support assigning keybinds to virtually any key through a UI.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
assert_receiver_is_total_eqNo Documentation 🚧
eqNo Documentation 🚧
cloneNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfNativeKeyCodeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfNativeKeyCodeNo Documentation 🚧
otherNativeKeyCodeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfNativeKeyCodeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0NativeKeyCodeNo Documentation 🚧

AccumulatedMouseMotion

AccumulatedMouseMotion

  • delta:glam::Vec2

Description

Tracks how much the mouse has moved every frame.

This resource is reset to zero every frame.

This resource sums the total [MouseMotion] events received this frame.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqNo Documentation 🚧
cloneNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAccumulatedMouseMotionNo Documentation 🚧
otherAccumulatedMouseMotionNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAccumulatedMouseMotionNo Documentation 🚧

Returns

NameTypeDocumentation
arg0AccumulatedMouseMotionNo Documentation 🚧

AccumulatedMouseScroll

AccumulatedMouseScroll

  • unit:bevy_input::mouse::MouseScrollUnit
  • delta:glam::Vec2

Description

Tracks how much the mouse has scrolled every frame.

This resource is reset to zero every frame.

This resource sums the total [MouseWheel] events received this frame.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
eqNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAccumulatedMouseScrollNo Documentation 🚧

Returns

NameTypeDocumentation
arg0AccumulatedMouseScrollNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAccumulatedMouseScrollNo Documentation 🚧
otherAccumulatedMouseScrollNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

MouseButton

Left

Middle

Back

Forward

Other

  1. u16

Description

A button on a mouse device.

Usage

It is used as the generic T value of an [ButtonInput] to create a bevy resource.

Updating

The resource is updated inside of the [mouse_button_input_system].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
assert_receiver_is_total_eqNo Documentation 🚧
eqNo Documentation 🚧
cloneNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMouseButtonNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMouseButtonNo Documentation 🚧
otherMouseButtonNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMouseButtonNo Documentation 🚧

Returns

NameTypeDocumentation
arg0MouseButtonNo Documentation 🚧

MouseButtonInput

MouseButtonInput

  • button:bevy_input::mouse::MouseButton
  • state:bevy_input::ButtonState
  • window:bevy_ecs::entity::Entity

Description

A mouse button input event.

This event is the translated version of the WindowEvent::MouseInput from the winit crate.

Usage

The event is read inside of the [mouse_button_input_system] to update the [ButtonInput<MouseButton>] resource.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqNo Documentation 🚧
cloneNo Documentation 🚧
assert_receiver_is_total_eqNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMouseButtonInputNo Documentation 🚧
otherMouseButtonInputNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMouseButtonInputNo Documentation 🚧

Returns

NameTypeDocumentation
arg0MouseButtonInputNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMouseButtonInputNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

MouseMotion

MouseMotion

  • delta:glam::Vec2

Description

An event reporting the change in physical position of a pointing device.

This represents raw, unfiltered physical motion. It is the translated version of DeviceEvent::MouseMotion from the winit crate.

All pointing devices connected to a single machine at the same time can emit the event independently. However, the event data does not make it possible to distinguish which device it is referring to.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
eqNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMouseMotionNo Documentation 🚧

Returns

NameTypeDocumentation
arg0MouseMotionNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMouseMotionNo Documentation 🚧
otherMouseMotionNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

MouseScrollUnit

Line

Pixel

Description

The scroll unit.

Describes how a value of a [MouseWheel] event has to be interpreted.

The value of the event can either be interpreted as the amount of lines or the amount of pixels to scroll.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
assert_receiver_is_total_eqNo Documentation 🚧
eqNo Documentation 🚧
cloneNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMouseScrollUnitNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMouseScrollUnitNo Documentation 🚧
otherMouseScrollUnitNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMouseScrollUnitNo Documentation 🚧

Returns

NameTypeDocumentation
arg0MouseScrollUnitNo Documentation 🚧

MouseWheel

MouseWheel

  • unit:bevy_input::mouse::MouseScrollUnit
  • x:f32
  • y:f32
  • window:bevy_ecs::entity::Entity

Description

A mouse wheel event.

This event is the translated version of the WindowEvent::MouseWheel from the winit crate.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
eqNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMouseWheelNo Documentation 🚧

Returns

NameTypeDocumentation
arg0MouseWheelNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMouseWheelNo Documentation 🚧
otherMouseWheelNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

ForceTouch

Calibrated

  • force:f64
  • max_possible_force:f64
  • altitude_angle:core::option::Option

Normalized

  1. f64

Description

A force description of a [Touch] input.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
eqNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfForceTouchNo Documentation 🚧

Returns

NameTypeDocumentation
arg0ForceTouchNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfForceTouchNo Documentation 🚧
otherForceTouchNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

TouchInput

TouchInput

  • phase:bevy_input::touch::TouchPhase
  • position:glam::Vec2
  • window:bevy_ecs::entity::Entity
  • force:core::option::Option<bevy_input::touch::ForceTouch>
  • id:u64

Description

A touch input event.

Logic

Every time the user touches the screen, a new [TouchPhase::Started] event with an unique identifier for the finger is generated. When the finger is lifted, the [TouchPhase::Ended] event is generated with the same finger id.

After a [TouchPhase::Started] event has been emitted, there may be zero or more [TouchPhase::Moved] events when the finger is moved or the touch pressure changes.

The finger id may be reused by the system after an [TouchPhase::Ended] event. The user should assume that a new [TouchPhase::Started] event received with the same id has nothing to do with the old finger and is a new finger.

A [TouchPhase::Canceled] event is emitted when the system has canceled tracking this touch, such as when the window loses focus, or on iOS if the user moves the device against their face.

Note

This event is the translated version of the WindowEvent::Touch from the winit crate. It is available to the end user and can be used for game logic.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqNo Documentation 🚧
cloneNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTouchInputNo Documentation 🚧
otherTouchInputNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTouchInputNo Documentation 🚧

Returns

NameTypeDocumentation
arg0TouchInputNo Documentation 🚧

TouchPhase

Started

Moved

Ended

Canceled

Description

A phase of a [TouchInput].

Usage

It is used to describe the phase of the touch input that is currently active. This includes a phase that indicates that a touch input has started or ended, or that a finger has moved. There is also a canceled phase that indicates that the system canceled the tracking of the finger.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqNo Documentation 🚧
cloneNo Documentation 🚧
assert_receiver_is_total_eqNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTouchPhaseNo Documentation 🚧
otherTouchPhaseNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTouchPhaseNo Documentation 🚧

Returns

NameTypeDocumentation
arg0TouchPhaseNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTouchPhaseNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

AspectRatio

AspectRatio

  1. f32

Description

An AspectRatio is the ratio of width to height.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
ratioReturns the aspect ratio as a f32 value.
eqNo Documentation 🚧
is_squareReturns true if the aspect ratio is exactly square.
inverseReturns the inverse of this aspect ratio (height/width).
is_landscapeReturns true if the aspect ratio represents a landscape orientation.
is_portraitReturns true if the aspect ratio represents a portrait orientation.

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAspectRatioNo Documentation 🚧

Returns

NameTypeDocumentation
arg0AspectRatioNo Documentation 🚧

ratio

Returns the aspect ratio as a f32 value.

Arguments

NameTypeDocumentation
_selfAspectRatioNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAspectRatioNo Documentation 🚧
otherAspectRatioNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_square

Returns true if the aspect ratio is exactly square.

Arguments

NameTypeDocumentation
_selfAspectRatioNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

inverse

Returns the inverse of this aspect ratio (height/width).

Arguments

NameTypeDocumentation
_selfAspectRatioNo Documentation 🚧

Returns

NameTypeDocumentation
arg0AspectRatioNo Documentation 🚧

is_landscape

Returns true if the aspect ratio represents a landscape orientation.

Arguments

NameTypeDocumentation
_selfAspectRatioNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_portrait

Returns true if the aspect ratio represents a portrait orientation.

Arguments

NameTypeDocumentation
_selfAspectRatioNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

Aabb2d

Aabb2d

  • min:glam::Vec2
  • max:glam::Vec2

Description

A 2D axis-aligned bounding box, or bounding rectangle

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
closest_pointFinds the point on the AABB that is closest to the given `point`. If the point is outside the AABB...
newConstructs an AABB from its center and half-size.
bounding_circleComputes the smallest [`BoundingCircle`] containing this [`Aabb2d`].

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAabb2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Aabb2dNo Documentation 🚧

closest_point

Finds the point on the AABB that is closest to the given point. If the point is outside the AABB, the returned point will be on the perimeter of the AABB. Otherwise, it will be inside the AABB and returned as is.

Arguments

NameTypeDocumentation
_selfAabb2dNo Documentation 🚧
pointVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

new

Constructs an AABB from its center and half-size.

Arguments

NameTypeDocumentation
centerVec2No Documentation 🚧
half_sizeVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Aabb2dNo Documentation 🚧

bounding_circle

Computes the smallest [BoundingCircle] containing this [Aabb2d].

Arguments

NameTypeDocumentation
_selfAabb2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0BoundingCircleNo Documentation 🚧

BoundingCircle

BoundingCircle

  • center:glam::Vec2
  • circle:bevy_math::primitives::dim2::Circle

Description

A bounding circle

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
closest_pointFinds the point on the bounding circle that is closest to the given `point`. If the point is outsi...
newConstructs a bounding circle from its center and radius.
cloneNo Documentation 🚧
aabb_2dComputes the smallest [`Aabb2d`] containing this [`BoundingCircle`].
radiusGet the radius of the bounding circle

closest_point

Finds the point on the bounding circle that is closest to the given point. If the point is outside the circle, the returned point will be on the perimeter of the circle. Otherwise, it will be inside the circle and returned as is.

Arguments

NameTypeDocumentation
_selfBoundingCircleNo Documentation 🚧
pointVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

new

Constructs a bounding circle from its center and radius.

Arguments

NameTypeDocumentation
centerVec2No Documentation 🚧
radiusf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0BoundingCircleNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfBoundingCircleNo Documentation 🚧

Returns

NameTypeDocumentation
arg0BoundingCircleNo Documentation 🚧

aabb_2d

Computes the smallest [Aabb2d] containing this [BoundingCircle].

Arguments

NameTypeDocumentation
_selfBoundingCircleNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Aabb2dNo Documentation 🚧

radius

Get the radius of the bounding circle

Arguments

NameTypeDocumentation
_selfBoundingCircleNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

Aabb3d

Aabb3d

  • min:glam::Vec3A
  • max:glam::Vec3A

Description

A 3D axis-aligned bounding box

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
bounding_sphereComputes the smallest [`BoundingSphere`] containing this [`Aabb3d`].
cloneNo Documentation 🚧

bounding_sphere

Computes the smallest [BoundingSphere] containing this [Aabb3d].

Arguments

NameTypeDocumentation
_selfAabb3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0BoundingSphereNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAabb3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Aabb3dNo Documentation 🚧

BoundingSphere

BoundingSphere

  • center:glam::Vec3A
  • sphere:bevy_math::primitives::dim3::Sphere

Description

A bounding sphere

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
radiusGet the radius of the bounding sphere
aabb_3dComputes the smallest [`Aabb3d`] containing this [`BoundingSphere`].

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfBoundingSphereNo Documentation 🚧

Returns

NameTypeDocumentation
arg0BoundingSphereNo Documentation 🚧

radius

Get the radius of the bounding sphere

Arguments

NameTypeDocumentation
_selfBoundingSphereNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

aabb_3d

Computes the smallest [Aabb3d] containing this [BoundingSphere].

Arguments

NameTypeDocumentation
_selfBoundingSphereNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Aabb3dNo Documentation 🚧

AabbCast2d

AabbCast2d

  • ray:bevy_math::bounding::raycast2d::RayCast2d
  • aabb:bevy_math::bounding::bounded2d::Aabb2d

Description

An intersection test that casts an [Aabb2d] along a ray.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
aabb_collision_atGet the distance at which the [`Aabb2d`]s collide, if at all.
from_rayConstruct an [`AabbCast2d`] from an [`Aabb2d`], [`Ray2d`], and max distance.
newConstruct an [`AabbCast2d`] from an [`Aabb2d`], origin, [`Dir2`], and max distance.
cloneNo Documentation 🚧

aabb_collision_at

Get the distance at which the [Aabb2d]s collide, if at all.

Arguments

NameTypeDocumentation
_selfAabbCast2dNo Documentation 🚧
aabbAabb2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Optional<f32>No Documentation 🚧

from_ray

Construct an [AabbCast2d] from an [Aabb2d], [Ray2d], and max distance.

Arguments

NameTypeDocumentation
aabbAabb2dNo Documentation 🚧
rayRay2dNo Documentation 🚧
maxf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0AabbCast2dNo Documentation 🚧

new

Construct an [AabbCast2d] from an [Aabb2d], origin, [Dir2], and max distance.

Arguments

NameTypeDocumentation
aabbAabb2dNo Documentation 🚧
originVec2No Documentation 🚧
directionDir2No Documentation 🚧
maxf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0AabbCast2dNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAabbCast2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0AabbCast2dNo Documentation 🚧

BoundingCircleCast

BoundingCircleCast

  • ray:bevy_math::bounding::raycast2d::RayCast2d
  • circle:bevy_math::bounding::bounded2d::BoundingCircle

Description

An intersection test that casts a [BoundingCircle] along a ray.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstruct a [`BoundingCircleCast`] from a [`BoundingCircle`], origin, [`Dir2`], and max distance.
circle_collision_atGet the distance at which the [`BoundingCircle`]s collide, if at all.
cloneNo Documentation 🚧
from_rayConstruct a [`BoundingCircleCast`] from a [`BoundingCircle`], [`Ray2d`], and max distance.

new

Construct a [BoundingCircleCast] from a [BoundingCircle], origin, [Dir2], and max distance.

Arguments

NameTypeDocumentation
circleBoundingCircleNo Documentation 🚧
originVec2No Documentation 🚧
directionDir2No Documentation 🚧
maxf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0BoundingCircleCastNo Documentation 🚧

circle_collision_at

Get the distance at which the [BoundingCircle]s collide, if at all.

Arguments

NameTypeDocumentation
_selfBoundingCircleCastNo Documentation 🚧
circleBoundingCircleNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Optional<f32>No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfBoundingCircleCastNo Documentation 🚧

Returns

NameTypeDocumentation
arg0BoundingCircleCastNo Documentation 🚧

from_ray

Construct a [BoundingCircleCast] from a [BoundingCircle], [Ray2d], and max distance.

Arguments

NameTypeDocumentation
circleBoundingCircleNo Documentation 🚧
rayRay2dNo Documentation 🚧
maxf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0BoundingCircleCastNo Documentation 🚧

RayCast2d

RayCast2d

  • ray:bevy_math::ray::Ray2d
  • max:f32
  • direction_recip:glam::Vec2

Description

A raycast intersection test for 2D bounding volumes

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
aabb_intersection_atGet the distance of an intersection with an [`Aabb2d`], if any.
cloneNo Documentation 🚧
direction_recipGet the cached multiplicative inverse of the direction of the ray.
newConstruct a [`RayCast2d`] from an origin, [`Dir2`], and max distance.
from_rayConstruct a [`RayCast2d`] from a [`Ray2d`] and max distance.
circle_intersection_atGet the distance of an intersection with a [`BoundingCircle`], if any.

aabb_intersection_at

Get the distance of an intersection with an [Aabb2d], if any.

Arguments

NameTypeDocumentation
_selfRayCast2dNo Documentation 🚧
aabbAabb2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Optional<f32>No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRayCast2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0RayCast2dNo Documentation 🚧

direction_recip

Get the cached multiplicative inverse of the direction of the ray.

Arguments

NameTypeDocumentation
_selfRayCast2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

new

Construct a [RayCast2d] from an origin, [Dir2], and max distance.

Arguments

NameTypeDocumentation
originVec2No Documentation 🚧
directionDir2No Documentation 🚧
maxf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0RayCast2dNo Documentation 🚧

from_ray

Construct a [RayCast2d] from a [Ray2d] and max distance.

Arguments

NameTypeDocumentation
rayRay2dNo Documentation 🚧
maxf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0RayCast2dNo Documentation 🚧

circle_intersection_at

Get the distance of an intersection with a [BoundingCircle], if any.

Arguments

NameTypeDocumentation
_selfRayCast2dNo Documentation 🚧
circleBoundingCircleNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Optional<f32>No Documentation 🚧

AabbCast3d

AabbCast3d

  • ray:bevy_math::bounding::raycast3d::RayCast3d
  • aabb:bevy_math::bounding::bounded3d::Aabb3d

Description

An intersection test that casts an [Aabb3d] along a ray.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
from_rayConstruct an [`AabbCast3d`] from an [`Aabb3d`], [`Ray3d`], and max distance.
aabb_collision_atGet the distance at which the [`Aabb3d`]s collide, if at all.

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAabbCast3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0AabbCast3dNo Documentation 🚧

from_ray

Construct an [AabbCast3d] from an [Aabb3d], [Ray3d], and max distance.

Arguments

NameTypeDocumentation
aabbAabb3dNo Documentation 🚧
rayRay3dNo Documentation 🚧
maxf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0AabbCast3dNo Documentation 🚧

aabb_collision_at

Get the distance at which the [Aabb3d]s collide, if at all.

Arguments

NameTypeDocumentation
_selfAabbCast3dNo Documentation 🚧
aabbAabb3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Optional<f32>No Documentation 🚧

BoundingSphereCast

BoundingSphereCast

  • ray:bevy_math::bounding::raycast3d::RayCast3d
  • sphere:bevy_math::bounding::bounded3d::BoundingSphere

Description

An intersection test that casts a [BoundingSphere] along a ray.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
sphere_collision_atGet the distance at which the [`BoundingSphere`]s collide, if at all.
cloneNo Documentation 🚧
from_rayConstruct a [`BoundingSphereCast`] from a [`BoundingSphere`], [`Ray3d`], and max distance.

sphere_collision_at

Get the distance at which the [BoundingSphere]s collide, if at all.

Arguments

NameTypeDocumentation
_selfBoundingSphereCastNo Documentation 🚧
sphereBoundingSphereNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Optional<f32>No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfBoundingSphereCastNo Documentation 🚧

Returns

NameTypeDocumentation
arg0BoundingSphereCastNo Documentation 🚧

from_ray

Construct a [BoundingSphereCast] from a [BoundingSphere], [Ray3d], and max distance.

Arguments

NameTypeDocumentation
sphereBoundingSphereNo Documentation 🚧
rayRay3dNo Documentation 🚧
maxf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0BoundingSphereCastNo Documentation 🚧

RayCast3d

RayCast3d

  • origin:glam::Vec3A
  • direction:bevy_math::direction::Dir3A
  • max:f32
  • direction_recip:glam::Vec3A

Description

A raycast intersection test for 3D bounding volumes

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_rayConstruct a [`RayCast3d`] from a [`Ray3d`] and max distance.
cloneNo Documentation 🚧
aabb_intersection_atGet the distance of an intersection with an [`Aabb3d`], if any.
direction_recipGet the cached multiplicative inverse of the direction of the ray.
sphere_intersection_atGet the distance of an intersection with a [`BoundingSphere`], if any.

from_ray

Construct a [RayCast3d] from a [Ray3d] and max distance.

Arguments

NameTypeDocumentation
rayRay3dNo Documentation 🚧
maxf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0RayCast3dNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRayCast3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0RayCast3dNo Documentation 🚧

aabb_intersection_at

Get the distance of an intersection with an [Aabb3d], if any.

Arguments

NameTypeDocumentation
_selfRayCast3dNo Documentation 🚧
aabbAabb3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Optional<f32>No Documentation 🚧

direction_recip

Get the cached multiplicative inverse of the direction of the ray.

Arguments

NameTypeDocumentation
_selfRayCast3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

sphere_intersection_at

Get the distance of an intersection with a [BoundingSphere], if any.

Arguments

NameTypeDocumentation
_selfRayCast3dNo Documentation 🚧
sphereBoundingSphereNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Optional<f32>No Documentation 🚧

CompassOctant

North

NorthEast

East

SouthEast

South

SouthWest

West

NorthWest

Description

A compass enum with 8 directions.

         N (North)
         ▲
    NW   │   NE
       ╲ │ ╱
W (West) ┼─────► E (East)
       ╱ │ ╲
    SW   │   SE
         ▼
         S (South)

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqNo Documentation 🚧
assert_receiver_is_total_eqNo Documentation 🚧
cloneNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCompassOctantNo Documentation 🚧
otherCompassOctantNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCompassOctantNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCompassOctantNo Documentation 🚧

Returns

NameTypeDocumentation
arg0CompassOctantNo Documentation 🚧

CompassQuadrant

North

East

South

West

Description

A compass enum with 4 directions.

         N (North)
         ▲
         │
         │
W (West) ┼─────► E (East)
         │
         │
         ▼
         S (South)

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqNo Documentation 🚧
cloneNo Documentation 🚧
assert_receiver_is_total_eqNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCompassQuadrantNo Documentation 🚧
otherCompassQuadrantNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCompassQuadrantNo Documentation 🚧

Returns

NameTypeDocumentation
arg0CompassQuadrantNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCompassQuadrantNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

EaseFunction

Linear

QuadraticIn

QuadraticOut

QuadraticInOut

CubicIn

CubicOut

CubicInOut

QuarticIn

QuarticOut

QuarticInOut

QuinticIn

QuinticOut

QuinticInOut

SineIn

SineOut

SineInOut

CircularIn

CircularOut

CircularInOut

ExponentialIn

ExponentialOut

ExponentialInOut

ElasticIn

ElasticOut

ElasticInOut

BackIn

BackOut

BackInOut

BounceIn

BounceOut

BounceInOut

Steps

  1. usize

Elastic

  1. f32

Description

Curve functions over the unit interval, commonly used for easing transitions.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
eqNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfEaseFunctionNo Documentation 🚧

Returns

NameTypeDocumentation
arg0EaseFunctionNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfEaseFunctionNo Documentation 🚧
otherEaseFunctionNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

Interval

Interval

  • start:f32
  • end:f32

Description

A nonempty closed interval, possibly unbounded in either direction.

In other words, the interval may stretch all the way to positive or negative infinity, but it will always have some nonempty interior.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
startGet the start of this interval.
has_finite_startReturns `true` if this interval has a finite start.
lengthGet the length of this interval. Note that the result may be infinite (`f32::INFINITY`).
endGet the end of this interval.
is_boundedReturns `true` if this interval is bounded — that is, if both its start and end are finite. Equi...
clampClamp the given `value` to lie within this interval.
eqNo Documentation 🚧
containsReturns `true` if `item` is contained in this interval.
contains_intervalReturns `true` if the other interval is contained in this interval. This is non-strict: each inter...
has_finite_endReturns `true` if this interval has a finite end.
cloneNo Documentation 🚧

start

Get the start of this interval.

Arguments

NameTypeDocumentation
_selfIntervalNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

has_finite_start

Returns true if this interval has a finite start.

Arguments

NameTypeDocumentation
_selfIntervalNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

length

Get the length of this interval. Note that the result may be infinite (f32::INFINITY).

Arguments

NameTypeDocumentation
_selfIntervalNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

end

Get the end of this interval.

Arguments

NameTypeDocumentation
_selfIntervalNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

is_bounded

Returns true if this interval is bounded — that is, if both its start and end are finite. Equivalently, an interval is bounded if its length is finite.

Arguments

NameTypeDocumentation
_selfIntervalNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clamp

Clamp the given value to lie within this interval.

Arguments

NameTypeDocumentation
_selfIntervalNo Documentation 🚧
valuef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIntervalNo Documentation 🚧
otherIntervalNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

contains

Returns true if item is contained in this interval.

Arguments

NameTypeDocumentation
_selfIntervalNo Documentation 🚧
itemf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

contains_interval

Returns true if the other interval is contained in this interval. This is non-strict: each interval will contain itself.

Arguments

NameTypeDocumentation
_selfIntervalNo Documentation 🚧
otherIntervalNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

has_finite_end

Returns true if this interval has a finite end.

Arguments

NameTypeDocumentation
_selfIntervalNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIntervalNo Documentation 🚧

Returns

NameTypeDocumentation
arg0IntervalNo Documentation 🚧

Dir2

Dir2

  1. glam::Vec2

Description

A normalized vector pointing in a direction in 2D space

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
rotation_from_yGet the rotation that rotates the Y-axis to this direction.
negNo Documentation 🚧
rotation_to_yGet the rotation that rotates this direction to the Y-axis.
slerpPerforms a spherical linear interpolation between `self` and `rhs` based on the value `s`. This c...
new_uncheckedCreate a [`Dir2`] from a [`Vec2`] that is already normalized. # Warning `value` must be normalize...
fast_renormalizeReturns `self` after an approximate normalization, assuming the value is already nearly normalized....
eqNo Documentation 🚧
rotation_toGet the rotation that rotates this direction to `other`.
mulNo Documentation 🚧
as_vec2Returns the inner [`Vec2`]
rotation_from_xGet the rotation that rotates the X-axis to this direction.
rotation_fromGet the rotation that rotates `other` to this direction.
cloneNo Documentation 🚧
from_xy_uncheckedCreate a direction from its `x` and `y` components, assuming the resulting vector is normalized. #...
rotation_to_xGet the rotation that rotates this direction to the X-axis.

rotation_from_y

Get the rotation that rotates the Y-axis to this direction.

Arguments

NameTypeDocumentation
_selfDir2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Rot2No Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDir2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir2No Documentation 🚧

rotation_to_y

Get the rotation that rotates this direction to the Y-axis.

Arguments

NameTypeDocumentation
_selfDir2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Rot2No Documentation 🚧

slerp

Performs a spherical linear interpolation between self and rhs based on the value s. This corresponds to interpolating between the two directions at a constant angular velocity. When s == 0.0, the result will be equal to self. When s == 1.0, the result will be equal to rhs.

Example

# use bevy_math::Dir2;
# use approx::{assert_relative_eq, RelativeEq};
#
let dir1 = Dir2::X;
let dir2 = Dir2::Y;
let result1 = dir1.slerp(dir2, 1.0 / 3.0);
assert_relative_eq!(result1, Dir2::from_xy(0.75_f32.sqrt(), 0.5).unwrap());
let result2 = dir1.slerp(dir2, 0.5);
assert_relative_eq!(result2, Dir2::from_xy(0.5_f32.sqrt(), 0.5_f32.sqrt()).unwrap());

Arguments

NameTypeDocumentation
_selfDir2No Documentation 🚧
rhsDir2No Documentation 🚧
sf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir2No Documentation 🚧

new_unchecked

Create a [Dir2] from a [Vec2] that is already normalized.

Warning

value must be normalized, i.e its length must be 1.0.

Arguments

NameTypeDocumentation
valueVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir2No Documentation 🚧

fast_renormalize

Returns self after an approximate normalization, assuming the value is already nearly normalized. Useful for preventing numerical error accumulation. See [Dir3::fast_renormalize] for an example of when such error accumulation might occur.

Arguments

NameTypeDocumentation
_selfDir2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir2No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDir2No Documentation 🚧
otherDir2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

rotation_to

Get the rotation that rotates this direction to other.

Arguments

NameTypeDocumentation
_selfDir2No Documentation 🚧
otherDir2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Rot2No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDir2No Documentation 🚧
rhsf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

as_vec2

Returns the inner [Vec2]

Arguments

NameTypeDocumentation
_selfDir2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

rotation_from_x

Get the rotation that rotates the X-axis to this direction.

Arguments

NameTypeDocumentation
_selfDir2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Rot2No Documentation 🚧

rotation_from

Get the rotation that rotates other to this direction.

Arguments

NameTypeDocumentation
_selfDir2No Documentation 🚧
otherDir2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Rot2No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDir2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir2No Documentation 🚧

from_xy_unchecked

Create a direction from its x and y components, assuming the resulting vector is normalized.

Warning

The vector produced from x and y must be normalized, i.e its length must be 1.0.

Arguments

NameTypeDocumentation
xf32No Documentation 🚧
yf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir2No Documentation 🚧

rotation_to_x

Get the rotation that rotates this direction to the X-axis.

Arguments

NameTypeDocumentation
_selfDir2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Rot2No Documentation 🚧

Dir3

Dir3

  1. glam::Vec3

Description

A normalized vector pointing in a direction in 3D space

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqNo Documentation 🚧
fast_renormalizeReturns `self` after an approximate normalization, assuming the value is already nearly normalized....
from_xyz_uncheckedCreate a direction from its `x`, `y`, and `z` components, assuming the resulting vector is normaliz...
negNo Documentation 🚧
cloneNo Documentation 🚧
as_vec3Returns the inner [`Vec3`]
mulNo Documentation 🚧
new_uncheckedCreate a [`Dir3`] from a [`Vec3`] that is already normalized. # Warning `value` must be normalize...
slerpPerforms a spherical linear interpolation between `self` and `rhs` based on the value `s`. This c...

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDir3No Documentation 🚧
otherDir3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

fast_renormalize

Returns self after an approximate normalization, assuming the value is already nearly normalized. Useful for preventing numerical error accumulation.

Example

The following seemingly benign code would start accumulating errors over time, leading to dir eventually not being normalized anymore.

# use bevy_math::prelude::*;
# let N: usize = 200;
let mut dir = Dir3::X;
let quaternion = Quat::from_euler(EulerRot::XYZ, 1.0, 2.0, 3.0);
for i in 0..N {
    dir = quaternion * dir;
}

Instead, do the following.

# use bevy_math::prelude::*;
# let N: usize = 200;
let mut dir = Dir3::X;
let quaternion = Quat::from_euler(EulerRot::XYZ, 1.0, 2.0, 3.0);
for i in 0..N {
    dir = quaternion * dir;
    dir = dir.fast_renormalize();
}

Arguments

NameTypeDocumentation
_selfDir3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

from_xyz_unchecked

Create a direction from its x, y, and z components, assuming the resulting vector is normalized.

Warning

The vector produced from x, y, and z must be normalized, i.e its length must be 1.0.

Arguments

NameTypeDocumentation
xf32No Documentation 🚧
yf32No Documentation 🚧
zf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDir3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDir3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

as_vec3

Returns the inner [Vec3]

Arguments

NameTypeDocumentation
_selfDir3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDir3No Documentation 🚧
rhsf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

new_unchecked

Create a [Dir3] from a [Vec3] that is already normalized.

Warning

value must be normalized, i.e its length must be 1.0.

Arguments

NameTypeDocumentation
valueVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

slerp

Performs a spherical linear interpolation between self and rhs based on the value s. This corresponds to interpolating between the two directions at a constant angular velocity. When s == 0.0, the result will be equal to self. When s == 1.0, the result will be equal to rhs.

Example

# use bevy_math::Dir3;
# use approx::{assert_relative_eq, RelativeEq};
#
let dir1 = Dir3::X;
let dir2 = Dir3::Y;
let result1 = dir1.slerp(dir2, 1.0 / 3.0);
assert_relative_eq!(
    result1,
    Dir3::from_xyz(0.75_f32.sqrt(), 0.5, 0.0).unwrap(),
    epsilon = 0.000001
);
let result2 = dir1.slerp(dir2, 0.5);
assert_relative_eq!(result2, Dir3::from_xyz(0.5_f32.sqrt(), 0.5_f32.sqrt(), 0.0).unwrap());

Arguments

NameTypeDocumentation
_selfDir3No Documentation 🚧
rhsDir3No Documentation 🚧
sf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

Dir3A

Dir3A

  1. glam::Vec3A

Description

A normalized SIMD vector pointing in a direction in 3D space.

This type stores a 16 byte aligned [Vec3A]. This may or may not be faster than [Dir3]: make sure to benchmark!

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_xyz_uncheckedCreate a direction from its `x`, `y`, and `z` components, assuming the resulting vector is normaliz...
cloneNo Documentation 🚧
mulNo Documentation 🚧
slerpPerforms a spherical linear interpolation between `self` and `rhs` based on the value `s`. This c...
negNo Documentation 🚧
fast_renormalizeReturns `self` after an approximate normalization, assuming the value is already nearly normalized....
eqNo Documentation 🚧
new_uncheckedCreate a [`Dir3A`] from a [`Vec3A`] that is already normalized. # Warning `value` must be normali...
as_vec3aReturns the inner [`Vec3A`]

from_xyz_unchecked

Create a direction from its x, y, and z components, assuming the resulting vector is normalized.

Warning

The vector produced from x, y, and z must be normalized, i.e its length must be 1.0.

Arguments

NameTypeDocumentation
xf32No Documentation 🚧
yf32No Documentation 🚧
zf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3ANo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDir3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3ANo Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDir3ANo Documentation 🚧
rhsf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

slerp

Performs a spherical linear interpolation between self and rhs based on the value s. This corresponds to interpolating between the two directions at a constant angular velocity. When s == 0.0, the result will be equal to self. When s == 1.0, the result will be equal to rhs.

Example

# use bevy_math::Dir3A;
# use approx::{assert_relative_eq, RelativeEq};
#
let dir1 = Dir3A::X;
let dir2 = Dir3A::Y;
let result1 = dir1.slerp(dir2, 1.0 / 3.0);
assert_relative_eq!(
    result1,
    Dir3A::from_xyz(0.75_f32.sqrt(), 0.5, 0.0).unwrap(),
    epsilon = 0.000001
);
let result2 = dir1.slerp(dir2, 0.5);
assert_relative_eq!(result2, Dir3A::from_xyz(0.5_f32.sqrt(), 0.5_f32.sqrt(), 0.0).unwrap());

Arguments

NameTypeDocumentation
_selfDir3ANo Documentation 🚧
rhsDir3ANo Documentation 🚧
sf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3ANo Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDir3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3ANo Documentation 🚧

fast_renormalize

Returns self after an approximate normalization, assuming the value is already nearly normalized. Useful for preventing numerical error accumulation. See [Dir3::fast_renormalize] for an example of when such error accumulation might occur.

Arguments

NameTypeDocumentation
_selfDir3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3ANo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDir3ANo Documentation 🚧
otherDir3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

new_unchecked

Create a [Dir3A] from a [Vec3A] that is already normalized.

Warning

value must be normalized, i.e its length must be 1.0.

Arguments

NameTypeDocumentation
valueVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3ANo Documentation 🚧

as_vec3a

Returns the inner [Vec3A]

Arguments

NameTypeDocumentation
_selfDir3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

FloatOrd

FloatOrd

  1. f32

Description

A wrapper for floats that implements [Ord], [Eq], and [Hash] traits.

This is a work around for the fact that the IEEE 754-2008 standard, implemented by Rust's [f32] type, doesn't define an ordering for NaN, and NaN is not considered equal to any other NaN.

Wrapping a float with FloatOrd breaks conformance with the standard by sorting NaN as less than all other numbers and equal to any other NaN.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
negNo Documentation 🚧
cloneNo Documentation 🚧
gtNo Documentation 🚧
leNo Documentation 🚧
ltNo Documentation 🚧
eqNo Documentation 🚧
geNo Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfFloatOrdNo Documentation 🚧

Returns

NameTypeDocumentation
arg0FloatOrdNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfFloatOrdNo Documentation 🚧

Returns

NameTypeDocumentation
arg0FloatOrdNo Documentation 🚧

gt

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfFloatOrdNo Documentation 🚧
otherFloatOrdNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

le

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfFloatOrdNo Documentation 🚧
otherFloatOrdNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

lt

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfFloatOrdNo Documentation 🚧
otherFloatOrdNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfFloatOrdNo Documentation 🚧
otherFloatOrdNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

ge

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfFloatOrdNo Documentation 🚧
otherFloatOrdNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

Isometry2d

Isometry2d

  • rotation:bevy_math::rotation2d::Rot2
  • translation:glam::Vec2

Description

An isometry in two dimensions, representing a rotation followed by a translation. This can often be useful for expressing relative positions and transformations from one position to another.

In particular, this type represents a distance-preserving transformation known as a rigid motion or a direct motion, and belongs to the special Euclidean group SE(2). This includes translation and rotation, but excludes reflection.

For the three-dimensional version, see [Isometry3d].

Example

Isometries can be created from a given translation and rotation:

# use bevy_math::{Isometry2d, Rot2, Vec2};
#
let iso = Isometry2d::new(Vec2::new(2.0, 1.0), Rot2::degrees(90.0));

Or from separate parts:

# use bevy_math::{Isometry2d, Rot2, Vec2};
#
let iso1 = Isometry2d::from_translation(Vec2::new(2.0, 1.0));
let iso2 = Isometry2d::from_rotation(Rot2::degrees(90.0));

The isometries can be used to transform points:

# use approx::assert_abs_diff_eq;
# use bevy_math::{Isometry2d, Rot2, Vec2};
#
let iso = Isometry2d::new(Vec2::new(2.0, 1.0), Rot2::degrees(90.0));
let point = Vec2::new(4.0, 4.0);

// These are equivalent
let result = iso.transform_point(point);
let result = iso * point;

assert_eq!(result, Vec2::new(-2.0, 5.0));

Isometries can also be composed together:

# use bevy_math::{Isometry2d, Rot2, Vec2};
#
# let iso = Isometry2d::new(Vec2::new(2.0, 1.0), Rot2::degrees(90.0));
# let iso1 = Isometry2d::from_translation(Vec2::new(2.0, 1.0));
# let iso2 = Isometry2d::from_rotation(Rot2::degrees(90.0));
#
assert_eq!(iso1 * iso2, iso);

One common operation is to compute an isometry representing the relative positions of two objects for things like intersection tests. This can be done with an inverse transformation:

# use bevy_math::{Isometry2d, Rot2, Vec2};
#
let circle_iso = Isometry2d::from_translation(Vec2::new(2.0, 1.0));
let rectangle_iso = Isometry2d::from_rotation(Rot2::degrees(90.0));

// Compute the relative position and orientation between the two shapes
let relative_iso = circle_iso.inverse() * rectangle_iso;

// Or alternatively, to skip an extra rotation operation:
let relative_iso = circle_iso.inverse_mul(rectangle_iso);

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_translationCreate a two-dimensional isometry from a translation.
eqNo Documentation 🚧
mulNo Documentation 🚧
mul-2No Documentation 🚧
inverseThe inverse isometry that undoes this one.
from_rotationCreate a two-dimensional isometry from a rotation.
newCreate a two-dimensional isometry from a rotation and a translation.
cloneNo Documentation 🚧
inverse_mulCompute `iso1.inverse() * iso2` in a more efficient way for one-shot cases. If the same isometry is used multiple times, it is more efficient to instead compute the inverse once and use that for each transformation.
transform_pointTransform a point by rotating and translating it using this isometry.
mul-1No Documentation 🚧
from_xyCreate a two-dimensional isometry from a translation with the given `x` and `y` components.
inverse_transform_pointTransform a point by rotating and translating it using the inverse of this isometry. This is more ...

from_translation

Create a two-dimensional isometry from a translation.

Arguments

NameTypeDocumentation
translationVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Isometry2dNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIsometry2dNo Documentation 🚧
otherIsometry2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIsometry2dNo Documentation 🚧
rhsIsometry2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Isometry2dNo Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Isometry2dNo Documentation 🚧
arg1Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

inverse

The inverse isometry that undoes this one.

Arguments

NameTypeDocumentation
_selfIsometry2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Isometry2dNo Documentation 🚧

from_rotation

Create a two-dimensional isometry from a rotation.

Arguments

NameTypeDocumentation
rotationRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Isometry2dNo Documentation 🚧

new

Create a two-dimensional isometry from a rotation and a translation.

Arguments

NameTypeDocumentation
translationVec2No Documentation 🚧
rotationRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Isometry2dNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIsometry2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Isometry2dNo Documentation 🚧

inverse_mul

Compute iso1.inverse() * iso2 in a more efficient way for one-shot cases. If the same isometry is used multiple times, it is more efficient to instead compute the inverse once and use that for each transformation.

Arguments

NameTypeDocumentation
_selfIsometry2dNo Documentation 🚧
rhsIsometry2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Isometry2dNo Documentation 🚧

transform_point

Transform a point by rotating and translating it using this isometry.

Arguments

NameTypeDocumentation
_selfIsometry2dNo Documentation 🚧
pointVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Isometry2dNo Documentation 🚧
arg1Dir2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir2No Documentation 🚧

from_xy

Create a two-dimensional isometry from a translation with the given x and y components.

Arguments

NameTypeDocumentation
xf32No Documentation 🚧
yf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Isometry2dNo Documentation 🚧

inverse_transform_point

Transform a point by rotating and translating it using the inverse of this isometry. This is more efficient than iso.inverse().transform_point(point) for one-shot cases. If the same isometry is used multiple times, it is more efficient to instead compute the inverse once and use that for each transformation.

Arguments

NameTypeDocumentation
_selfIsometry2dNo Documentation 🚧
pointVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

Isometry3d

Isometry3d

  • rotation:glam::Quat
  • translation:glam::Vec3A

Description

An isometry in three dimensions, representing a rotation followed by a translation. This can often be useful for expressing relative positions and transformations from one position to another.

In particular, this type represents a distance-preserving transformation known as a rigid motion or a direct motion, and belongs to the special Euclidean group SE(3). This includes translation and rotation, but excludes reflection.

For the two-dimensional version, see [Isometry2d].

Example

Isometries can be created from a given translation and rotation:

# use bevy_math::{Isometry3d, Quat, Vec3};
# use std::f32::consts::FRAC_PI_2;
#
let iso = Isometry3d::new(Vec3::new(2.0, 1.0, 3.0), Quat::from_rotation_z(FRAC_PI_2));

Or from separate parts:

# use bevy_math::{Isometry3d, Quat, Vec3};
# use std::f32::consts::FRAC_PI_2;
#
let iso1 = Isometry3d::from_translation(Vec3::new(2.0, 1.0, 3.0));
let iso2 = Isometry3d::from_rotation(Quat::from_rotation_z(FRAC_PI_2));

The isometries can be used to transform points:

# use approx::assert_relative_eq;
# use bevy_math::{Isometry3d, Quat, Vec3};
# use std::f32::consts::FRAC_PI_2;
#
let iso = Isometry3d::new(Vec3::new(2.0, 1.0, 3.0), Quat::from_rotation_z(FRAC_PI_2));
let point = Vec3::new(4.0, 4.0, 4.0);

// These are equivalent
let result = iso.transform_point(point);
let result = iso * point;

assert_relative_eq!(result, Vec3::new(-2.0, 5.0, 7.0));

Isometries can also be composed together:

# use bevy_math::{Isometry3d, Quat, Vec3};
# use std::f32::consts::FRAC_PI_2;
#
# let iso = Isometry3d::new(Vec3::new(2.0, 1.0, 3.0), Quat::from_rotation_z(FRAC_PI_2));
# let iso1 = Isometry3d::from_translation(Vec3::new(2.0, 1.0, 3.0));
# let iso2 = Isometry3d::from_rotation(Quat::from_rotation_z(FRAC_PI_2));
#
assert_eq!(iso1 * iso2, iso);

One common operation is to compute an isometry representing the relative positions of two objects for things like intersection tests. This can be done with an inverse transformation:

# use bevy_math::{Isometry3d, Quat, Vec3};
# use std::f32::consts::FRAC_PI_2;
#
let sphere_iso = Isometry3d::from_translation(Vec3::new(2.0, 1.0, 3.0));
let cuboid_iso = Isometry3d::from_rotation(Quat::from_rotation_z(FRAC_PI_2));

// Compute the relative position and orientation between the two shapes
let relative_iso = sphere_iso.inverse() * cuboid_iso;

// Or alternatively, to skip an extra rotation operation:
let relative_iso = sphere_iso.inverse_mul(cuboid_iso);

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
mul-3No Documentation 🚧
mul-1No Documentation 🚧
eqNo Documentation 🚧
inverse_mulCompute `iso1.inverse() * iso2` in a more efficient way for one-shot cases. If the same isometry is used multiple times, it is more efficient to instead compute the inverse once and use that for each transformation.
mulNo Documentation 🚧
mul-2No Documentation 🚧
inverseThe inverse isometry that undoes this one.
cloneNo Documentation 🚧
from_xyzCreate a three-dimensional isometry from a translation with the given `x`, `y`, and `z` components.
from_rotationCreate a three-dimensional isometry from a rotation.

mul-3

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Isometry3dNo Documentation 🚧
arg1Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Isometry3dNo Documentation 🚧
arg1Vec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIsometry3dNo Documentation 🚧
otherIsometry3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

inverse_mul

Compute iso1.inverse() * iso2 in a more efficient way for one-shot cases. If the same isometry is used multiple times, it is more efficient to instead compute the inverse once and use that for each transformation.

Arguments

NameTypeDocumentation
_selfIsometry3dNo Documentation 🚧
rhsIsometry3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Isometry3dNo Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIsometry3dNo Documentation 🚧
rhsIsometry3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Isometry3dNo Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Isometry3dNo Documentation 🚧
arg1Dir3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

inverse

The inverse isometry that undoes this one.

Arguments

NameTypeDocumentation
_selfIsometry3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Isometry3dNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIsometry3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Isometry3dNo Documentation 🚧

from_xyz

Create a three-dimensional isometry from a translation with the given x, y, and z components.

Arguments

NameTypeDocumentation
xf32No Documentation 🚧
yf32No Documentation 🚧
zf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Isometry3dNo Documentation 🚧

from_rotation

Create a three-dimensional isometry from a rotation.

Arguments

NameTypeDocumentation
rotationQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Isometry3dNo Documentation 🚧

Annulus

Annulus

  • inner_circle:bevy_math::primitives::dim2::Circle
  • outer_circle:bevy_math::primitives::dim2::Circle

Description

A primitive shape formed by the region between two circles, also known as a ring.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
closest_pointFinds the point on the annulus that is closest to the given `point`: - If the point is outside of ...
diameterGet the diameter of the annulus
newCreate a new [`Annulus`] from the radii of the inner and outer circle
eqNo Documentation 🚧
thicknessGet the thickness of the annulus

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAnnulusNo Documentation 🚧

Returns

NameTypeDocumentation
arg0AnnulusNo Documentation 🚧

closest_point

Finds the point on the annulus that is closest to the given point:

  • If the point is outside of the annulus completely, the returned point will be on the outer perimeter.
  • If the point is inside of the inner circle (hole) of the annulus, the returned point will be on the inner perimeter.
  • Otherwise, the returned point is overlapping the annulus and returned as is.

Arguments

NameTypeDocumentation
_selfAnnulusNo Documentation 🚧
pointVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

diameter

Get the diameter of the annulus

Arguments

NameTypeDocumentation
_selfAnnulusNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

new

Create a new [Annulus] from the radii of the inner and outer circle

Arguments

NameTypeDocumentation
inner_radiusf32No Documentation 🚧
outer_radiusf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0AnnulusNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAnnulusNo Documentation 🚧
otherAnnulusNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

thickness

Get the thickness of the annulus

Arguments

NameTypeDocumentation
_selfAnnulusNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

Arc2d

Arc2d

  • radius:f32
  • half_angle:f32

Description

A primitive representing an arc between two points on a circle.

An arc has no area. If you want to include the portion of a circle's area swept out by the arc, use the pie-shaped [CircularSector]. If you want to include only the space inside the convex hull of the arc, use the bowl-shaped [CircularSegment].

The arc is drawn starting from [Vec2::Y], extending by half_angle radians on either side. The center of the circle is the origin [Vec2::ZERO]. Note that this means that the origin may not be within the Arc2d's convex hull.

Warning: Arcs with negative angle or radius, or with angle greater than an entire circle, are not officially supported. It is recommended to normalize arcs to have an angle in [0, 2π].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_degreesCreate a new [`Arc2d`] from a `radius` and an `angle` in degrees.
chord_lengthGet the distance between the endpoints (the length of the chord)
from_turnsCreate a new [`Arc2d`] from a `radius` and a `fraction` of a single turn. For instance, `0.5` turns is a semicircle.
lengthGet the length of the arc
is_minorProduces true if the arc is at most half a circle. **Note:** This is not the negation of [`is_major`](Self::is_major): an exact semicircle is both major and minor.
left_endpointGet the left-hand end point of the arc
from_radiansCreate a new [`Arc2d`] from a `radius` and an `angle` in radians
cloneNo Documentation 🚧
newCreate a new [`Arc2d`] from a `radius` and a `half_angle`
angleGet the angle of the arc
right_endpointGet the right-hand end point of the arc
chord_midpointGet the midpoint of the two endpoints (the midpoint of the chord)
is_majorProduces true if the arc is at least half a circle. **Note:** This is not the negation of [`is_minor`](Self::is_minor): an exact semicircle is both major and minor.
sagittaGet the length of the sagitta of this arc, that is, the length of the line between the midpoints o...
eqNo Documentation 🚧
midpointGet the midpoint of the arc
half_chord_lengthGet half the distance between the endpoints (half the length of the chord)
apothemGet the length of the apothem of this arc, that is, the distance from the center of the circle to ...

from_degrees

Create a new [Arc2d] from a radius and an angle in degrees.

Arguments

NameTypeDocumentation
radiusf32No Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Arc2dNo Documentation 🚧

chord_length

Get the distance between the endpoints (the length of the chord)

Arguments

NameTypeDocumentation
_selfArc2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

from_turns

Create a new [Arc2d] from a radius and a fraction of a single turn. For instance, 0.5 turns is a semicircle.

Arguments

NameTypeDocumentation
radiusf32No Documentation 🚧
fractionf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Arc2dNo Documentation 🚧

length

Get the length of the arc

Arguments

NameTypeDocumentation
_selfArc2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

is_minor

Produces true if the arc is at most half a circle. Note: This is not the negation of is_major: an exact semicircle is both major and minor.

Arguments

NameTypeDocumentation
_selfArc2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

left_endpoint

Get the left-hand end point of the arc

Arguments

NameTypeDocumentation
_selfArc2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

from_radians

Create a new [Arc2d] from a radius and an angle in radians

Arguments

NameTypeDocumentation
radiusf32No Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Arc2dNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfArc2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Arc2dNo Documentation 🚧

new

Create a new [Arc2d] from a radius and a half_angle

Arguments

NameTypeDocumentation
radiusf32No Documentation 🚧
half_anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Arc2dNo Documentation 🚧

angle

Get the angle of the arc

Arguments

NameTypeDocumentation
_selfArc2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

right_endpoint

Get the right-hand end point of the arc

Arguments

NameTypeDocumentation
_selfArc2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

chord_midpoint

Get the midpoint of the two endpoints (the midpoint of the chord)

Arguments

NameTypeDocumentation
_selfArc2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

is_major

Produces true if the arc is at least half a circle. Note: This is not the negation of is_minor: an exact semicircle is both major and minor.

Arguments

NameTypeDocumentation
_selfArc2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

sagitta

Get the length of the sagitta of this arc, that is, the length of the line between the midpoints of the arc and its chord. Equivalently, the height of the triangle whose base is the chord and whose apex is the midpoint of the arc. The sagitta is also the sum of the radius and the apothem.

Arguments

NameTypeDocumentation
_selfArc2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfArc2dNo Documentation 🚧
otherArc2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

midpoint

Get the midpoint of the arc

Arguments

NameTypeDocumentation
_selfArc2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

half_chord_length

Get half the distance between the endpoints (half the length of the chord)

Arguments

NameTypeDocumentation
_selfArc2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

apothem

Get the length of the apothem of this arc, that is, the distance from the center of the circle to the midpoint of the chord, in the direction of the midpoint of the arc. Equivalently, the radius minus the sagitta. Note that for a major arc, the apothem will be negative.

Arguments

NameTypeDocumentation
_selfArc2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

Capsule2d

Capsule2d

  • radius:f32
  • half_length:f32

Description

A 2D capsule primitive, also known as a stadium or pill shape.

A two-dimensional capsule is defined as a neighborhood of points at a distance (radius) from a line

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqNo Documentation 🚧
to_inner_rectangleGet the part connecting the semicircular ends of the capsule as a [`Rectangle`]
newCreate a new `Capsule2d` from a radius and length
cloneNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCapsule2dNo Documentation 🚧
otherCapsule2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

to_inner_rectangle

Get the part connecting the semicircular ends of the capsule as a [Rectangle]

Arguments

NameTypeDocumentation
_selfCapsule2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0RectangleNo Documentation 🚧

new

Create a new Capsule2d from a radius and length

Arguments

NameTypeDocumentation
radiusf32No Documentation 🚧
lengthf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Capsule2dNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCapsule2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Capsule2dNo Documentation 🚧

Circle

Circle

  • radius:f32

Description

A circle primitive, representing the set of points some distance from the origin

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
diameterGet the diameter of the circle
closest_pointFinds the point on the circle that is closest to the given `point`. If the point is outside the ci...
eqNo Documentation 🚧
newCreate a new [`Circle`] from a `radius`

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCircleNo Documentation 🚧

Returns

NameTypeDocumentation
arg0CircleNo Documentation 🚧

diameter

Get the diameter of the circle

Arguments

NameTypeDocumentation
_selfCircleNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

closest_point

Finds the point on the circle that is closest to the given point. If the point is outside the circle, the returned point will be on the perimeter of the circle. Otherwise, it will be inside the circle and returned as is.

Arguments

NameTypeDocumentation
_selfCircleNo Documentation 🚧
pointVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCircleNo Documentation 🚧
otherCircleNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

new

Create a new [Circle] from a radius

Arguments

NameTypeDocumentation
radiusf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0CircleNo Documentation 🚧

CircularSector

CircularSector

  • arc:bevy_math::primitives::dim2::Arc2d

Description

A primitive representing a circular sector: a pie slice of a circle.

The segment is positioned so that it always includes [Vec2::Y] and is vertically symmetrical. To orient the sector differently, apply a rotation. The sector is drawn with the center of its circle at the origin [Vec2::ZERO].

Warning: Circular sectors with negative angle or radius, or with angle greater than an entire circle, are not officially supported. We recommend normalizing circular sectors to have an angle in [0, 2π].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
angleGet the angle of the sector
half_angleGet half the angle of the sector
eqNo Documentation 🚧
sagittaGet the length of the sagitta of this sector See [`Arc2d::sagitta`]
arc_lengthGet the length of the arc defining the sector
from_degreesCreate a new [`CircularSector`] from a `radius` and an `angle` in degrees.
from_turnsCreate a new [`CircularSector`] from a `radius` and a number of `turns` of a circle. For instance, `0.5` turns is a semicircle.
radiusGet the radius of the sector
half_chord_lengthGet half the length of the chord defined by the sector See [`Arc2d::half_chord_length`]
chord_lengthGet the length of the chord defined by the sector See [`Arc2d::chord_length`]
newCreate a new [`CircularSector`] from a `radius` and an `angle`
cloneNo Documentation 🚧
chord_midpointGet the midpoint of the chord defined by the sector See [`Arc2d::chord_midpoint`]
from_radiansCreate a new [`CircularSector`] from a `radius` and an `angle` in radians.
apothemGet the length of the apothem of this sector See [`Arc2d::apothem`]

angle

Get the angle of the sector

Arguments

NameTypeDocumentation
_selfCircularSectorNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

half_angle

Get half the angle of the sector

Arguments

NameTypeDocumentation
_selfCircularSectorNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCircularSectorNo Documentation 🚧
otherCircularSectorNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

sagitta

Get the length of the sagitta of this sector See [Arc2d::sagitta]

Arguments

NameTypeDocumentation
_selfCircularSectorNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

arc_length

Get the length of the arc defining the sector

Arguments

NameTypeDocumentation
_selfCircularSectorNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

from_degrees

Create a new [CircularSector] from a radius and an angle in degrees.

Arguments

NameTypeDocumentation
radiusf32No Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0CircularSectorNo Documentation 🚧

from_turns

Create a new [CircularSector] from a radius and a number of turns of a circle. For instance, 0.5 turns is a semicircle.

Arguments

NameTypeDocumentation
radiusf32No Documentation 🚧
fractionf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0CircularSectorNo Documentation 🚧

radius

Get the radius of the sector

Arguments

NameTypeDocumentation
_selfCircularSectorNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

half_chord_length

Get half the length of the chord defined by the sector See [Arc2d::half_chord_length]

Arguments

NameTypeDocumentation
_selfCircularSectorNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

chord_length

Get the length of the chord defined by the sector See [Arc2d::chord_length]

Arguments

NameTypeDocumentation
_selfCircularSectorNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

new

Create a new [CircularSector] from a radius and an angle

Arguments

NameTypeDocumentation
radiusf32No Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0CircularSectorNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCircularSectorNo Documentation 🚧

Returns

NameTypeDocumentation
arg0CircularSectorNo Documentation 🚧

chord_midpoint

Get the midpoint of the chord defined by the sector See [Arc2d::chord_midpoint]

Arguments

NameTypeDocumentation
_selfCircularSectorNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

from_radians

Create a new [CircularSector] from a radius and an angle in radians.

Arguments

NameTypeDocumentation
radiusf32No Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0CircularSectorNo Documentation 🚧

apothem

Get the length of the apothem of this sector See [Arc2d::apothem]

Arguments

NameTypeDocumentation
_selfCircularSectorNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

CircularSegment

CircularSegment

  • arc:bevy_math::primitives::dim2::Arc2d

Description

A primitive representing a circular segment: the area enclosed by the arc of a circle and its chord (the line between its endpoints).

The segment is drawn starting from [Vec2::Y], extending equally on either side. To orient the segment differently, apply a rotation. The segment is drawn with the center of its circle at the origin [Vec2::ZERO]. When positioning a segment, the apothem function may be particularly useful.

Warning: Circular segments with negative angle or radius, or with angle greater than an entire circle, are not officially supported. We recommend normalizing circular segments to have an angle in [0, 2π].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
angleGet the angle of the segment
arc_lengthGet the length of the arc defining the segment
chord_midpointGet the midpoint of the segment's base, also known as its chord
chord_lengthGet the length of the segment's base, also known as its chord
half_chord_lengthGet half the length of the segment's base, also known as its chord
half_angleGet the half-angle of the segment
from_radiansCreate a new [`CircularSegment`] from a `radius` and an `angle` in radians.
newCreate a new [`CircularSegment`] from a `radius`, and an `angle`
radiusGet the radius of the segment
from_turnsCreate a new [`CircularSegment`] from a `radius` and a number of `turns` of a circle. For instance, `0.5` turns is a semicircle.
apothemGet the length of the apothem of this segment, which is the signed distance between the segment an...
eqNo Documentation 🚧
from_degreesCreate a new [`CircularSegment`] from a `radius` and an `angle` in degrees.
sagittaGet the length of the sagitta of this segment, also known as its height See [`Arc2d::sagitta`]

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCircularSegmentNo Documentation 🚧

Returns

NameTypeDocumentation
arg0CircularSegmentNo Documentation 🚧

angle

Get the angle of the segment

Arguments

NameTypeDocumentation
_selfCircularSegmentNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

arc_length

Get the length of the arc defining the segment

Arguments

NameTypeDocumentation
_selfCircularSegmentNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

chord_midpoint

Get the midpoint of the segment's base, also known as its chord

Arguments

NameTypeDocumentation
_selfCircularSegmentNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

chord_length

Get the length of the segment's base, also known as its chord

Arguments

NameTypeDocumentation
_selfCircularSegmentNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

half_chord_length

Get half the length of the segment's base, also known as its chord

Arguments

NameTypeDocumentation
_selfCircularSegmentNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

half_angle

Get the half-angle of the segment

Arguments

NameTypeDocumentation
_selfCircularSegmentNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

from_radians

Create a new [CircularSegment] from a radius and an angle in radians.

Arguments

NameTypeDocumentation
radiusf32No Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0CircularSegmentNo Documentation 🚧

new

Create a new [CircularSegment] from a radius, and an angle

Arguments

NameTypeDocumentation
radiusf32No Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0CircularSegmentNo Documentation 🚧

radius

Get the radius of the segment

Arguments

NameTypeDocumentation
_selfCircularSegmentNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

from_turns

Create a new [CircularSegment] from a radius and a number of turns of a circle. For instance, 0.5 turns is a semicircle.

Arguments

NameTypeDocumentation
radiusf32No Documentation 🚧
fractionf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0CircularSegmentNo Documentation 🚧

apothem

Get the length of the apothem of this segment, which is the signed distance between the segment and the center of its circle See [Arc2d::apothem]

Arguments

NameTypeDocumentation
_selfCircularSegmentNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCircularSegmentNo Documentation 🚧
otherCircularSegmentNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_degrees

Create a new [CircularSegment] from a radius and an angle in degrees.

Arguments

NameTypeDocumentation
radiusf32No Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0CircularSegmentNo Documentation 🚧

sagitta

Get the length of the sagitta of this segment, also known as its height See [Arc2d::sagitta]

Arguments

NameTypeDocumentation
_selfCircularSegmentNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

Ellipse

Ellipse

  • half_size:glam::Vec2

Description

An ellipse primitive, which is like a circle, but the width and height can be different

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newCreate a new `Ellipse` from half of its width and height. This corresponds to the two perpendicula...
focal_lengthGet the focal length of the ellipse. This corresponds to the distance between one of the foci and t...
semi_majorReturns the length of the semi-major axis. This corresponds to the longest radius of the ellipse.
from_sizeCreate a new `Ellipse` from a given full size. `size.x` is the diameter along the X axis, and `size.y`...
eccentricityReturns the [eccentricity](https://en.wikipedia.org/wiki/Eccentricity_(mathematics)) of the ellipse. It can be thought of as a measure of how "stretched" or elongated the ellipse is. The value should be in the range [0, 1), where 0 represents a circle, and 1 represents a parabola.
semi_minorReturns the length of the semi-minor axis. This corresponds to the shortest radius of the ellipse.
cloneNo Documentation 🚧
eqNo Documentation 🚧

new

Create a new Ellipse from half of its width and height. This corresponds to the two perpendicular radii defining the ellipse.

Arguments

NameTypeDocumentation
half_widthf32No Documentation 🚧
half_heightf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0EllipseNo Documentation 🚧

focal_length

Get the focal length of the ellipse. This corresponds to the distance between one of the foci and the center of the ellipse. The focal length of an ellipse is related to its eccentricity by eccentricity = focal_length / semi_major

Arguments

NameTypeDocumentation
_selfEllipseNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

semi_major

Returns the length of the semi-major axis. This corresponds to the longest radius of the ellipse.

Arguments

NameTypeDocumentation
_selfEllipseNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

from_size

Create a new Ellipse from a given full size. size.x is the diameter along the X axis, and size.y is the diameter along the Y axis.

Arguments

NameTypeDocumentation
sizeVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0EllipseNo Documentation 🚧

eccentricity

Returns the eccentricity of the ellipse. It can be thought of as a measure of how "stretched" or elongated the ellipse is. The value should be in the range [0, 1), where 0 represents a circle, and 1 represents a parabola.

Arguments

NameTypeDocumentation
_selfEllipseNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

semi_minor

Returns the length of the semi-minor axis. This corresponds to the shortest radius of the ellipse.

Arguments

NameTypeDocumentation
_selfEllipseNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfEllipseNo Documentation 🚧

Returns

NameTypeDocumentation
arg0EllipseNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfEllipseNo Documentation 🚧
otherEllipseNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

Line2d

Line2d

  • direction:bevy_math::direction::Dir2

Description

An infinite line going through the origin along a direction in 2D space.

For a finite line: [Segment2d]

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
eqNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfLine2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Line2dNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfLine2dNo Documentation 🚧
otherLine2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

Plane2d

Plane2d

  • normal:bevy_math::direction::Dir2

Description

An unbounded plane in 2D space. It forms a separating surface through the origin, stretching infinitely far

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqNo Documentation 🚧
newCreate a new `Plane2d` from a normal # Panics Panics if the given `normal` is zero (or very close...
cloneNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfPlane2dNo Documentation 🚧
otherPlane2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

new

Create a new Plane2d from a normal

Panics

Panics if the given normal is zero (or very close to zero), or non-finite.

Arguments

NameTypeDocumentation
normalVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Plane2dNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfPlane2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Plane2dNo Documentation 🚧

Rectangle

Rectangle

  • half_size:glam::Vec2

Description

A rectangle primitive, which is like a square, except that the width and height can be different

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_sizeCreate a new `Rectangle` from a given full size
eqNo Documentation 🚧
from_cornersCreate a new `Rectangle` from two corner points
closest_pointFinds the point on the rectangle that is closest to the given `point`. If the point is outside the...
sizeGet the size of the rectangle
from_lengthCreate a `Rectangle` from a single length. The resulting `Rectangle` will be the same size in ever...
cloneNo Documentation 🚧
newCreate a new `Rectangle` from a full width and height

from_size

Create a new Rectangle from a given full size

Arguments

NameTypeDocumentation
sizeVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0RectangleNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRectangleNo Documentation 🚧
otherRectangleNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_corners

Create a new Rectangle from two corner points

Arguments

NameTypeDocumentation
point1Vec2No Documentation 🚧
point2Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0RectangleNo Documentation 🚧

closest_point

Finds the point on the rectangle that is closest to the given point. If the point is outside the rectangle, the returned point will be on the perimeter of the rectangle. Otherwise, it will be inside the rectangle and returned as is.

Arguments

NameTypeDocumentation
_selfRectangleNo Documentation 🚧
pointVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

size

Get the size of the rectangle

Arguments

NameTypeDocumentation
_selfRectangleNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

from_length

Create a Rectangle from a single length. The resulting Rectangle will be the same size in every direction.

Arguments

NameTypeDocumentation
lengthf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0RectangleNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRectangleNo Documentation 🚧

Returns

NameTypeDocumentation
arg0RectangleNo Documentation 🚧

new

Create a new Rectangle from a full width and height

Arguments

NameTypeDocumentation
widthf32No Documentation 🚧
heightf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0RectangleNo Documentation 🚧

RegularPolygon

RegularPolygon

  • circumcircle:bevy_math::primitives::dim2::Circle
  • sides:u32

Description

A polygon centered on the origin where all vertices lie on a circle, equally far apart.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
external_angle_degreesGet the external angle of the regular polygon in degrees. This is the angle formed by two adjacent...
circumradiusGet the radius of the circumcircle on which all vertices of the regular polygon lie
side_lengthGet the length of one side of the regular polygon
inradiusGet the inradius or apothem of the regular polygon. This is the radius of the largest circle that ...
eqNo Documentation 🚧
cloneNo Documentation 🚧
newCreate a new `RegularPolygon` from the radius of the circumcircle and a number of sides # Panics ...
internal_angle_degreesGet the internal angle of the regular polygon in degrees. This is the angle formed by two adjacent...
external_angle_radiansGet the external angle of the regular polygon in radians. This is the angle formed by two adjacent...
internal_angle_radiansGet the internal angle of the regular polygon in radians. This is the angle formed by two adjacent...

external_angle_degrees

Get the external angle of the regular polygon in degrees. This is the angle formed by two adjacent sides with points within the angle being in the exterior of the polygon

Arguments

NameTypeDocumentation
_selfRegularPolygonNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

circumradius

Get the radius of the circumcircle on which all vertices of the regular polygon lie

Arguments

NameTypeDocumentation
_selfRegularPolygonNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

side_length

Get the length of one side of the regular polygon

Arguments

NameTypeDocumentation
_selfRegularPolygonNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

inradius

Get the inradius or apothem of the regular polygon. This is the radius of the largest circle that can be drawn within the polygon

Arguments

NameTypeDocumentation
_selfRegularPolygonNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRegularPolygonNo Documentation 🚧
otherRegularPolygonNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRegularPolygonNo Documentation 🚧

Returns

NameTypeDocumentation
arg0RegularPolygonNo Documentation 🚧

new

Create a new RegularPolygon from the radius of the circumcircle and a number of sides

Panics

Panics if circumradius is negative

Arguments

NameTypeDocumentation
circumradiusf32No Documentation 🚧
sidesu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0RegularPolygonNo Documentation 🚧

internal_angle_degrees

Get the internal angle of the regular polygon in degrees. This is the angle formed by two adjacent sides with points within the angle being in the interior of the polygon

Arguments

NameTypeDocumentation
_selfRegularPolygonNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

external_angle_radians

Get the external angle of the regular polygon in radians. This is the angle formed by two adjacent sides with points within the angle being in the exterior of the polygon

Arguments

NameTypeDocumentation
_selfRegularPolygonNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

internal_angle_radians

Get the internal angle of the regular polygon in radians. This is the angle formed by two adjacent sides with points within the angle being in the interior of the polygon

Arguments

NameTypeDocumentation
_selfRegularPolygonNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

Rhombus

Rhombus

  • half_diagonals:glam::Vec2

Description

A rhombus primitive, also known as a diamond shape. A four sided polygon, centered on the origin, where opposite sides are parallel but without requiring right angles.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
circumradiusGet the radius of the circumcircle on which all vertices of the rhombus lie
inradiusGet the radius of the largest circle that can be drawn within the rhombus
from_inradiusCreate a new `Rhombus` from a given inradius with all inner angles equal.
sideGet the length of each side of the rhombus
closest_pointFinds the point on the rhombus that is closest to the given `point`. If the point is outside the r...
eqNo Documentation 🚧
newCreate a new `Rhombus` from a vertical and horizontal diagonal sizes.
from_sideCreate a new `Rhombus` from a side length with all inner angles equal.
cloneNo Documentation 🚧

circumradius

Get the radius of the circumcircle on which all vertices of the rhombus lie

Arguments

NameTypeDocumentation
_selfRhombusNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

inradius

Get the radius of the largest circle that can be drawn within the rhombus

Arguments

NameTypeDocumentation
_selfRhombusNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

from_inradius

Create a new Rhombus from a given inradius with all inner angles equal.

Arguments

NameTypeDocumentation
inradiusf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0RhombusNo Documentation 🚧

side

Get the length of each side of the rhombus

Arguments

NameTypeDocumentation
_selfRhombusNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

closest_point

Finds the point on the rhombus that is closest to the given point. If the point is outside the rhombus, the returned point will be on the perimeter of the rhombus. Otherwise, it will be inside the rhombus and returned as is.

Arguments

NameTypeDocumentation
_selfRhombusNo Documentation 🚧
pointVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRhombusNo Documentation 🚧
otherRhombusNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

new

Create a new Rhombus from a vertical and horizontal diagonal sizes.

Arguments

NameTypeDocumentation
horizontal_diagonalf32No Documentation 🚧
vertical_diagonalf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0RhombusNo Documentation 🚧

from_side

Create a new Rhombus from a side length with all inner angles equal.

Arguments

NameTypeDocumentation
sidef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0RhombusNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRhombusNo Documentation 🚧

Returns

NameTypeDocumentation
arg0RhombusNo Documentation 🚧

Segment2d

Segment2d

  • direction:bevy_math::direction::Dir2
  • half_length:f32

Description

A segment of a line going through the origin along a direction in 2D space.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
point2Get the position of the second point on the line segment
point1Get the position of the first point on the line segment
newCreate a new `Segment2d` from a direction and full length of the segment
eqNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfSegment2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Segment2dNo Documentation 🚧

point2

Get the position of the second point on the line segment

Arguments

NameTypeDocumentation
_selfSegment2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

point1

Get the position of the first point on the line segment

Arguments

NameTypeDocumentation
_selfSegment2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

new

Create a new Segment2d from a direction and full length of the segment

Arguments

NameTypeDocumentation
directionDir2No Documentation 🚧
lengthf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Segment2dNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfSegment2dNo Documentation 🚧
otherSegment2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

Triangle2d

Triangle2d

  • vertices:[glam::Vec2; 3]

Description

A triangle in 2D space

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newCreate a new `Triangle2d` from points `a`, `b`, and `c`
is_acuteChecks if the triangle is acute, meaning all angles are less than 90 degrees
is_degenerateChecks if the triangle is degenerate, meaning it has zero area. A triangle is degenerate if the cr...
is_obtuseChecks if the triangle is obtuse, meaning one angle is greater than 90 degrees
eqNo Documentation 🚧
reversedThis triangle but reversed.
reverseReverse the [`WindingOrder`] of the triangle by swapping the first and last vertices.
cloneNo Documentation 🚧

new

Create a new Triangle2d from points a, b, and c

Arguments

NameTypeDocumentation
aVec2No Documentation 🚧
bVec2No Documentation 🚧
cVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Triangle2dNo Documentation 🚧

is_acute

Checks if the triangle is acute, meaning all angles are less than 90 degrees

Arguments

NameTypeDocumentation
_selfTriangle2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_degenerate

Checks if the triangle is degenerate, meaning it has zero area. A triangle is degenerate if the cross product of the vectors ab and ac has a length less than 10e-7. This indicates that the three vertices are collinear or nearly collinear.

Arguments

NameTypeDocumentation
_selfTriangle2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_obtuse

Checks if the triangle is obtuse, meaning one angle is greater than 90 degrees

Arguments

NameTypeDocumentation
_selfTriangle2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTriangle2dNo Documentation 🚧
otherTriangle2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

reversed

This triangle but reversed.

Arguments

NameTypeDocumentation
_selfTriangle2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Triangle2dNo Documentation 🚧

reverse

Reverse the [WindingOrder] of the triangle by swapping the first and last vertices.

Arguments

NameTypeDocumentation
_selfTriangle2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTriangle2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Triangle2dNo Documentation 🚧

Capsule3d

Capsule3d

  • radius:f32
  • half_length:f32

Description

A 3D capsule primitive centered on the origin A three-dimensional capsule is defined as a surface at a distance (radius) from a line

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
newCreate a new `Capsule3d` from a radius and length
eqNo Documentation 🚧
to_cylinderGet the part connecting the hemispherical ends of the capsule as a [`Cylinder`]

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCapsule3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Capsule3dNo Documentation 🚧

new

Create a new Capsule3d from a radius and length

Arguments

NameTypeDocumentation
radiusf32No Documentation 🚧
lengthf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Capsule3dNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCapsule3dNo Documentation 🚧
otherCapsule3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

to_cylinder

Get the part connecting the hemispherical ends of the capsule as a [Cylinder]

Arguments

NameTypeDocumentation
_selfCapsule3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0CylinderNo Documentation 🚧

Cone

Cone

  • radius:f32
  • height:f32

Description

A cone primitive centered on the midpoint between the tip of the cone and the center of its base.

The cone is oriented with its tip pointing towards the Y axis.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
base_areaGet the surface area of the base of the cone
baseGet the base of the cone as a [`Circle`]
cloneNo Documentation 🚧
lateral_areaGet the surface area of the side of the cone, also known as the lateral area
eqNo Documentation 🚧
newCreate a new [`Cone`] from a radius and height.
slant_heightGet the slant height of the cone, the length of the line segment connecting a point on the base to...

base_area

Get the surface area of the base of the cone

Arguments

NameTypeDocumentation
_selfConeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

base

Get the base of the cone as a [Circle]

Arguments

NameTypeDocumentation
_selfConeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0CircleNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfConeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0ConeNo Documentation 🚧

lateral_area

Get the surface area of the side of the cone, also known as the lateral area

Arguments

NameTypeDocumentation
_selfConeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfConeNo Documentation 🚧
otherConeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

new

Create a new [Cone] from a radius and height.

Arguments

NameTypeDocumentation
radiusf32No Documentation 🚧
heightf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0ConeNo Documentation 🚧

slant_height

Get the slant height of the cone, the length of the line segment connecting a point on the base to the apex

Arguments

NameTypeDocumentation
_selfConeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

ConicalFrustum

ConicalFrustum

  • radius_top:f32
  • radius_bottom:f32
  • height:f32

Description

A conical frustum primitive. A conical frustum can be created by slicing off a section of a cone.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
eqNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfConicalFrustumNo Documentation 🚧

Returns

NameTypeDocumentation
arg0ConicalFrustumNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfConicalFrustumNo Documentation 🚧
otherConicalFrustumNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

Cuboid

Cuboid

  • half_size:glam::Vec3

Description

A cuboid primitive, which is like a cube, except that the x, y, and z dimensions are not required to be the same.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
closest_pointFinds the point on the cuboid that is closest to the given `point`. If the point is outside the cu...
eqNo Documentation 🚧
from_sizeCreate a new `Cuboid` from a given full size
cloneNo Documentation 🚧
sizeGet the size of the cuboid
newCreate a new `Cuboid` from a full x, y, and z length
from_cornersCreate a new `Cuboid` from two corner points
from_lengthCreate a `Cuboid` from a single length. The resulting `Cuboid` will be the same size in every dire...

closest_point

Finds the point on the cuboid that is closest to the given point. If the point is outside the cuboid, the returned point will be on the surface of the cuboid. Otherwise, it will be inside the cuboid and returned as is.

Arguments

NameTypeDocumentation
_selfCuboidNo Documentation 🚧
pointVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCuboidNo Documentation 🚧
otherCuboidNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_size

Create a new Cuboid from a given full size

Arguments

NameTypeDocumentation
sizeVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0CuboidNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCuboidNo Documentation 🚧

Returns

NameTypeDocumentation
arg0CuboidNo Documentation 🚧

size

Get the size of the cuboid

Arguments

NameTypeDocumentation
_selfCuboidNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

new

Create a new Cuboid from a full x, y, and z length

Arguments

NameTypeDocumentation
x_lengthf32No Documentation 🚧
y_lengthf32No Documentation 🚧
z_lengthf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0CuboidNo Documentation 🚧

from_corners

Create a new Cuboid from two corner points

Arguments

NameTypeDocumentation
point1Vec3No Documentation 🚧
point2Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0CuboidNo Documentation 🚧

from_length

Create a Cuboid from a single length. The resulting Cuboid will be the same size in every direction.

Arguments

NameTypeDocumentation
lengthf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0CuboidNo Documentation 🚧

Cylinder

Cylinder

  • radius:f32
  • half_height:f32

Description

A cylinder primitive centered on the origin

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
lateral_areaGet the surface area of the side of the cylinder, also known as the lateral area
baseGet the base of the cylinder as a [`Circle`]
eqNo Documentation 🚧
newCreate a new `Cylinder` from a radius and full height
base_areaGet the surface area of one base of the cylinder
cloneNo Documentation 🚧

lateral_area

Get the surface area of the side of the cylinder, also known as the lateral area

Arguments

NameTypeDocumentation
_selfCylinderNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

base

Get the base of the cylinder as a [Circle]

Arguments

NameTypeDocumentation
_selfCylinderNo Documentation 🚧

Returns

NameTypeDocumentation
arg0CircleNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCylinderNo Documentation 🚧
otherCylinderNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

new

Create a new Cylinder from a radius and full height

Arguments

NameTypeDocumentation
radiusf32No Documentation 🚧
heightf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0CylinderNo Documentation 🚧

base_area

Get the surface area of one base of the cylinder

Arguments

NameTypeDocumentation
_selfCylinderNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfCylinderNo Documentation 🚧

Returns

NameTypeDocumentation
arg0CylinderNo Documentation 🚧

InfinitePlane3d

InfinitePlane3d

  • normal:bevy_math::direction::Dir3

Description

An unbounded plane in 3D space. It forms a separating surface through the origin, stretching infinitely far

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
isometry_into_xyComputes an [`Isometry3d`] which transforms points from the plane in 3D space with the given `origin` to the XY-plane. ## Guarantees * the transformation is a [congruence]...
eqNo Documentation 🚧
isometry_from_xyComputes an [`Isometry3d`] which transforms points from the XY-plane to this plane with the given `origin`. ## Guarantees * the transformation is a [congruence]...
cloneNo Documentation 🚧

isometry_into_xy

Computes an [Isometry3d] which transforms points from the plane in 3D space with the given origin to the XY-plane.

Guarantees

  • the transformation is a [congruence] meaning it will preserve all distances and angles of the transformed geometry
  • uses the least rotation possible to transform the geometry
  • if two geometries are transformed with the same isometry, then the relations between them, like distances, are also preserved
  • compared to projections, the transformation is lossless (up to floating point errors) reversible

Non-Guarantees

  • the rotation used is generally not unique
  • the orientation of the transformed geometry in the XY plane might be arbitrary, to enforce some kind of alignment the user has to use an extra transformation ontop of this one See [isometries_xy] for example usescases. [congruence]: https://en.wikipedia.org/wiki/Congruence_(geometry) [isometries_xy]: InfinitePlane3d::isometries_xy

Arguments

NameTypeDocumentation
_selfInfinitePlane3dNo Documentation 🚧
originVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Isometry3dNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfInfinitePlane3dNo Documentation 🚧
otherInfinitePlane3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

isometry_from_xy

Computes an [Isometry3d] which transforms points from the XY-plane to this plane with the given origin.

Guarantees

  • the transformation is a [congruence] meaning it will preserve all distances and angles of the transformed geometry
  • uses the least rotation possible to transform the geometry
  • if two geometries are transformed with the same isometry, then the relations between them, like distances, are also preserved
  • compared to projections, the transformation is lossless (up to floating point errors) reversible

Non-Guarantees

  • the rotation used is generally not unique
  • the orientation of the transformed geometry in the XY plane might be arbitrary, to enforce some kind of alignment the user has to use an extra transformation ontop of this one See [isometries_xy] for example usescases. [congruence]: https://en.wikipedia.org/wiki/Congruence_(geometry) [isometries_xy]: InfinitePlane3d::isometries_xy

Arguments

NameTypeDocumentation
_selfInfinitePlane3dNo Documentation 🚧
originVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Isometry3dNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfInfinitePlane3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0InfinitePlane3dNo Documentation 🚧

Line3d

Line3d

  • direction:bevy_math::direction::Dir3

Description

An infinite line going through the origin along a direction in 3D space.

For a finite line: [Segment3d]

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
eqNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfLine3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Line3dNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfLine3dNo Documentation 🚧
otherLine3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

Plane3d

Plane3d

  • normal:bevy_math::direction::Dir3
  • half_size:glam::Vec2

Description

A bounded plane in 3D space. It forms a surface starting from the origin with a defined height and width.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newCreate a new `Plane3d` from a normal and a half size # Panics Panics if the given `normal` is zer...
cloneNo Documentation 🚧
eqNo Documentation 🚧

new

Create a new Plane3d from a normal and a half size

Panics

Panics if the given normal is zero (or very close to zero), or non-finite.

Arguments

NameTypeDocumentation
normalVec3No Documentation 🚧
half_sizeVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Plane3dNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfPlane3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Plane3dNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfPlane3dNo Documentation 🚧
otherPlane3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

Segment3d

Segment3d

  • direction:bevy_math::direction::Dir3
  • half_length:f32

Description

A segment of a line going through the origin along a direction in 3D space.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
point2Get the position of the second point on the line segment
point1Get the position of the first point on the line segment
cloneNo Documentation 🚧
newCreate a new `Segment3d` from a direction and full length of the segment
eqNo Documentation 🚧

point2

Get the position of the second point on the line segment

Arguments

NameTypeDocumentation
_selfSegment3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

point1

Get the position of the first point on the line segment

Arguments

NameTypeDocumentation
_selfSegment3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfSegment3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Segment3dNo Documentation 🚧

new

Create a new Segment3d from a direction and full length of the segment

Arguments

NameTypeDocumentation
directionDir3No Documentation 🚧
lengthf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Segment3dNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfSegment3dNo Documentation 🚧
otherSegment3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

Sphere

Sphere

  • radius:f32

Description

A sphere primitive, representing the set of all points some distance from the origin

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
diameterGet the diameter of the sphere
newCreate a new [`Sphere`] from a `radius`
eqNo Documentation 🚧
closest_pointFinds the point on the sphere that is closest to the given `point`. If the point is outside the sp...

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfSphereNo Documentation 🚧

Returns

NameTypeDocumentation
arg0SphereNo Documentation 🚧

diameter

Get the diameter of the sphere

Arguments

NameTypeDocumentation
_selfSphereNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

new

Create a new [Sphere] from a radius

Arguments

NameTypeDocumentation
radiusf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0SphereNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfSphereNo Documentation 🚧
otherSphereNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

closest_point

Finds the point on the sphere that is closest to the given point. If the point is outside the sphere, the returned point will be on the surface of the sphere. Otherwise, it will be inside the sphere and returned as is.

Arguments

NameTypeDocumentation
_selfSphereNo Documentation 🚧
pointVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

Tetrahedron

Tetrahedron

  • vertices:[glam::Vec3; 4]

Description

A tetrahedron primitive.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
centroidGet the centroid of the tetrahedron. This function finds the geometric center of the tetrahedron ...
signed_volumeGet the signed volume of the tetrahedron. If it's negative, the normal vector of the face defined ...
newCreate a new [`Tetrahedron`] from points `a`, `b`, `c` and `d`.
eqNo Documentation 🚧
cloneNo Documentation 🚧

centroid

Get the centroid of the tetrahedron. This function finds the geometric center of the tetrahedron by averaging the vertices: centroid = (a + b + c + d) / 4.

Arguments

NameTypeDocumentation
_selfTetrahedronNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

signed_volume

Get the signed volume of the tetrahedron. If it's negative, the normal vector of the face defined by the first three points using the right-hand rule points away from the fourth vertex.

Arguments

NameTypeDocumentation
_selfTetrahedronNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

new

Create a new [Tetrahedron] from points a, b, c and d.

Arguments

NameTypeDocumentation
aVec3No Documentation 🚧
bVec3No Documentation 🚧
cVec3No Documentation 🚧
dVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0TetrahedronNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTetrahedronNo Documentation 🚧
otherTetrahedronNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTetrahedronNo Documentation 🚧

Returns

NameTypeDocumentation
arg0TetrahedronNo Documentation 🚧

Torus

Torus

  • minor_radius:f32
  • major_radius:f32

Description

A torus primitive, often representing a ring or donut shape The set of points some distance from a circle centered at the origin

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
inner_radiusGet the inner radius of the torus. For a ring torus, this corresponds to the radius of the hole, ...
newCreate a new `Torus` from an inner and outer radius. The inner radius is the radius of the hole, a...
outer_radiusGet the outer radius of the torus. This corresponds to the overall radius of the entire object, o...
cloneNo Documentation 🚧
eqNo Documentation 🚧

inner_radius

Get the inner radius of the torus. For a ring torus, this corresponds to the radius of the hole, or major_radius - minor_radius

Arguments

NameTypeDocumentation
_selfTorusNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

new

Create a new Torus from an inner and outer radius. The inner radius is the radius of the hole, and the outer radius is the radius of the entire object

Arguments

NameTypeDocumentation
inner_radiusf32No Documentation 🚧
outer_radiusf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0TorusNo Documentation 🚧

outer_radius

Get the outer radius of the torus. This corresponds to the overall radius of the entire object, or major_radius + minor_radius

Arguments

NameTypeDocumentation
_selfTorusNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTorusNo Documentation 🚧

Returns

NameTypeDocumentation
arg0TorusNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTorusNo Documentation 🚧
otherTorusNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

Triangle3d

Triangle3d

  • vertices:[glam::Vec3; 3]

Description

A 3D triangle primitive.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
is_degenerateChecks if the triangle is degenerate, meaning it has zero area. A triangle is degenerate if the cr...
eqNo Documentation 🚧
is_acuteChecks if the triangle is acute, meaning all angles are less than 90 degrees
circumcenterGet the circumcenter of the triangle.
reverseReverse the triangle by swapping the first and last vertices.
newCreate a new [`Triangle3d`] from points `a`, `b`, and `c`.
reversedThis triangle but reversed.
is_obtuseChecks if the triangle is obtuse, meaning one angle is greater than 90 degrees
centroidGet the centroid of the triangle. This function finds the geometric center of the triangle by aver...
cloneNo Documentation 🚧

is_degenerate

Checks if the triangle is degenerate, meaning it has zero area. A triangle is degenerate if the cross product of the vectors ab and ac has a length less than 10e-7. This indicates that the three vertices are collinear or nearly collinear.

Arguments

NameTypeDocumentation
_selfTriangle3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTriangle3dNo Documentation 🚧
otherTriangle3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_acute

Checks if the triangle is acute, meaning all angles are less than 90 degrees

Arguments

NameTypeDocumentation
_selfTriangle3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

circumcenter

Get the circumcenter of the triangle.

Arguments

NameTypeDocumentation
_selfTriangle3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

reverse

Reverse the triangle by swapping the first and last vertices.

Arguments

NameTypeDocumentation
_selfTriangle3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

new

Create a new [Triangle3d] from points a, b, and c.

Arguments

NameTypeDocumentation
aVec3No Documentation 🚧
bVec3No Documentation 🚧
cVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Triangle3dNo Documentation 🚧

reversed

This triangle but reversed.

Arguments

NameTypeDocumentation
_selfTriangle3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Triangle3dNo Documentation 🚧

is_obtuse

Checks if the triangle is obtuse, meaning one angle is greater than 90 degrees

Arguments

NameTypeDocumentation
_selfTriangle3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

centroid

Get the centroid of the triangle. This function finds the geometric center of the triangle by averaging the vertices: centroid = (a + b + c) / 3.

Arguments

NameTypeDocumentation
_selfTriangle3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTriangle3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Triangle3dNo Documentation 🚧

Ray2d

Ray2d

  • origin:glam::Vec2
  • direction:bevy_math::direction::Dir2

Description

An infinite half-line starting at origin and going in direction in 2D space.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
newCreate a new `Ray2d` from a given origin and direction
eqNo Documentation 🚧
get_pointGet a point at a given distance along the ray
intersect_planeGet the distance to a plane if the ray intersects it

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRay2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Ray2dNo Documentation 🚧

new

Create a new Ray2d from a given origin and direction

Arguments

NameTypeDocumentation
originVec2No Documentation 🚧
directionDir2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Ray2dNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRay2dNo Documentation 🚧
otherRay2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

get_point

Get a point at a given distance along the ray

Arguments

NameTypeDocumentation
_selfRay2dNo Documentation 🚧
distancef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

intersect_plane

Get the distance to a plane if the ray intersects it

Arguments

NameTypeDocumentation
_selfRay2dNo Documentation 🚧
plane_originVec2No Documentation 🚧
planePlane2dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Optional<f32>No Documentation 🚧

Ray3d

Ray3d

  • origin:glam::Vec3
  • direction:bevy_math::direction::Dir3

Description

An infinite half-line starting at origin and going in direction in 3D space.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
get_pointGet a point at a given distance along the ray
intersect_planeGet the distance to a plane if the ray intersects it
newCreate a new `Ray3d` from a given origin and direction
eqNo Documentation 🚧
cloneNo Documentation 🚧

get_point

Get a point at a given distance along the ray

Arguments

NameTypeDocumentation
_selfRay3dNo Documentation 🚧
distancef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

intersect_plane

Get the distance to a plane if the ray intersects it

Arguments

NameTypeDocumentation
_selfRay3dNo Documentation 🚧
plane_originVec3No Documentation 🚧
planeInfinitePlane3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Optional<f32>No Documentation 🚧

new

Create a new Ray3d from a given origin and direction

Arguments

NameTypeDocumentation
originVec3No Documentation 🚧
directionDir3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Ray3dNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRay3dNo Documentation 🚧
otherRay3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRay3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Ray3dNo Documentation 🚧

IRect

IRect

  • min:glam::IVec2
  • max:glam::IVec2

Description

A rectangle defined by two opposite corners.

The rectangle is axis aligned, and defined by its minimum and maximum coordinates, stored in IRect::min and IRect::max, respectively. The minimum/maximum invariant must be upheld by the user when directly assigning the fields, otherwise some methods produce invalid results. It is generally recommended to use one of the constructor methods instead, which will ensure this invariant is met, unless you already have the minimum and maximum corners.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newCreate a new rectangle from two corner points. The two points do not need to be the minimum and/or...
centerThe center point of the rectangle. # Rounding Behavior If the (min + max) contains odd numbers th...
as_rectReturns self as [`Rect`] (f32)
assert_receiver_is_total_eqNo Documentation 🚧
widthRectangle width (max.x - min.x). # Examples ``` # use bevy_math::IRect; let r = IRect::new(0, 0, 5, 1); // w=5 h=1 assert_eq!(r.width(), 5); `...
union_pointBuild a new rectangle formed of the union of this rectangle and a point. The union is the smallest...
from_cornersCreate a new rectangle from two corner points. The two points do not need to be the minimum and/or...
from_center_half_sizeCreate a new rectangle from its center and half-size. # Panics This method panics if any of the c...
heightRectangle height (max.y - min.y). # Examples ``` # use bevy_math::IRect; let r = IRect::new(0, 0, 5, 1); // w=5 h=1 assert_eq!(r.height(), 1); `...
as_urectReturns self as [`URect`] (u32)
containsCheck if a point lies within this rectangle, inclusive of its edges. # Examples ``` # use bevy_math::IRect; let r = IRect::new(0, 0, 5, 1); // w=5 h=1 assert!(r.contains(r.center())); assert!(r.contains(r.min)); assert!(r.contains(r.max)); ```
inflateCreate a new rectangle by expanding it evenly on all sides. A positive expansion value produces a ...
cloneNo Documentation 🚧
sizeRectangle size. # Examples ``` # use bevy_math::{IRect, IVec2}; let r = IRect::new(0, 0, 5, 1); // w=5 h=1 assert_eq!(r.size(), IVec2::new(5, 1)); `...
intersectBuild a new rectangle formed of the intersection of this rectangle and another rectangle. The inte...
unionBuild a new rectangle formed of the union of this rectangle and another rectangle. The union is th...
from_center_sizeCreate a new rectangle from its center and size. # Rounding Behavior If the size contains odd num...
is_emptyCheck if the rectangle is empty. # Examples ``` # use bevy_math::{IRect, IVec2}; let r = IRect::from_corners(IVec2::ZERO, IVec2::new(0, 1)); // w=0 h=1 assert!(r.is_empty()); ```
eqNo Documentation 🚧
half_sizeRectangle half-size. # Rounding Behavior If the full size contains odd numbers they will be round...

new

Create a new rectangle from two corner points. The two points do not need to be the minimum and/or maximum corners. They only need to be two opposite corners.

Examples

# use bevy_math::IRect;
let r = IRect::new(0, 4, 10, 6); // w=10 h=2
let r = IRect::new(2, 3, 5, -1); // w=3 h=4

Arguments

NameTypeDocumentation
x0i32No Documentation 🚧
y0i32No Documentation 🚧
x1i32No Documentation 🚧
y1i32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IRectNo Documentation 🚧

center

The center point of the rectangle.

Rounding Behavior

If the (min + max) contains odd numbers they will be rounded down to the nearest whole number when calculating the center.

Examples

# use bevy_math::{IRect, IVec2};
let r = IRect::new(0, 0, 5, 2); // w=5 h=2
assert_eq!(r.center(), IVec2::new(2, 1));

Arguments

NameTypeDocumentation
_selfIRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

as_rect

Returns self as [Rect] (f32)

Arguments

NameTypeDocumentation
_selfIRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0RectNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

width

Rectangle width (max.x - min.x).

Examples

# use bevy_math::IRect;
let r = IRect::new(0, 0, 5, 1); // w=5 h=1
assert_eq!(r.width(), 5);

Arguments

NameTypeDocumentation
_selfIRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

union_point

Build a new rectangle formed of the union of this rectangle and a point. The union is the smallest rectangle enclosing both the rectangle and the point. If the point is already inside the rectangle, this method returns a copy of the rectangle.

Examples

# use bevy_math::{IRect, IVec2};
let r = IRect::new(0, 0, 5, 1); // w=5 h=1
let u = r.union_point(IVec2::new(3, 6));
assert_eq!(u.min, IVec2::ZERO);
assert_eq!(u.max, IVec2::new(5, 6));

Arguments

NameTypeDocumentation
_selfIRectNo Documentation 🚧
otherIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IRectNo Documentation 🚧

from_corners

Create a new rectangle from two corner points. The two points do not need to be the minimum and/or maximum corners. They only need to be two opposite corners.

Examples

# use bevy_math::{IRect, IVec2};
// Unit rect from [0,0] to [1,1]
let r = IRect::from_corners(IVec2::ZERO, IVec2::ONE); // w=1 h=1
// Same; the points do not need to be ordered
let r = IRect::from_corners(IVec2::ONE, IVec2::ZERO); // w=1 h=1

Arguments

NameTypeDocumentation
p0IVec2No Documentation 🚧
p1IVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IRectNo Documentation 🚧

from_center_half_size

Create a new rectangle from its center and half-size.

Panics

This method panics if any of the components of the half-size is negative.

Examples

# use bevy_math::{IRect, IVec2};
let r = IRect::from_center_half_size(IVec2::ZERO, IVec2::ONE); // w=2 h=2
assert_eq!(r.min, IVec2::splat(-1));
assert_eq!(r.max, IVec2::splat(1));

Arguments

NameTypeDocumentation
originIVec2No Documentation 🚧
half_sizeIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IRectNo Documentation 🚧

height

Rectangle height (max.y - min.y).

Examples

# use bevy_math::IRect;
let r = IRect::new(0, 0, 5, 1); // w=5 h=1
assert_eq!(r.height(), 1);

Arguments

NameTypeDocumentation
_selfIRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

as_urect

Returns self as [URect] (u32)

Arguments

NameTypeDocumentation
_selfIRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0URectNo Documentation 🚧

contains

Check if a point lies within this rectangle, inclusive of its edges.

Examples

# use bevy_math::IRect;
let r = IRect::new(0, 0, 5, 1); // w=5 h=1
assert!(r.contains(r.center()));
assert!(r.contains(r.min));
assert!(r.contains(r.max));

Arguments

NameTypeDocumentation
_selfIRectNo Documentation 🚧
pointIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

inflate

Create a new rectangle by expanding it evenly on all sides. A positive expansion value produces a larger rectangle, while a negative expansion value produces a smaller rectangle. If this would result in zero or negative width or height, [IRect::EMPTY] is returned instead.

Examples

# use bevy_math::{IRect, IVec2};
let r = IRect::new(0, 0, 5, 1); // w=5 h=1
let r2 = r.inflate(3); // w=11 h=7
assert_eq!(r2.min, IVec2::splat(-3));
assert_eq!(r2.max, IVec2::new(8, 4));
let r = IRect::new(0, -1, 4, 3); // w=4 h=4
let r2 = r.inflate(-1); // w=2 h=2
assert_eq!(r2.min, IVec2::new(1, 0));
assert_eq!(r2.max, IVec2::new(3, 2));

Arguments

NameTypeDocumentation
_selfIRectNo Documentation 🚧
expansioni32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IRectNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0IRectNo Documentation 🚧

size

Rectangle size.

Examples

# use bevy_math::{IRect, IVec2};
let r = IRect::new(0, 0, 5, 1); // w=5 h=1
assert_eq!(r.size(), IVec2::new(5, 1));

Arguments

NameTypeDocumentation
_selfIRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

intersect

Build a new rectangle formed of the intersection of this rectangle and another rectangle. The intersection is the largest rectangle enclosed in both rectangles. If the intersection is empty, this method returns an empty rectangle ([IRect::is_empty()] returns true), but the actual values of [IRect::min] and [IRect::max] are implementation-dependent.

Examples

# use bevy_math::{IRect, IVec2};
let r1 = IRect::new(0, 0, 5, 1); // w=5 h=1
let r2 = IRect::new(1, -1, 3, 3); // w=2 h=4
let r = r1.intersect(r2);
assert_eq!(r.min, IVec2::new(1, 0));
assert_eq!(r.max, IVec2::new(3, 1));

Arguments

NameTypeDocumentation
_selfIRectNo Documentation 🚧
otherIRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0IRectNo Documentation 🚧

union

Build a new rectangle formed of the union of this rectangle and another rectangle. The union is the smallest rectangle enclosing both rectangles.

Examples

# use bevy_math::{IRect, IVec2};
let r1 = IRect::new(0, 0, 5, 1); // w=5 h=1
let r2 = IRect::new(1, -1, 3, 3); // w=2 h=4
let r = r1.union(r2);
assert_eq!(r.min, IVec2::new(0, -1));
assert_eq!(r.max, IVec2::new(5, 3));

Arguments

NameTypeDocumentation
_selfIRectNo Documentation 🚧
otherIRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0IRectNo Documentation 🚧

from_center_size

Create a new rectangle from its center and size.

Rounding Behavior

If the size contains odd numbers they will be rounded down to the nearest whole number.

Panics

This method panics if any of the components of the size is negative.

Examples

# use bevy_math::{IRect, IVec2};
let r = IRect::from_center_size(IVec2::ZERO, IVec2::new(3, 2)); // w=2 h=2
assert_eq!(r.min, IVec2::splat(-1));
assert_eq!(r.max, IVec2::splat(1));

Arguments

NameTypeDocumentation
originIVec2No Documentation 🚧
sizeIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IRectNo Documentation 🚧

is_empty

Check if the rectangle is empty.

Examples

# use bevy_math::{IRect, IVec2};
let r = IRect::from_corners(IVec2::ZERO, IVec2::new(0, 1)); // w=0 h=1
assert!(r.is_empty());

Arguments

NameTypeDocumentation
_selfIRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIRectNo Documentation 🚧
otherIRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

half_size

Rectangle half-size.

Rounding Behavior

If the full size contains odd numbers they will be rounded down to the nearest whole number when calculating the half size.

Examples

# use bevy_math::{IRect, IVec2};
let r = IRect::new(0, 0, 4, 3); // w=4 h=3
assert_eq!(r.half_size(), IVec2::new(2, 1));

Arguments

NameTypeDocumentation
_selfIRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

Rect

Rect

  • min:glam::Vec2
  • max:glam::Vec2

Description

A rectangle defined by two opposite corners.

The rectangle is axis aligned, and defined by its minimum and maximum coordinates, stored in Rect::min and Rect::max, respectively. The minimum/maximum invariant must be upheld by the user when directly assigning the fields, otherwise some methods produce invalid results. It is generally recommended to use one of the constructor methods instead, which will ensure this invariant is met, unless you already have the minimum and maximum corners.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_center_sizeCreate a new rectangle from its center and size. # Panics This method panics if any of the compon...
centerThe center point of the rectangle. # Examples ``` # use bevy_math::{Rect, Vec2}; let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 assert!(r.center().abs_diff_eq(Vec2::new(2.5, 0.5), 1e-5)); ```
union_pointBuild a new rectangle formed of the union of this rectangle and a point. The union is the smallest...
heightRectangle height (max.y - min.y). # Examples ``` # use bevy_math::Rect; let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 assert!((r.height() - 1.).abs() <= 1e-5); ```
intersectBuild a new rectangle formed of the intersection of this rectangle and another rectangle. The inte...
is_emptyCheck if the rectangle is empty. # Examples ``` # use bevy_math::{Rect, Vec2}; let r = Rect::from_corners(Vec2::ZERO, Vec2::new(0., 1.)); // w=0 h=1 assert!(r.is_empty()); ```
normalizeBuild a new rectangle from this one with its coordinates expressed relative to `other` in a normal...
newCreate a new rectangle from two corner points. The two points do not need to be the minimum and/or...
eqNo Documentation 🚧
sizeRectangle size. # Examples ``` # use bevy_math::{Rect, Vec2}; let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 assert!(r.size().abs_diff_eq(Vec2::new(5., 1.), 1e-5)); ```
containsCheck if a point lies within this rectangle, inclusive of its edges. # Examples ``` # use bevy_math::Rect; let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 assert!(r.contains(r.center())); assert!(r.contains(r.min)); assert!(r.contains(r.max)); ```
from_center_half_sizeCreate a new rectangle from its center and half-size. # Panics This method panics if any of the c...
widthRectangle width (max.x - min.x). # Examples ``` # use bevy_math::Rect; let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 assert!((r.width() - 5.).abs() <= 1e-5); ```
as_irectReturns self as [`IRect`] (i32)
as_urectReturns self as [`URect`] (u32)
half_sizeRectangle half-size. # Examples ``` # use bevy_math::{Rect, Vec2}; let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 assert!(r.half_size().abs_diff_eq(Vec2::new(2.5, 0.5), 1e-5)); `...
cloneNo Documentation 🚧
inflateCreate a new rectangle by expanding it evenly on all sides. A positive expansion value produces a ...
from_cornersCreate a new rectangle from two corner points. The two points do not need to be the minimum and/or...
unionBuild a new rectangle formed of the union of this rectangle and another rectangle. The union is th...

from_center_size

Create a new rectangle from its center and size.

Panics

This method panics if any of the components of the size is negative.

Examples

# use bevy_math::{Rect, Vec2};
let r = Rect::from_center_size(Vec2::ZERO, Vec2::ONE); // w=1 h=1
assert!(r.min.abs_diff_eq(Vec2::splat(-0.5), 1e-5));
assert!(r.max.abs_diff_eq(Vec2::splat(0.5), 1e-5));

Arguments

NameTypeDocumentation
originVec2No Documentation 🚧
sizeVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0RectNo Documentation 🚧

center

The center point of the rectangle.

Examples

# use bevy_math::{Rect, Vec2};
let r = Rect::new(0., 0., 5., 1.); // w=5 h=1
assert!(r.center().abs_diff_eq(Vec2::new(2.5, 0.5), 1e-5));

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

union_point

Build a new rectangle formed of the union of this rectangle and a point. The union is the smallest rectangle enclosing both the rectangle and the point. If the point is already inside the rectangle, this method returns a copy of the rectangle.

Examples

# use bevy_math::{Rect, Vec2};
let r = Rect::new(0., 0., 5., 1.); // w=5 h=1
let u = r.union_point(Vec2::new(3., 6.));
assert!(u.min.abs_diff_eq(Vec2::ZERO, 1e-5));
assert!(u.max.abs_diff_eq(Vec2::new(5., 6.), 1e-5));

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧
otherVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0RectNo Documentation 🚧

height

Rectangle height (max.y - min.y).

Examples

# use bevy_math::Rect;
let r = Rect::new(0., 0., 5., 1.); // w=5 h=1
assert!((r.height() - 1.).abs() <= 1e-5);

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

intersect

Build a new rectangle formed of the intersection of this rectangle and another rectangle. The intersection is the largest rectangle enclosed in both rectangles. If the intersection is empty, this method returns an empty rectangle ([Rect::is_empty()] returns true), but the actual values of [Rect::min] and [Rect::max] are implementation-dependent.

Examples

# use bevy_math::{Rect, Vec2};
let r1 = Rect::new(0., 0., 5., 1.); // w=5 h=1
let r2 = Rect::new(1., -1., 3., 3.); // w=2 h=4
let r = r1.intersect(r2);
assert!(r.min.abs_diff_eq(Vec2::new(1., 0.), 1e-5));
assert!(r.max.abs_diff_eq(Vec2::new(3., 1.), 1e-5));

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧
otherRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0RectNo Documentation 🚧

is_empty

Check if the rectangle is empty.

Examples

# use bevy_math::{Rect, Vec2};
let r = Rect::from_corners(Vec2::ZERO, Vec2::new(0., 1.)); // w=0 h=1
assert!(r.is_empty());

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

normalize

Build a new rectangle from this one with its coordinates expressed relative to other in a normalized ([0..1] x [0..1]) coordinate system.

Examples

# use bevy_math::{Rect, Vec2};
let r = Rect::new(2., 3., 4., 6.);
let s = Rect::new(0., 0., 10., 10.);
let n = r.normalize(s);
assert_eq!(n.min.x, 0.2);
assert_eq!(n.min.y, 0.3);
assert_eq!(n.max.x, 0.4);
assert_eq!(n.max.y, 0.6);

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧
otherRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0RectNo Documentation 🚧

new

Create a new rectangle from two corner points. The two points do not need to be the minimum and/or maximum corners. They only need to be two opposite corners.

Examples

# use bevy_math::Rect;
let r = Rect::new(0., 4., 10., 6.); // w=10 h=2
let r = Rect::new(2., 3., 5., -1.); // w=3 h=4

Arguments

NameTypeDocumentation
x0f32No Documentation 🚧
y0f32No Documentation 🚧
x1f32No Documentation 🚧
y1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0RectNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧
otherRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

size

Rectangle size.

Examples

# use bevy_math::{Rect, Vec2};
let r = Rect::new(0., 0., 5., 1.); // w=5 h=1
assert!(r.size().abs_diff_eq(Vec2::new(5., 1.), 1e-5));

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

contains

Check if a point lies within this rectangle, inclusive of its edges.

Examples

# use bevy_math::Rect;
let r = Rect::new(0., 0., 5., 1.); // w=5 h=1
assert!(r.contains(r.center()));
assert!(r.contains(r.min));
assert!(r.contains(r.max));

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧
pointVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_center_half_size

Create a new rectangle from its center and half-size.

Panics

This method panics if any of the components of the half-size is negative.

Examples

# use bevy_math::{Rect, Vec2};
let r = Rect::from_center_half_size(Vec2::ZERO, Vec2::ONE); // w=2 h=2
assert!(r.min.abs_diff_eq(Vec2::splat(-1.), 1e-5));
assert!(r.max.abs_diff_eq(Vec2::splat(1.), 1e-5));

Arguments

NameTypeDocumentation
originVec2No Documentation 🚧
half_sizeVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0RectNo Documentation 🚧

width

Rectangle width (max.x - min.x).

Examples

# use bevy_math::Rect;
let r = Rect::new(0., 0., 5., 1.); // w=5 h=1
assert!((r.width() - 5.).abs() <= 1e-5);

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

as_irect

Returns self as [IRect] (i32)

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0IRectNo Documentation 🚧

as_urect

Returns self as [URect] (u32)

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0URectNo Documentation 🚧

half_size

Rectangle half-size.

Examples

# use bevy_math::{Rect, Vec2};
let r = Rect::new(0., 0., 5., 1.); // w=5 h=1
assert!(r.half_size().abs_diff_eq(Vec2::new(2.5, 0.5), 1e-5));

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0RectNo Documentation 🚧

inflate

Create a new rectangle by expanding it evenly on all sides. A positive expansion value produces a larger rectangle, while a negative expansion value produces a smaller rectangle. If this would result in zero or negative width or height, [Rect::EMPTY] is returned instead.

Examples

# use bevy_math::{Rect, Vec2};
let r = Rect::new(0., 0., 5., 1.); // w=5 h=1
let r2 = r.inflate(3.); // w=11 h=7
assert!(r2.min.abs_diff_eq(Vec2::splat(-3.), 1e-5));
assert!(r2.max.abs_diff_eq(Vec2::new(8., 4.), 1e-5));
let r = Rect::new(0., -1., 6., 7.); // w=6 h=8
let r2 = r.inflate(-2.); // w=11 h=7
assert!(r2.min.abs_diff_eq(Vec2::new(2., 1.), 1e-5));
assert!(r2.max.abs_diff_eq(Vec2::new(4., 5.), 1e-5));

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧
expansionf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0RectNo Documentation 🚧

from_corners

Create a new rectangle from two corner points. The two points do not need to be the minimum and/or maximum corners. They only need to be two opposite corners.

Examples

# use bevy_math::{Rect, Vec2};
// Unit rect from [0,0] to [1,1]
let r = Rect::from_corners(Vec2::ZERO, Vec2::ONE); // w=1 h=1
// Same; the points do not need to be ordered
let r = Rect::from_corners(Vec2::ONE, Vec2::ZERO); // w=1 h=1

Arguments

NameTypeDocumentation
p0Vec2No Documentation 🚧
p1Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0RectNo Documentation 🚧

union

Build a new rectangle formed of the union of this rectangle and another rectangle. The union is the smallest rectangle enclosing both rectangles.

Examples

# use bevy_math::{Rect, Vec2};
let r1 = Rect::new(0., 0., 5., 1.); // w=5 h=1
let r2 = Rect::new(1., -1., 3., 3.); // w=2 h=4
let r = r1.union(r2);
assert!(r.min.abs_diff_eq(Vec2::new(0., -1.), 1e-5));
assert!(r.max.abs_diff_eq(Vec2::new(5., 3.), 1e-5));

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧
otherRectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0RectNo Documentation 🚧

URect

URect

  • min:glam::UVec2
  • max:glam::UVec2

Description

A rectangle defined by two opposite corners.

The rectangle is axis aligned, and defined by its minimum and maximum coordinates, stored in URect::min and URect::max, respectively. The minimum/maximum invariant must be upheld by the user when directly assigning the fields, otherwise some methods produce invalid results. It is generally recommended to use one of the constructor methods instead, which will ensure this invariant is met, unless you already have the minimum and maximum corners.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
as_irectReturns self as [`IRect`] (i32)
unionBuild a new rectangle formed of the union of this rectangle and another rectangle. The union is th...
newCreate a new rectangle from two corner points. The two points do not need to be the minimum and/or...
cloneNo Documentation 🚧
inflateCreate a new rectangle by expanding it evenly on all sides. A positive expansion value produces a ...
assert_receiver_is_total_eqNo Documentation 🚧
centerThe center point of the rectangle. # Rounding Behavior If the (min + max) contains odd numbers th...
intersectBuild a new rectangle formed of the intersection of this rectangle and another rectangle. The inte...
half_sizeRectangle half-size. # Rounding Behavior If the full size contains odd numbers they will be round...
from_center_half_sizeCreate a new rectangle from its center and half-size. # Panics This method panics if any of the c...
containsCheck if a point lies within this rectangle, inclusive of its edges. # Examples ``` # use bevy_math::URect; let r = URect::new(0, 0, 5, 1); // w=5 h=1 assert!(r.contains(r.center())); assert!(r.contains(r.min)); assert!(r.contains(r.max)); ```
is_emptyCheck if the rectangle is empty. # Examples ``` # use bevy_math::{URect, UVec2}; let r = URect::from_corners(UVec2::ZERO, UVec2::new(0, 1)); // w=0 h=1 assert!(r.is_empty()); ```
union_pointBuild a new rectangle formed of the union of this rectangle and a point. The union is the smallest...
from_cornersCreate a new rectangle from two corner points. The two points do not need to be the minimum and/or...
widthRectangle width (max.x - min.x). # Examples ``` # use bevy_math::URect; let r = URect::new(0, 0, 5, 1); // w=5 h=1 assert_eq!(r.width(), 5); `...
eqNo Documentation 🚧
as_rectReturns self as [`Rect`] (f32)
from_center_sizeCreate a new rectangle from its center and size. # Rounding Behavior If the size contains odd num...
heightRectangle height (max.y - min.y). # Examples ``` # use bevy_math::URect; let r = URect::new(0, 0, 5, 1); // w=5 h=1 assert_eq!(r.height(), 1); `...
sizeRectangle size. # Examples ``` # use bevy_math::{URect, UVec2}; let r = URect::new(0, 0, 5, 1); // w=5 h=1 assert_eq!(r.size(), UVec2::new(5, 1)); `...

as_irect

Returns self as [IRect] (i32)

Arguments

NameTypeDocumentation
_selfURectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0IRectNo Documentation 🚧

union

Build a new rectangle formed of the union of this rectangle and another rectangle. The union is the smallest rectangle enclosing both rectangles.

Examples

# use bevy_math::{URect, UVec2};
let r1 = URect::new(0, 0, 5, 1); // w=5 h=1
let r2 = URect::new(1, 0, 3, 8); // w=2 h=4
let r = r1.union(r2);
assert_eq!(r.min, UVec2::new(0, 0));
assert_eq!(r.max, UVec2::new(5, 8));

Arguments

NameTypeDocumentation
_selfURectNo Documentation 🚧
otherURectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0URectNo Documentation 🚧

new

Create a new rectangle from two corner points. The two points do not need to be the minimum and/or maximum corners. They only need to be two opposite corners.

Examples

# use bevy_math::URect;
let r = URect::new(0, 4, 10, 6); // w=10 h=2
let r = URect::new(2, 4, 5, 0); // w=3 h=4

Arguments

NameTypeDocumentation
x0u32No Documentation 🚧
y0u32No Documentation 🚧
x1u32No Documentation 🚧
y1u32No Documentation 🚧

Returns

NameTypeDocumentation
arg0URectNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfURectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0URectNo Documentation 🚧

inflate

Create a new rectangle by expanding it evenly on all sides. A positive expansion value produces a larger rectangle, while a negative expansion value produces a smaller rectangle. If this would result in zero width or height, [URect::EMPTY] is returned instead.

Examples

# use bevy_math::{URect, UVec2};
let r = URect::new(4, 4, 6, 6); // w=2 h=2
let r2 = r.inflate(1); // w=4 h=4
assert_eq!(r2.min, UVec2::splat(3));
assert_eq!(r2.max, UVec2::splat(7));
let r = URect::new(4, 4, 8, 8); // w=4 h=4
let r2 = r.inflate(-1); // w=2 h=2
assert_eq!(r2.min, UVec2::splat(5));
assert_eq!(r2.max, UVec2::splat(7));

Arguments

NameTypeDocumentation
_selfURectNo Documentation 🚧
expansioni32No Documentation 🚧

Returns

NameTypeDocumentation
arg0URectNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfURectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

center

The center point of the rectangle.

Rounding Behavior

If the (min + max) contains odd numbers they will be rounded down to the nearest whole number when calculating the center.

Examples

# use bevy_math::{URect, UVec2};
let r = URect::new(0, 0, 4, 2); // w=4 h=2
assert_eq!(r.center(), UVec2::new(2, 1));

Arguments

NameTypeDocumentation
_selfURectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

intersect

Build a new rectangle formed of the intersection of this rectangle and another rectangle. The intersection is the largest rectangle enclosed in both rectangles. If the intersection is empty, this method returns an empty rectangle ([URect::is_empty()] returns true), but the actual values of [URect::min] and [URect::max] are implementation-dependent.

Examples

# use bevy_math::{URect, UVec2};
let r1 = URect::new(0, 0, 2, 2); // w=2 h=2
let r2 = URect::new(1, 1, 3, 3); // w=2 h=2
let r = r1.intersect(r2);
assert_eq!(r.min, UVec2::new(1, 1));
assert_eq!(r.max, UVec2::new(2, 2));

Arguments

NameTypeDocumentation
_selfURectNo Documentation 🚧
otherURectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0URectNo Documentation 🚧

half_size

Rectangle half-size.

Rounding Behavior

If the full size contains odd numbers they will be rounded down to the nearest whole number when calculating the half size.

Examples

# use bevy_math::{URect, UVec2};
let r = URect::new(0, 0, 4, 2); // w=4 h=2
assert_eq!(r.half_size(), UVec2::new(2, 1));

Arguments

NameTypeDocumentation
_selfURectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

from_center_half_size

Create a new rectangle from its center and half-size.

Panics

This method panics if any of the components of the half-size is negative or if origin - half_size results in any negatives.

Examples

# use bevy_math::{URect, UVec2};
let r = URect::from_center_half_size(UVec2::ONE, UVec2::ONE); // w=2 h=2
assert_eq!(r.min, UVec2::splat(0));
assert_eq!(r.max, UVec2::splat(2));

Arguments

NameTypeDocumentation
originUVec2No Documentation 🚧
half_sizeUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0URectNo Documentation 🚧

contains

Check if a point lies within this rectangle, inclusive of its edges.

Examples

# use bevy_math::URect;
let r = URect::new(0, 0, 5, 1); // w=5 h=1
assert!(r.contains(r.center()));
assert!(r.contains(r.min));
assert!(r.contains(r.max));

Arguments

NameTypeDocumentation
_selfURectNo Documentation 🚧
pointUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_empty

Check if the rectangle is empty.

Examples

# use bevy_math::{URect, UVec2};
let r = URect::from_corners(UVec2::ZERO, UVec2::new(0, 1)); // w=0 h=1
assert!(r.is_empty());

Arguments

NameTypeDocumentation
_selfURectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

union_point

Build a new rectangle formed of the union of this rectangle and a point. The union is the smallest rectangle enclosing both the rectangle and the point. If the point is already inside the rectangle, this method returns a copy of the rectangle.

Examples

# use bevy_math::{URect, UVec2};
let r = URect::new(0, 0, 5, 1); // w=5 h=1
let u = r.union_point(UVec2::new(3, 6));
assert_eq!(u.min, UVec2::ZERO);
assert_eq!(u.max, UVec2::new(5, 6));

Arguments

NameTypeDocumentation
_selfURectNo Documentation 🚧
otherUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0URectNo Documentation 🚧

from_corners

Create a new rectangle from two corner points. The two points do not need to be the minimum and/or maximum corners. They only need to be two opposite corners.

Examples

# use bevy_math::{URect, UVec2};
// Unit rect from [0,0] to [1,1]
let r = URect::from_corners(UVec2::ZERO, UVec2::ONE); // w=1 h=1
// Same; the points do not need to be ordered
let r = URect::from_corners(UVec2::ONE, UVec2::ZERO); // w=1 h=1

Arguments

NameTypeDocumentation
p0UVec2No Documentation 🚧
p1UVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0URectNo Documentation 🚧

width

Rectangle width (max.x - min.x).

Examples

# use bevy_math::URect;
let r = URect::new(0, 0, 5, 1); // w=5 h=1
assert_eq!(r.width(), 5);

Arguments

NameTypeDocumentation
_selfURectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfURectNo Documentation 🚧
otherURectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

as_rect

Returns self as [Rect] (f32)

Arguments

NameTypeDocumentation
_selfURectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0RectNo Documentation 🚧

from_center_size

Create a new rectangle from its center and size.

Rounding Behavior

If the size contains odd numbers they will be rounded down to the nearest whole number.

Panics

This method panics if any of the components of the size is negative or if origin - (size / 2) results in any negatives.

Examples

# use bevy_math::{URect, UVec2};
let r = URect::from_center_size(UVec2::ONE, UVec2::splat(2)); // w=2 h=2
assert_eq!(r.min, UVec2::splat(0));
assert_eq!(r.max, UVec2::splat(2));

Arguments

NameTypeDocumentation
originUVec2No Documentation 🚧
sizeUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0URectNo Documentation 🚧

height

Rectangle height (max.y - min.y).

Examples

# use bevy_math::URect;
let r = URect::new(0, 0, 5, 1); // w=5 h=1
assert_eq!(r.height(), 1);

Arguments

NameTypeDocumentation
_selfURectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

size

Rectangle size.

Examples

# use bevy_math::{URect, UVec2};
let r = URect::new(0, 0, 5, 1); // w=5 h=1
assert_eq!(r.size(), UVec2::new(5, 1));

Arguments

NameTypeDocumentation
_selfURectNo Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

Rot2

Rot2

  • cos:f32
  • sin:f32

Description

A counterclockwise 2D rotation.

Example

# use approx::assert_relative_eq;
# use bevy_math::{Rot2, Vec2};
use std::f32::consts::PI;

// Create rotations from radians or degrees
let rotation1 = Rot2::radians(PI / 2.0);
let rotation2 = Rot2::degrees(45.0);

// Get the angle back as radians or degrees
assert_eq!(rotation1.as_degrees(), 90.0);
assert_eq!(rotation2.as_radians(), PI / 4.0);

// "Add" rotations together using `*`
assert_relative_eq!(rotation1 * rotation2, Rot2::degrees(135.0));

// Rotate vectors
assert_relative_eq!(rotation1 * Vec2::X, Vec2::Y);

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
is_nanReturns `true` if the rotation is NaN.
sin_cosReturns the sine and cosine of the rotation angle in radians.
length_squaredComputes the squared length or norm of the complex number used to represent the rotation. This is ...
slerpPerforms a spherical linear interpolation between `self` and `end` based on the value `s`. This c...
as_radiansReturns the rotation in radians in the `(-pi, pi]` range.
nlerpPerforms a linear interpolation between `self` and `rhs` based on the value `s`, and normalizes th...
radiansCreates a [`Rot2`] from a counterclockwise angle in radians. # Note The input rotation will always be clamped to the range `(-π, π]...
turn_fractionCreates a [`Rot2`] from a counterclockwise fraction of a full turn of 360 degrees. # Note The input rotation will always be clamped to the range `(-50%, 50%]...
angle_toReturns the angle in radians needed to make `self` and `other` coincide.
inverseReturns the inverse of the rotation. This is also the conjugate of the unit complex number represe...
mul-1No Documentation 🚧
fast_renormalizeReturns `self` after an approximate normalization, assuming the value is already nearly normalized....
is_finiteReturns `true` if the rotation is neither infinite nor NaN.
mul-2No Documentation 🚧
lengthComputes the length or norm of the complex number used to represent the rotation. The length is ty...
from_sin_cosCreates a [`Rot2`] from the sine and cosine of an angle in radians. The rotation is only valid if `sin * sin + cos * cos == 1.0`. # Panics Panics if `sin * sin + cos * cos != 1.0` when the `glam_assert` feature is enabled.
normalizeReturns `self` with a length of `1.0`. Note that [`Rot2`] should typically already be normalized by design. Manual normalization is only needed when successive operations result in accumulated floating point error, or if the rotation was constructed with invalid values. # Panics Panics if `self` has a length of zero, NaN, or infinity when debug assertions are enabled.
degreesCreates a [`Rot2`] from a counterclockwise angle in degrees. # Note The input rotation will always be clamped to the range `(-180°, 180°]...
as_turn_fractionReturns the rotation as a fraction of a full 360 degree turn.
cloneNo Documentation 🚧
eqNo Documentation 🚧
is_near_identityReturns `true` if the rotation is near [`Rot2::IDENTITY`].
length_recipComputes `1.0 / self.length()`. For valid results, `self` must _not_ have a length of zero.
as_degreesReturns the rotation in degrees in the `(-180, 180]` range.
angle_betweenReturns the angle in radians needed to make `self` and `other` coincide.
mulNo Documentation 🚧
is_normalizedReturns whether `self` has a length of `1.0` or not. Uses a precision threshold of approximately `1e-4`...

is_nan

Returns true if the rotation is NaN.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

sin_cos

Returns the sine and cosine of the rotation angle in radians.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0(f32, f32)No Documentation 🚧

length_squared

Computes the squared length or norm of the complex number used to represent the rotation. This is generally faster than [Rot2::length()], as it avoids a square root operation. The length is typically expected to be 1.0. Unexpectedly denormalized rotations can be a result of incorrect construction or floating point error caused by successive operations.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

slerp

Performs a spherical linear interpolation between self and end based on the value s. This corresponds to interpolating between the two angles at a constant angular velocity. When s == 0.0, the result will be equal to self. When s == 1.0, the result will be equal to rhs. If you would like the rotation to have a kind of ease-in-out effect, consider using the slightly more efficient nlerp instead.

Example

# use bevy_math::Rot2;
#
let rot1 = Rot2::IDENTITY;
let rot2 = Rot2::degrees(135.0);
let result1 = rot1.slerp(rot2, 1.0 / 3.0);
assert_eq!(result1.as_degrees(), 45.0);
let result2 = rot1.slerp(rot2, 0.5);
assert_eq!(result2.as_degrees(), 67.5);

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧
endRot2No Documentation 🚧
sf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Rot2No Documentation 🚧

as_radians

Returns the rotation in radians in the (-pi, pi] range.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

nlerp

Performs a linear interpolation between self and rhs based on the value s, and normalizes the rotation afterwards. When s == 0.0, the result will be equal to self. When s == 1.0, the result will be equal to rhs. This is slightly more efficient than slerp, and produces a similar result when the difference between the two rotations is small. At larger differences, the result resembles a kind of ease-in-out effect. If you would like the angular velocity to remain constant, consider using slerp instead.

Details

nlerp corresponds to computing an angle for a point at position s on a line drawn between the endpoints of the arc formed by self and rhs on a unit circle, and normalizing the result afterwards. Note that if the angles are opposite like 0 and π, the line will pass through the origin, and the resulting angle will always be either self or rhs depending on s. If s happens to be 0.5 in this case, a valid rotation cannot be computed, and self will be returned as a fallback.

Example

# use bevy_math::Rot2;
#
let rot1 = Rot2::IDENTITY;
let rot2 = Rot2::degrees(135.0);
let result1 = rot1.nlerp(rot2, 1.0 / 3.0);
assert_eq!(result1.as_degrees(), 28.675055);
let result2 = rot1.nlerp(rot2, 0.5);
assert_eq!(result2.as_degrees(), 67.5);

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧
endRot2No Documentation 🚧
sf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Rot2No Documentation 🚧

radians

Creates a [Rot2] from a counterclockwise angle in radians.

Note

The input rotation will always be clamped to the range (-π, π] by design.

Example

# use bevy_math::Rot2;
# use approx::assert_relative_eq;
# use std::f32::consts::{FRAC_PI_2, PI};
let rot1 = Rot2::radians(3.0 * FRAC_PI_2);
let rot2 = Rot2::radians(-FRAC_PI_2);
assert_relative_eq!(rot1, rot2);
let rot3 = Rot2::radians(PI);
assert_relative_eq!(rot1 * rot1, rot3);

Arguments

NameTypeDocumentation
radiansf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Rot2No Documentation 🚧

turn_fraction

Creates a [Rot2] from a counterclockwise fraction of a full turn of 360 degrees.

Note

The input rotation will always be clamped to the range (-50%, 50%] by design.

Example

# use bevy_math::Rot2;
# use approx::assert_relative_eq;
let rot1 = Rot2::turn_fraction(0.75);
let rot2 = Rot2::turn_fraction(-0.25);
assert_relative_eq!(rot1, rot2);
let rot3 = Rot2::turn_fraction(0.5);
assert_relative_eq!(rot1 * rot1, rot3);

Arguments

NameTypeDocumentation
fractionf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Rot2No Documentation 🚧

angle_to

Returns the angle in radians needed to make self and other coincide.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧
otherRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

inverse

Returns the inverse of the rotation. This is also the conjugate of the unit complex number representing the rotation.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Rot2No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Rot2No Documentation 🚧
arg1Dir2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir2No Documentation 🚧

fast_renormalize

Returns self after an approximate normalization, assuming the value is already nearly normalized. Useful for preventing numerical error accumulation. See Dir3::fast_renormalize for an example of when such error accumulation might occur.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Rot2No Documentation 🚧

is_finite

Returns true if the rotation is neither infinite nor NaN.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Rot2No Documentation 🚧
arg1Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

length

Computes the length or norm of the complex number used to represent the rotation. The length is typically expected to be 1.0. Unexpectedly denormalized rotations can be a result of incorrect construction or floating point error caused by successive operations.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

from_sin_cos

Creates a [Rot2] from the sine and cosine of an angle in radians. The rotation is only valid if sin * sin + cos * cos == 1.0.

Panics

Panics if sin * sin + cos * cos != 1.0 when the glam_assert feature is enabled.

Arguments

NameTypeDocumentation
sinf32No Documentation 🚧
cosf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Rot2No Documentation 🚧

normalize

Returns self with a length of 1.0. Note that [Rot2] should typically already be normalized by design. Manual normalization is only needed when successive operations result in accumulated floating point error, or if the rotation was constructed with invalid values.

Panics

Panics if self has a length of zero, NaN, or infinity when debug assertions are enabled.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Rot2No Documentation 🚧

degrees

Creates a [Rot2] from a counterclockwise angle in degrees.

Note

The input rotation will always be clamped to the range (-180°, 180°] by design.

Example

# use bevy_math::Rot2;
# use approx::assert_relative_eq;
let rot1 = Rot2::degrees(270.0);
let rot2 = Rot2::degrees(-90.0);
assert_relative_eq!(rot1, rot2);
let rot3 = Rot2::degrees(180.0);
assert_relative_eq!(rot1 * rot1, rot3);

Arguments

NameTypeDocumentation
degreesf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Rot2No Documentation 🚧

as_turn_fraction

Returns the rotation as a fraction of a full 360 degree turn.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Rot2No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧
otherRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_near_identity

Returns true if the rotation is near [Rot2::IDENTITY].

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

length_recip

Computes 1.0 / self.length(). For valid results, self must not have a length of zero.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

as_degrees

Returns the rotation in degrees in the (-180, 180] range.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

angle_between

Returns the angle in radians needed to make self and other coincide.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧
otherRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧
rhsRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Rot2No Documentation 🚧

is_normalized

Returns whether self has a length of 1.0 or not. Uses a precision threshold of approximately 1e-4.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

Fixed

Fixed

  • timestep:bevy_utils::Duration
  • overstep:bevy_utils::Duration

Description

The fixed timestep game clock following virtual time.

A specialization of the [Time] structure. For method documentation, see [Time<Fixed>#impl-Time<Fixed>].

It is automatically inserted as a resource by TimePlugin and updated based on Time<Virtual>. The fixed clock is automatically set as the generic [Time] resource during FixedUpdate schedule processing.

The fixed timestep clock advances in fixed-size increments, which is extremely useful for writing logic (like physics) that should have consistent behavior, regardless of framerate.

The default timestep() is 64 hertz, or 15625 microseconds. This value was chosen because using 60 hertz has the potential for a pathological interaction with the monitor refresh rate where the game alternates between running two fixed timesteps and zero fixed timesteps per frame (for example when running two fixed timesteps takes longer than a frame). Additionally, the value is a power of two which losslessly converts into [f32] and [f64].

To run a system on a fixed timestep, add it to one of the [FixedMain] schedules, most commonly FixedUpdate.

This schedule is run a number of times between PreUpdate and Update according to the accumulated overstep() time divided by the timestep(). This means the schedule may run 0, 1 or more times during a single update (which typically corresponds to a rendered frame).

Time<Fixed> and the generic [Time] resource will report a delta() equal to timestep() and always grow elapsed() by one timestep() per iteration.

The fixed timestep clock follows the Time<Virtual> clock, which means it is affected by pause(), set_relative_speed() and set_max_delta() from virtual time. If the virtual clock is paused, the FixedUpdate schedule will not run. It is guaranteed that the elapsed() time in Time<Fixed> is always between the previous elapsed() and the current elapsed() value in Time<Virtual>, so the values are compatible.

Changing the timestep size while the game is running should not normally be done, as having a regular interval is the point of this schedule, but it may be necessary for effects like "bullet-time" if the normal granularity of the fixed timestep is too big for the slowed down time. In this case, set_timestep() and be called to set a new value. The new value will be used immediately for the next run of the FixedUpdate schedule, meaning that it will affect the delta() value for the very next FixedUpdate, even if it is still during the same frame. Any overstep() present in the accumulator will be processed according to the new timestep() value.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfFixedNo Documentation 🚧

Returns

NameTypeDocumentation
arg0FixedNo Documentation 🚧

Real

Real

  • startup:bevy_utils::Instant
  • first_update:core::option::Option<bevy_utils::Instant>
  • last_update:core::option::Option<bevy_utils::Instant>

Description

Real time clock representing elapsed wall clock time.

A specialization of the [Time] structure. For method documentation, see [Time<Real>#impl-Time<Real>].

It is automatically inserted as a resource by TimePlugin and updated with time instants according to TimeUpdateStrategy.1

Note: Using TimeUpdateStrategy::ManualDuration allows for mocking the wall clock for testing purposes. Besides this use case, it is not recommended to do this, as it will no longer represent "wall clock" time as intended.

The delta() and elapsed() values of this clock should be used for anything which deals specifically with real time (wall clock time). It will not be affected by relative game speed adjustments, pausing or other adjustments.1

The clock does not count time from startup() to first_update() into elapsed, but instead will start counting time from the first update call. delta() and elapsed() will report zero on the first update as there is no previous update instant. This means that a delta() of zero must be handled without errors in application logic, as it may theoretically also happen at other times.

[Instant]s for startup(), first_update() and last_update() are recorded and accessible.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧

  1. When using TimeUpdateStrategy::ManualDuration, [Time<Real>#impl-Time<Real>] is only a mock of wall clock time. ↩2

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRealNo Documentation 🚧

Returns

NameTypeDocumentation
arg0RealNo Documentation 🚧

Stopwatch

Stopwatch

  • elapsed:bevy_utils::Duration
  • is_paused:bool

Description

A Stopwatch is a struct that tracks elapsed time when started.

Note that in order to advance the stopwatch tick MUST be called.

Examples

# use bevy_time::*;
use std::time::Duration;
let mut stopwatch = Stopwatch::new();
assert_eq!(stopwatch.elapsed_secs(), 0.0);

stopwatch.tick(Duration::from_secs_f32(1.0)); // tick one second
assert_eq!(stopwatch.elapsed_secs(), 1.0);

stopwatch.pause();
stopwatch.tick(Duration::from_secs_f32(1.0)); // paused stopwatches don't tick
assert_eq!(stopwatch.elapsed_secs(), 1.0);

stopwatch.reset(); // reset the stopwatch
assert!(stopwatch.is_paused());
assert_eq!(stopwatch.elapsed_secs(), 0.0);

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
elapsed_secsReturns the elapsed time since the last [`reset`](Stopwatch::reset) of the stopwatch, in seconds. # Examples ``` # use bevy_time::*; use std::time::Duration; let mut stopwatch = Stopwatch::new(); stopwatch.tick(Duration::from_secs(1)); assert_eq!(stopwatch.elapsed_secs(), 1.0); ``` # See Also [`elapsed`](Stopwatch::elapsed)...
elapsedReturns the elapsed time since the last [`reset`](Stopwatch::reset) of the stopwatch. # Examples ``` # use bevy_time::*; use std::time::Duration; let mut stopwatch = Stopwatch::new(); stopwatch.tick(Duration::from_secs(1)); assert_eq!(stopwatch.elapsed(), Duration::from_secs(1)); ``` # See Also [`elapsed_secs`](Stopwatch::elapsed_secs)...
unpauseUnpauses the stopwatch. Resume the effect of ticking on elapsed time. # Examples ``` # use bevy_time::*; use std::time::Duration; let mut stopwatch = Stopwatch::new(); stopwatch.pause(); stopwatch.tick(Duration::from_secs_f32(1.0)); stopwatch.unpause(); stopwatch.tick(Duration::from_secs_f32(1.0)); assert!(!stopwatch.is_paused()); assert_eq!(stopwatch.elapsed_secs(), 1.0); ```
set_elapsedSets the elapsed time of the stopwatch. # Examples ``` # use bevy_time::*; use std::time::Duration; let mut stopwatch = Stopwatch::new(); stopwatch.set_elapsed(Duration::from_secs_f32(1.0)); assert_eq!(stopwatch.elapsed_secs(), 1.0); ```
is_pausedReturns `true` if the stopwatch is paused. # Examples ``` # use bevy_time::*; let mut stopwatch = Stopwatch::new(); assert!(!stopwatch.is_paused()); stopwatch.pause(); assert!(stopwatch.is_paused()); stopwatch.unpause(); assert!(!stopwatch.is_paused()); ```
eqNo Documentation 🚧
pausePauses the stopwatch. Any call to [`tick`](Stopwatch::tick) while paused will not have any effect on the elapsed time. # Examples ``` # use bevy_time::*; use std::time::Duration; let mut stopwatch = Stopwatch::new(); stopwatch.pause(); stopwatch.tick(Duration::from_secs_f32(1.5)); assert!(stopwatch.is_paused()); assert_eq!(stopwatch.elapsed_secs(), 0.0); ```
cloneNo Documentation 🚧
resetResets the stopwatch. The reset doesn't affect the paused state of the stopwatch. # Examples ``` # use bevy_time::*; use std::time::Duration; let mut stopwatch = Stopwatch::new(); stopwatch.tick(Duration::from_secs_f32(1.5)); stopwatch.reset(); assert_eq!(stopwatch.elapsed_secs(), 0.0); ```
newCreate a new unpaused `Stopwatch` with no elapsed time. # Examples ``` # use bevy_time::*; let stopwatch = Stopwatch::new(); assert_eq!(stopwatch.elapsed_secs(), 0.0); assert_eq!(stopwatch.is_paused(), false); ```
elapsed_secs_f64Returns the elapsed time since the last [`reset`](Stopwatch::reset) of the stopwatch, in seconds, as f64. # See Also [`elapsed`](Stopwatch::elapsed)...
assert_receiver_is_total_eqNo Documentation 🚧

elapsed_secs

Returns the elapsed time since the last reset of the stopwatch, in seconds.

Examples

# use bevy_time::*;
use std::time::Duration;
let mut stopwatch = Stopwatch::new();
stopwatch.tick(Duration::from_secs(1));
assert_eq!(stopwatch.elapsed_secs(), 1.0);

See Also

elapsed - if a Duration is desirable instead. elapsed_secs_f64 - if an f64 is desirable instead.

Arguments

NameTypeDocumentation
_selfStopwatchNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

elapsed

Returns the elapsed time since the last reset of the stopwatch.

Examples

# use bevy_time::*;
use std::time::Duration;
let mut stopwatch = Stopwatch::new();
stopwatch.tick(Duration::from_secs(1));
assert_eq!(stopwatch.elapsed(), Duration::from_secs(1));

See Also

elapsed_secs - if an f32 value is desirable instead. elapsed_secs_f64 - if an f64 is desirable instead.

Arguments

NameTypeDocumentation
_selfStopwatchNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

unpause

Unpauses the stopwatch. Resume the effect of ticking on elapsed time.

Examples

# use bevy_time::*;
use std::time::Duration;
let mut stopwatch = Stopwatch::new();
stopwatch.pause();
stopwatch.tick(Duration::from_secs_f32(1.0));
stopwatch.unpause();
stopwatch.tick(Duration::from_secs_f32(1.0));
assert!(!stopwatch.is_paused());
assert_eq!(stopwatch.elapsed_secs(), 1.0);

Arguments

NameTypeDocumentation
_selfStopwatchNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

set_elapsed

Sets the elapsed time of the stopwatch.

Examples

# use bevy_time::*;
use std::time::Duration;
let mut stopwatch = Stopwatch::new();
stopwatch.set_elapsed(Duration::from_secs_f32(1.0));
assert_eq!(stopwatch.elapsed_secs(), 1.0);

Arguments

NameTypeDocumentation
_selfStopwatchNo Documentation 🚧
timeDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

is_paused

Returns true if the stopwatch is paused.

Examples

# use bevy_time::*;
let mut stopwatch = Stopwatch::new();
assert!(!stopwatch.is_paused());
stopwatch.pause();
assert!(stopwatch.is_paused());
stopwatch.unpause();
assert!(!stopwatch.is_paused());

Arguments

NameTypeDocumentation
_selfStopwatchNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfStopwatchNo Documentation 🚧
otherStopwatchNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

pause

Pauses the stopwatch. Any call to tick while paused will not have any effect on the elapsed time.

Examples

# use bevy_time::*;
use std::time::Duration;
let mut stopwatch = Stopwatch::new();
stopwatch.pause();
stopwatch.tick(Duration::from_secs_f32(1.5));
assert!(stopwatch.is_paused());
assert_eq!(stopwatch.elapsed_secs(), 0.0);

Arguments

NameTypeDocumentation
_selfStopwatchNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfStopwatchNo Documentation 🚧

Returns

NameTypeDocumentation
arg0StopwatchNo Documentation 🚧

reset

Resets the stopwatch. The reset doesn't affect the paused state of the stopwatch.

Examples

# use bevy_time::*;
use std::time::Duration;
let mut stopwatch = Stopwatch::new();
stopwatch.tick(Duration::from_secs_f32(1.5));
stopwatch.reset();
assert_eq!(stopwatch.elapsed_secs(), 0.0);

Arguments

NameTypeDocumentation
_selfStopwatchNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

new

Create a new unpaused Stopwatch with no elapsed time.

Examples

# use bevy_time::*;
let stopwatch = Stopwatch::new();
assert_eq!(stopwatch.elapsed_secs(), 0.0);
assert_eq!(stopwatch.is_paused(), false);

Arguments

Returns

NameTypeDocumentation
arg0StopwatchNo Documentation 🚧

elapsed_secs_f64

Returns the elapsed time since the last reset of the stopwatch, in seconds, as f64.

See Also

elapsed - if a Duration is desirable instead. elapsed_secs - if an f32 is desirable instead.

Arguments

NameTypeDocumentation
_selfStopwatchNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfStopwatchNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

Timer

Timer

  • stopwatch:bevy_time::stopwatch::Stopwatch
  • duration:bevy_utils::Duration
  • mode:bevy_time::timer::TimerMode
  • finished:bool
  • times_finished_this_tick:u32

Description

Tracks elapsed time. Enters the finished state once duration is reached.

Non repeating timers will stop tracking and stay in the finished state until reset. Repeating timers will only be in the finished state on each tick duration is reached or exceeded, and can still be reset at any given point.

Paused timers will not have elapsed time increased.

Note that in order to advance the timer tick MUST be called.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
elapsed_secs_f64Returns the time elapsed on the timer as an `f64`. See also [`Timer::elapsed`](Timer::elapsed).
newCreates a new timer with a given duration. See also [`Timer::from_seconds`](Timer::from_seconds).
modeReturns the mode of the timer. # Examples ``` # use bevy_time::*; let mut timer = Timer::from_seconds(1.0, TimerMode::Repeating); assert_eq!(timer.mode(), TimerMode::Repeating); ```
unpauseUnpauses the Timer. Resumes the ticking of the timer. See also [`Stopwatch::unpause()`](Stopwatch::unpause). # Examples ``` # use bevy_time::*; use std::time::Duration; let mut timer = Timer::from_seconds(1.0, TimerMode::Once); timer.pause(); timer.tick(Duration::from_secs_f32(0.5)); timer.unpause(); timer.tick(Duration::from_secs_f32(0.5)); assert_eq!(timer.elapsed_secs(), 0.5); ```
fraction_remainingReturns the fraction of the timer remaining time (goes from 1.0 to 0.0). # Examples ``` # use bevy_time::*; use std::time::Duration; let mut timer = Timer::from_seconds(2.0, TimerMode::Once); timer.tick(Duration::from_secs_f32(0.5)); assert_eq!(timer.fraction_remaining(), 0.75); ```
elapsed_secsReturns the time elapsed on the timer as an `f32`. See also [`Timer::elapsed`](Timer::elapsed).
elapsedReturns the time elapsed on the timer. Guaranteed to be between 0.0 and `duration`. Will only equa...
resetResets the timer. The reset doesn't affect the `paused` state of the timer. See also [`Stopwatch::reset`](Stopwatch::reset)...
pausedReturns `true` if the timer is paused. See also [`Stopwatch::is_paused`](Stopwatch::is_paused). # Examples ``` # use bevy_time::*; let mut timer = Timer::from_seconds(1.0, TimerMode::Once); assert!(!timer.paused()); timer.pause(); assert!(timer.paused()); timer.unpause(); assert!(!timer.paused()); ```
from_secondsCreates a new timer with a given duration in seconds. # Example ``` # use bevy_time::*; let mut timer = Timer::from_seconds(1.0, TimerMode::Once); ```
just_finishedReturns `true` only on the tick the timer reached its duration. # Examples ``` # use bevy_time::*; use std::time::Duration; let mut timer = Timer::from_seconds(1.0, TimerMode::Once); timer.tick(Duration::from_secs_f32(1.5)); assert!(timer.just_finished()); timer.tick(Duration::from_secs_f32(0.5)); assert!(!timer.just_finished()); ```
finishedReturns `true` if the timer has reached its duration. For repeating timers, this method behaves id...
cloneNo Documentation 🚧
set_durationSets the duration of the timer. # Examples ``` # use bevy_time::*; use std::time::Duration; let mut timer = Timer::from_seconds(1.5, TimerMode::Once); timer.set_duration(Duration::from_secs(1)); assert_eq!(timer.duration(), Duration::from_secs(1)); ```
pausePauses the Timer. Disables the ticking of the timer. See also [`Stopwatch::pause`](Stopwatch::pause). # Examples ``` # use bevy_time::*; use std::time::Duration; let mut timer = Timer::from_seconds(1.0, TimerMode::Once); timer.pause(); timer.tick(Duration::from_secs_f32(0.5)); assert_eq!(timer.elapsed_secs(), 0.0); ```
durationReturns the duration of the timer. # Examples ``` # use bevy_time::*; use std::time::Duration; let timer = Timer::new(Duration::from_secs(1), TimerMode::Once); assert_eq!(timer.duration(), Duration::from_secs(1)); ```
times_finished_this_tickReturns the number of times a repeating timer finished during the last [`tick`](Timer::tick) call. For non repeating-timers, this method will only ever return 0 or 1. # Examples ``` # use bevy_time::*; use std::time::Duration; let mut timer = Timer::from_seconds(1.0, TimerMode::Repeating); timer.tick(Duration::from_secs_f32(6.0)); assert_eq!(timer.times_finished_this_tick(), 6); timer.tick(Duration::from_secs_f32(2.0)); assert_eq!(timer.times_finished_this_tick(), 2); timer.tick(Duration::from_secs_f32(0.5)); assert_eq!(timer.times_finished_this_tick(), 0); ```
assert_receiver_is_total_eqNo Documentation 🚧
remainingReturns the remaining time using Duration # Examples ``` # use bevy_time::*; use std::time::Duration; let mut timer = Timer::from_seconds(2.0, TimerMode::Once); timer.tick(Duration::from_secs_f32(0.5)); assert_eq!(timer.remaining(), Duration::from_secs_f32(1.5)); ```
remaining_secsReturns the remaining time in seconds # Examples ``` # use bevy_time::*; use std::cmp::Ordering; use std::time::Duration; let mut timer = Timer::from_seconds(2.0, TimerMode::Once); timer.tick(Duration::from_secs_f32(0.5)); let result = timer.remaining_secs().total_cmp(&1.5); assert_eq!(Ordering::Equal, result); ```
set_elapsedSets the elapsed time of the timer without any other considerations. See also [`Stopwatch::set`](Stopwatch::set). # ``` # use bevy_time::*; use std::time::Duration; let mut timer = Timer::from_seconds(1.0, TimerMode::Once); timer.set_elapsed(Duration::from_secs(2)); assert_eq!(timer.elapsed(), Duration::from_secs(2)); // the timer is not finished even if the elapsed time is greater than the duration. assert!(!timer.finished()); ```
eqNo Documentation 🚧
set_modeSets the mode of the timer. # Examples ``` # use bevy_time::*; let mut timer = Timer::from_seconds(1.0, TimerMode::Repeating); timer.set_mode(TimerMode::Once); assert_eq!(timer.mode(), TimerMode::Once); ```
fractionReturns the fraction of the timer elapsed time (goes from 0.0 to 1.0). # Examples ``` # use bevy_time::*; use std::time::Duration; let mut timer = Timer::from_seconds(2.0, TimerMode::Once); timer.tick(Duration::from_secs_f32(0.5)); assert_eq!(timer.fraction(), 0.25); ```

elapsed_secs_f64

Returns the time elapsed on the timer as an f64. See also Timer::elapsed.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

new

Creates a new timer with a given duration. See also Timer::from_seconds.

Arguments

NameTypeDocumentation
durationDurationNo Documentation 🚧
modeTimerModeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0TimerNo Documentation 🚧

mode

Returns the mode of the timer.

Examples

# use bevy_time::*;
let mut timer = Timer::from_seconds(1.0, TimerMode::Repeating);
assert_eq!(timer.mode(), TimerMode::Repeating);

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
arg0TimerModeNo Documentation 🚧

unpause

Unpauses the Timer. Resumes the ticking of the timer. See also Stopwatch::unpause().

Examples

# use bevy_time::*;
use std::time::Duration;
let mut timer = Timer::from_seconds(1.0, TimerMode::Once);
timer.pause();
timer.tick(Duration::from_secs_f32(0.5));
timer.unpause();
timer.tick(Duration::from_secs_f32(0.5));
assert_eq!(timer.elapsed_secs(), 0.5);

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

fraction_remaining

Returns the fraction of the timer remaining time (goes from 1.0 to 0.0).

Examples

# use bevy_time::*;
use std::time::Duration;
let mut timer = Timer::from_seconds(2.0, TimerMode::Once);
timer.tick(Duration::from_secs_f32(0.5));
assert_eq!(timer.fraction_remaining(), 0.75);

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

elapsed_secs

Returns the time elapsed on the timer as an f32. See also Timer::elapsed.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

elapsed

Returns the time elapsed on the timer. Guaranteed to be between 0.0 and duration. Will only equal duration when the timer is finished and non repeating. See also Stopwatch::elapsed.

Examples

# use bevy_time::*;
use std::time::Duration;
let mut timer = Timer::from_seconds(1.0, TimerMode::Once);
timer.tick(Duration::from_secs_f32(0.5));
assert_eq!(timer.elapsed(), Duration::from_secs_f32(0.5));

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

reset

Resets the timer. The reset doesn't affect the paused state of the timer. See also Stopwatch::reset. Examples

# use bevy_time::*;
use std::time::Duration;
let mut timer = Timer::from_seconds(1.0, TimerMode::Once);
timer.tick(Duration::from_secs_f32(1.5));
timer.reset();
assert!(!timer.finished());
assert!(!timer.just_finished());
assert_eq!(timer.elapsed_secs(), 0.0);

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

paused

Returns true if the timer is paused. See also Stopwatch::is_paused.

Examples

# use bevy_time::*;
let mut timer = Timer::from_seconds(1.0, TimerMode::Once);
assert!(!timer.paused());
timer.pause();
assert!(timer.paused());
timer.unpause();
assert!(!timer.paused());

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_seconds

Creates a new timer with a given duration in seconds.

Example

# use bevy_time::*;
let mut timer = Timer::from_seconds(1.0, TimerMode::Once);

Arguments

NameTypeDocumentation
durationf32No Documentation 🚧
modeTimerModeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0TimerNo Documentation 🚧

just_finished

Returns true only on the tick the timer reached its duration.

Examples

# use bevy_time::*;
use std::time::Duration;
let mut timer = Timer::from_seconds(1.0, TimerMode::Once);
timer.tick(Duration::from_secs_f32(1.5));
assert!(timer.just_finished());
timer.tick(Duration::from_secs_f32(0.5));
assert!(!timer.just_finished());

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

finished

Returns true if the timer has reached its duration. For repeating timers, this method behaves identically to [Timer::just_finished].

Examples

# use bevy_time::*;
use std::time::Duration;
let mut timer_once = Timer::from_seconds(1.0, TimerMode::Once);
timer_once.tick(Duration::from_secs_f32(1.5));
assert!(timer_once.finished());
timer_once.tick(Duration::from_secs_f32(0.5));
assert!(timer_once.finished());
let mut timer_repeating = Timer::from_seconds(1.0, TimerMode::Repeating);
timer_repeating.tick(Duration::from_secs_f32(1.1));
assert!(timer_repeating.finished());
timer_repeating.tick(Duration::from_secs_f32(0.8));
assert!(!timer_repeating.finished());
timer_repeating.tick(Duration::from_secs_f32(0.6));
assert!(timer_repeating.finished());

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
arg0TimerNo Documentation 🚧

set_duration

Sets the duration of the timer.

Examples

# use bevy_time::*;
use std::time::Duration;
let mut timer = Timer::from_seconds(1.5, TimerMode::Once);
timer.set_duration(Duration::from_secs(1));
assert_eq!(timer.duration(), Duration::from_secs(1));

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧
durationDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

pause

Pauses the Timer. Disables the ticking of the timer. See also Stopwatch::pause.

Examples

# use bevy_time::*;
use std::time::Duration;
let mut timer = Timer::from_seconds(1.0, TimerMode::Once);
timer.pause();
timer.tick(Duration::from_secs_f32(0.5));
assert_eq!(timer.elapsed_secs(), 0.0);

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

duration

Returns the duration of the timer.

Examples

# use bevy_time::*;
use std::time::Duration;
let timer = Timer::new(Duration::from_secs(1), TimerMode::Once);
assert_eq!(timer.duration(), Duration::from_secs(1));

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

times_finished_this_tick

Returns the number of times a repeating timer finished during the last tick call. For non repeating-timers, this method will only ever return 0 or 1.

Examples

# use bevy_time::*;
use std::time::Duration;
let mut timer = Timer::from_seconds(1.0, TimerMode::Repeating);
timer.tick(Duration::from_secs_f32(6.0));
assert_eq!(timer.times_finished_this_tick(), 6);
timer.tick(Duration::from_secs_f32(2.0));
assert_eq!(timer.times_finished_this_tick(), 2);
timer.tick(Duration::from_secs_f32(0.5));
assert_eq!(timer.times_finished_this_tick(), 0);

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

remaining

Returns the remaining time using Duration

Examples

# use bevy_time::*;
use std::time::Duration;
let mut timer = Timer::from_seconds(2.0, TimerMode::Once);
timer.tick(Duration::from_secs_f32(0.5));
assert_eq!(timer.remaining(), Duration::from_secs_f32(1.5));

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

remaining_secs

Returns the remaining time in seconds

Examples

# use bevy_time::*;
use std::cmp::Ordering;
use std::time::Duration;
let mut timer = Timer::from_seconds(2.0, TimerMode::Once);
timer.tick(Duration::from_secs_f32(0.5));
let result = timer.remaining_secs().total_cmp(&1.5);
assert_eq!(Ordering::Equal, result);

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

set_elapsed

Sets the elapsed time of the timer without any other considerations. See also Stopwatch::set.

# use bevy_time::*;
use std::time::Duration;
let mut timer = Timer::from_seconds(1.0, TimerMode::Once);
timer.set_elapsed(Duration::from_secs(2));
assert_eq!(timer.elapsed(), Duration::from_secs(2));
// the timer is not finished even if the elapsed time is greater than the duration.
assert!(!timer.finished());

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧
timeDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧
otherTimerNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

set_mode

Sets the mode of the timer.

Examples

# use bevy_time::*;
let mut timer = Timer::from_seconds(1.0, TimerMode::Repeating);
timer.set_mode(TimerMode::Once);
assert_eq!(timer.mode(), TimerMode::Once);

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧
modeTimerModeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

fraction

Returns the fraction of the timer elapsed time (goes from 0.0 to 1.0).

Examples

# use bevy_time::*;
use std::time::Duration;
let mut timer = Timer::from_seconds(2.0, TimerMode::Once);
timer.tick(Duration::from_secs_f32(0.5));
assert_eq!(timer.fraction(), 0.25);

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

TimerMode

Once

Repeating

Description

Specifies [Timer] behavior.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
eqNo Documentation 🚧
assert_receiver_is_total_eqNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTimerModeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0TimerModeNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTimerModeNo Documentation 🚧
otherTimerModeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTimerModeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

Virtual

Virtual

  • max_delta:bevy_utils::Duration
  • paused:bool
  • relative_speed:f64
  • effective_speed:f64

Description

The virtual game clock representing game time.

A specialization of the [Time] structure. For method documentation, see [Time<Virtual>#impl-Time<Virtual>].

Normally used as Time<Virtual>. It is automatically inserted as a resource by TimePlugin and updated based on Time<Real>. The virtual clock is automatically set as the default generic [Time] resource for the update.

The virtual clock differs from real time clock in that it can be paused, sped up and slowed down. It also limits how much it can advance in a single update in order to prevent unexpected behavior in cases where updates do not happen at regular intervals (e.g. coming back after the program was suspended a long time).

The virtual clock can be paused by calling pause() and unpaused by calling unpause(). When the game clock is paused delta() will be zero on each update, and elapsed() will not grow. effective_speed() will return 0.0. Calling pause() will not affect value the delta() value for the update currently being processed.

The speed of the virtual clock can be changed by calling set_relative_speed(). A value of 2.0 means that virtual clock should advance twice as fast as real time, meaning that delta() values will be double of what Time<Real>::delta() reports and elapsed() will go twice as fast as Time<Real>::elapsed(). Calling set_relative_speed() will not affect the delta() value for the update currently being processed.

The maximum amount of delta time that can be added by a single update can be set by set_max_delta(). This value serves a dual purpose in the virtual clock.

If the game temporarily freezes due to any reason, such as disk access, a blocking system call, or operating system level suspend, reporting the full elapsed delta time is likely to cause bugs in game logic. Usually if a laptop is suspended for an hour, it doesn't make sense to try to simulate the game logic for the elapsed hour when resuming. Instead it is better to lose the extra time and pretend a shorter duration of time passed. Setting max_delta() to a relatively short time means that the impact on game logic will be minimal.

If the game lags for some reason, meaning that it will take a longer time to compute a frame than the real time that passes during the computation, then we would fall behind in processing virtual time. If this situation persists, and computing a frame takes longer depending on how much virtual time has passed, the game would enter a "death spiral" where computing each frame takes longer and longer and the game will appear to freeze. By limiting the maximum time that can be added at once, we also limit the amount of virtual time the game needs to compute for each frame. This means that the game will run slow, and it will run slower than real time, but it will not freeze and it will recover as soon as computation becomes fast again.

You should set max_delta() to a value that is approximately the minimum FPS your game should have even if heavily lagged for a moment. The actual FPS when lagged will be somewhat lower than this, depending on how much more time it takes to compute a frame compared to real time. You should also consider how stable your FPS is, as the limit will also dictate how big of an FPS drop you can accept without losing time and falling behind real time.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVirtualNo Documentation 🚧

Returns

NameTypeDocumentation
arg0VirtualNo Documentation 🚧

GlobalTransform

GlobalTransform

  1. glam::Affine3A

Description

[GlobalTransform] is an affine transformation from entity-local coordinates to worldspace coordinates.

You cannot directly mutate [GlobalTransform]; instead, you change an entity's transform by manipulating its [Transform], which indirectly causes Bevy to update its [GlobalTransform].

  • To get the global transform of an entity, you should get its [GlobalTransform].
  • For transform hierarchies to work correctly, you must have both a [Transform] and a [GlobalTransform].
    • You may use the TransformBundle to guarantee this. TransformBundle is now deprecated. [GlobalTransform] is automatically inserted whenever [Transform] is inserted.

[Transform] and [GlobalTransform]

[Transform] transforms an entity relative to its parent's reference frame, or relative to world space coordinates, if it doesn't have a Parent.

[GlobalTransform] is managed by Bevy; it is computed by successively applying the [Transform] of each ancestor entity which has a Transform. This is done automatically by Bevy-internal systems in the system set TransformPropagate.

This system runs during PostUpdate. If you update the [Transform] of an entity in this schedule or after, you will notice a 1 frame lag before the [GlobalTransform] is updated.

Examples

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
compute_transformReturns the transformation as a [`Transform`]. The transform is expected to be non-degenerate and without shearing, or the output will be invalid.
from_rotationNo Documentation 🚧
from_xyzNo Documentation 🚧
mul-1No Documentation 🚧
backReturn the local back vector (Z).
upReturn the local up vector (Y).
translation_vec3aGet the translation as a [`Vec3A`].
rightReturn the local right vector (X).
forwardReturn the local forward vector (-Z).
transform_pointTransforms the given point from local space to global space, applying shear, scale, rotation and tr...
affineReturns the 3d affine transformation matrix as an [`Affine3A`].
mul-2No Documentation 🚧
compute_matrixReturns the 3d affine transformation matrix as a [`Mat4`].
cloneNo Documentation 🚧
leftReturn the local left vector (-X).
from_isometryNo Documentation 🚧
eqNo Documentation 🚧
mulNo Documentation 🚧
from_translationNo Documentation 🚧
reparented_toReturns the [`Transform`] `self` would have if it was a child of an entity with the `parent` [`GlobalTransform`...
scaleGet the scale as a [`Vec3`]. The transform is expected to be non-degenerate and without shearing, or the output will be invalid. Some of the computations overlap with `to_scale_rotation_translation`, which means you should use it instead if you also need rotation.
mul_transformMultiplies `self` with `transform` component by component, returning the resulting [`GlobalTransform`]...
translationGet the translation as a [`Vec3`].
to_isometryReturns the isometric part of the transformation as an [isometry]. Any scaling done by the transformation will be ignored. The transform is expected to be non-degenerate and without shearing, or the output will be invalid. [isometry]...
from_scaleNo Documentation 🚧
radius_vec3aGet an upper bound of the radius from the given `extents`.
downReturn the local down vector (-Y).
rotationGet the rotation as a [`Quat`]. The transform is expected to be non-degenerate and without shearing, or the output will be invalid. # Warning This is calculated using `to_scale_rotation_translation`, meaning that you should probably use it directly if you also need translation or scale.

compute_transform

Returns the transformation as a [Transform]. The transform is expected to be non-degenerate and without shearing, or the output will be invalid.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0TransformNo Documentation 🚧

from_rotation

No Documentation 🚧

Arguments

NameTypeDocumentation
rotationQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GlobalTransformNo Documentation 🚧

from_xyz

No Documentation 🚧

Arguments

NameTypeDocumentation
xf32No Documentation 🚧
yf32No Documentation 🚧
zf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0GlobalTransformNo Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0GlobalTransformNo Documentation 🚧
arg1GlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GlobalTransformNo Documentation 🚧

back

Return the local back vector (Z).

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

up

Return the local up vector (Y).

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

translation_vec3a

Get the translation as a [Vec3A].

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

right

Return the local right vector (X).

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

forward

Return the local forward vector (-Z).

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

transform_point

Transforms the given point from local space to global space, applying shear, scale, rotation and translation. It can be used like this:

# use bevy_transform::prelude::{GlobalTransform};
# use bevy_math::prelude::Vec3;
let global_transform = GlobalTransform::from_xyz(1., 2., 3.);
let local_point = Vec3::new(1., 2., 3.);
let global_point = global_transform.transform_point(local_point);
assert_eq!(global_point, Vec3::new(2., 4., 6.));
# use bevy_transform::prelude::{GlobalTransform};
# use bevy_math::Vec3;
let global_point = Vec3::new(2., 4., 6.);
let global_transform = GlobalTransform::from_xyz(1., 2., 3.);
let local_point = global_transform.affine().inverse().transform_point3(global_point);
assert_eq!(local_point, Vec3::new(1., 2., 3.))

To apply shear, scale, and rotation without applying translation, different functions are available:

# use bevy_transform::prelude::{GlobalTransform};
# use bevy_math::prelude::Vec3;
let global_transform = GlobalTransform::from_xyz(1., 2., 3.);
let local_direction = Vec3::new(1., 2., 3.);
let global_direction = global_transform.affine().transform_vector3(local_direction);
assert_eq!(global_direction, Vec3::new(1., 2., 3.));
let roundtripped_local_direction = global_transform.affine().inverse().transform_vector3(global_direction);
assert_eq!(roundtripped_local_direction, local_direction);

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧
pointVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

affine

Returns the 3d affine transformation matrix as an [Affine3A].

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0GlobalTransformNo Documentation 🚧
arg1TransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GlobalTransformNo Documentation 🚧

compute_matrix

Returns the 3d affine transformation matrix as a [Mat4].

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GlobalTransformNo Documentation 🚧

left

Return the local left vector (-X).

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

from_isometry

No Documentation 🚧

Arguments

NameTypeDocumentation
isoIsometry3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GlobalTransformNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧
otherGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧
valueVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

from_translation

No Documentation 🚧

Arguments

NameTypeDocumentation
translationVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0GlobalTransformNo Documentation 🚧

reparented_to

Returns the [Transform] self would have if it was a child of an entity with the parent [GlobalTransform]. This is useful if you want to "reparent" an Entity. Say you have an entity e1 that you want to turn into a child of e2, but you want e1 to keep the same global transform, even after re-parenting. You would use:

# use bevy_transform::prelude::{GlobalTransform, Transform};
# use bevy_ecs::prelude::{Entity, Query, Component, Commands};
# use bevy_hierarchy::{prelude::Parent, BuildChildren};
#[derive(Component)]
struct ToReparent {
    new_parent: Entity,
}
fn reparent_system(
    mut commands: Commands,
    mut targets: Query<(&mut Transform, Entity, &GlobalTransform, &ToReparent)>,
    transforms: Query<&GlobalTransform>,
) {
    for (mut transform, entity, initial, to_reparent) in targets.iter_mut() {
        if let Ok(parent_transform) = transforms.get(to_reparent.new_parent) {
            *transform = initial.reparented_to(parent_transform);
            commands.entity(entity)
                .remove::<ToReparent>()
                .set_parent(to_reparent.new_parent);
        }
    }
}

The transform is expected to be non-degenerate and without shearing, or the output will be invalid.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧
parentGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0TransformNo Documentation 🚧

scale

Get the scale as a [Vec3]. The transform is expected to be non-degenerate and without shearing, or the output will be invalid. Some of the computations overlap with to_scale_rotation_translation, which means you should use it instead if you also need rotation.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

mul_transform

Multiplies self with transform component by component, returning the resulting [GlobalTransform]

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧
transformTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GlobalTransformNo Documentation 🚧

translation

Get the translation as a [Vec3].

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

to_isometry

Returns the isometric part of the transformation as an [isometry]. Any scaling done by the transformation will be ignored. The transform is expected to be non-degenerate and without shearing, or the output will be invalid. [isometry]: Isometry3d

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Isometry3dNo Documentation 🚧

from_scale

No Documentation 🚧

Arguments

NameTypeDocumentation
scaleVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0GlobalTransformNo Documentation 🚧

radius_vec3a

Get an upper bound of the radius from the given extents.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧
extentsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

down

Return the local down vector (-Y).

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

rotation

Get the rotation as a [Quat]. The transform is expected to be non-degenerate and without shearing, or the output will be invalid.

Warning

This is calculated using to_scale_rotation_translation, meaning that you should probably use it directly if you also need translation or scale.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

Transform

Transform

  • translation:glam::Vec3
  • rotation:glam::Quat
  • scale:glam::Vec3

Description

Describe the position of an entity. If the entity has a parent, the position is relative to its parent position.

  • To place or move an entity, you should set its [Transform].
  • To get the global transform of an entity, you should get its [GlobalTransform].
  • To be displayed, an entity must have both a [Transform] and a [GlobalTransform].
    • You may use the TransformBundle to guarantee this. TransformBundle is now deprecated. [GlobalTransform] is automatically inserted whenever [Transform] is inserted.

[Transform] and [GlobalTransform]

[Transform] is the position of an entity relative to its parent position, or the reference frame if it doesn't have a Parent.

[GlobalTransform] is the position of an entity relative to the reference frame.

[GlobalTransform] is updated from [Transform] by systems in the system set TransformPropagate.

This system runs during PostUpdate. If you update the [Transform] of an entity during this set or after, you will notice a 1 frame lag before the [GlobalTransform] is updated.

Examples

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
with_scaleReturns this [`Transform`] with a new scale.
is_finiteReturns `true` if, and only if, translation, rotation and scale all are finite. If any of them con...
leftEquivalent to [`-local_x()`][Transform::local_x()]
from_xyzCreates a new [`Transform`] at the position `(x, y, z)`. In 2d, the `z` component is used for z-ordering elements: higher `z`-value will be in front of lower `z`-value.
mul-1No Documentation 🚧
local_zGet the unit vector in the local `Z` direction.
local_xGet the unit vector in the local `X` direction.
transform_pointTransforms the given `point`, applying scale, rotation and translation. If this [`Transform`] has an ancestor entity with a [`Transform`]...
rotate_local_xRotates this [`Transform`] around its local `X` axis by `angle` (in radians).
from_rotationCreates a new [`Transform`], with `rotation`. Translation will be 0 and scale 1 on all axes.
rightEquivalent to [`local_x()`][Transform::local_x()]
from_scaleCreates a new [`Transform`], with `scale`. Translation will be 0 and rotation 0 on all axes.
from_isometryCreates a new [`Transform`] that is equivalent to the given [isometry]. [isometry]: Isometry3d
rotateRotates this [`Transform`] by the given rotation. If this [`Transform`] has a parent, the `rotation`...
mulNo Documentation 🚧
rotate_local_zRotates this [`Transform`] around its local `Z` axis by `angle` (in radians).
compute_affineReturns the 3d affine transformation matrix from this transforms translation, rotation, and scale.
with_translationReturns this [`Transform`] with a new translation.
downEquivalent to [`-local_y()`][Transform::local_y]
rotate_aroundRotates this [`Transform`] around a `point` in space. If this [`Transform`] has a parent, the `point`...
from_translationCreates a new [`Transform`], with `translation`. Rotation will be 0 and scale 1 on all axes.
with_rotationReturns this [`Transform`] with a new rotation.
rotate_local_yRotates this [`Transform`] around its local `Y` axis by `angle` (in radians).
local_yGet the unit vector in the local `Y` direction.
compute_matrixReturns the 3d affine transformation matrix from this transforms translation, rotation, and scale.
rotate_local_axisRotates this [`Transform`] around its local `axis` by `angle` (in radians).
rotate_xRotates this [`Transform`] around the `X` axis by `angle` (in radians). If this [`Transform`] has ...
rotate_yRotates this [`Transform`] around the `Y` axis by `angle` (in radians). If this [`Transform`] has ...
forwardEquivalent to [`-local_z()`][Transform::local_z]
from_matrixExtracts the translation, rotation, and scale from `matrix`. It must be a 3d affine transformation...
upEquivalent to [`local_y()`][Transform::local_y]
eqNo Documentation 🚧
backEquivalent to [`local_z()`][Transform::local_z]
rotate_zRotates this [`Transform`] around the `Z` axis by `angle` (in radians). If this [`Transform`] has ...
to_isometryGet the [isometry] defined by this transform's rotation and translation, ignoring scale. [isometry...
rotate_axisRotates this [`Transform`] around the given `axis` by `angle` (in radians). If this [`Transform`] ...
mul-2No Documentation 🚧
mul_transformMultiplies `self` with `transform` component by component, returning the resulting [`Transform`]
rotate_localRotates this [`Transform`] by the given `rotation`. The `rotation` is relative to this [`Transform...
cloneNo Documentation 🚧
translate_aroundTranslates this [`Transform`] around a `point` in space. If this [`Transform`] has a parent, the `point`...

with_scale

Returns this [Transform] with a new scale.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
scaleVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0TransformNo Documentation 🚧

is_finite

Returns true if, and only if, translation, rotation and scale all are finite. If any of them contains a NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

left

Equivalent to [-local_x()][Transform::local_x()]

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

from_xyz

Creates a new [Transform] at the position (x, y, z). In 2d, the z component is used for z-ordering elements: higher z-value will be in front of lower z-value.

Arguments

NameTypeDocumentation
xf32No Documentation 🚧
yf32No Documentation 🚧
zf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0TransformNo Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0TransformNo Documentation 🚧
arg1GlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0GlobalTransformNo Documentation 🚧

local_z

Get the unit vector in the local Z direction.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

local_x

Get the unit vector in the local X direction.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

transform_point

Transforms the given point, applying scale, rotation and translation. If this [Transform] has an ancestor entity with a [Transform] component, [Transform::transform_point] will transform a point in local space into its parent transform's space. If this [Transform] does not have a parent, [Transform::transform_point] will transform a point in local space into worldspace coordinates. If you always want to transform a point in local space to worldspace, or if you need the inverse transformations, see [GlobalTransform::transform_point()].

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
pointVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

rotate_local_x

Rotates this [Transform] around its local X axis by angle (in radians).

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

from_rotation

Creates a new [Transform], with rotation. Translation will be 0 and scale 1 on all axes.

Arguments

NameTypeDocumentation
rotationQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0TransformNo Documentation 🚧

right

Equivalent to [local_x()][Transform::local_x()]

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

from_scale

Creates a new [Transform], with scale. Translation will be 0 and rotation 0 on all axes.

Arguments

NameTypeDocumentation
scaleVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0TransformNo Documentation 🚧

from_isometry

Creates a new [Transform] that is equivalent to the given [isometry]. [isometry]: Isometry3d

Arguments

NameTypeDocumentation
isoIsometry3dNo Documentation 🚧

Returns

NameTypeDocumentation
arg0TransformNo Documentation 🚧

rotate

Rotates this [Transform] by the given rotation. If this [Transform] has a parent, the rotation is relative to the rotation of the parent.

Examples

  • [3d_rotation] [3d_rotation]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/3d_rotation.rs

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
rotationQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
valueVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

rotate_local_z

Rotates this [Transform] around its local Z axis by angle (in radians).

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

compute_affine

Returns the 3d affine transformation matrix from this transforms translation, rotation, and scale.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

with_translation

Returns this [Transform] with a new translation.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
translationVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0TransformNo Documentation 🚧

down

Equivalent to [-local_y()][Transform::local_y]

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

rotate_around

Rotates this [Transform] around a point in space. If this [Transform] has a parent, the point is relative to the [Transform] of the parent.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
pointVec3No Documentation 🚧
rotationQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

from_translation

Creates a new [Transform], with translation. Rotation will be 0 and scale 1 on all axes.

Arguments

NameTypeDocumentation
translationVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0TransformNo Documentation 🚧

with_rotation

Returns this [Transform] with a new rotation.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
rotationQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0TransformNo Documentation 🚧

rotate_local_y

Rotates this [Transform] around its local Y axis by angle (in radians).

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

local_y

Get the unit vector in the local Y direction.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

compute_matrix

Returns the 3d affine transformation matrix from this transforms translation, rotation, and scale.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

rotate_local_axis

Rotates this [Transform] around its local axis by angle (in radians).

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
axisDir3No Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

rotate_x

Rotates this [Transform] around the X axis by angle (in radians). If this [Transform] has a parent, the axis is relative to the rotation of the parent.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

rotate_y

Rotates this [Transform] around the Y axis by angle (in radians). If this [Transform] has a parent, the axis is relative to the rotation of the parent.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

forward

Equivalent to [-local_z()][Transform::local_z]

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

from_matrix

Extracts the translation, rotation, and scale from matrix. It must be a 3d affine transformation matrix.

Arguments

NameTypeDocumentation
world_from_localMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0TransformNo Documentation 🚧

up

Equivalent to [local_y()][Transform::local_y]

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
otherTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

back

Equivalent to [local_z()][Transform::local_z]

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Dir3No Documentation 🚧

rotate_z

Rotates this [Transform] around the Z axis by angle (in radians). If this [Transform] has a parent, the axis is relative to the rotation of the parent.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

to_isometry

Get the [isometry] defined by this transform's rotation and translation, ignoring scale. [isometry]: Isometry3d

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Isometry3dNo Documentation 🚧

rotate_axis

Rotates this [Transform] around the given axis by angle (in radians). If this [Transform] has a parent, the axis is relative to the rotation of the parent.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
axisDir3No Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0TransformNo Documentation 🚧
arg1TransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0TransformNo Documentation 🚧

mul_transform

Multiplies self with transform component by component, returning the resulting [Transform]

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
transformTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0TransformNo Documentation 🚧

rotate_local

Rotates this [Transform] by the given rotation. The rotation is relative to this [Transform]'s current rotation.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
rotationQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
arg0TransformNo Documentation 🚧

translate_around

Translates this [Transform] around a point in space. If this [Transform] has a parent, the point is relative to the [Transform] of the parent.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
pointVec3No Documentation 🚧
rotationQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

Duration

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_secsCreates a new `Duration` from the specified number of whole seconds. # Examples ``` use std::time::Duration; let duration = Duration::from_secs(5); assert_eq!(5, duration.as_secs()); assert_eq!(0, duration.subsec_nanos()); ```
divNo Documentation 🚧
eqNo Documentation 🚧
saturating_subSaturating `Duration` subtraction. Computes `self - other`, returning [`Duration::ZERO`] if the result would be negative or if overflow occurred. # Examples ``` use std::time::Duration; assert_eq!(Duration::new(0, 1).saturating_sub(Duration::new(0, 0)), Duration::new(0, 1)); assert_eq!(Duration::new(0, 0).saturating_sub(Duration::new(0, 1)), Duration::ZERO); ```
as_secs_f32Returns the number of seconds contained by this `Duration` as `f32`. The returned value includes t...
addNo Documentation 🚧
as_nanosReturns the total number of nanoseconds contained by this `Duration`. # Examples ``` use std::time::Duration; let duration = Duration::new(5, 730_023_852); assert_eq!(duration.as_nanos(), 5_730_023_852); ```
from_secs_f32Creates a new `Duration` from the specified number of seconds represented as `f32`. # Panics Thi...
from_microsCreates a new `Duration` from the specified number of microseconds. # Examples ``` use std::time::Duration; let duration = Duration::from_micros(1_000_002); assert_eq!(1, duration.as_secs()); assert_eq!(2_000, duration.subsec_nanos()); `...
div_duration_f64Divides `Duration` by `Duration` and returns `f64`. # Examples ``` use std::time::Duration; let dur1 = Duration::new(2, 700_000_000); let dur2 = Duration::new(5, 400_000_000); assert_eq!(dur1.div_duration_f64(dur2), 0.5); ```
subsec_nanosReturns the fractional part of this `Duration`, in nanoseconds. This method does **not** return th...
newCreates a new `Duration` from the specified number of whole seconds and additional nanoseconds. I...
mulNo Documentation 🚧
is_zeroReturns true if this `Duration` spans no time. # Examples ``` use std::time::Duration; assert!(Duration::ZERO.is_zero()); assert!(Duration::new(0, 0).is_zero()); assert!(Duration::from_nanos(0).is_zero()); assert!(Duration::from_secs(0).is_zero()); assert!(!Duration::new(1, 1).is_zero()); assert!(!Duration::from_nanos(1).is_zero()); assert!(!Duration::from_secs(1).is_zero()); ```
as_millisReturns the total number of whole milliseconds contained by this `Duration`. # Examples ``` use std::time::Duration; let duration = Duration::new(5, 730_023_852); assert_eq!(duration.as_millis(), 5_730); ```
abs_diffComputes the absolute difference between `self` and `other`. # Examples ``` use std::time::Duration; assert_eq!(Duration::new(100, 0).abs_diff(Duration::new(80, 0)), Duration::new(20, 0)); assert_eq!(Duration::new(100, 400_000_000).abs_diff(Duration::new(110, 0)), Duration::new(9, 600_000_000)); `...
subsec_millisReturns the fractional part of this `Duration`, in whole milliseconds. This method does **not** re...
saturating_addSaturating `Duration` addition. Computes `self + other`, returning [`Duration::MAX`] if overflow occurred. # Examples ``` #![feature(duration_constants)]...
cloneNo Documentation 🚧
as_secs_f64Returns the number of seconds contained by this `Duration` as `f64`. The returned value includes t...
as_secsReturns the number of _whole_ seconds contained by this `Duration`. The returned value does not in...
from_millisCreates a new `Duration` from the specified number of milliseconds. # Examples ``` use std::time::Duration; let duration = Duration::from_millis(2_569); assert_eq!(2, duration.as_secs()); assert_eq!(569_000_000, duration.subsec_nanos()); `...
div_f32Divides `Duration` by `f32`. # Panics This method will panic if result is negative, overflows `Duration`...
mul_f32Multiplies `Duration` by `f32`. # Panics This method will panic if result is negative, overflows `Duration`...
subNo Documentation 🚧
div_duration_f32Divides `Duration` by `Duration` and returns `f32`. # Examples ``` use std::time::Duration; let dur1 = Duration::new(2, 700_000_000); let dur2 = Duration::new(5, 400_000_000); assert_eq!(dur1.div_duration_f32(dur2), 0.5); ```
saturating_mulSaturating `Duration` multiplication. Computes `self * other`, returning [`Duration::MAX`] if overflow occurred. # Examples ``` #![feature(duration_constants)] use std::time::Duration; assert_eq!(Duration::new(0, 500_000_001).saturating_mul(2), Duration::new(1, 2)); assert_eq!(Duration::new(u64::MAX - 1, 0).saturating_mul(2), Duration::MAX); ```
subsec_microsReturns the fractional part of this `Duration`, in whole microseconds. This method does **not** re...
div_f64Divides `Duration` by `f64`. # Panics This method will panic if result is negative, overflows `Duration`...
from_secs_f64Creates a new `Duration` from the specified number of seconds represented as `f64`. # Panics Thi...
from_nanosCreates a new `Duration` from the specified number of nanoseconds. Note: Using this on the return ...
mul_f64Multiplies `Duration` by `f64`. # Panics This method will panic if result is negative, overflows `Duration`...
as_microsReturns the total number of whole microseconds contained by this `Duration`. # Examples ``` use std::time::Duration; let duration = Duration::new(5, 730_023_852); assert_eq!(duration.as_micros(), 5_730_023); `...
assert_receiver_is_total_eqNo Documentation 🚧

from_secs

Creates a new Duration from the specified number of whole seconds.

Examples

use std::time::Duration;
let duration = Duration::from_secs(5);
assert_eq!(5, duration.as_secs());
assert_eq!(0, duration.subsec_nanos());

Arguments

NameTypeDocumentation
secsu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
rhsu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
otherDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

saturating_sub

Saturating Duration subtraction. Computes self - other, returning [Duration::ZERO] if the result would be negative or if overflow occurred.

Examples

use std::time::Duration;
assert_eq!(Duration::new(0, 1).saturating_sub(Duration::new(0, 0)), Duration::new(0, 1));
assert_eq!(Duration::new(0, 0).saturating_sub(Duration::new(0, 1)), Duration::ZERO);

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
rhsDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

as_secs_f32

Returns the number of seconds contained by this Duration as f32. The returned value includes the fractional (nanosecond) part of the duration.

Examples

use std::time::Duration;
let dur = Duration::new(2, 700_000_000);
assert_eq!(dur.as_secs_f32(), 2.7);

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
rhsDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

as_nanos

Returns the total number of nanoseconds contained by this Duration.

Examples

use std::time::Duration;
let duration = Duration::new(5, 730_023_852);
assert_eq!(duration.as_nanos(), 5_730_023_852);

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0u128No Documentation 🚧

from_secs_f32

Creates a new Duration from the specified number of seconds represented as f32.

Panics

This constructor will panic if secs is negative, overflows Duration or not finite.

Examples

use std::time::Duration;
let res = Duration::from_secs_f32(0.0);
assert_eq!(res, Duration::new(0, 0));
let res = Duration::from_secs_f32(1e-20);
assert_eq!(res, Duration::new(0, 0));
let res = Duration::from_secs_f32(4.2e-7);
assert_eq!(res, Duration::new(0, 420));
let res = Duration::from_secs_f32(2.7);
assert_eq!(res, Duration::new(2, 700_000_048));
let res = Duration::from_secs_f32(3e10);
assert_eq!(res, Duration::new(30_000_001_024, 0));
// subnormal float
let res = Duration::from_secs_f32(f32::from_bits(1));
assert_eq!(res, Duration::new(0, 0));
// conversion uses rounding
let res = Duration::from_secs_f32(0.999e-9);
assert_eq!(res, Duration::new(0, 1));

Arguments

NameTypeDocumentation
secsf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

from_micros

Creates a new Duration from the specified number of microseconds.

Examples

use std::time::Duration;
let duration = Duration::from_micros(1_000_002);
assert_eq!(1, duration.as_secs());
assert_eq!(2_000, duration.subsec_nanos());

Arguments

NameTypeDocumentation
microsu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

div_duration_f64

Divides Duration by Duration and returns f64.

Examples

use std::time::Duration;
let dur1 = Duration::new(2, 700_000_000);
let dur2 = Duration::new(5, 400_000_000);
assert_eq!(dur1.div_duration_f64(dur2), 0.5);

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
rhsDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

subsec_nanos

Returns the fractional part of this Duration, in nanoseconds. This method does not return the length of the duration when represented by nanoseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one billion).

Examples

use std::time::Duration;
let duration = Duration::from_millis(5_010);
assert_eq!(duration.as_secs(), 5);
assert_eq!(duration.subsec_nanos(), 10_000_000);

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

new

Creates a new Duration from the specified number of whole seconds and additional nanoseconds. If the number of nanoseconds is greater than 1 billion (the number of nanoseconds in a second), then it will carry over into the seconds provided.

Panics

This constructor will panic if the carry from the nanoseconds overflows the seconds counter.

Examples

use std::time::Duration;
let five_seconds = Duration::new(5, 0);

Arguments

NameTypeDocumentation
secsu64No Documentation 🚧
nanosu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
rhsu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

is_zero

Returns true if this Duration spans no time.

Examples

use std::time::Duration;
assert!(Duration::ZERO.is_zero());
assert!(Duration::new(0, 0).is_zero());
assert!(Duration::from_nanos(0).is_zero());
assert!(Duration::from_secs(0).is_zero());
assert!(!Duration::new(1, 1).is_zero());
assert!(!Duration::from_nanos(1).is_zero());
assert!(!Duration::from_secs(1).is_zero());

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

as_millis

Returns the total number of whole milliseconds contained by this Duration.

Examples

use std::time::Duration;
let duration = Duration::new(5, 730_023_852);
assert_eq!(duration.as_millis(), 5_730);

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0u128No Documentation 🚧

abs_diff

Computes the absolute difference between self and other.

Examples

use std::time::Duration;
assert_eq!(Duration::new(100, 0).abs_diff(Duration::new(80, 0)), Duration::new(20, 0));
assert_eq!(Duration::new(100, 400_000_000).abs_diff(Duration::new(110, 0)), Duration::new(9, 600_000_000));

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
otherDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

subsec_millis

Returns the fractional part of this Duration, in whole milliseconds. This method does not return the length of the duration when represented by milliseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one thousand).

Examples

use std::time::Duration;
let duration = Duration::from_millis(5_432);
assert_eq!(duration.as_secs(), 5);
assert_eq!(duration.subsec_millis(), 432);

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

saturating_add

Saturating Duration addition. Computes self + other, returning [Duration::MAX] if overflow occurred.

Examples

#![feature(duration_constants)]
use std::time::Duration;
assert_eq!(Duration::new(0, 0).saturating_add(Duration::new(0, 1)), Duration::new(0, 1));
assert_eq!(Duration::new(1, 0).saturating_add(Duration::new(u64::MAX, 0)), Duration::MAX);

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
rhsDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

as_secs_f64

Returns the number of seconds contained by this Duration as f64. The returned value includes the fractional (nanosecond) part of the duration.

Examples

use std::time::Duration;
let dur = Duration::new(2, 700_000_000);
assert_eq!(dur.as_secs_f64(), 2.7);

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

as_secs

Returns the number of whole seconds contained by this Duration. The returned value does not include the fractional (nanosecond) part of the duration, which can be obtained using [subsec_nanos].

Examples

use std::time::Duration;
let duration = Duration::new(5, 730_023_852);
assert_eq!(duration.as_secs(), 5);

To determine the total number of seconds represented by the Duration including the fractional part, use [as_secs_f64] or [as_secs_f32] [as_secs_f64]: Duration::as_secs_f64 [as_secs_f32]: Duration::as_secs_f32 [subsec_nanos]: Duration::subsec_nanos

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

from_millis

Creates a new Duration from the specified number of milliseconds.

Examples

use std::time::Duration;
let duration = Duration::from_millis(2_569);
assert_eq!(2, duration.as_secs());
assert_eq!(569_000_000, duration.subsec_nanos());

Arguments

NameTypeDocumentation
millisu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

div_f32

Divides Duration by f32.

Panics

This method will panic if result is negative, overflows Duration or not finite.

Examples

use std::time::Duration;
let dur = Duration::new(2, 700_000_000);
// note that due to rounding errors result is slightly
// different from 0.859_872_611
assert_eq!(dur.div_f32(3.14), Duration::new(0, 859_872_580));
assert_eq!(dur.div_f32(3.14e5), Duration::new(0, 8_599));

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
rhsf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

mul_f32

Multiplies Duration by f32.

Panics

This method will panic if result is negative, overflows Duration or not finite.

Examples

use std::time::Duration;
let dur = Duration::new(2, 700_000_000);
assert_eq!(dur.mul_f32(3.14), Duration::new(8, 478_000_641));
assert_eq!(dur.mul_f32(3.14e5), Duration::new(847_800, 0));

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
rhsf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
rhsDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

div_duration_f32

Divides Duration by Duration and returns f32.

Examples

use std::time::Duration;
let dur1 = Duration::new(2, 700_000_000);
let dur2 = Duration::new(5, 400_000_000);
assert_eq!(dur1.div_duration_f32(dur2), 0.5);

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
rhsDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

saturating_mul

Saturating Duration multiplication. Computes self * other, returning [Duration::MAX] if overflow occurred.

Examples

#![feature(duration_constants)]
use std::time::Duration;
assert_eq!(Duration::new(0, 500_000_001).saturating_mul(2), Duration::new(1, 2));
assert_eq!(Duration::new(u64::MAX - 1, 0).saturating_mul(2), Duration::MAX);

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
rhsu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

subsec_micros

Returns the fractional part of this Duration, in whole microseconds. This method does not return the length of the duration when represented by microseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one million).

Examples

use std::time::Duration;
let duration = Duration::from_micros(1_234_567);
assert_eq!(duration.as_secs(), 1);
assert_eq!(duration.subsec_micros(), 234_567);

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

div_f64

Divides Duration by f64.

Panics

This method will panic if result is negative, overflows Duration or not finite.

Examples

use std::time::Duration;
let dur = Duration::new(2, 700_000_000);
assert_eq!(dur.div_f64(3.14), Duration::new(0, 859_872_611));
assert_eq!(dur.div_f64(3.14e5), Duration::new(0, 8_599));

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
rhsf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

from_secs_f64

Creates a new Duration from the specified number of seconds represented as f64.

Panics

This constructor will panic if secs is negative, overflows Duration or not finite.

Examples

use std::time::Duration;
let res = Duration::from_secs_f64(0.0);
assert_eq!(res, Duration::new(0, 0));
let res = Duration::from_secs_f64(1e-20);
assert_eq!(res, Duration::new(0, 0));
let res = Duration::from_secs_f64(4.2e-7);
assert_eq!(res, Duration::new(0, 420));
let res = Duration::from_secs_f64(2.7);
assert_eq!(res, Duration::new(2, 700_000_000));
let res = Duration::from_secs_f64(3e10);
assert_eq!(res, Duration::new(30_000_000_000, 0));
// subnormal float
let res = Duration::from_secs_f64(f64::from_bits(1));
assert_eq!(res, Duration::new(0, 0));
// conversion uses rounding
let res = Duration::from_secs_f64(0.999e-9);
assert_eq!(res, Duration::new(0, 1));

Arguments

NameTypeDocumentation
secsf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

from_nanos

Creates a new Duration from the specified number of nanoseconds. Note: Using this on the return value of as_nanos() might cause unexpected behavior: as_nanos() returns a u128, and can return values that do not fit in u64, e.g. 585 years. Instead, consider using the pattern Duration::new(d.as_secs(), d.subsec_nanos()) if you cannot copy/clone the Duration directly.

Examples

use std::time::Duration;
let duration = Duration::from_nanos(1_000_000_123);
assert_eq!(1, duration.as_secs());
assert_eq!(123, duration.subsec_nanos());

Arguments

NameTypeDocumentation
nanosu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

mul_f64

Multiplies Duration by f64.

Panics

This method will panic if result is negative, overflows Duration or not finite.

Examples

use std::time::Duration;
let dur = Duration::new(2, 700_000_000);
assert_eq!(dur.mul_f64(3.14), Duration::new(8, 478_000_000));
assert_eq!(dur.mul_f64(3.14e5), Duration::new(847_800, 0));

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
rhsf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

as_micros

Returns the total number of whole microseconds contained by this Duration.

Examples

use std::time::Duration;
let duration = Duration::new(5, 730_023_852);
assert_eq!(duration.as_micros(), 5_730_023);

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0u128No Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

Instant

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
saturating_duration_sinceReturns the amount of time elapsed from another instant to this one, or zero duration if that inst...
subNo Documentation 🚧
add# Panics This function may panic if the resulting point in time cannot be represented by the unde...
nowReturns an instant corresponding to "now". # Examples ``` use std::time::Instant; let now = Instant::now(); `...
elapsedReturns the amount of time elapsed since this instant. # Panics Previous Rust versions panicked w...
assert_receiver_is_total_eqNo Documentation 🚧
duration_sinceReturns the amount of time elapsed from another instant to this one, or zero duration if that inst...
eqNo Documentation 🚧
cloneNo Documentation 🚧
sub-1No Documentation 🚧

saturating_duration_since

Returns the amount of time elapsed from another instant to this one, or zero duration if that instant is later than this one.

Examples

use std::time::{Duration, Instant};
use std::thread::sleep;
let now = Instant::now();
sleep(Duration::new(1, 0));
let new_now = Instant::now();
println!("{:?}", new_now.saturating_duration_since(now));
println!("{:?}", now.saturating_duration_since(new_now)); // 0ns

Arguments

NameTypeDocumentation
_selfInstantNo Documentation 🚧
earlierInstantNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfInstantNo Documentation 🚧
otherDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0InstantNo Documentation 🚧

add

Panics

This function may panic if the resulting point in time cannot be represented by the underlying data structure. See [Instant::checked_add] for a version without panic.

Arguments

NameTypeDocumentation
_selfInstantNo Documentation 🚧
otherDurationNo Documentation 🚧

Returns

NameTypeDocumentation
arg0InstantNo Documentation 🚧

now

Returns an instant corresponding to "now".

Examples

use std::time::Instant;
let now = Instant::now();

Arguments

Returns

NameTypeDocumentation
arg0InstantNo Documentation 🚧

elapsed

Returns the amount of time elapsed since this instant.

Panics

Previous Rust versions panicked when the current time was earlier than self. Currently this method returns a Duration of zero in that case. Future versions may reintroduce the panic. See [Monotonicity]. [Monotonicity]: Instant#monotonicity

Examples

use std::thread::sleep;
use std::time::{Duration, Instant};
let instant = Instant::now();
let three_secs = Duration::from_secs(3);
sleep(three_secs);
assert!(instant.elapsed() >= three_secs);

Arguments

NameTypeDocumentation
_selfInstantNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfInstantNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

duration_since

Returns the amount of time elapsed from another instant to this one, or zero duration if that instant is later than this one.

Panics

Previous Rust versions panicked when earlier was later than self. Currently this method saturates. Future versions may reintroduce the panic in some circumstances. See [Monotonicity]. [Monotonicity]: Instant#monotonicity

Examples

use std::time::{Duration, Instant};
use std::thread::sleep;
let now = Instant::now();
sleep(Duration::new(1, 0));
let new_now = Instant::now();
println!("{:?}", new_now.duration_since(now));
println!("{:?}", now.duration_since(new_now)); // 0ns

Arguments

NameTypeDocumentation
_selfInstantNo Documentation 🚧
earlierInstantNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfInstantNo Documentation 🚧
otherInstantNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfInstantNo Documentation 🚧

Returns

NameTypeDocumentation
arg0InstantNo Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0InstantNo Documentation 🚧
arg1InstantNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DurationNo Documentation 🚧

RangeFull

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqNo Documentation 🚧
assert_receiver_is_total_eqNo Documentation 🚧
cloneNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRangeFullNo Documentation 🚧
otherRangeFullNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRangeFullNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfRangeFullNo Documentation 🚧

Returns

NameTypeDocumentation
arg0RangeFullNo Documentation 🚧

AtomicBool

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newCreates a new `AtomicBool`. # Examples ``` use std::sync::atomic::AtomicBool; let atomic_true = AtomicBool::new(true); let atomic_false = AtomicBool::new(false); `...
into_innerConsumes the atomic and returns the contained value. This is safe because passing `self` by value ...

new

Creates a new AtomicBool.

Examples

use std::sync::atomic::AtomicBool;
let atomic_true = AtomicBool::new(true);
let atomic_false = AtomicBool::new(false);

Arguments

NameTypeDocumentation
vboolNo Documentation 🚧

Returns

NameTypeDocumentation
arg0AtomicBoolNo Documentation 🚧

into_inner

Consumes the atomic and returns the contained value. This is safe because passing self by value guarantees that no other threads are concurrently accessing the atomic data.

Examples

use std::sync::atomic::AtomicBool;
let some_bool = AtomicBool::new(true);
assert_eq!(some_bool.into_inner(), true);

Arguments

NameTypeDocumentation
_selfAtomicBoolNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

AtomicI16

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newCreates a new atomic integer. # Examples ``` use std::sync::atomic::AtomicI16; let atomic_forty_two = AtomicI16::new(42); `...
into_innerConsumes the atomic and returns the contained value. This is safe because passing `self` by value ...

new

Creates a new atomic integer.

Examples

use std::sync::atomic::AtomicI16;
let atomic_forty_two = AtomicI16::new(42);

Arguments

NameTypeDocumentation
vi16No Documentation 🚧

Returns

NameTypeDocumentation
arg0AtomicI16No Documentation 🚧

into_inner

Consumes the atomic and returns the contained value. This is safe because passing self by value guarantees that no other threads are concurrently accessing the atomic data.

Examples

use std::sync::atomic::AtomicI16;
let some_var = AtomicI16::new(5);
assert_eq!(some_var.into_inner(), 5);

Arguments

NameTypeDocumentation
_selfAtomicI16No Documentation 🚧

Returns

NameTypeDocumentation
arg0i16No Documentation 🚧

AtomicI32

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
into_innerConsumes the atomic and returns the contained value. This is safe because passing `self` by value ...
newCreates a new atomic integer. # Examples ``` use std::sync::atomic::AtomicI32; let atomic_forty_two = AtomicI32::new(42); `...

into_inner

Consumes the atomic and returns the contained value. This is safe because passing self by value guarantees that no other threads are concurrently accessing the atomic data.

Examples

use std::sync::atomic::AtomicI32;
let some_var = AtomicI32::new(5);
assert_eq!(some_var.into_inner(), 5);

Arguments

NameTypeDocumentation
_selfAtomicI32No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

new

Creates a new atomic integer.

Examples

use std::sync::atomic::AtomicI32;
let atomic_forty_two = AtomicI32::new(42);

Arguments

NameTypeDocumentation
vi32No Documentation 🚧

Returns

NameTypeDocumentation
arg0AtomicI32No Documentation 🚧

AtomicI64

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newCreates a new atomic integer. # Examples ``` use std::sync::atomic::AtomicI64; let atomic_forty_two = AtomicI64::new(42); `...
into_innerConsumes the atomic and returns the contained value. This is safe because passing `self` by value ...

new

Creates a new atomic integer.

Examples

use std::sync::atomic::AtomicI64;
let atomic_forty_two = AtomicI64::new(42);

Arguments

NameTypeDocumentation
vi64No Documentation 🚧

Returns

NameTypeDocumentation
arg0AtomicI64No Documentation 🚧

into_inner

Consumes the atomic and returns the contained value. This is safe because passing self by value guarantees that no other threads are concurrently accessing the atomic data.

Examples

use std::sync::atomic::AtomicI64;
let some_var = AtomicI64::new(5);
assert_eq!(some_var.into_inner(), 5);

Arguments

NameTypeDocumentation
_selfAtomicI64No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

AtomicI8

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newCreates a new atomic integer. # Examples ``` use std::sync::atomic::AtomicI8; let atomic_forty_two = AtomicI8::new(42); `...
into_innerConsumes the atomic and returns the contained value. This is safe because passing `self` by value ...

new

Creates a new atomic integer.

Examples

use std::sync::atomic::AtomicI8;
let atomic_forty_two = AtomicI8::new(42);

Arguments

NameTypeDocumentation
vi8No Documentation 🚧

Returns

NameTypeDocumentation
arg0AtomicI8No Documentation 🚧

into_inner

Consumes the atomic and returns the contained value. This is safe because passing self by value guarantees that no other threads are concurrently accessing the atomic data.

Examples

use std::sync::atomic::AtomicI8;
let some_var = AtomicI8::new(5);
assert_eq!(some_var.into_inner(), 5);

Arguments

NameTypeDocumentation
_selfAtomicI8No Documentation 🚧

Returns

NameTypeDocumentation
arg0i8No Documentation 🚧

AtomicIsize

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newCreates a new atomic integer. # Examples ``` use std::sync::atomic::AtomicIsize; let atomic_forty_two = AtomicIsize::new(42); `...
into_innerConsumes the atomic and returns the contained value. This is safe because passing `self` by value ...

new

Creates a new atomic integer.

Examples

use std::sync::atomic::AtomicIsize;
let atomic_forty_two = AtomicIsize::new(42);

Arguments

NameTypeDocumentation
visizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0AtomicIsizeNo Documentation 🚧

into_inner

Consumes the atomic and returns the contained value. This is safe because passing self by value guarantees that no other threads are concurrently accessing the atomic data.

Examples

use std::sync::atomic::AtomicIsize;
let some_var = AtomicIsize::new(5);
assert_eq!(some_var.into_inner(), 5);

Arguments

NameTypeDocumentation
_selfAtomicIsizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0isizeNo Documentation 🚧

AtomicU16

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
into_innerConsumes the atomic and returns the contained value. This is safe because passing `self` by value ...
newCreates a new atomic integer. # Examples ``` use std::sync::atomic::AtomicU16; let atomic_forty_two = AtomicU16::new(42); `...

into_inner

Consumes the atomic and returns the contained value. This is safe because passing self by value guarantees that no other threads are concurrently accessing the atomic data.

Examples

use std::sync::atomic::AtomicU16;
let some_var = AtomicU16::new(5);
assert_eq!(some_var.into_inner(), 5);

Arguments

NameTypeDocumentation
_selfAtomicU16No Documentation 🚧

Returns

NameTypeDocumentation
arg0u16No Documentation 🚧

new

Creates a new atomic integer.

Examples

use std::sync::atomic::AtomicU16;
let atomic_forty_two = AtomicU16::new(42);

Arguments

NameTypeDocumentation
vu16No Documentation 🚧

Returns

NameTypeDocumentation
arg0AtomicU16No Documentation 🚧

AtomicU32

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newCreates a new atomic integer. # Examples ``` use std::sync::atomic::AtomicU32; let atomic_forty_two = AtomicU32::new(42); `...
into_innerConsumes the atomic and returns the contained value. This is safe because passing `self` by value ...

new

Creates a new atomic integer.

Examples

use std::sync::atomic::AtomicU32;
let atomic_forty_two = AtomicU32::new(42);

Arguments

NameTypeDocumentation
vu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0AtomicU32No Documentation 🚧

into_inner

Consumes the atomic and returns the contained value. This is safe because passing self by value guarantees that no other threads are concurrently accessing the atomic data.

Examples

use std::sync::atomic::AtomicU32;
let some_var = AtomicU32::new(5);
assert_eq!(some_var.into_inner(), 5);

Arguments

NameTypeDocumentation
_selfAtomicU32No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

AtomicU64

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newCreates a new atomic integer. # Examples ``` use std::sync::atomic::AtomicU64; let atomic_forty_two = AtomicU64::new(42); `...
into_innerConsumes the atomic and returns the contained value. This is safe because passing `self` by value ...

new

Creates a new atomic integer.

Examples

use std::sync::atomic::AtomicU64;
let atomic_forty_two = AtomicU64::new(42);

Arguments

NameTypeDocumentation
vu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0AtomicU64No Documentation 🚧

into_inner

Consumes the atomic and returns the contained value. This is safe because passing self by value guarantees that no other threads are concurrently accessing the atomic data.

Examples

use std::sync::atomic::AtomicU64;
let some_var = AtomicU64::new(5);
assert_eq!(some_var.into_inner(), 5);

Arguments

NameTypeDocumentation
_selfAtomicU64No Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

AtomicU8

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newCreates a new atomic integer. # Examples ``` use std::sync::atomic::AtomicU8; let atomic_forty_two = AtomicU8::new(42); `...
into_innerConsumes the atomic and returns the contained value. This is safe because passing `self` by value ...

new

Creates a new atomic integer.

Examples

use std::sync::atomic::AtomicU8;
let atomic_forty_two = AtomicU8::new(42);

Arguments

NameTypeDocumentation
vu8No Documentation 🚧

Returns

NameTypeDocumentation
arg0AtomicU8No Documentation 🚧

into_inner

Consumes the atomic and returns the contained value. This is safe because passing self by value guarantees that no other threads are concurrently accessing the atomic data.

Examples

use std::sync::atomic::AtomicU8;
let some_var = AtomicU8::new(5);
assert_eq!(some_var.into_inner(), 5);

Arguments

NameTypeDocumentation
_selfAtomicU8No Documentation 🚧

Returns

NameTypeDocumentation
arg0u8No Documentation 🚧

AtomicUsize

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
into_innerConsumes the atomic and returns the contained value. This is safe because passing `self` by value ...
newCreates a new atomic integer. # Examples ``` use std::sync::atomic::AtomicUsize; let atomic_forty_two = AtomicUsize::new(42); `...

into_inner

Consumes the atomic and returns the contained value. This is safe because passing self by value guarantees that no other threads are concurrently accessing the atomic data.

Examples

use std::sync::atomic::AtomicUsize;
let some_var = AtomicUsize::new(5);
assert_eq!(some_var.into_inner(), 5);

Arguments

NameTypeDocumentation
_selfAtomicUsizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0usizeNo Documentation 🚧

new

Creates a new atomic integer.

Examples

use std::sync::atomic::AtomicUsize;
let atomic_forty_two = AtomicUsize::new(42);

Arguments

NameTypeDocumentation
vusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0AtomicUsizeNo Documentation 🚧

Affine2

Affine2

  • matrix2:glam::Mat2
  • translation:glam::Vec2

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_mat2_translationCreates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) and a transla...
from_mat2Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation)
eqNo Documentation 🚧
transform_vector2Transforms the given 2D vector, applying shear, scale and rotation (but NOT translation). To also...
from_angleCreates an affine transform from the given rotation `angle`.
to_cols_array_2dCreates a `[[f32; 2]; 3]` 2D array storing data in column major order. If you require data in row...
inverseReturn the inverse of this transform. Note that if the transform is not invertible the result will...
to_cols_arrayCreates a `[f32; 6]` array storing data in column major order.
from_mat3The given `Mat3` must be an affine transform,
from_translationCreates an affine transformation from the given 2D `translation`.
mul-1No Documentation 🚧
from_scaleCreates an affine transform that changes scale. Note that if any scale is zero the transform will ...
mul-2No Documentation 🚧
from_mat3aThe given [`Mat3A`] must be an affine transform,
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive ...
mulNo Documentation 🚧
from_scale_angle_translationCreates an affine transform from the given 2D `scale`, rotation `angle` (in radians) and `translation`...
cloneNo Documentation 🚧
is_nanReturns `true` if any elements are `NaN`.
from_angle_translationCreates an affine transform from the given 2D rotation `angle` (in radians) and `translation`. Eq...
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...
from_colsCreates an affine transform from three column vectors.
transform_point2Transforms the given 2D point, applying shear, scale, rotation and translation.

from_mat2_translation

Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) and a translation vector. Equivalent to Affine2::from_translation(translation) * Affine2::from_mat2(mat2)

Arguments

NameTypeDocumentation
matrix2Mat2No Documentation 🚧
translationVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine2No Documentation 🚧

from_mat2

Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation)

Arguments

NameTypeDocumentation
matrix2Mat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine2No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAffine2No Documentation 🚧
rhsAffine2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

transform_vector2

Transforms the given 2D vector, applying shear, scale and rotation (but NOT translation). To also apply translation, use [Self::transform_point2()] instead.

Arguments

NameTypeDocumentation
_selfAffine2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

from_angle

Creates an affine transform from the given rotation angle.

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine2No Documentation 🚧

to_cols_array_2d

Creates a [[f32; 2]; 3] 2D array storing data in column major order. If you require data in row major order transpose the matrix first.

Arguments

NameTypeDocumentation
_selfAffine2No Documentation 🚧

Returns

NameTypeDocumentation
arg0[[f32; 2]; 3]No Documentation 🚧

inverse

Return the inverse of this transform. Note that if the transform is not invertible the result will be invalid.

Arguments

NameTypeDocumentation
_selfAffine2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine2No Documentation 🚧

to_cols_array

Creates a [f32; 6] array storing data in column major order.

Arguments

NameTypeDocumentation
_selfAffine2No Documentation 🚧

Returns

NameTypeDocumentation
arg0[f32; 6]No Documentation 🚧

from_mat3

The given Mat3 must be an affine transform,

Arguments

NameTypeDocumentation
mMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine2No Documentation 🚧

from_translation

Creates an affine transformation from the given 2D translation.

Arguments

NameTypeDocumentation
translationVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine2No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Affine2No Documentation 🚧
arg1Mat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

from_scale

Creates an affine transform that changes scale. Note that if any scale is zero the transform will be non-invertible.

Arguments

NameTypeDocumentation
scaleVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine2No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Affine2No Documentation 🚧
arg1Mat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

from_mat3a

The given [Mat3A] must be an affine transform,

Arguments

NameTypeDocumentation
mMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine2No Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfAffine2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAffine2No Documentation 🚧
rhsAffine2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine2No Documentation 🚧

from_scale_angle_translation

Creates an affine transform from the given 2D scale, rotation angle (in radians) and translation. Equivalent to Affine2::from_translation(translation) * Affine2::from_angle(angle) * Affine2::from_scale(scale)

Arguments

NameTypeDocumentation
scaleVec2No Documentation 🚧
anglef32No Documentation 🚧
translationVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine2No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAffine2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine2No Documentation 🚧

is_nan

Returns true if any elements are NaN.

Arguments

NameTypeDocumentation
_selfAffine2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_angle_translation

Creates an affine transform from the given 2D rotation angle (in radians) and translation. Equivalent to Affine2::from_translation(translation) * Affine2::from_angle(angle)

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧
translationVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine2No Documentation 🚧

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two 3x4 matrices contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfAffine2No Documentation 🚧
rhsAffine2No Documentation 🚧
max_abs_difff32No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_cols

Creates an affine transform from three column vectors.

Arguments

NameTypeDocumentation
x_axisVec2No Documentation 🚧
y_axisVec2No Documentation 🚧
z_axisVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine2No Documentation 🚧

transform_point2

Transforms the given 2D point, applying shear, scale, rotation and translation.

Arguments

NameTypeDocumentation
_selfAffine2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

Affine3A

Affine3A

  • matrix3:glam::Mat3A
  • translation:glam::Vec3A

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_quatCreates an affine transform from the given `rotation` quaternion.
transform_point3Transforms the given 3D points, applying shear, scale, rotation and translation.
transform_vector3Transforms the given 3D vector, applying shear, scale and rotation (but NOT translation). To also...
from_rotation_zCreates an affine transform containing a 3D rotation around the z axis of `angle` (in radians).
to_cols_arrayCreates a `[f32; 12]` array storing data in column major order.
from_rotation_yCreates an affine transform containing a 3D rotation around the y axis of `angle` (in radians).
transform_vector3aTransforms the given [`Vec3A`], applying shear, scale and rotation (but NOT translation). To also apply translation, use [`Self::transform_point3a()`]...
to_cols_array_2dCreates a `[[f32; 3]; 4]` 3D array storing data in column major order. If you require data in row...
from_scaleCreates an affine transform that changes scale. Note that if any scale is zero the transform will ...
look_to_rhCreates a right-handed view transform using a camera position, an up direction, and a facing direc...
look_at_rhCreates a right-handed view transform using a camera position, an up direction, and a focal point....
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...
from_mat3_translationCreates an affine transform from a 3x3 matrix (expressing scale, shear and rotation) and a transla...
is_nanReturns `true` if any elements are `NaN`.
eqNo Documentation 🚧
from_scale_rotation_translationCreates an affine transform from the given 3D `scale`, `rotation` and `translation`. Equivalent t...
from_mat3Creates an affine transform from a 3x3 matrix (expressing scale, shear and rotation)
from_colsCreates an affine transform from three column vectors.
from_rotation_translationCreates an affine transform from the given 3D `rotation` and `translation`. Equivalent to `Affine3A::from_translation(translation) * Affine3A::from_quat(rotation)`
inverseReturn the inverse of this transform. Note that if the transform is not invertible the result will...
mul-1No Documentation 🚧
look_to_lhCreates a left-handed view transform using a camera position, an up direction, and a facing direct...
look_at_lhCreates a left-handed view transform using a camera position, an up direction, and a focal point. ...
cloneNo Documentation 🚧
transform_point3aTransforms the given [`Vec3A`], applying shear, scale, rotation and translation.
from_translationCreates an affine transformation from the given 3D `translation`.
mulNo Documentation 🚧
from_mat4The given `Mat4` must be an affine transform, i.e. contain no perspective transform.
from_axis_angleCreates an affine transform containing a 3D rotation around a normalized rotation `axis` of `angle...
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive ...
from_rotation_xCreates an affine transform containing a 3D rotation around the x axis of `angle` (in radians).

from_quat

Creates an affine transform from the given rotation quaternion.

Arguments

NameTypeDocumentation
rotationQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

transform_point3

Transforms the given 3D points, applying shear, scale, rotation and translation.

Arguments

NameTypeDocumentation
_selfAffine3ANo Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

transform_vector3

Transforms the given 3D vector, applying shear, scale and rotation (but NOT translation). To also apply translation, use [Self::transform_point3()] instead.

Arguments

NameTypeDocumentation
_selfAffine3ANo Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

from_rotation_z

Creates an affine transform containing a 3D rotation around the z axis of angle (in radians).

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

to_cols_array

Creates a [f32; 12] array storing data in column major order.

Arguments

NameTypeDocumentation
_selfAffine3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0[f32; 12]No Documentation 🚧

from_rotation_y

Creates an affine transform containing a 3D rotation around the y axis of angle (in radians).

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

transform_vector3a

Transforms the given [Vec3A], applying shear, scale and rotation (but NOT translation). To also apply translation, use [Self::transform_point3a()] instead.

Arguments

NameTypeDocumentation
_selfAffine3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

to_cols_array_2d

Creates a [[f32; 3]; 4] 3D array storing data in column major order. If you require data in row major order transpose the matrix first.

Arguments

NameTypeDocumentation
_selfAffine3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0[[f32; 3]; 4]No Documentation 🚧

from_scale

Creates an affine transform that changes scale. Note that if any scale is zero the transform will be non-invertible.

Arguments

NameTypeDocumentation
scaleVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

look_to_rh

Creates a right-handed view transform using a camera position, an up direction, and a facing direction. For a view coordinate system with +X=right, +Y=up and +Z=back.

Arguments

NameTypeDocumentation
eyeVec3No Documentation 🚧
dirVec3No Documentation 🚧
upVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

look_at_rh

Creates a right-handed view transform using a camera position, an up direction, and a focal point. For a view coordinate system with +X=right, +Y=up and +Z=back.

Panics

Will panic if up is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
eyeVec3No Documentation 🚧
centerVec3No Documentation 🚧
upVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two 3x4 matrices contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfAffine3ANo Documentation 🚧
rhsAffine3ANo Documentation 🚧
max_abs_difff32No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_mat3_translation

Creates an affine transform from a 3x3 matrix (expressing scale, shear and rotation) and a translation vector. Equivalent to Affine3A::from_translation(translation) * Affine3A::from_mat3(mat3)

Arguments

NameTypeDocumentation
mat3Mat3No Documentation 🚧
translationVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

is_nan

Returns true if any elements are NaN.

Arguments

NameTypeDocumentation
_selfAffine3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAffine3ANo Documentation 🚧
rhsAffine3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_scale_rotation_translation

Creates an affine transform from the given 3D scale, rotation and translation. Equivalent to Affine3A::from_translation(translation) * Affine3A::from_quat(rotation) * Affine3A::from_scale(scale)

Arguments

NameTypeDocumentation
scaleVec3No Documentation 🚧
rotationQuatNo Documentation 🚧
translationVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

from_mat3

Creates an affine transform from a 3x3 matrix (expressing scale, shear and rotation)

Arguments

NameTypeDocumentation
mat3Mat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

from_cols

Creates an affine transform from three column vectors.

Arguments

NameTypeDocumentation
x_axisVec3ANo Documentation 🚧
y_axisVec3ANo Documentation 🚧
z_axisVec3ANo Documentation 🚧
w_axisVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

from_rotation_translation

Creates an affine transform from the given 3D rotation and translation. Equivalent to Affine3A::from_translation(translation) * Affine3A::from_quat(rotation)

Arguments

NameTypeDocumentation
rotationQuatNo Documentation 🚧
translationVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

inverse

Return the inverse of this transform. Note that if the transform is not invertible the result will be invalid.

Arguments

NameTypeDocumentation
_selfAffine3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧
arg1Mat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

look_to_lh

Creates a left-handed view transform using a camera position, an up direction, and a facing direction. For a view coordinate system with +X=right, +Y=up and +Z=forward.

Arguments

NameTypeDocumentation
eyeVec3No Documentation 🚧
dirVec3No Documentation 🚧
upVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

look_at_lh

Creates a left-handed view transform using a camera position, an up direction, and a focal point. For a view coordinate system with +X=right, +Y=up and +Z=forward.

Panics

Will panic if up is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
eyeVec3No Documentation 🚧
centerVec3No Documentation 🚧
upVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAffine3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

transform_point3a

Transforms the given [Vec3A], applying shear, scale, rotation and translation.

Arguments

NameTypeDocumentation
_selfAffine3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

from_translation

Creates an affine transformation from the given 3D translation.

Arguments

NameTypeDocumentation
translationVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfAffine3ANo Documentation 🚧
rhsAffine3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

from_mat4

The given Mat4 must be an affine transform, i.e. contain no perspective transform.

Arguments

NameTypeDocumentation
mMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

from_axis_angle

Creates an affine transform containing a 3D rotation around a normalized rotation axis of angle (in radians).

Arguments

NameTypeDocumentation
axisVec3No Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfAffine3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_rotation_x

Creates an affine transform containing a 3D rotation around the x axis of angle (in radians).

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Affine3ANo Documentation 🚧

BVec2

BVec2

  • x:bool
  • y:bool

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
testTests the value at `index`. Panics if `index` is greater than 1.
eqNo Documentation 🚧
splatCreates a vector mask with all elements set to `v`.
from_arrayCreates a new vector mask from a bool array.
setSets the element at `index`. Panics if `index` is greater than 1.
cloneNo Documentation 🚧
anyReturns true if any of the elements are true, false otherwise.
allReturns true if all the elements are true, false otherwise.
newCreates a new vector mask.
assert_receiver_is_total_eqNo Documentation 🚧
bitmaskReturns a bitmask with the lowest 2 bits set from the elements of `self`. A true element results i...

test

Tests the value at index. Panics if index is greater than 1.

Arguments

NameTypeDocumentation
_selfBVec2No Documentation 🚧
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfBVec2No Documentation 🚧
otherBVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

splat

Creates a vector mask with all elements set to v.

Arguments

NameTypeDocumentation
vboolNo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

from_array

Creates a new vector mask from a bool array.

Arguments

NameTypeDocumentation
a[bool; 2]No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

set

Sets the element at index. Panics if index is greater than 1.

Arguments

NameTypeDocumentation
_selfBVec2No Documentation 🚧
indexusizeNo Documentation 🚧
valueboolNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfBVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

any

Returns true if any of the elements are true, false otherwise.

Arguments

NameTypeDocumentation
_selfBVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

all

Returns true if all the elements are true, false otherwise.

Arguments

NameTypeDocumentation
_selfBVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

new

Creates a new vector mask.

Arguments

NameTypeDocumentation
xboolNo Documentation 🚧
yboolNo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfBVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

bitmask

Returns a bitmask with the lowest 2 bits set from the elements of self. A true element results in a 1 bit and a false element in a 0 bit. Element x goes into the first lowest bit, element y into the second, etc.

Arguments

NameTypeDocumentation
_selfBVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

BVec3

BVec3

  • x:bool
  • y:bool
  • z:bool

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
assert_receiver_is_total_eqNo Documentation 🚧
bitmaskReturns a bitmask with the lowest 3 bits set from the elements of `self`. A true element results i...
newCreates a new vector mask.
eqNo Documentation 🚧
testTests the value at `index`. Panics if `index` is greater than 2.
splatCreates a vector mask with all elements set to `v`.
allReturns true if all the elements are true, false otherwise.
anyReturns true if any of the elements are true, false otherwise.
cloneNo Documentation 🚧
setSets the element at `index`. Panics if `index` is greater than 2.
from_arrayCreates a new vector mask from a bool array.

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfBVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

bitmask

Returns a bitmask with the lowest 3 bits set from the elements of self. A true element results in a 1 bit and a false element in a 0 bit. Element x goes into the first lowest bit, element y into the second, etc.

Arguments

NameTypeDocumentation
_selfBVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

new

Creates a new vector mask.

Arguments

NameTypeDocumentation
xboolNo Documentation 🚧
yboolNo Documentation 🚧
zboolNo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfBVec3No Documentation 🚧
otherBVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

test

Tests the value at index. Panics if index is greater than 2.

Arguments

NameTypeDocumentation
_selfBVec3No Documentation 🚧
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

splat

Creates a vector mask with all elements set to v.

Arguments

NameTypeDocumentation
vboolNo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

all

Returns true if all the elements are true, false otherwise.

Arguments

NameTypeDocumentation
_selfBVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

any

Returns true if any of the elements are true, false otherwise.

Arguments

NameTypeDocumentation
_selfBVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfBVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

set

Sets the element at index. Panics if index is greater than 2.

Arguments

NameTypeDocumentation
_selfBVec3No Documentation 🚧
indexusizeNo Documentation 🚧
valueboolNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

from_array

Creates a new vector mask from a bool array.

Arguments

NameTypeDocumentation
a[bool; 3]No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

BVec3A

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
setSets the element at `index`. Panics if `index` is greater than 2.
from_arrayCreates a new vector mask from a bool array.
eqNo Documentation 🚧
testTests the value at `index`. Panics if `index` is greater than 2.
anyReturns true if any of the elements are true, false otherwise.
newCreates a new vector mask.
cloneNo Documentation 🚧
allReturns true if all the elements are true, false otherwise.
bitmaskReturns a bitmask with the lowest 3 bits set from the elements of `self`. A true element results i...
splatCreates a vector mask with all elements set to `v`.

set

Sets the element at index. Panics if index is greater than 2.

Arguments

NameTypeDocumentation
_selfBVec3ANo Documentation 🚧
indexusizeNo Documentation 🚧
valueboolNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

from_array

Creates a new vector mask from a bool array.

Arguments

NameTypeDocumentation
a[bool; 3]No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3ANo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfBVec3ANo Documentation 🚧
rhsBVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

test

Tests the value at index. Panics if index is greater than 2.

Arguments

NameTypeDocumentation
_selfBVec3ANo Documentation 🚧
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

any

Returns true if any of the elements are true, false otherwise.

Arguments

NameTypeDocumentation
_selfBVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

new

Creates a new vector mask.

Arguments

NameTypeDocumentation
xboolNo Documentation 🚧
yboolNo Documentation 🚧
zboolNo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3ANo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfBVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3ANo Documentation 🚧

all

Returns true if all the elements are true, false otherwise.

Arguments

NameTypeDocumentation
_selfBVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

bitmask

Returns a bitmask with the lowest 3 bits set from the elements of self. A true element results in a 1 bit and a false element in a 0 bit. Element x goes into the first lowest bit, element y into the second, etc.

Arguments

NameTypeDocumentation
_selfBVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

splat

Creates a vector mask with all elements set to v.

Arguments

NameTypeDocumentation
vboolNo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3ANo Documentation 🚧

BVec4

BVec4

  • x:bool
  • y:bool
  • z:bool
  • w:bool

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cloneNo Documentation 🚧
anyReturns true if any of the elements are true, false otherwise.
allReturns true if all the elements are true, false otherwise.
eqNo Documentation 🚧
from_arrayCreates a new vector mask from a bool array.
bitmaskReturns a bitmask with the lowest 4 bits set from the elements of `self`. A true element results i...
newCreates a new vector mask.
assert_receiver_is_total_eqNo Documentation 🚧
setSets the element at `index`. Panics if `index` is greater than 3.
testTests the value at `index`. Panics if `index` is greater than 3.
splatCreates a vector mask with all elements set to `v`.

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfBVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

any

Returns true if any of the elements are true, false otherwise.

Arguments

NameTypeDocumentation
_selfBVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

all

Returns true if all the elements are true, false otherwise.

Arguments

NameTypeDocumentation
_selfBVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfBVec4No Documentation 🚧
otherBVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_array

Creates a new vector mask from a bool array.

Arguments

NameTypeDocumentation
a[bool; 4]No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

bitmask

Returns a bitmask with the lowest 4 bits set from the elements of self. A true element results in a 1 bit and a false element in a 0 bit. Element x goes into the first lowest bit, element y into the second, etc.

Arguments

NameTypeDocumentation
_selfBVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

new

Creates a new vector mask.

Arguments

NameTypeDocumentation
xboolNo Documentation 🚧
yboolNo Documentation 🚧
zboolNo Documentation 🚧
wboolNo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfBVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

set

Sets the element at index. Panics if index is greater than 3.

Arguments

NameTypeDocumentation
_selfBVec4No Documentation 🚧
indexusizeNo Documentation 🚧
valueboolNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

test

Tests the value at index. Panics if index is greater than 3.

Arguments

NameTypeDocumentation
_selfBVec4No Documentation 🚧
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

splat

Creates a vector mask with all elements set to v.

Arguments

NameTypeDocumentation
vboolNo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

BVec4A

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_arrayCreates a new vector mask from a bool array.
bitmaskReturns a bitmask with the lowest 4 bits set from the elements of `self`. A true element results i...
newCreates a new vector mask.
testTests the value at `index`. Panics if `index` is greater than 3.
eqNo Documentation 🚧
cloneNo Documentation 🚧
splatCreates a vector mask with all elements set to `v`.
allReturns true if all the elements are true, false otherwise.
setSets the element at `index`. Panics if `index` is greater than 3.
anyReturns true if any of the elements are true, false otherwise.

from_array

Creates a new vector mask from a bool array.

Arguments

NameTypeDocumentation
a[bool; 4]No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4ANo Documentation 🚧

bitmask

Returns a bitmask with the lowest 4 bits set from the elements of self. A true element results in a 1 bit and a false element in a 0 bit. Element x goes into the first lowest bit, element y into the second, etc.

Arguments

NameTypeDocumentation
_selfBVec4ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

new

Creates a new vector mask.

Arguments

NameTypeDocumentation
xboolNo Documentation 🚧
yboolNo Documentation 🚧
zboolNo Documentation 🚧
wboolNo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4ANo Documentation 🚧

test

Tests the value at index. Panics if index is greater than 3.

Arguments

NameTypeDocumentation
_selfBVec4ANo Documentation 🚧
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfBVec4ANo Documentation 🚧
rhsBVec4ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfBVec4ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4ANo Documentation 🚧

splat

Creates a vector mask with all elements set to v.

Arguments

NameTypeDocumentation
vboolNo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4ANo Documentation 🚧

all

Returns true if all the elements are true, false otherwise.

Arguments

NameTypeDocumentation
_selfBVec4ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

set

Sets the element at index. Panics if index is greater than 3.

Arguments

NameTypeDocumentation
_selfBVec4ANo Documentation 🚧
indexusizeNo Documentation 🚧
valueboolNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

any

Returns true if any of the elements are true, false otherwise.

Arguments

NameTypeDocumentation
_selfBVec4ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

DAffine2

DAffine2

  • matrix2:glam::DMat2
  • translation:glam::DVec2

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_colsCreates an affine transform from three column vectors.
to_cols_arrayCreates a `[f64; 6]` array storing data in column major order.
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...
from_mat3The given `DMat3` must be an affine transform,
from_angle_translationCreates an affine transform from the given 2D rotation `angle` (in radians) and `translation`. Eq...
mulNo Documentation 🚧
mul-1No Documentation 🚧
from_scale_angle_translationCreates an affine transform from the given 2D `scale`, rotation `angle` (in radians) and `translation`...
eqNo Documentation 🚧
from_mat2Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation)
from_translationCreates an affine transformation from the given 2D `translation`.
transform_vector2Transforms the given 2D vector, applying shear, scale and rotation (but NOT translation). To also...
transform_point2Transforms the given 2D point, applying shear, scale, rotation and translation.
from_mat2_translationCreates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) and a transla...
is_nanReturns `true` if any elements are `NaN`.
from_scaleCreates an affine transform that changes scale. Note that if any scale is zero the transform will ...
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive ...
to_cols_array_2dCreates a `[[f64; 2]; 3]` 2D array storing data in column major order. If you require data in row...
inverseReturn the inverse of this transform. Note that if the transform is not invertible the result will...
from_angleCreates an affine transform from the given rotation `angle`.
cloneNo Documentation 🚧

from_cols

Creates an affine transform from three column vectors.

Arguments

NameTypeDocumentation
x_axisDVec2No Documentation 🚧
y_axisDVec2No Documentation 🚧
z_axisDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine2No Documentation 🚧

to_cols_array

Creates a [f64; 6] array storing data in column major order.

Arguments

NameTypeDocumentation
_selfDAffine2No Documentation 🚧

Returns

NameTypeDocumentation
arg0[f64; 6]No Documentation 🚧

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two 3x4 matrices contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfDAffine2No Documentation 🚧
rhsDAffine2No Documentation 🚧
max_abs_difff64No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_mat3

The given DMat3 must be an affine transform,

Arguments

NameTypeDocumentation
mDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine2No Documentation 🚧

from_angle_translation

Creates an affine transform from the given 2D rotation angle (in radians) and translation. Equivalent to DAffine2::from_translation(translation) * DAffine2::from_angle(angle)

Arguments

NameTypeDocumentation
anglef64No Documentation 🚧
translationDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine2No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDAffine2No Documentation 🚧
rhsDAffine2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine2No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DAffine2No Documentation 🚧
arg1DMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

from_scale_angle_translation

Creates an affine transform from the given 2D scale, rotation angle (in radians) and translation. Equivalent to DAffine2::from_translation(translation) * DAffine2::from_angle(angle) * DAffine2::from_scale(scale)

Arguments

NameTypeDocumentation
scaleDVec2No Documentation 🚧
anglef64No Documentation 🚧
translationDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine2No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDAffine2No Documentation 🚧
rhsDAffine2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_mat2

Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation)

Arguments

NameTypeDocumentation
matrix2DMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine2No Documentation 🚧

from_translation

Creates an affine transformation from the given 2D translation.

Arguments

NameTypeDocumentation
translationDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine2No Documentation 🚧

transform_vector2

Transforms the given 2D vector, applying shear, scale and rotation (but NOT translation). To also apply translation, use [Self::transform_point2()] instead.

Arguments

NameTypeDocumentation
_selfDAffine2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

transform_point2

Transforms the given 2D point, applying shear, scale, rotation and translation.

Arguments

NameTypeDocumentation
_selfDAffine2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

from_mat2_translation

Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) and a translation vector. Equivalent to DAffine2::from_translation(translation) * DAffine2::from_mat2(mat2)

Arguments

NameTypeDocumentation
matrix2DMat2No Documentation 🚧
translationDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine2No Documentation 🚧

is_nan

Returns true if any elements are NaN.

Arguments

NameTypeDocumentation
_selfDAffine2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_scale

Creates an affine transform that changes scale. Note that if any scale is zero the transform will be non-invertible.

Arguments

NameTypeDocumentation
scaleDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine2No Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfDAffine2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

to_cols_array_2d

Creates a [[f64; 2]; 3] 2D array storing data in column major order. If you require data in row major order transpose the matrix first.

Arguments

NameTypeDocumentation
_selfDAffine2No Documentation 🚧

Returns

NameTypeDocumentation
arg0[[f64; 2]; 3]No Documentation 🚧

inverse

Return the inverse of this transform. Note that if the transform is not invertible the result will be invalid.

Arguments

NameTypeDocumentation
_selfDAffine2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine2No Documentation 🚧

from_angle

Creates an affine transform from the given rotation angle.

Arguments

NameTypeDocumentation
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine2No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDAffine2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine2No Documentation 🚧

DAffine3

DAffine3

  • matrix3:glam::DMat3
  • translation:glam::DVec3

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...
look_to_rhCreates a right-handed view transform using a camera position, an up direction, and a facing direc...
from_mat3_translationCreates an affine transform from a 3x3 matrix (expressing scale, shear and rotation) and a transla...
transform_point3Transforms the given 3D points, applying shear, scale, rotation and translation.
to_cols_array_2dCreates a `[[f64; 3]; 4]` 3D array storing data in column major order. If you require data in row...
look_at_lhCreates a left-handed view transform using a camera position, an up direction, and a focal point. ...
from_rotation_zCreates an affine transform containing a 3D rotation around the z axis of `angle` (in radians).
from_translationCreates an affine transformation from the given 3D `translation`.
cloneNo Documentation 🚧
from_axis_angleCreates an affine transform containing a 3D rotation around a normalized rotation `axis` of `angle...
inverseReturn the inverse of this transform. Note that if the transform is not invertible the result will...
from_quatCreates an affine transform from the given `rotation` quaternion.
from_colsCreates an affine transform from three column vectors.
from_rotation_xCreates an affine transform containing a 3D rotation around the x axis of `angle` (in radians).
eqNo Documentation 🚧
mulNo Documentation 🚧
to_cols_arrayCreates a `[f64; 12]` array storing data in column major order.
from_scale_rotation_translationCreates an affine transform from the given 3D `scale`, `rotation` and `translation`. Equivalent t...
from_mat4The given `DMat4` must be an affine transform, i.e. contain no perspective transform.
from_mat3Creates an affine transform from a 3x3 matrix (expressing scale, shear and rotation)
is_nanReturns `true` if any elements are `NaN`.
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive ...
from_scaleCreates an affine transform that changes scale. Note that if any scale is zero the transform will ...
mul-1No Documentation 🚧
look_to_lhCreates a left-handed view transform using a camera position, an up direction, and a facing direct...
transform_vector3Transforms the given 3D vector, applying shear, scale and rotation (but NOT translation). To also...
from_rotation_yCreates an affine transform containing a 3D rotation around the y axis of `angle` (in radians).
from_rotation_translationCreates an affine transform from the given 3D `rotation` and `translation`. Equivalent to `DAffine3::from_translation(translation) * DAffine3::from_quat(rotation)`
look_at_rhCreates a right-handed view transform using a camera position, an up direction, and a focal point....

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two 3x4 matrices contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfDAffine3No Documentation 🚧
rhsDAffine3No Documentation 🚧
max_abs_difff64No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

look_to_rh

Creates a right-handed view transform using a camera position, an up direction, and a facing direction. For a view coordinate system with +X=right, +Y=up and +Z=back.

Arguments

NameTypeDocumentation
eyeDVec3No Documentation 🚧
dirDVec3No Documentation 🚧
upDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

from_mat3_translation

Creates an affine transform from a 3x3 matrix (expressing scale, shear and rotation) and a translation vector. Equivalent to DAffine3::from_translation(translation) * DAffine3::from_mat3(mat3)

Arguments

NameTypeDocumentation
mat3DMat3No Documentation 🚧
translationDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

transform_point3

Transforms the given 3D points, applying shear, scale, rotation and translation.

Arguments

NameTypeDocumentation
_selfDAffine3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

to_cols_array_2d

Creates a [[f64; 3]; 4] 3D array storing data in column major order. If you require data in row major order transpose the matrix first.

Arguments

NameTypeDocumentation
_selfDAffine3No Documentation 🚧

Returns

NameTypeDocumentation
arg0[[f64; 3]; 4]No Documentation 🚧

look_at_lh

Creates a left-handed view transform using a camera position, an up direction, and a focal point. For a view coordinate system with +X=right, +Y=up and +Z=forward.

Panics

Will panic if up is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
eyeDVec3No Documentation 🚧
centerDVec3No Documentation 🚧
upDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

from_rotation_z

Creates an affine transform containing a 3D rotation around the z axis of angle (in radians).

Arguments

NameTypeDocumentation
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

from_translation

Creates an affine transformation from the given 3D translation.

Arguments

NameTypeDocumentation
translationDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDAffine3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

from_axis_angle

Creates an affine transform containing a 3D rotation around a normalized rotation axis of angle (in radians).

Arguments

NameTypeDocumentation
axisDVec3No Documentation 🚧
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

inverse

Return the inverse of this transform. Note that if the transform is not invertible the result will be invalid.

Arguments

NameTypeDocumentation
_selfDAffine3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

from_quat

Creates an affine transform from the given rotation quaternion.

Arguments

NameTypeDocumentation
rotationDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

from_cols

Creates an affine transform from three column vectors.

Arguments

NameTypeDocumentation
x_axisDVec3No Documentation 🚧
y_axisDVec3No Documentation 🚧
z_axisDVec3No Documentation 🚧
w_axisDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

from_rotation_x

Creates an affine transform containing a 3D rotation around the x axis of angle (in radians).

Arguments

NameTypeDocumentation
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDAffine3No Documentation 🚧
rhsDAffine3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDAffine3No Documentation 🚧
rhsDAffine3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

to_cols_array

Creates a [f64; 12] array storing data in column major order.

Arguments

NameTypeDocumentation
_selfDAffine3No Documentation 🚧

Returns

NameTypeDocumentation
arg0[f64; 12]No Documentation 🚧

from_scale_rotation_translation

Creates an affine transform from the given 3D scale, rotation and translation. Equivalent to DAffine3::from_translation(translation) * DAffine3::from_quat(rotation) * DAffine3::from_scale(scale)

Arguments

NameTypeDocumentation
scaleDVec3No Documentation 🚧
rotationDQuatNo Documentation 🚧
translationDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

from_mat4

The given DMat4 must be an affine transform, i.e. contain no perspective transform.

Arguments

NameTypeDocumentation
mDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

from_mat3

Creates an affine transform from a 3x3 matrix (expressing scale, shear and rotation)

Arguments

NameTypeDocumentation
mat3DMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

is_nan

Returns true if any elements are NaN.

Arguments

NameTypeDocumentation
_selfDAffine3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfDAffine3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_scale

Creates an affine transform that changes scale. Note that if any scale is zero the transform will be non-invertible.

Arguments

NameTypeDocumentation
scaleDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DAffine3No Documentation 🚧
arg1DMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

look_to_lh

Creates a left-handed view transform using a camera position, an up direction, and a facing direction. For a view coordinate system with +X=right, +Y=up and +Z=forward.

Arguments

NameTypeDocumentation
eyeDVec3No Documentation 🚧
dirDVec3No Documentation 🚧
upDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

transform_vector3

Transforms the given 3D vector, applying shear, scale and rotation (but NOT translation). To also apply translation, use [Self::transform_point3()] instead.

Arguments

NameTypeDocumentation
_selfDAffine3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

from_rotation_y

Creates an affine transform containing a 3D rotation around the y axis of angle (in radians).

Arguments

NameTypeDocumentation
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

from_rotation_translation

Creates an affine transform from the given 3D rotation and translation. Equivalent to DAffine3::from_translation(translation) * DAffine3::from_quat(rotation)

Arguments

NameTypeDocumentation
rotationDQuatNo Documentation 🚧
translationDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

look_at_rh

Creates a right-handed view transform using a camera position, an up direction, and a focal point. For a view coordinate system with +X=right, +Y=up and +Z=back.

Panics

Will panic if up is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
eyeDVec3No Documentation 🚧
centerDVec3No Documentation 🚧
upDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DAffine3No Documentation 🚧

DMat2

DMat2

  • x_axis:glam::DVec2
  • y_axis:glam::DVec2

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
addNo Documentation 🚧
sub_mat2Subtracts two 2x2 matrices.
mul-1No Documentation 🚧
from_colsCreates a 2x2 matrix from two column vectors.
eqNo Documentation 🚧
divNo Documentation 🚧
from_diagonalCreates a 2x2 matrix with its diagonal set to `diagonal` and all other entries set to 0.
colReturns the matrix column for the given `index`. # Panics Panics if `index` is greater than 1.
to_cols_array_2dCreates a `[[f64; 2]; 2]` 2D array storing data in column major order. If you require data in row ...
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...
mul_scalarMultiplies a 2x2 matrix by a scalar.
rowReturns the matrix row for the given `index`. # Panics Panics if `index` is greater than 1.
as_mat2No Documentation 🚧
absTakes the absolute value of each element in `self`
negNo Documentation 🚧
mulNo Documentation 🚧
mul-2No Documentation 🚧
determinantReturns the determinant of `self`.
from_mat3Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column.
from_scale_angleCreates a 2x2 matrix containing the combining non-uniform `scale` and rotation of `angle` (in radi...
from_mat3_minorCreates a 2x2 matrix from the minor of the given 3x3 matrix, discarding the `i`th column and `j`th...
to_cols_arrayCreates a `[f64; 4]` array storing data in column major order. If you require data in row major order `transpose` the matrix first.
cloneNo Documentation 🚧
is_nanReturns `true` if any elements are `NaN`.
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive ...
mul_vec2Transforms a 2D vector.
mul_mat2Multiplies two 2x2 matrices.
inverseReturns the inverse of `self`. If the matrix is not invertible the returned matrix will be invalid...
subNo Documentation 🚧
div_scalarDivides a 2x2 matrix by a scalar.
from_angleCreates a 2x2 matrix containing a rotation of `angle` (in radians).
transposeReturns the transpose of `self`.
add_mat2Adds two 2x2 matrices.

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧
rhsDMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

sub_mat2

Subtracts two 2x2 matrices.

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧
rhsDMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DMat2No Documentation 🚧
arg1DVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

from_cols

Creates a 2x2 matrix from two column vectors.

Arguments

NameTypeDocumentation
x_axisDVec2No Documentation 🚧
y_axisDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧
rhsDMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧
rhsf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

from_diagonal

Creates a 2x2 matrix with its diagonal set to diagonal and all other entries set to 0.

Arguments

NameTypeDocumentation
diagonalDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

col

Returns the matrix column for the given index.

Panics

Panics if index is greater than 1.

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

to_cols_array_2d

Creates a [[f64; 2]; 2] 2D array storing data in column major order. If you require data in row major order transpose the matrix first.

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0[[f64; 2]; 2]No Documentation 🚧

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two matrices contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧
rhsDMat2No Documentation 🚧
max_abs_difff64No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

mul_scalar

Multiplies a 2x2 matrix by a scalar.

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧
rhsf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

row

Returns the matrix row for the given index.

Panics

Panics if index is greater than 1.

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

as_mat2

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

abs

Takes the absolute value of each element in self

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧
rhsDMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DMat2No Documentation 🚧
arg1f64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

determinant

Returns the determinant of self.

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

from_mat3

Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column.

Arguments

NameTypeDocumentation
mDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

from_scale_angle

Creates a 2x2 matrix containing the combining non-uniform scale and rotation of angle (in radians).

Arguments

NameTypeDocumentation
scaleDVec2No Documentation 🚧
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

from_mat3_minor

Creates a 2x2 matrix from the minor of the given 3x3 matrix, discarding the ith column and jth row.

Panics

Panics if i or j is greater than 2.

Arguments

NameTypeDocumentation
mDMat3No Documentation 🚧
iusizeNo Documentation 🚧
jusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

to_cols_array

Creates a [f64; 4] array storing data in column major order. If you require data in row major order transpose the matrix first.

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0[f64; 4]No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

is_nan

Returns true if any elements are NaN.

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

mul_vec2

Transforms a 2D vector.

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

mul_mat2

Multiplies two 2x2 matrices.

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧
rhsDMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

inverse

Returns the inverse of self. If the matrix is not invertible the returned matrix will be invalid.

Panics

Will panic if the determinant of self is zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧
rhsDMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

div_scalar

Divides a 2x2 matrix by a scalar.

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧
rhsf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

from_angle

Creates a 2x2 matrix containing a rotation of angle (in radians).

Arguments

NameTypeDocumentation
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

transpose

Returns the transpose of self.

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

add_mat2

Adds two 2x2 matrices.

Arguments

NameTypeDocumentation
_selfDMat2No Documentation 🚧
rhsDMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

DMat3

DMat3

  • x_axis:glam::DVec3
  • y_axis:glam::DVec3
  • z_axis:glam::DVec3

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
to_cols_arrayCreates a `[f64; 9]` array storing data in column major order. If you require data in row major order `transpose` the matrix first.
div_scalarDivides a 3x3 matrix by a scalar.
mul-3No Documentation 🚧
as_mat3No Documentation 🚧
transform_point2Transforms the given 2D vector as a point. This is the equivalent of multiplying `rhs` as a 3D vec...
determinantReturns the determinant of `self`.
eqNo Documentation 🚧
from_angleCreates an affine transformation matrix from the given 2D rotation `angle` (in radians). The resu...
from_mat4_minorCreates a 3x3 matrix from the minor of the given 4x4 matrix, discarding the `i`th column and `j`th...
mul_vec3Transforms a 3D vector.
from_mat4Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column.
from_rotation_yCreates a 3D rotation matrix from `angle` (in radians) around the y axis.
to_eulerExtract Euler angles with the given Euler rotation order. Note if the input matrix contains scales...
absTakes the absolute value of each element in `self`
add_mat3Adds two 3x3 matrices.
colReturns the matrix column for the given `index`. # Panics Panics if `index` is greater than 2.
from_colsCreates a 3x3 matrix from three column vectors.
is_nanReturns `true` if any elements are `NaN`.
divNo Documentation 🚧
transposeReturns the transpose of `self`.
from_translationCreates an affine transformation matrix from the given 2D `translation`. The resulting matrix can ...
from_rotation_zCreates a 3D rotation matrix from `angle` (in radians) around the z axis.
cloneNo Documentation 🚧
from_eulerCreates a 3D rotation matrix from the given euler rotation sequence and the angles (in radians).
mul-2No Documentation 🚧
addNo Documentation 🚧
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...
rowReturns the matrix row for the given `index`. # Panics Panics if `index` is greater than 2.
inverseReturns the inverse of `self`. If the matrix is not invertible the returned matrix will be invalid...
from_mat2Creates an affine transformation matrix from the given 2x2 matrix. The resulting matrix can be use...
from_rotation_xCreates a 3D rotation matrix from `angle` (in radians) around the x axis.
from_scaleCreates an affine transformation matrix from the given non-uniform 2D `scale`. The resulting matri...
mul-1No Documentation 🚧
to_cols_array_2dCreates a `[[f64; 3]; 3]` 3D array storing data in column major order. If you require data in row ...
from_diagonalCreates a 3x3 matrix with its diagonal set to `diagonal` and all other entries set to 0.
mul_mat3Multiplies two 3x3 matrices.
transform_vector2Rotates the given 2D vector. This is the equivalent of multiplying `rhs` as a 3D vector where `z` ...
from_axis_angleCreates a 3D rotation matrix from a normalized rotation `axis` and `angle` (in radians). # Panics...
mulNo Documentation 🚧
from_scale_angle_translationCreates an affine transformation matrix from the given 2D `scale`, rotation `angle` (in radians) a...
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive ...
sub_mat3Subtracts two 3x3 matrices.
mul_scalarMultiplies a 3x3 matrix by a scalar.
negNo Documentation 🚧
subNo Documentation 🚧
from_quatCreates a 3D rotation matrix from the given quaternion. # Panics Will panic if `rotation` is not ...

to_cols_array

Creates a [f64; 9] array storing data in column major order. If you require data in row major order transpose the matrix first.

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0[f64; 9]No Documentation 🚧

div_scalar

Divides a 3x3 matrix by a scalar.

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧
rhsf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

mul-3

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DMat3No Documentation 🚧
arg1f64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

as_mat3

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

transform_point2

Transforms the given 2D vector as a point. This is the equivalent of multiplying rhs as a 3D vector where z is 1. This method assumes that self contains a valid affine transform.

Panics

Will panic if the 2nd row of self is not (0, 0, 1) when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

determinant

Returns the determinant of self.

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧
rhsDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_angle

Creates an affine transformation matrix from the given 2D rotation angle (in radians). The resulting matrix can be used to transform 2D points and vectors. See [Self::transform_point2()] and [Self::transform_vector2()].

Arguments

NameTypeDocumentation
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

from_mat4_minor

Creates a 3x3 matrix from the minor of the given 4x4 matrix, discarding the ith column and jth row.

Panics

Panics if i or j is greater than 3.

Arguments

NameTypeDocumentation
mDMat4No Documentation 🚧
iusizeNo Documentation 🚧
jusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

mul_vec3

Transforms a 3D vector.

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

from_mat4

Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column.

Arguments

NameTypeDocumentation
mDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

from_rotation_y

Creates a 3D rotation matrix from angle (in radians) around the y axis.

Arguments

NameTypeDocumentation
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

to_euler

Extract Euler angles with the given Euler rotation order. Note if the input matrix contains scales, shears, or other non-rotation transformations then the resulting Euler angles will be ill-defined.

Panics

Will panic if any input matrix column is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧
orderEulerRotNo Documentation 🚧

Returns

NameTypeDocumentation
arg0(f64, f64, f64)No Documentation 🚧

abs

Takes the absolute value of each element in self

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

add_mat3

Adds two 3x3 matrices.

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧
rhsDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

col

Returns the matrix column for the given index.

Panics

Panics if index is greater than 2.

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

from_cols

Creates a 3x3 matrix from three column vectors.

Arguments

NameTypeDocumentation
x_axisDVec3No Documentation 🚧
y_axisDVec3No Documentation 🚧
z_axisDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

is_nan

Returns true if any elements are NaN.

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧
rhsf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

transpose

Returns the transpose of self.

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

from_translation

Creates an affine transformation matrix from the given 2D translation. The resulting matrix can be used to transform 2D points and vectors. See [Self::transform_point2()] and [Self::transform_vector2()].

Arguments

NameTypeDocumentation
translationDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

from_rotation_z

Creates a 3D rotation matrix from angle (in radians) around the z axis.

Arguments

NameTypeDocumentation
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

from_euler

Creates a 3D rotation matrix from the given euler rotation sequence and the angles (in radians).

Arguments

NameTypeDocumentation
orderEulerRotNo Documentation 🚧
af64No Documentation 🚧
bf64No Documentation 🚧
cf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DMat3No Documentation 🚧
arg1DVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧
rhsDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two matrices contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧
rhsDMat3No Documentation 🚧
max_abs_difff64No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

row

Returns the matrix row for the given index.

Panics

Panics if index is greater than 2.

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

inverse

Returns the inverse of self. If the matrix is not invertible the returned matrix will be invalid.

Panics

Will panic if the determinant of self is zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

from_mat2

Creates an affine transformation matrix from the given 2x2 matrix. The resulting matrix can be used to transform 2D points and vectors. See [Self::transform_point2()] and [Self::transform_vector2()].

Arguments

NameTypeDocumentation
mDMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

from_rotation_x

Creates a 3D rotation matrix from angle (in radians) around the x axis.

Arguments

NameTypeDocumentation
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

from_scale

Creates an affine transformation matrix from the given non-uniform 2D scale. The resulting matrix can be used to transform 2D points and vectors. See [Self::transform_point2()] and [Self::transform_vector2()].

Panics

Will panic if all elements of scale are zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
scaleDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DMat3No Documentation 🚧
arg1DMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

to_cols_array_2d

Creates a [[f64; 3]; 3] 3D array storing data in column major order. If you require data in row major order transpose the matrix first.

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0[[f64; 3]; 3]No Documentation 🚧

from_diagonal

Creates a 3x3 matrix with its diagonal set to diagonal and all other entries set to 0.

Arguments

NameTypeDocumentation
diagonalDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

mul_mat3

Multiplies two 3x3 matrices.

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧
rhsDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

transform_vector2

Rotates the given 2D vector. This is the equivalent of multiplying rhs as a 3D vector where z is 0. This method assumes that self contains a valid affine transform.

Panics

Will panic if the 2nd row of self is not (0, 0, 1) when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

from_axis_angle

Creates a 3D rotation matrix from a normalized rotation axis and angle (in radians).

Panics

Will panic if axis is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
axisDVec3No Documentation 🚧
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧
rhsDAffine2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

from_scale_angle_translation

Creates an affine transformation matrix from the given 2D scale, rotation angle (in radians) and translation. The resulting matrix can be used to transform 2D points and vectors. See [Self::transform_point2()] and [Self::transform_vector2()].

Arguments

NameTypeDocumentation
scaleDVec2No Documentation 🚧
anglef64No Documentation 🚧
translationDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

sub_mat3

Subtracts two 3x3 matrices.

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧
rhsDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

mul_scalar

Multiplies a 3x3 matrix by a scalar.

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧
rhsf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat3No Documentation 🚧
rhsDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

from_quat

Creates a 3D rotation matrix from the given quaternion.

Panics

Will panic if rotation is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
rotationDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

DMat4

DMat4

  • x_axis:glam::DVec4
  • y_axis:glam::DVec4
  • z_axis:glam::DVec4
  • w_axis:glam::DVec4

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_quatCreates an affine transformation matrix from the given `rotation` quaternion. The resulting matrix...
mul_mat4Multiplies two 4x4 matrices.
as_mat4No Documentation 🚧
mul-2No Documentation 🚧
look_to_lhCreates a left-handed view matrix using a camera position, an up direction, and a facing direction...
to_eulerExtract Euler angles with the given Euler rotation order. Note if the upper 3x3 matrix contain sca...
divNo Documentation 🚧
from_rotation_translationCreates an affine transformation matrix from the given 3D `translation`. The resulting matrix can ...
from_mat3Creates an affine transformation matrix from the given 3x3 linear transformation matrix. The resu...
colReturns the matrix column for the given `index`. # Panics Panics if `index` is greater than 3.
transform_vector3Transforms the give 3D vector as a direction. This is the equivalent of multiplying the 3D vector ...
mulNo Documentation 🚧
look_at_lhCreates a left-handed view matrix using a camera position, an up direction, and a focal point. Fo...
transform_point3Transforms the given 3D vector as a point. This is the equivalent of multiplying the 3D vector as ...
perspective_lhCreates a left-handed perspective projection matrix with `[0,1]` depth range. Useful to map the standard left-handed coordinate system into what WebGPU/Metal/Direct3D expect. # Panics Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is enabled.
transposeReturns the transpose of `self`.
from_diagonalCreates a 4x4 matrix with its diagonal set to `diagonal` and all other entries set to 0.
mul_scalarMultiplies a 4x4 matrix by a scalar.
mul-3No Documentation 🚧
from_rotation_xCreates an affine transformation matrix containing a 3D rotation around the x axis of `angle` (in ...
rowReturns the matrix row for the given `index`. # Panics Panics if `index` is greater than 3.
perspective_infinite_rhCreates an infinite right-handed perspective projection matrix with `[0,1]` depth range. Like `perspective_rh`, but with an infinite value for `z_far`. The result is that points near `z_near` are mapped to depth `0`, and as they move towards infinity the depth approaches `1`. # Panics Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is enabled.
from_rotation_zCreates an affine transformation matrix containing a 3D rotation around the z axis of `angle` (in ...
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive ...
negNo Documentation 🚧
div_scalarDivides a 4x4 matrix by a scalar.
from_scale_rotation_translationCreates an affine transformation matrix from the given 3D `scale`, `rotation` and `translation`. ...
addNo Documentation 🚧
perspective_rh_glCreates a right-handed perspective projection matrix with `[-1,1]` depth range. Useful to map the standard right-handed coordinate system into what OpenGL expects. This is the same as the OpenGL `gluPerspective` function. See https://www\.khronos\.org/registry/OpenGL\-Refpages/gl2\.1/xhtml/gluPerspective\.xml
from_rotation_yCreates an affine transformation matrix containing a 3D rotation around the y axis of `angle` (in ...
orthographic_rhCreates a right-handed orthographic projection matrix with `[0,1]` depth range. Useful to map a right-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect.
look_to_rhCreates a right-handed view matrix using a camera position, an up direction, and a facing directio...
subNo Documentation 🚧
to_cols_arrayCreates a `[f64; 16]` array storing data in column major order. If you require data in row major order `transpose` the matrix first.
from_eulerCreates a affine transformation matrix containing a rotation from the given euler rotation sequenc...
look_at_rhCreates a right-handed view matrix using a camera position, an up direction, and a focal point. F...
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...
sub_mat4Subtracts two 4x4 matrices.
add_mat4Adds two 4x4 matrices.
perspective_rhCreates a right-handed perspective projection matrix with `[0,1]` depth range. Useful to map the standard right-handed coordinate system into what WebGPU/Metal/Direct3D expect. # Panics Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is enabled.
from_translationCreates an affine transformation matrix from the given 3D `translation`. The resulting matrix can ...
cloneNo Documentation 🚧
perspective_infinite_reverse_lhCreates an infinite reverse left-handed perspective projection matrix with `[0,1]` depth range. Similar to `perspective_infinite_lh`, but maps `Z = z_near` to a depth of `1` and `Z = infinity` to a depth of `0`. # Panics Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled.
orthographic_lhCreates a left-handed orthographic projection matrix with `[0,1]` depth range. Useful to map a left-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect.
eqNo Documentation 🚧
from_axis_angleCreates an affine transformation matrix containing a 3D rotation around a normalized rotation `axis`...
mul-1No Documentation 🚧
mul_vec4Transforms a 4D vector.
determinantReturns the determinant of `self`.
from_scaleCreates an affine transformation matrix containing the given 3D non-uniform `scale`. The resulting...
to_cols_array_2dCreates a `[[f64; 4]; 4]` 4D array storing data in column major order. If you require data in row ...
absTakes the absolute value of each element in `self`
inverseReturns the inverse of `self`. If the matrix is not invertible the returned matrix will be invalid...
perspective_infinite_lhCreates an infinite left-handed perspective projection matrix with `[0,1]` depth range. Like `perspective_lh`, but with an infinite value for `z_far`. The result is that points near `z_near` are mapped to depth `0`, and as they move towards infinity the depth approaches `1`. # Panics Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is enabled.
orthographic_rh_glCreates a right-handed orthographic projection matrix with `[-1,1]` depth range. This is the same as the OpenGL `glOrtho` function in OpenGL. See https://www\.khronos\.org/registry/OpenGL\-Refpages/gl2\.1/xhtml/glOrtho\.xml Useful to map a right-handed coordinate system to the normalized device coordinates that OpenGL expects.
is_nanReturns `true` if any elements are `NaN`.
from_colsCreates a 4x4 matrix from four column vectors.
perspective_infinite_reverse_rhCreates an infinite reverse right-handed perspective projection matrix with `[0,1]` depth range. Similar to `perspective_infinite_rh`, but maps `Z = z_near` to a depth of `1` and `Z = infinity` to a depth of `0`. # Panics Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled.
project_point3Transforms the given 3D vector as a point, applying perspective correction. This is the equivalent...

from_quat

Creates an affine transformation matrix from the given rotation quaternion. The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Panics

Will panic if rotation is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
rotationDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

mul_mat4

Multiplies two 4x4 matrices.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧
rhsDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

as_mat4

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DMat4No Documentation 🚧
arg1DVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

look_to_lh

Creates a left-handed view matrix using a camera position, an up direction, and a facing direction. For a view coordinate system with +X=right, +Y=up and +Z=forward.

Arguments

NameTypeDocumentation
eyeDVec3No Documentation 🚧
dirDVec3No Documentation 🚧
upDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

to_euler

Extract Euler angles with the given Euler rotation order. Note if the upper 3x3 matrix contain scales, shears, or other non-rotation transformations then the resulting Euler angles will be ill-defined.

Panics

Will panic if any column of the upper 3x3 rotation matrix is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧
orderEulerRotNo Documentation 🚧

Returns

NameTypeDocumentation
arg0(f64, f64, f64)No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧
rhsf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

from_rotation_translation

Creates an affine transformation matrix from the given 3D translation. The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Panics

Will panic if rotation is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
rotationDQuatNo Documentation 🚧
translationDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

from_mat3

Creates an affine transformation matrix from the given 3x3 linear transformation matrix. The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Arguments

NameTypeDocumentation
mDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

col

Returns the matrix column for the given index.

Panics

Panics if index is greater than 3.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

transform_vector3

Transforms the give 3D vector as a direction. This is the equivalent of multiplying the 3D vector as a 4D vector where w is 0.0. This method assumes that self contains a valid affine transform.

Panics

Will panic if the 3rd row of self is not (0, 0, 0, 1) when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧
rhsDAffine3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

look_at_lh

Creates a left-handed view matrix using a camera position, an up direction, and a focal point. For a view coordinate system with +X=right, +Y=up and +Z=forward.

Panics

Will panic if up is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
eyeDVec3No Documentation 🚧
centerDVec3No Documentation 🚧
upDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

transform_point3

Transforms the given 3D vector as a point. This is the equivalent of multiplying the 3D vector as a 4D vector where w is 1.0. This method assumes that self contains a valid affine transform. It does not perform a perspective divide, if self contains a perspective transform, or if you are unsure, the [Self::project_point3()] method should be used instead.

Panics

Will panic if the 3rd row of self is not (0, 0, 0, 1) when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

perspective_lh

Creates a left-handed perspective projection matrix with [0,1] depth range. Useful to map the standard left-handed coordinate system into what WebGPU/Metal/Direct3D expect.

Panics

Will panic if z_near or z_far are less than or equal to zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
fov_y_radiansf64No Documentation 🚧
aspect_ratiof64No Documentation 🚧
z_nearf64No Documentation 🚧
z_farf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

transpose

Returns the transpose of self.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

from_diagonal

Creates a 4x4 matrix with its diagonal set to diagonal and all other entries set to 0.

Arguments

NameTypeDocumentation
diagonalDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

mul_scalar

Multiplies a 4x4 matrix by a scalar.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧
rhsf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

mul-3

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DMat4No Documentation 🚧
arg1f64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

from_rotation_x

Creates an affine transformation matrix containing a 3D rotation around the x axis of angle (in radians). The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Arguments

NameTypeDocumentation
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

row

Returns the matrix row for the given index.

Panics

Panics if index is greater than 3.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

perspective_infinite_rh

Creates an infinite right-handed perspective projection matrix with [0,1] depth range. Like perspective_rh, but with an infinite value for z_far. The result is that points near z_near are mapped to depth 0, and as they move towards infinity the depth approaches 1.

Panics

Will panic if z_near or z_far are less than or equal to zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
fov_y_radiansf64No Documentation 🚧
aspect_ratiof64No Documentation 🚧
z_nearf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

from_rotation_z

Creates an affine transformation matrix containing a 3D rotation around the z axis of angle (in radians). The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Arguments

NameTypeDocumentation
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

div_scalar

Divides a 4x4 matrix by a scalar.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧
rhsf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

from_scale_rotation_translation

Creates an affine transformation matrix from the given 3D scale, rotation and translation. The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Panics

Will panic if rotation is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
scaleDVec3No Documentation 🚧
rotationDQuatNo Documentation 🚧
translationDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧
rhsDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

perspective_rh_gl

Creates a right-handed perspective projection matrix with [-1,1] depth range. Useful to map the standard right-handed coordinate system into what OpenGL expects. This is the same as the OpenGL gluPerspective function. See https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluPerspective.xml

Arguments

NameTypeDocumentation
fov_y_radiansf64No Documentation 🚧
aspect_ratiof64No Documentation 🚧
z_nearf64No Documentation 🚧
z_farf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

from_rotation_y

Creates an affine transformation matrix containing a 3D rotation around the y axis of angle (in radians). The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Arguments

NameTypeDocumentation
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

orthographic_rh

Creates a right-handed orthographic projection matrix with [0,1] depth range. Useful to map a right-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect.

Arguments

NameTypeDocumentation
leftf64No Documentation 🚧
rightf64No Documentation 🚧
bottomf64No Documentation 🚧
topf64No Documentation 🚧
nearf64No Documentation 🚧
farf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

look_to_rh

Creates a right-handed view matrix using a camera position, an up direction, and a facing direction. For a view coordinate system with +X=right, +Y=up and +Z=back.

Arguments

NameTypeDocumentation
eyeDVec3No Documentation 🚧
dirDVec3No Documentation 🚧
upDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧
rhsDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

to_cols_array

Creates a [f64; 16] array storing data in column major order. If you require data in row major order transpose the matrix first.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0[f64; 16]No Documentation 🚧

from_euler

Creates a affine transformation matrix containing a rotation from the given euler rotation sequence and angles (in radians). The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Arguments

NameTypeDocumentation
orderEulerRotNo Documentation 🚧
af64No Documentation 🚧
bf64No Documentation 🚧
cf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

look_at_rh

Creates a right-handed view matrix using a camera position, an up direction, and a focal point. For a view coordinate system with +X=right, +Y=up and +Z=back.

Panics

Will panic if up is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
eyeDVec3No Documentation 🚧
centerDVec3No Documentation 🚧
upDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two matrices contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧
rhsDMat4No Documentation 🚧
max_abs_difff64No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

sub_mat4

Subtracts two 4x4 matrices.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧
rhsDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

add_mat4

Adds two 4x4 matrices.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧
rhsDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

perspective_rh

Creates a right-handed perspective projection matrix with [0,1] depth range. Useful to map the standard right-handed coordinate system into what WebGPU/Metal/Direct3D expect.

Panics

Will panic if z_near or z_far are less than or equal to zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
fov_y_radiansf64No Documentation 🚧
aspect_ratiof64No Documentation 🚧
z_nearf64No Documentation 🚧
z_farf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

from_translation

Creates an affine transformation matrix from the given 3D translation. The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Arguments

NameTypeDocumentation
translationDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

perspective_infinite_reverse_lh

Creates an infinite reverse left-handed perspective projection matrix with [0,1] depth range. Similar to perspective_infinite_lh, but maps Z = z_near to a depth of 1 and Z = infinity to a depth of 0.

Panics

Will panic if z_near is less than or equal to zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
fov_y_radiansf64No Documentation 🚧
aspect_ratiof64No Documentation 🚧
z_nearf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

orthographic_lh

Creates a left-handed orthographic projection matrix with [0,1] depth range. Useful to map a left-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect.

Arguments

NameTypeDocumentation
leftf64No Documentation 🚧
rightf64No Documentation 🚧
bottomf64No Documentation 🚧
topf64No Documentation 🚧
nearf64No Documentation 🚧
farf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧
rhsDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_axis_angle

Creates an affine transformation matrix containing a 3D rotation around a normalized rotation axis of angle (in radians). The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Panics

Will panic if axis is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
axisDVec3No Documentation 🚧
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DMat4No Documentation 🚧
arg1DMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

mul_vec4

Transforms a 4D vector.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

determinant

Returns the determinant of self.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

from_scale

Creates an affine transformation matrix containing the given 3D non-uniform scale. The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Panics

Will panic if all elements of scale are zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
scaleDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

to_cols_array_2d

Creates a [[f64; 4]; 4] 4D array storing data in column major order. If you require data in row major order transpose the matrix first.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0[[f64; 4]; 4]No Documentation 🚧

abs

Takes the absolute value of each element in self

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

inverse

Returns the inverse of self. If the matrix is not invertible the returned matrix will be invalid.

Panics

Will panic if the determinant of self is zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

perspective_infinite_lh

Creates an infinite left-handed perspective projection matrix with [0,1] depth range. Like perspective_lh, but with an infinite value for z_far. The result is that points near z_near are mapped to depth 0, and as they move towards infinity the depth approaches 1.

Panics

Will panic if z_near or z_far are less than or equal to zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
fov_y_radiansf64No Documentation 🚧
aspect_ratiof64No Documentation 🚧
z_nearf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

orthographic_rh_gl

Creates a right-handed orthographic projection matrix with [-1,1] depth range. This is the same as the OpenGL glOrtho function in OpenGL. See https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glOrtho.xml Useful to map a right-handed coordinate system to the normalized device coordinates that OpenGL expects.

Arguments

NameTypeDocumentation
leftf64No Documentation 🚧
rightf64No Documentation 🚧
bottomf64No Documentation 🚧
topf64No Documentation 🚧
nearf64No Documentation 🚧
farf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

is_nan

Returns true if any elements are NaN.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_cols

Creates a 4x4 matrix from four column vectors.

Arguments

NameTypeDocumentation
x_axisDVec4No Documentation 🚧
y_axisDVec4No Documentation 🚧
z_axisDVec4No Documentation 🚧
w_axisDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

perspective_infinite_reverse_rh

Creates an infinite reverse right-handed perspective projection matrix with [0,1] depth range. Similar to perspective_infinite_rh, but maps Z = z_near to a depth of 1 and Z = infinity to a depth of 0.

Panics

Will panic if z_near is less than or equal to zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
fov_y_radiansf64No Documentation 🚧
aspect_ratiof64No Documentation 🚧
z_nearf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

project_point3

Transforms the given 3D vector as a point, applying perspective correction. This is the equivalent of multiplying the 3D vector as a 4D vector where w is 1.0. The perspective divide is performed meaning the resulting 3D vector is divided by w. This method assumes that self contains a projective transform.

Arguments

NameTypeDocumentation
_selfDMat4No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

DQuat

DQuat

  • x:f64
  • y:f64
  • z:f64
  • w:f64

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_mat3Creates a quaternion from a 3x3 rotation matrix. Note if the input matrix contain scales, shears, ...
xyzReturns the vector part of the quaternion.
addAdds two quaternions. The sum is not guaranteed to be normalized. Note that addition is not the s...
eqNo Documentation 🚧
is_near_identityNo Documentation 🚧
mulMultiplies two quaternions. If they each represent a rotation, the result will represent the combi...
from_vec4Creates a new rotation quaternion from a 4D vector. # Preconditions This function does not check ...
from_mat4Creates a quaternion from the upper 3x3 rotation matrix inside a homogeneous 4x4 matrix. Note if t...
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...
dotComputes the dot product of `self` and `rhs`. The dot product is equal to the cosine of the angle ...
to_eulerReturns the rotation angles for the given euler rotation sequence.
length_recipComputes `1.0 / length()`. For valid results, `self` must _not_ be of length zero.
lerpPerforms a linear interpolation between `self` and `rhs` based on the value `s`. When `s` is `0.0...
from_rotation_yCreates a quaternion from the `angle` (in radians) around the y axis.
from_rotation_arc_colinearGets the minimal rotation for transforming `from` to either `to` or `-to`. This means that the re...
mul_quatMultiplies two quaternions. If they each represent a rotation, the result will represent the combi...
cloneNo Documentation 🚧
from_rotation_xCreates a quaternion from the `angle` (in radians) around the x axis.
is_nanReturns `true` if any elements are `NAN`.
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive ...
mul-2No Documentation 🚧
from_affine3Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. Note if the input af...
length_squaredComputes the squared length of `self`. This is generally faster than `length()` as it avoids a squ...
slerpPerforms a spherical linear interpolation between `self` and `end` based on the value `s`. When `s`...
mul-1No Documentation 🚧
from_rotation_arc_2dGets the minimal rotation for transforming `from` to `to`. The resulting rotation is around the z...
subSubtracts the `rhs` quaternion from `self`. The difference is not guaranteed to be normalized.
normalizeReturns `self` normalized to length 1.0. For valid results, `self` must _not_ be of length zero. ...
as_quatNo Documentation 🚧
divDivides a quaternion by a scalar value. The quotient is not guaranteed to be normalized.
angle_betweenReturns the angle (in radians) for the minimal rotation for transforming this quaternion into anot...
conjugateReturns the quaternion conjugate of `self`. For a unit quaternion the conjugate is also the invers...
is_normalizedReturns whether `self` of length `1.0` or not. Uses a precision threshold of `1e-6`.
lengthComputes the length of `self`.
from_arrayCreates a rotation quaternion from an array. # Preconditions This function does not check if the ...
rotate_towardsRotates towards `rhs` up to `max_angle` (in radians). When `max_angle` is `0.0`, the result will b...
from_rotation_arcGets the minimal rotation for transforming `from` to `to`. The rotation is in the plane spanned b...
from_scaled_axisCreate a quaternion that rotates `v.length()` radians around `v.normalize()`. `from_scaled_axis(Vec3::ZERO)`...
negNo Documentation 🚧
to_scaled_axisReturns the rotation axis scaled by the rotation in radians.
to_array`[x, y, z, w]`
from_eulerCreates a quaternion from the given Euler rotation sequence and the angles (in radians).
from_rotation_zCreates a quaternion from the `angle` (in radians) around the z axis.
from_axis_angleCreate a quaternion for a normalized rotation `axis` and `angle` (in radians). The axis must be a ...
mul_vec3Multiplies a quaternion and a 3D vector, returning the rotated vector. # Panics Will panic if `self`...
inverseReturns the inverse of a normalized quaternion. Typically quaternion inverse returns the conjugate...
from_xyzwCreates a new rotation quaternion. This should generally not be called manually unless you know wh...

from_mat3

Creates a quaternion from a 3x3 rotation matrix. Note if the input matrix contain scales, shears, or other non-rotation transformations then the resulting quaternion will be ill-defined.

Panics

Will panic if any input matrix column is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
matDMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

xyz

Returns the vector part of the quaternion.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

add

Adds two quaternions. The sum is not guaranteed to be normalized. Note that addition is not the same as combining the rotations represented by the two quaternions! That corresponds to multiplication.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧
rhsDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧
rhsDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_near_identity

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

mul

Multiplies two quaternions. If they each represent a rotation, the result will represent the combined rotation. Note that due to floating point rounding the result may not be perfectly normalized.

Panics

Will panic if self or rhs are not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧
rhsDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

from_vec4

Creates a new rotation quaternion from a 4D vector.

Preconditions

This function does not check if the input is normalized, it is up to the user to provide normalized input or to normalized the resulting quaternion.

Arguments

NameTypeDocumentation
vDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

from_mat4

Creates a quaternion from the upper 3x3 rotation matrix inside a homogeneous 4x4 matrix. Note if the upper 3x3 matrix contain scales, shears, or other non-rotation transformations then the resulting quaternion will be ill-defined.

Panics

Will panic if any column of the upper 3x3 rotation matrix is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
matDMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two quaternions contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧
rhsDQuatNo Documentation 🚧
max_abs_difff64No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

dot

Computes the dot product of self and rhs. The dot product is equal to the cosine of the angle between two quaternion rotations.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧
rhsDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

to_euler

Returns the rotation angles for the given euler rotation sequence.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧
orderEulerRotNo Documentation 🚧

Returns

NameTypeDocumentation
arg0(f64, f64, f64)No Documentation 🚧

length_recip

Computes 1.0 / length(). For valid results, self must not be of length zero.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

lerp

Performs a linear interpolation between self and rhs based on the value s. When s is 0.0, the result will be equal to self. When s is 1.0, the result will be equal to rhs.

Panics

Will panic if self or end are not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧
endDQuatNo Documentation 🚧
sf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

from_rotation_y

Creates a quaternion from the angle (in radians) around the y axis.

Arguments

NameTypeDocumentation
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

from_rotation_arc_colinear

Gets the minimal rotation for transforming from to either to or -to. This means that the resulting quaternion will rotate from so that it is colinear with to. The rotation is in the plane spanned by the two vectors. Will rotate at most 90 degrees. The inputs must be unit vectors. to.dot(from_rotation_arc_colinear(from, to) * from).abs() ≈ 1.

Panics

Will panic if from or to are not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
fromDVec3No Documentation 🚧
toDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

mul_quat

Multiplies two quaternions. If they each represent a rotation, the result will represent the combined rotation. Note that due to floating point rounding the result may not be perfectly normalized.

Panics

Will panic if self or rhs are not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧
rhsDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

from_rotation_x

Creates a quaternion from the angle (in radians) around the x axis.

Arguments

NameTypeDocumentation
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

is_nan

Returns true if any elements are NAN.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DQuatNo Documentation 🚧
arg1f64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

from_affine3

Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. Note if the input affine matrix contain scales, shears, or other non-rotation transformations then the resulting quaternion will be ill-defined.

Panics

Will panic if any input affine matrix column is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
aDAffine3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

length_squared

Computes the squared length of self. This is generally faster than length() as it avoids a square root operation.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

slerp

Performs a spherical linear interpolation between self and end based on the value s. When s is 0.0, the result will be equal to self. When s is 1.0, the result will be equal to end.

Panics

Will panic if self or end are not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧
endDQuatNo Documentation 🚧
sf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DQuatNo Documentation 🚧
arg1DVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

from_rotation_arc_2d

Gets the minimal rotation for transforming from to to. The resulting rotation is around the z axis. Will rotate at most 180 degrees. The inputs must be unit vectors. from_rotation_arc_2d(from, to) * from ≈ to. For near-singular cases (from≈to and from≈-to) the current implementation is only accurate to about 0.001 (for f32).

Panics

Will panic if from or to are not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
fromDVec2No Documentation 🚧
toDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

sub

Subtracts the rhs quaternion from self. The difference is not guaranteed to be normalized.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧
rhsDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

normalize

Returns self normalized to length 1.0. For valid results, self must not be of length zero. Panics Will panic if self is zero length when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

as_quat

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

div

Divides a quaternion by a scalar value. The quotient is not guaranteed to be normalized.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧
rhsf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

angle_between

Returns the angle (in radians) for the minimal rotation for transforming this quaternion into another. Both quaternions must be normalized.

Panics

Will panic if self or rhs are not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧
rhsDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

conjugate

Returns the quaternion conjugate of self. For a unit quaternion the conjugate is also the inverse.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

is_normalized

Returns whether self of length 1.0 or not. Uses a precision threshold of 1e-6.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

length

Computes the length of self.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

from_array

Creates a rotation quaternion from an array.

Preconditions

This function does not check if the input is normalized, it is up to the user to provide normalized input or to normalized the resulting quaternion.

Arguments

NameTypeDocumentation
a[f64; 4]No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

rotate_towards

Rotates towards rhs up to max_angle (in radians). When max_angle is 0.0, the result will be equal to self. When max_angle is equal to self.angle_between(rhs), the result will be equal to rhs. If max_angle is negative, rotates towards the exact opposite of rhs. Will not go past the target. Both quaternions must be normalized.

Panics

Will panic if self or rhs are not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧
rhsDQuatNo Documentation 🚧
max_anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

from_rotation_arc

Gets the minimal rotation for transforming from to to. The rotation is in the plane spanned by the two vectors. Will rotate at most 180 degrees. The inputs must be unit vectors. from_rotation_arc(from, to) * from ≈ to. For near-singular cases (from≈to and from≈-to) the current implementation is only accurate to about 0.001 (for f32).

Panics

Will panic if from or to are not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
fromDVec3No Documentation 🚧
toDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

from_scaled_axis

Create a quaternion that rotates v.length() radians around v.normalize(). from_scaled_axis(Vec3::ZERO) results in the identity quaternion.

Arguments

NameTypeDocumentation
vDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

to_scaled_axis

Returns the rotation axis scaled by the rotation in radians.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

to_array

[x, y, z, w]

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0[f64; 4]No Documentation 🚧

from_euler

Creates a quaternion from the given Euler rotation sequence and the angles (in radians).

Arguments

NameTypeDocumentation
eulerEulerRotNo Documentation 🚧
af64No Documentation 🚧
bf64No Documentation 🚧
cf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

from_rotation_z

Creates a quaternion from the angle (in radians) around the z axis.

Arguments

NameTypeDocumentation
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

from_axis_angle

Create a quaternion for a normalized rotation axis and angle (in radians). The axis must be a unit vector.

Panics

Will panic if axis is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
axisDVec3No Documentation 🚧
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

mul_vec3

Multiplies a quaternion and a 3D vector, returning the rotated vector.

Panics

Will panic if self is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

inverse

Returns the inverse of a normalized quaternion. Typically quaternion inverse returns the conjugate of a normalized quaternion. Because self is assumed to already be unit length this method does not normalize before returning the conjugate.

Panics

Will panic if self is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

from_xyzw

Creates a new rotation quaternion. This should generally not be called manually unless you know what you are doing. Use one of the other constructors instead such as identity or from_axis_angle. from_xyzw is mostly used by unit tests and serde deserialization.

Preconditions

This function does not check if the input is normalized, it is up to the user to provide normalized input or to normalized the resulting quaternion.

Arguments

NameTypeDocumentation
xf64No Documentation 🚧
yf64No Documentation 🚧
zf64No Documentation 🚧
wf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

DVec2

DVec2

  • x:f64
  • y:f64

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
minReturns a vector containing the minimum values for each element of `self` and `rhs`. In other word...
div-2No Documentation 🚧
length_recipComputes `1.0 / length()`. For valid results, `self` must _not_ be of length zero.
newCreates a new vector.
is_nanReturns `true` if any elements are `NaN`.
selectCreates a vector from the elements in `if_true` and `if_false`, selecting which to use for each el...
to_angleReturns the angle (in radians) of this vector in the range `[-π, +π]`. The input does not need to be a unit vector however it must be non-zero.
fract_glReturns a vector containing the fractional part of the vector as `self - self.floor()`. Note that ...
with_yCreates a 2D vector from `self` with the given value of `y`.
absReturns a vector containing the absolute value of each element of `self`.
truncReturns a vector containing the integer part each element of `self`. This means numbers are always...
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive...
from_arrayCreates a new vector from an array.
length_squaredComputes the squared length of `self`. This is faster than `length()` as it avoids a square root o...
project_ontoReturns the vector projection of `self` onto `rhs`. `rhs` must be of non-zero length. # Panics W...
roundReturns a vector containing the nearest integer to a number for each element of `self`. Round half...
distanceComputes the Euclidean distance between two points in space.
reflectReturns the reflection vector for a given incident vector `self` and surface normal `normal`. `normal`...
divNo Documentation 🚧
project_onto_normalizedReturns the vector projection of `self` onto `rhs`. `rhs` must be normalized. # Panics Will pani...
normalize_orReturns `self` normalized to length 1.0 if possible, else returns a fallback value. In particular...
reject_fromReturns the vector rejection of `self` from `rhs`. The vector rejection is the vector perpendicula...
reject_from_normalizedReturns the vector rejection of `self` from `rhs`. The vector rejection is the vector perpendicula...
midpointCalculates the midpoint between `self` and `rhs`. The midpoint is the average of, or halfway point...
rem-2No Documentation 🚧
angle_betweenNo Documentation 🚧
is_normalizedReturns whether `self` is length `1.0` or not. Uses a precision threshold of approximately `1e-4`.
extendCreates a 3D vector from `self` and the given `z` value.
distance_squaredCompute the squared euclidean distance between two points in space.
cmpneReturns a vector mask containing the result of a `!=` comparison for each element of `self` and `rhs`...
normalizeReturns `self` normalized to length 1.0. For valid results, `self` must be finite and _not_ of len...
as_i64vec2Casts all elements of `self` to `i64`.
signumReturns a vector with elements representing the sign of `self`. - `1.0` if the number is positive,...
cmpltReturns a vector mask containing the result of a `<` comparison for each element of `self` and `rhs`...
add-1No Documentation 🚧
is_finite_maskPerforms `is_finite` on each element of self, returning a vector mask of the results. In other words, this computes `[x.is_finite(), y.is_finite(), ...]...
sub-1No Documentation 🚧
perp_dotThe perpendicular dot product of `self` and `rhs`. Also known as the wedge product, 2D cross produ...
add-2No Documentation 🚧
with_xCreates a 2D vector from `self` with the given value of `x`.
as_ivec2Casts all elements of `self` to `i32`.
mulNo Documentation 🚧
lengthComputes the length of `self`.
dot_into_vecReturns a vector where every component is the dot product of `self` and `rhs`.
cloneNo Documentation 🚧
floorReturns a vector containing the largest integer less than or equal to a number for each element of...
eqNo Documentation 🚧
rotateReturns `rhs` rotated by the angle of `self`. If `self` is normalized, then this just rotation. Th...
cmpgeReturns a vector mask containing the result of a `>=` comparison for each element of `self` and `rhs`...
element_productReturns the product of all elements of `self`. In other words, this computes `self.x * self.y * .....
powfReturns a vector containing each element of `self` raised to the power of `n`.
remNo Documentation 🚧
cmpleReturns a vector mask containing the result of a `<=` comparison for each element of `self` and `rhs`...
sub-2No Documentation 🚧
recipReturns a vector containing the reciprocal `1.0/n` of each element of `self`.
normalize_or_zeroReturns `self` normalized to length 1.0 if possible, else returns zero. In particular, if the inpu...
div_euclidReturns the element-wise quotient of [Euclidean division] of `self` by `rhs`.
clamp_lengthReturns a vector with a length no less than `min` and no more than `max`. # Panics Will panic if `min`...
mul_addFused multiply-add. Computes `(self * a) + b` element-wise with only one rounding error, yielding a more accurate result than an unfused multiply-add. Using `mul_add` *may* be more performant than an unfused multiply-add if the target architecture has a dedicated fma CPU instruction. However, this is not always true, and will be heavily dependant on designing algorithms with specific target hardware in mind.
cmpgtReturns a vector mask containing the result of a `>` comparison for each element of `self` and `rhs`...
element_sumReturns the sum of all elements of `self`. In other words, this computes `self.x + self.y + ..`.
copysignReturns a vector with signs of `rhs` and the magnitudes of `self`.
expReturns a vector containing `e^self` (the exponential function) for each element of `self`.
as_u64vec2Casts all elements of `self` to `u64`.
perpReturns a vector that is equal to `self` rotated by 90 degrees.
refractReturns the refraction direction for a given incident vector `self`, surface normal `normal` and r...
splatCreates a vector with all elements set to `v`.
to_array`[x, y]`
max_elementReturns the horizontal maximum of `self`. In other words this computes `max(x, y, ..)`.
ceilReturns a vector containing the smallest integer greater than or equal to a number for each elemen...
addNo Documentation 🚧
as_vec2Casts all elements of `self` to `f32`.
is_negative_bitmaskReturns a bitmask with the lowest 2 bits set to the sign bits from the elements of `self`. A negat...
rem-1No Documentation 🚧
subNo Documentation 🚧
clamp_length_maxReturns a vector with a length no more than `max`. # Panics Will panic if `max` is negative when `glam_assert` is enabled.
angle_toReturns the angle of rotation (in radians) from `self` to `rhs` in the range `[-π, +π]`. The inputs do not need to be unit vectors however they must be non-zero.
fractReturns a vector containing the fractional part of the vector as `self - self.trunc()`. Note that ...
negNo Documentation 🚧
maxReturns a vector containing the maximum values for each element of `self` and `rhs`. In other word...
rotate_towardsRotates towards `rhs` up to `max_angle` (in radians). When `max_angle` is `0.0`, the result will b...
dotComputes the dot product of `self` and `rhs`.
mul-2No Documentation 🚧
min_elementReturns the horizontal minimum of `self`. In other words this computes `min(x, y, ..)`.
div-1No Documentation 🚧
move_towardsMoves towards `rhs` based on the value `d`. When `d` is `0.0`, the result will be equal to `self`....
lerpPerforms a linear interpolation between `self` and `rhs` based on the value `s`. When `s` is `0.0`...
as_uvec2Casts all elements of `self` to `u32`.
from_angleCreates a 2D vector containing `[angle.cos(), angle.sin()]`. This can be used in conjunction with the [`rotate()`]...
is_nan_maskPerforms `is_nan` on each element of self, returning a vector mask of the results. In other words, this computes `[x.is_nan(), y.is_nan(), ...]...
cmpeqReturns a vector mask containing the result of a `==` comparison for each element of `self` and `rhs`...
mul-1No Documentation 🚧
clamp_length_minReturns a vector with a length no less than `min`. # Panics Will panic if `min` is negative when `glam_assert` is enabled.
rem_euclidReturns the element-wise remainder of [Euclidean division] of `self` by `rhs`. [Euclidean division...
clampComponent-wise clamping of values, similar to [`f64::clamp`]. Each element in `min` must be less-or-equal to the corresponding element in `max`. # Panics Will panic if `min` is greater than `max` when `glam_assert` is enabled.
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...

min

Returns a vector containing the minimum values for each element of self and rhs. In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

div-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec2No Documentation 🚧
arg1f64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

length_recip

Computes 1.0 / length(). For valid results, self must not be of length zero.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xf64No Documentation 🚧
yf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

is_nan

Returns true if any elements are NaN.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

select

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self. A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

Arguments

NameTypeDocumentation
maskBVec2No Documentation 🚧
if_trueDVec2No Documentation 🚧
if_falseDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

to_angle

Returns the angle (in radians) of this vector in the range [-π, +π]. The input does not need to be a unit vector however it must be non-zero.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

fract_gl

Returns a vector containing the fractional part of the vector as self - self.floor(). Note that this differs from the Rust implementation of fract which returns self - self.trunc(). Note that this is fast but not precise for large numbers.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

with_y

Creates a 2D vector from self with the given value of y.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
yf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

abs

Returns a vector containing the absolute value of each element of self.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

trunc

Returns a vector containing the integer part each element of self. This means numbers are always truncated towards zero.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_array

Creates a new vector from an array.

Arguments

NameTypeDocumentation
a[f64; 2]No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

length_squared

Computes the squared length of self. This is faster than length() as it avoids a square root operation.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

project_onto

Returns the vector projection of self onto rhs. rhs must be of non-zero length.

Panics

Will panic if rhs is zero length when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

round

Returns a vector containing the nearest integer to a number for each element of self. Round half-way cases away from 0.0.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

distance

Computes the Euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

reflect

Returns the reflection vector for a given incident vector self and surface normal normal. normal must be normalized.

Panics

Will panic if normal is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
normalDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

project_onto_normalized

Returns the vector projection of self onto rhs. rhs must be normalized.

Panics

Will panic if rhs is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

normalize_or

Returns self normalized to length 1.0 if possible, else returns a fallback value. In particular, if the input is zero (or very close to zero), or non-finite, the result of this operation will be the fallback value. See also [Self::try_normalize()].

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
fallbackDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

reject_from

Returns the vector rejection of self from rhs. The vector rejection is the vector perpendicular to the projection of self onto rhs, in rhs words the result of self - self.project_onto(rhs). rhs must be of non-zero length.

Panics

Will panic if rhs has a length of zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

reject_from_normalized

Returns the vector rejection of self from rhs. The vector rejection is the vector perpendicular to the projection of self onto rhs, in rhs words the result of self - self.project_onto(rhs). rhs must be normalized.

Panics

Will panic if rhs is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

midpoint

Calculates the midpoint between self and rhs. The midpoint is the average of, or halfway point between, two vectors. a.midpoint(b) should yield the same result as a.lerp(b, 0.5) while being slightly cheaper to compute.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

rem-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec2No Documentation 🚧
arg1f64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

angle_between

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

is_normalized

Returns whether self is length 1.0 or not. Uses a precision threshold of approximately 1e-4.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

extend

Creates a 3D vector from self and the given z value.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
zf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

distance_squared

Compute the squared euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

cmpne

Returns a vector mask containing the result of a != comparison for each element of self and rhs. In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

normalize

Returns self normalized to length 1.0. For valid results, self must be finite and not of length zero, nor very close to zero. See also [Self::try_normalize()] and [Self::normalize_or_zero()]. Panics Will panic if the resulting normalized vector is not finite when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

as_i64vec2

Casts all elements of self to i64.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

signum

Returns a vector with elements representing the sign of self.

  • 1.0 if the number is positive, +0.0 or INFINITY
  • -1.0 if the number is negative, -0.0 or NEG_INFINITY
  • NAN if the number is NAN

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

cmplt

Returns a vector mask containing the result of a < comparison for each element of self and rhs. In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

add-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec2No Documentation 🚧
arg1DVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

is_finite_mask

Performs is_finite on each element of self, returning a vector mask of the results. In other words, this computes [x.is_finite(), y.is_finite(), ...].

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec2No Documentation 🚧
arg1DVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

perp_dot

The perpendicular dot product of self and rhs. Also known as the wedge product, 2D cross product, and determinant.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

add-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec2No Documentation 🚧
arg1f64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

with_x

Creates a 2D vector from self with the given value of x.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
xf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

as_ivec2

Casts all elements of self to i32.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

length

Computes the length of self.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

dot_into_vec

Returns a vector where every component is the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

floor

Returns a vector containing the largest integer less than or equal to a number for each element of self.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
otherDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

rotate

Returns rhs rotated by the angle of self. If self is normalized, then this just rotation. This is what you usually want. Otherwise, it will be like a rotation with a multiplication by self's length.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

cmpge

Returns a vector mask containing the result of a >= comparison for each element of self and rhs. In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

element_product

Returns the product of all elements of self. In other words, this computes self.x * self.y * ...

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

powf

Returns a vector containing each element of self raised to the power of n.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
nf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

rem

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

cmple

Returns a vector mask containing the result of a <= comparison for each element of self and rhs. In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

sub-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec2No Documentation 🚧
arg1f64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

recip

Returns a vector containing the reciprocal 1.0/n of each element of self.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

normalize_or_zero

Returns self normalized to length 1.0 if possible, else returns zero. In particular, if the input is zero (or very close to zero), or non-finite, the result of this operation will be zero. See also [Self::try_normalize()].

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

div_euclid

Returns the element-wise quotient of [Euclidean division] of self by rhs.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

clamp_length

Returns a vector with a length no less than min and no more than max.

Panics

Will panic if min is greater than max, or if either min or max is negative, when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
minf64No Documentation 🚧
maxf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

mul_add

Fused multiply-add. Computes (self * a) + b element-wise with only one rounding error, yielding a more accurate result than an unfused multiply-add. Using mul_add may be more performant than an unfused multiply-add if the target architecture has a dedicated fma CPU instruction. However, this is not always true, and will be heavily dependant on designing algorithms with specific target hardware in mind.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
aDVec2No Documentation 🚧
bDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

cmpgt

Returns a vector mask containing the result of a > comparison for each element of self and rhs. In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

element_sum

Returns the sum of all elements of self. In other words, this computes self.x + self.y + ...

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

copysign

Returns a vector with signs of rhs and the magnitudes of self.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

exp

Returns a vector containing e^self (the exponential function) for each element of self.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

as_u64vec2

Casts all elements of self to u64.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

perp

Returns a vector that is equal to self rotated by 90 degrees.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

refract

Returns the refraction direction for a given incident vector self, surface normal normal and ratio of indices of refraction, eta. When total internal reflection occurs, a zero vector will be returned. self and normal must be normalized.

Panics

Will panic if self or normal is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
normalDVec2No Documentation 🚧
etaf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

splat

Creates a vector with all elements set to v.

Arguments

NameTypeDocumentation
vf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

to_array

[x, y]

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0[f64; 2]No Documentation 🚧

max_element

Returns the horizontal maximum of self. In other words this computes max(x, y, ..).

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

ceil

Returns a vector containing the smallest integer greater than or equal to a number for each element of self.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

as_vec2

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

is_negative_bitmask

Returns a bitmask with the lowest 2 bits set to the sign bits from the elements of self. A negative element results in a 1 bit and a positive element in a 0 bit. Element x goes into the first lowest bit, element y into the second, etc.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

rem-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec2No Documentation 🚧
arg1DVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

clamp_length_max

Returns a vector with a length no more than max.

Panics

Will panic if max is negative when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
maxf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

angle_to

Returns the angle of rotation (in radians) from self to rhs in the range [-π, +π]. The inputs do not need to be unit vectors however they must be non-zero.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

fract

Returns a vector containing the fractional part of the vector as self - self.trunc(). Note that this differs from the GLSL implementation of fract which returns self - self.floor(). Note that this is fast but not precise for large numbers.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

max

Returns a vector containing the maximum values for each element of self and rhs. In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

rotate_towards

Rotates towards rhs up to max_angle (in radians). When max_angle is 0.0, the result will be equal to self. When max_angle is equal to self.angle_between(rhs), the result will be equal to rhs. If max_angle is negative, rotates towards the exact opposite of rhs. Will not go past the target.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧
max_anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

dot

Computes the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec2No Documentation 🚧
arg1f64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

min_element

Returns the horizontal minimum of self. In other words this computes min(x, y, ..).

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

div-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec2No Documentation 🚧
arg1DVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

move_towards

Moves towards rhs based on the value d. When d is 0.0, the result will be equal to self. When d is equal to self.distance(rhs), the result will be equal to rhs. Will not go past rhs.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧
df64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

lerp

Performs a linear interpolation between self and rhs based on the value s. When s is 0.0, the result will be equal to self. When s is 1.0, the result will be equal to rhs. When s is outside of range [0, 1], the result is linearly extrapolated.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧
sf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

as_uvec2

Casts all elements of self to u32.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

from_angle

Creates a 2D vector containing [angle.cos(), angle.sin()]. This can be used in conjunction with the [rotate()][Self::rotate()] method, e.g. DVec2::from_angle(PI).rotate(DVec2::Y) will create the vector [-1, 0] and rotate [DVec2::Y] around it returning -DVec2::Y.

Arguments

NameTypeDocumentation
anglef64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

is_nan_mask

Performs is_nan on each element of self, returning a vector mask of the results. In other words, this computes [x.is_nan(), y.is_nan(), ...].

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

cmpeq

Returns a vector mask containing the result of a == comparison for each element of self and rhs. In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec2No Documentation 🚧
arg1DVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

clamp_length_min

Returns a vector with a length no less than min.

Panics

Will panic if min is negative when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
minf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

rem_euclid

Returns the element-wise remainder of [Euclidean division] of self by rhs. [Euclidean division]: f64::rem_euclid

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

clamp

Component-wise clamping of values, similar to [f64::clamp]. Each element in min must be less-or-equal to the corresponding element in max.

Panics

Will panic if min is greater than max when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
minDVec2No Documentation 🚧
maxDVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two vectors contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧
rhsDVec2No Documentation 🚧
max_abs_difff64No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

DVec3

DVec3

  • x:f64
  • y:f64
  • z:f64

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
clamp_length_minReturns a vector with a length no less than `min`. # Panics Will panic if `min` is negative when `glam_assert` is enabled.
with_xCreates a 3D vector from `self` with the given value of `x`.
to_array`[x, y, z]`
rem_euclidReturns the element-wise remainder of [Euclidean division] of `self` by `rhs`. [Euclidean division...
any_orthonormal_vectorReturns any unit vector that is orthogonal to the given one. The input vector must be unit length....
mul-2No Documentation 🚧
as_vec3aCasts all elements of `self` to `f32`.
selectCreates a vector from the elements in `if_true` and `if_false`, selecting which to use for each el...
fractReturns a vector containing the fractional part of the vector as `self - self.trunc()`. Note that ...
clampComponent-wise clamping of values, similar to [`f64::clamp`]. Each element in `min` must be less-or-equal to the corresponding element in `max`. # Panics Will panic if `min` is greater than `max` when `glam_assert` is enabled.
floorReturns a vector containing the largest integer less than or equal to a number for each element of...
as_uvec3Casts all elements of `self` to `u32`.
splatCreates a vector with all elements set to `v`.
maxReturns a vector containing the maximum values for each element of `self` and `rhs`. In other word...
is_finite_maskPerforms `is_finite` on each element of self, returning a vector mask of the results. In other words, this computes `[x.is_finite(), y.is_finite(), ...]...
reject_from_normalizedReturns the vector rejection of `self` from `rhs`. The vector rejection is the vector perpendicula...
is_nan_maskPerforms `is_nan` on each element of self, returning a vector mask of the results. In other words, this computes `[x.is_nan(), y.is_nan(), ...]...
any_orthogonal_vectorReturns some vector that is orthogonal to the given one. The input vector must be finite and non-z...
truncateCreates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. Truncation may also b...
with_yCreates a 3D vector from `self` with the given value of `y`.
cloneNo Documentation 🚧
normalizeReturns `self` normalized to length 1.0. For valid results, `self` must be finite and _not_ of len...
mul-1No Documentation 🚧
project_ontoReturns the vector projection of `self` onto `rhs`. `rhs` must be of non-zero length. # Panics W...
distanceComputes the Euclidean distance between two points in space.
fract_glReturns a vector containing the fractional part of the vector as `self - self.floor()`. Note that ...
addNo Documentation 🚧
cmpltReturns a vector mask containing the result of a `<` comparison for each element of `self` and `rhs`...
div-1No Documentation 🚧
mulNo Documentation 🚧
sub-2No Documentation 🚧
rem-2No Documentation 🚧
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive...
newCreates a new vector.
refractReturns the refraction direction for a given incident vector `self`, surface normal `normal` and r...
recipReturns a vector containing the reciprocal `1.0/n` of each element of `self`.
absReturns a vector containing the absolute value of each element of `self`.
distance_squaredCompute the squared euclidean distance between two points in space.
cmpgtReturns a vector mask containing the result of a `>` comparison for each element of `self` and `rhs`...
normalize_orReturns `self` normalized to length 1.0 if possible, else returns a fallback value. In particular...
element_productReturns the product of all elements of `self`. In other words, this computes `self.x * self.y * .....
lengthComputes the length of `self`.
ceilReturns a vector containing the smallest integer greater than or equal to a number for each elemen...
from_arrayCreates a new vector from an array.
truncReturns a vector containing the integer part each element of `self`. This means numbers are always...
cmpneReturns a vector mask containing the result of a `!=` comparison for each element of `self` and `rhs`...
as_i64vec3Casts all elements of `self` to `i64`.
clamp_lengthReturns a vector with a length no less than `min` and no more than `max`. # Panics Will panic if `min`...
midpointCalculates the midpoint between `self` and `rhs`. The midpoint is the average of, or halfway point...
negNo Documentation 🚧
as_ivec3Casts all elements of `self` to `i32`.
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...
is_normalizedReturns whether `self` is length `1.0` or not. Uses a precision threshold of approximately `1e-4`.
is_negative_bitmaskReturns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. A negat...
div-2No Documentation 🚧
min_elementReturns the horizontal minimum of `self`. In other words this computes `min(x, y, ..)`.
dot_into_vecReturns a vector where every component is the dot product of `self` and `rhs`.
as_u64vec3Casts all elements of `self` to `u64`.
length_recipComputes `1.0 / length()`. For valid results, `self` must _not_ be of length zero.
expReturns a vector containing `e^self` (the exponential function) for each element of `self`.
length_squaredComputes the squared length of `self`. This is faster than `length()` as it avoids a square root o...
add-2No Documentation 🚧
crossComputes the cross product of `self` and `rhs`.
is_nanReturns `true` if any elements are `NaN`.
move_towardsMoves towards `rhs` based on the value `d`. When `d` is `0.0`, the result will be equal to `self`....
rem-1No Documentation 🚧
reject_fromReturns the vector rejection of `self` from `rhs`. The vector rejection is the vector perpendicula...
mul_addFused multiply-add. Computes `(self * a) + b` element-wise with only one rounding error, yielding a more accurate result than an unfused multiply-add. Using `mul_add` *may* be more performant than an unfused multiply-add if the target architecture has a dedicated fma CPU instruction. However, this is not always true, and will be heavily dependant on designing algorithms with specific target hardware in mind.
dotComputes the dot product of `self` and `rhs`.
signumReturns a vector with elements representing the sign of `self`. - `1.0` if the number is positive,...
reflectReturns the reflection vector for a given incident vector `self` and surface normal `normal`. `normal`...
clamp_length_maxReturns a vector with a length no more than `max`. # Panics Will panic if `max` is negative when `glam_assert` is enabled.
angle_betweenReturns the angle (in radians) between two vectors in the range `[0, +π]`. The inputs do not need to be unit vectors however they must be non-zero.
divNo Documentation 🚧
roundReturns a vector containing the nearest integer to a number for each element of `self`. Round half...
minReturns a vector containing the minimum values for each element of `self` and `rhs`. In other word...
powfReturns a vector containing each element of `self` raised to the power of `n`.
cmpeqReturns a vector mask containing the result of a `==` comparison for each element of `self` and `rhs`...
max_elementReturns the horizontal maximum of `self`. In other words this computes `max(x, y, ..)`.
as_vec3Casts all elements of `self` to `f32`.
element_sumReturns the sum of all elements of `self`. In other words, this computes `self.x + self.y + ..`.
div_euclidReturns the element-wise quotient of [Euclidean division] of `self` by `rhs`.
normalize_or_zeroReturns `self` normalized to length 1.0 if possible, else returns zero. In particular, if the inpu...
extendCreates a 4D vector from `self` and the given `w` value.
copysignReturns a vector with signs of `rhs` and the magnitudes of `self`.
with_zCreates a 3D vector from `self` with the given value of `z`.
project_onto_normalizedReturns the vector projection of `self` onto `rhs`. `rhs` must be normalized. # Panics Will pani...
sub-1No Documentation 🚧
cmpleReturns a vector mask containing the result of a `<=` comparison for each element of `self` and `rhs`...
cmpgeReturns a vector mask containing the result of a `>=` comparison for each element of `self` and `rhs`...
lerpPerforms a linear interpolation between `self` and `rhs` based on the value `s`. When `s` is `0.0`...
eqNo Documentation 🚧
subNo Documentation 🚧
add-1No Documentation 🚧
remNo Documentation 🚧

clamp_length_min

Returns a vector with a length no less than min.

Panics

Will panic if min is negative when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
minf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

with_x

Creates a 3D vector from self with the given value of x.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
xf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

to_array

[x, y, z]

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0[f64; 3]No Documentation 🚧

rem_euclid

Returns the element-wise remainder of [Euclidean division] of self by rhs. [Euclidean division]: f64::rem_euclid

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

any_orthonormal_vector

Returns any unit vector that is orthogonal to the given one. The input vector must be unit length.

Panics

Will panic if self is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec3No Documentation 🚧
arg1f64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

as_vec3a

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

select

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self. A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

Arguments

NameTypeDocumentation
maskBVec3No Documentation 🚧
if_trueDVec3No Documentation 🚧
if_falseDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

fract

Returns a vector containing the fractional part of the vector as self - self.trunc(). Note that this differs from the GLSL implementation of fract which returns self - self.floor(). Note that this is fast but not precise for large numbers.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

clamp

Component-wise clamping of values, similar to [f64::clamp]. Each element in min must be less-or-equal to the corresponding element in max.

Panics

Will panic if min is greater than max when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
minDVec3No Documentation 🚧
maxDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

floor

Returns a vector containing the largest integer less than or equal to a number for each element of self.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

as_uvec3

Casts all elements of self to u32.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

splat

Creates a vector with all elements set to v.

Arguments

NameTypeDocumentation
vf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

max

Returns a vector containing the maximum values for each element of self and rhs. In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

is_finite_mask

Performs is_finite on each element of self, returning a vector mask of the results. In other words, this computes [x.is_finite(), y.is_finite(), ...].

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

reject_from_normalized

Returns the vector rejection of self from rhs. The vector rejection is the vector perpendicular to the projection of self onto rhs, in rhs words the result of self - self.project_onto(rhs). rhs must be normalized.

Panics

Will panic if rhs is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

is_nan_mask

Performs is_nan on each element of self, returning a vector mask of the results. In other words, this computes [x.is_nan(), y.is_nan(), ...].

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

any_orthogonal_vector

Returns some vector that is orthogonal to the given one. The input vector must be finite and non-zero. The output vector is not necessarily unit length. For that use [Self::any_orthonormal_vector()] instead.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

truncate

Creates a 2D vector from the x and y elements of self, discarding z. Truncation may also be performed by using [self.xy()][crate::swizzles::Vec3Swizzles::xy()].

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

with_y

Creates a 3D vector from self with the given value of y.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
yf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

normalize

Returns self normalized to length 1.0. For valid results, self must be finite and not of length zero, nor very close to zero. See also [Self::try_normalize()] and [Self::normalize_or_zero()]. Panics Will panic if the resulting normalized vector is not finite when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec3No Documentation 🚧
arg1DVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

project_onto

Returns the vector projection of self onto rhs. rhs must be of non-zero length.

Panics

Will panic if rhs is zero length when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

distance

Computes the Euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

fract_gl

Returns a vector containing the fractional part of the vector as self - self.floor(). Note that this differs from the Rust implementation of fract which returns self - self.trunc(). Note that this is fast but not precise for large numbers.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

cmplt

Returns a vector mask containing the result of a < comparison for each element of self and rhs. In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

div-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec3No Documentation 🚧
arg1DVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

sub-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec3No Documentation 🚧
arg1f64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

rem-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec3No Documentation 🚧
arg1f64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xf64No Documentation 🚧
yf64No Documentation 🚧
zf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

refract

Returns the refraction direction for a given incident vector self, surface normal normal and ratio of indices of refraction, eta. When total internal reflection occurs, a zero vector will be returned. self and normal must be normalized.

Panics

Will panic if self or normal is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
normalDVec3No Documentation 🚧
etaf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

recip

Returns a vector containing the reciprocal 1.0/n of each element of self.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

abs

Returns a vector containing the absolute value of each element of self.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

distance_squared

Compute the squared euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

cmpgt

Returns a vector mask containing the result of a > comparison for each element of self and rhs. In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

normalize_or

Returns self normalized to length 1.0 if possible, else returns a fallback value. In particular, if the input is zero (or very close to zero), or non-finite, the result of this operation will be the fallback value. See also [Self::try_normalize()].

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
fallbackDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

element_product

Returns the product of all elements of self. In other words, this computes self.x * self.y * ...

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

length

Computes the length of self.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

ceil

Returns a vector containing the smallest integer greater than or equal to a number for each element of self.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

from_array

Creates a new vector from an array.

Arguments

NameTypeDocumentation
a[f64; 3]No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

trunc

Returns a vector containing the integer part each element of self. This means numbers are always truncated towards zero.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

cmpne

Returns a vector mask containing the result of a != comparison for each element of self and rhs. In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

as_i64vec3

Casts all elements of self to i64.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

clamp_length

Returns a vector with a length no less than min and no more than max.

Panics

Will panic if min is greater than max, or if either min or max is negative, when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
minf64No Documentation 🚧
maxf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

midpoint

Calculates the midpoint between self and rhs. The midpoint is the average of, or halfway point between, two vectors. a.midpoint(b) should yield the same result as a.lerp(b, 0.5) while being slightly cheaper to compute.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

as_ivec3

Casts all elements of self to i32.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two vectors contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧
max_abs_difff64No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_normalized

Returns whether self is length 1.0 or not. Uses a precision threshold of approximately 1e-4.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_negative_bitmask

Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of self. A negative element results in a 1 bit and a positive element in a 0 bit. Element x goes into the first lowest bit, element y into the second, etc.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

div-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec3No Documentation 🚧
arg1f64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

min_element

Returns the horizontal minimum of self. In other words this computes min(x, y, ..).

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

dot_into_vec

Returns a vector where every component is the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

as_u64vec3

Casts all elements of self to u64.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

length_recip

Computes 1.0 / length(). For valid results, self must not be of length zero.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

exp

Returns a vector containing e^self (the exponential function) for each element of self.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

length_squared

Computes the squared length of self. This is faster than length() as it avoids a square root operation.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

add-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec3No Documentation 🚧
arg1f64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

cross

Computes the cross product of self and rhs.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

is_nan

Returns true if any elements are NaN.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

move_towards

Moves towards rhs based on the value d. When d is 0.0, the result will be equal to self. When d is equal to self.distance(rhs), the result will be equal to rhs. Will not go past rhs.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧
df64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

rem-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec3No Documentation 🚧
arg1DVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

reject_from

Returns the vector rejection of self from rhs. The vector rejection is the vector perpendicular to the projection of self onto rhs, in rhs words the result of self - self.project_onto(rhs). rhs must be of non-zero length.

Panics

Will panic if rhs has a length of zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

mul_add

Fused multiply-add. Computes (self * a) + b element-wise with only one rounding error, yielding a more accurate result than an unfused multiply-add. Using mul_add may be more performant than an unfused multiply-add if the target architecture has a dedicated fma CPU instruction. However, this is not always true, and will be heavily dependant on designing algorithms with specific target hardware in mind.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
aDVec3No Documentation 🚧
bDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

dot

Computes the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

signum

Returns a vector with elements representing the sign of self.

  • 1.0 if the number is positive, +0.0 or INFINITY
  • -1.0 if the number is negative, -0.0 or NEG_INFINITY
  • NAN if the number is NAN

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

reflect

Returns the reflection vector for a given incident vector self and surface normal normal. normal must be normalized.

Panics

Will panic if normal is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
normalDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

clamp_length_max

Returns a vector with a length no more than max.

Panics

Will panic if max is negative when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
maxf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

angle_between

Returns the angle (in radians) between two vectors in the range [0, +π]. The inputs do not need to be unit vectors however they must be non-zero.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

round

Returns a vector containing the nearest integer to a number for each element of self. Round half-way cases away from 0.0.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

min

Returns a vector containing the minimum values for each element of self and rhs. In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

powf

Returns a vector containing each element of self raised to the power of n.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
nf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

cmpeq

Returns a vector mask containing the result of a == comparison for each element of self and rhs. In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

max_element

Returns the horizontal maximum of self. In other words this computes max(x, y, ..).

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

as_vec3

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

element_sum

Returns the sum of all elements of self. In other words, this computes self.x + self.y + ...

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

div_euclid

Returns the element-wise quotient of [Euclidean division] of self by rhs.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

normalize_or_zero

Returns self normalized to length 1.0 if possible, else returns zero. In particular, if the input is zero (or very close to zero), or non-finite, the result of this operation will be zero. See also [Self::try_normalize()].

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

extend

Creates a 4D vector from self and the given w value.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
wf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

copysign

Returns a vector with signs of rhs and the magnitudes of self.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

with_z

Creates a 3D vector from self with the given value of z.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
zf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

project_onto_normalized

Returns the vector projection of self onto rhs. rhs must be normalized.

Panics

Will panic if rhs is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec3No Documentation 🚧
arg1DVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

cmple

Returns a vector mask containing the result of a <= comparison for each element of self and rhs. In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

cmpge

Returns a vector mask containing the result of a >= comparison for each element of self and rhs. In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

lerp

Performs a linear interpolation between self and rhs based on the value s. When s is 0.0, the result will be equal to self. When s is 1.0, the result will be equal to rhs. When s is outside of range [0, 1], the result is linearly extrapolated.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧
sf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
otherDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

add-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec3No Documentation 🚧
arg1DVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

rem

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧
rhsDVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

DVec4

DVec4

  • x:f64
  • y:f64
  • z:f64
  • w:f64

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
rem_euclidReturns the element-wise remainder of [Euclidean division] of `self` by `rhs`. [Euclidean division...
div_euclidReturns the element-wise quotient of [Euclidean division] of `self` by `rhs`.
dotComputes the dot product of `self` and `rhs`.
distance_squaredCompute the squared euclidean distance between two points in space.
sub-1No Documentation 🚧
with_xCreates a 4D vector from `self` with the given value of `x`.
is_negative_bitmaskReturns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`. A negat...
lengthComputes the length of `self`.
reject_fromReturns the vector rejection of `self` from `rhs`. The vector rejection is the vector perpendicula...
truncateCreates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. Truncation to [`DVec3`]...
dot_into_vecReturns a vector where every component is the dot product of `self` and `rhs`.
mul-1No Documentation 🚧
project_onto_normalizedReturns the vector projection of `self` onto `rhs`. `rhs` must be normalized. # Panics Will pani...
move_towardsMoves towards `rhs` based on the value `d`. When `d` is `0.0`, the result will be equal to `self`....
as_vec4Casts all elements of `self` to `f32`.
length_squaredComputes the squared length of `self`. This is faster than `length()` as it avoids a square root o...
clampComponent-wise clamping of values, similar to [`f64::clamp`]. Each element in `min` must be less-or-equal to the corresponding element in `max`. # Panics Will panic if `min` is greater than `max` when `glam_assert` is enabled.
add-1No Documentation 🚧
fractReturns a vector containing the fractional part of the vector as `self - self.trunc()`. Note that ...
cmpneReturns a vector mask containing the result of a `!=` comparison for each element of `self` and `rhs`...
eqNo Documentation 🚧
negNo Documentation 🚧
newCreates a new vector.
project_ontoReturns the vector projection of `self` onto `rhs`. `rhs` must be of non-zero length. # Panics W...
element_sumReturns the sum of all elements of `self`. In other words, this computes `self.x + self.y + ..`.
add-2No Documentation 🚧
max_elementReturns the horizontal maximum of `self`. In other words this computes `max(x, y, ..)`.
is_nan_maskPerforms `is_nan` on each element of self, returning a vector mask of the results. In other words, this computes `[x.is_nan(), y.is_nan(), ...]...
with_wCreates a 4D vector from `self` with the given value of `w`.
splatCreates a vector with all elements set to `v`.
minReturns a vector containing the minimum values for each element of `self` and `rhs`. In other word...
rem-1No Documentation 🚧
roundReturns a vector containing the nearest integer to a number for each element of `self`. Round half...
cmpgeReturns a vector mask containing the result of a `>=` comparison for each element of `self` and `rhs`...
truncReturns a vector containing the integer part each element of `self`. This means numbers are always...
sub-2No Documentation 🚧
is_normalizedReturns whether `self` is length `1.0` or not. Uses a precision threshold of approximately `1e-4`.
as_uvec4Casts all elements of `self` to `u32`.
mul-2No Documentation 🚧
mulNo Documentation 🚧
clamp_length_minReturns a vector with a length no less than `min`. # Panics Will panic if `min` is negative when `glam_assert` is enabled.
expReturns a vector containing `e^self` (the exponential function) for each element of `self`.
maxReturns a vector containing the maximum values for each element of `self` and `rhs`. In other word...
cmpgtReturns a vector mask containing the result of a `>` comparison for each element of `self` and `rhs`...
addNo Documentation 🚧
recipReturns a vector containing the reciprocal `1.0/n` of each element of `self`.
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...
div-1No Documentation 🚧
absReturns a vector containing the absolute value of each element of `self`.
mul_addFused multiply-add. Computes `(self * a) + b` element-wise with only one rounding error, yielding a more accurate result than an unfused multiply-add. Using `mul_add` *may* be more performant than an unfused multiply-add if the target architecture has a dedicated fma CPU instruction. However, this is not always true, and will be heavily dependant on designing algorithms with specific target hardware in mind.
lerpPerforms a linear interpolation between `self` and `rhs` based on the value `s`. When `s` is `0.0`...
reject_from_normalizedReturns the vector rejection of `self` from `rhs`. The vector rejection is the vector perpendicula...
with_zCreates a 4D vector from `self` with the given value of `z`.
fract_glReturns a vector containing the fractional part of the vector as `self - self.floor()`. Note that ...
clamp_length_maxReturns a vector with a length no more than `max`. # Panics Will panic if `max` is negative when `glam_assert` is enabled.
with_yCreates a 4D vector from `self` with the given value of `y`.
div-2No Documentation 🚧
cmpleReturns a vector mask containing the result of a `<=` comparison for each element of `self` and `rhs`...
from_arrayCreates a new vector from an array.
selectCreates a vector from the elements in `if_true` and `if_false`, selecting which to use for each el...
cloneNo Documentation 🚧
normalizeReturns `self` normalized to length 1.0. For valid results, `self` must be finite and _not_ of len...
as_i64vec4Casts all elements of `self` to `i64`.
distanceComputes the Euclidean distance between two points in space.
as_u64vec4Casts all elements of `self` to `u64`.
normalize_or_zeroReturns `self` normalized to length 1.0 if possible, else returns zero. In particular, if the inpu...
rem-2No Documentation 🚧
clamp_lengthReturns a vector with a length no less than `min` and no more than `max`. # Panics Will panic if `min`...
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive...
refractReturns the refraction direction for a given incident vector `self`, surface normal `normal` and r...
remNo Documentation 🚧
is_finite_maskPerforms `is_finite` on each element of self, returning a vector mask of the results. In other words, this computes `[x.is_finite(), y.is_finite(), ...]...
cmpltReturns a vector mask containing the result of a `<` comparison for each element of `self` and `rhs`...
signumReturns a vector with elements representing the sign of `self`. - `1.0` if the number is positive,...
normalize_orReturns `self` normalized to length 1.0 if possible, else returns a fallback value. In particular...
floorReturns a vector containing the largest integer less than or equal to a number for each element of...
midpointCalculates the midpoint between `self` and `rhs`. The midpoint is the average of, or halfway point...
to_array`[x, y, z, w]`
ceilReturns a vector containing the smallest integer greater than or equal to a number for each elemen...
copysignReturns a vector with signs of `rhs` and the magnitudes of `self`.
reflectReturns the reflection vector for a given incident vector `self` and surface normal `normal`. `normal`...
min_elementReturns the horizontal minimum of `self`. In other words this computes `min(x, y, ..)`.
as_ivec4Casts all elements of `self` to `i32`.
element_productReturns the product of all elements of `self`. In other words, this computes `self.x * self.y * .....
powfReturns a vector containing each element of `self` raised to the power of `n`.
subNo Documentation 🚧
cmpeqReturns a vector mask containing the result of a `==` comparison for each element of `self` and `rhs`...
is_nanReturns `true` if any elements are `NaN`.
length_recipComputes `1.0 / length()`. For valid results, `self` must _not_ be of length zero.
divNo Documentation 🚧

rem_euclid

Returns the element-wise remainder of [Euclidean division] of self by rhs. [Euclidean division]: f64::rem_euclid

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

div_euclid

Returns the element-wise quotient of [Euclidean division] of self by rhs.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

dot

Computes the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

distance_squared

Compute the squared euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec4No Documentation 🚧
arg1DVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

with_x

Creates a 4D vector from self with the given value of x.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
xf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

is_negative_bitmask

Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of self. A negative element results in a 1 bit and a positive element in a 0 bit. Element x goes into the first lowest bit, element y into the second, etc.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

length

Computes the length of self.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

reject_from

Returns the vector rejection of self from rhs. The vector rejection is the vector perpendicular to the projection of self onto rhs, in rhs words the result of self - self.project_onto(rhs). rhs must be of non-zero length.

Panics

Will panic if rhs has a length of zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

truncate

Creates a 3D vector from the x, y and z elements of self, discarding w. Truncation to [DVec3] may also be performed by using [self.xyz()][crate::swizzles::Vec4Swizzles::xyz()].

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

dot_into_vec

Returns a vector where every component is the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec4No Documentation 🚧
arg1DVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

project_onto_normalized

Returns the vector projection of self onto rhs. rhs must be normalized.

Panics

Will panic if rhs is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

move_towards

Moves towards rhs based on the value d. When d is 0.0, the result will be equal to self. When d is equal to self.distance(rhs), the result will be equal to rhs. Will not go past rhs.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧
df64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

as_vec4

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

length_squared

Computes the squared length of self. This is faster than length() as it avoids a square root operation.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

clamp

Component-wise clamping of values, similar to [f64::clamp]. Each element in min must be less-or-equal to the corresponding element in max.

Panics

Will panic if min is greater than max when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
minDVec4No Documentation 🚧
maxDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

add-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec4No Documentation 🚧
arg1DVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

fract

Returns a vector containing the fractional part of the vector as self - self.trunc(). Note that this differs from the GLSL implementation of fract which returns self - self.floor(). Note that this is fast but not precise for large numbers.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

cmpne

Returns a vector mask containing the result of a != comparison for each element of self and rhs. In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
otherDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xf64No Documentation 🚧
yf64No Documentation 🚧
zf64No Documentation 🚧
wf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

project_onto

Returns the vector projection of self onto rhs. rhs must be of non-zero length.

Panics

Will panic if rhs is zero length when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

element_sum

Returns the sum of all elements of self. In other words, this computes self.x + self.y + ...

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

add-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec4No Documentation 🚧
arg1f64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

max_element

Returns the horizontal maximum of self. In other words this computes max(x, y, ..).

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

is_nan_mask

Performs is_nan on each element of self, returning a vector mask of the results. In other words, this computes [x.is_nan(), y.is_nan(), ...].

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

with_w

Creates a 4D vector from self with the given value of w.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
wf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

splat

Creates a vector with all elements set to v.

Arguments

NameTypeDocumentation
vf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

min

Returns a vector containing the minimum values for each element of self and rhs. In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

rem-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec4No Documentation 🚧
arg1DVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

round

Returns a vector containing the nearest integer to a number for each element of self. Round half-way cases away from 0.0.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

cmpge

Returns a vector mask containing the result of a >= comparison for each element of self and rhs. In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

trunc

Returns a vector containing the integer part each element of self. This means numbers are always truncated towards zero.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

sub-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec4No Documentation 🚧
arg1f64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

is_normalized

Returns whether self is length 1.0 or not. Uses a precision threshold of approximately 1e-4.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

as_uvec4

Casts all elements of self to u32.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec4No Documentation 🚧
arg1f64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

clamp_length_min

Returns a vector with a length no less than min.

Panics

Will panic if min is negative when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
minf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

exp

Returns a vector containing e^self (the exponential function) for each element of self.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

max

Returns a vector containing the maximum values for each element of self and rhs. In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

cmpgt

Returns a vector mask containing the result of a > comparison for each element of self and rhs. In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

recip

Returns a vector containing the reciprocal 1.0/n of each element of self.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two vectors contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧
max_abs_difff64No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

div-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec4No Documentation 🚧
arg1DVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

abs

Returns a vector containing the absolute value of each element of self.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

mul_add

Fused multiply-add. Computes (self * a) + b element-wise with only one rounding error, yielding a more accurate result than an unfused multiply-add. Using mul_add may be more performant than an unfused multiply-add if the target architecture has a dedicated fma CPU instruction. However, this is not always true, and will be heavily dependant on designing algorithms with specific target hardware in mind.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
aDVec4No Documentation 🚧
bDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

lerp

Performs a linear interpolation between self and rhs based on the value s. When s is 0.0, the result will be equal to self. When s is 1.0, the result will be equal to rhs. When s is outside of range [0, 1], the result is linearly extrapolated.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧
sf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

reject_from_normalized

Returns the vector rejection of self from rhs. The vector rejection is the vector perpendicular to the projection of self onto rhs, in rhs words the result of self - self.project_onto(rhs). rhs must be normalized.

Panics

Will panic if rhs is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

with_z

Creates a 4D vector from self with the given value of z.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
zf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

fract_gl

Returns a vector containing the fractional part of the vector as self - self.floor(). Note that this differs from the Rust implementation of fract which returns self - self.trunc(). Note that this is fast but not precise for large numbers.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

clamp_length_max

Returns a vector with a length no more than max.

Panics

Will panic if max is negative when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
maxf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

with_y

Creates a 4D vector from self with the given value of y.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
yf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

div-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec4No Documentation 🚧
arg1f64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

cmple

Returns a vector mask containing the result of a <= comparison for each element of self and rhs. In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

from_array

Creates a new vector from an array.

Arguments

NameTypeDocumentation
a[f64; 4]No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

select

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self. A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

Arguments

NameTypeDocumentation
maskBVec4No Documentation 🚧
if_trueDVec4No Documentation 🚧
if_falseDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

normalize

Returns self normalized to length 1.0. For valid results, self must be finite and not of length zero, nor very close to zero. See also [Self::try_normalize()] and [Self::normalize_or_zero()]. Panics Will panic if the resulting normalized vector is not finite when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

as_i64vec4

Casts all elements of self to i64.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

distance

Computes the Euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

as_u64vec4

Casts all elements of self to u64.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

normalize_or_zero

Returns self normalized to length 1.0 if possible, else returns zero. In particular, if the input is zero (or very close to zero), or non-finite, the result of this operation will be zero. See also [Self::try_normalize()].

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

rem-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0DVec4No Documentation 🚧
arg1f64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

clamp_length

Returns a vector with a length no less than min and no more than max.

Panics

Will panic if min is greater than max, or if either min or max is negative, when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
minf64No Documentation 🚧
maxf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

refract

Returns the refraction direction for a given incident vector self, surface normal normal and ratio of indices of refraction, eta. When total internal reflection occurs, a zero vector will be returned. self and normal must be normalized.

Panics

Will panic if self or normal is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
normalDVec4No Documentation 🚧
etaf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

rem

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

is_finite_mask

Performs is_finite on each element of self, returning a vector mask of the results. In other words, this computes [x.is_finite(), y.is_finite(), ...].

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

cmplt

Returns a vector mask containing the result of a < comparison for each element of self and rhs. In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

signum

Returns a vector with elements representing the sign of self.

  • 1.0 if the number is positive, +0.0 or INFINITY
  • -1.0 if the number is negative, -0.0 or NEG_INFINITY
  • NAN if the number is NAN

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

normalize_or

Returns self normalized to length 1.0 if possible, else returns a fallback value. In particular, if the input is zero (or very close to zero), or non-finite, the result of this operation will be the fallback value. See also [Self::try_normalize()].

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
fallbackDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

floor

Returns a vector containing the largest integer less than or equal to a number for each element of self.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

midpoint

Calculates the midpoint between self and rhs. The midpoint is the average of, or halfway point between, two vectors. a.midpoint(b) should yield the same result as a.lerp(b, 0.5) while being slightly cheaper to compute.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

to_array

[x, y, z, w]

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0[f64; 4]No Documentation 🚧

ceil

Returns a vector containing the smallest integer greater than or equal to a number for each element of self.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

copysign

Returns a vector with signs of rhs and the magnitudes of self.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

reflect

Returns the reflection vector for a given incident vector self and surface normal normal. normal must be normalized.

Panics

Will panic if normal is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
normalDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

min_element

Returns the horizontal minimum of self. In other words this computes min(x, y, ..).

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

as_ivec4

Casts all elements of self to i32.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

element_product

Returns the product of all elements of self. In other words, this computes self.x * self.y * ...

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

powf

Returns a vector containing each element of self raised to the power of n.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
nf64No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

cmpeq

Returns a vector mask containing the result of a == comparison for each element of self and rhs. In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

is_nan

Returns true if any elements are NaN.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

length_recip

Computes 1.0 / length(). For valid results, self must not be of length zero.

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f64No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfDVec4No Documentation 🚧
rhsDVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

EulerRot

ZYX

ZXY

YXZ

YZX

XYZ

XZY

ZYZ

ZXZ

YXY

YZY

XYX

XZX

ZYXEx

ZXYEx

YXZEx

YZXEx

XYZEx

XZYEx

ZYZEx

ZXZEx

YXYEx

YZYEx

XYXEx

XZXEx

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
assert_receiver_is_total_eqNo Documentation 🚧
eqNo Documentation 🚧
cloneNo Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfEulerRotNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfEulerRotNo Documentation 🚧
otherEulerRotNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfEulerRotNo Documentation 🚧

Returns

NameTypeDocumentation
arg0EulerRotNo Documentation 🚧

I64Vec2

I64Vec2

  • x:i64
  • y:i64

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
rem_euclidReturns the element-wise remainder of [Euclidean division] of `self` by `rhs`. # Panics This function will panic if any `rhs` element is 0 or the division results in overflow. [Euclidean division]...
saturating_divReturns a vector containing the saturating division of `self` and `rhs`. In other words this compu...
div-1No Documentation 🚧
saturating_sub_unsignedReturns a vector containing the saturating subtraction of `self` and unsigned vector `rhs`. In oth...
as_u64vec2Casts all elements of `self` to `u64`.
cmpneReturns a vector mask containing the result of a `!=` comparison for each element of `self` and `rhs`...
mulNo Documentation 🚧
cloneNo Documentation 🚧
wrapping_sub_unsignedReturns a vector containing the wrapping subtraction of `self` and unsigned vector `rhs`. In other...
cmpgtReturns a vector mask containing the result of a `>` comparison for each element of `self` and `rhs`...
max_elementReturns the horizontal maximum of `self`. In other words this computes `max(x, y, ..)`.
rem-1No Documentation 🚧
wrapping_subReturns a vector containing the wrapping subtraction of `self` and `rhs`. In other words this comp...
wrapping_addReturns a vector containing the wrapping addition of `self` and `rhs`. In other words this compute...
as_uvec2Casts all elements of `self` to `u32`.
dot_into_vecReturns a vector where every component is the dot product of `self` and `rhs`.
wrapping_mulReturns a vector containing the wrapping multiplication of `self` and `rhs`. In other words this c...
from_arrayCreates a new vector from an array.
saturating_addReturns a vector containing the saturating addition of `self` and `rhs`. In other words this compu...
with_xCreates a 2D vector from `self` with the given value of `x`.
selectCreates a vector from the elements in `if_true` and `if_false`, selecting which to use for each el...
cmpleReturns a vector mask containing the result of a `<=` comparison for each element of `self` and `rhs`...
perp_dotThe perpendicular dot product of `self` and `rhs`. Also known as the wedge product, 2D cross produ...
mul-2No Documentation 🚧
div-2No Documentation 🚧
sub-1No Documentation 🚧
saturating_mulReturns a vector containing the saturating multiplication of `self` and `rhs`. In other words this...
dotComputes the dot product of `self` and `rhs`.
rotateReturns `rhs` rotated by the angle of `self`. If `self` is normalized, then this just rotation. Th...
cmpgeReturns a vector mask containing the result of a `>=` comparison for each element of `self` and `rhs`...
saturating_subReturns a vector containing the saturating subtraction of `self` and `rhs`. In other words this co...
subNo Documentation 🚧
wrapping_add_unsignedReturns a vector containing the wrapping addition of `self` and unsigned vector `rhs`. In other wo...
minReturns a vector containing the minimum values for each element of `self` and `rhs`. In other word...
distance_squaredCompute the squared euclidean distance between two points in space.
perpReturns a vector that is equal to `self` rotated by 90 degrees.
maxReturns a vector containing the maximum values for each element of `self` and `rhs`. In other word...
element_productReturns the product of all elements of `self`. In other words, this computes `self.x * self.y * .....
extendCreates a 3D vector from `self` and the given `z` value.
rem-2No Documentation 🚧
element_sumReturns the sum of all elements of `self`. In other words, this computes `self.x + self.y + ..`.
as_ivec2Casts all elements of `self` to `i32`.
absReturns a vector containing the absolute value of each element of `self`.
min_elementReturns the horizontal minimum of `self`. In other words this computes `min(x, y, ..)`.
splatCreates a vector with all elements set to `v`.
is_negative_bitmaskReturns a bitmask with the lowest 2 bits set to the sign bits from the elements of `self`. A negat...
saturating_add_unsignedIn other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`.
signumReturns a vector with elements representing the sign of `self`. - `0` if the number is zero - `1`...
newCreates a new vector.
clampComponent-wise clamping of values, similar to [`i64::clamp`]. Each element in `min` must be less-or-equal to the corresponding element in `max`. # Panics Will panic if `min` is greater than `max` when `glam_assert` is enabled.
cmpltReturns a vector mask containing the result of a `<` comparison for each element of `self` and `rhs`...
with_yCreates a 2D vector from `self` with the given value of `y`.
sub-2No Documentation 🚧
length_squaredComputes the squared length of `self`.
negNo Documentation 🚧
div_euclidReturns the element-wise quotient of [Euclidean division] of `self` by `rhs`. # Panics This function will panic if any `rhs` element is 0 or the division results in overflow.
eqNo Documentation 🚧
addNo Documentation 🚧
as_vec2Casts all elements of `self` to `f32`.
add-1No Documentation 🚧
remNo Documentation 🚧
assert_receiver_is_total_eqNo Documentation 🚧
add-2No Documentation 🚧
to_array`[x, y]`
divNo Documentation 🚧
cmpeqReturns a vector mask containing the result of a `==` comparison for each element of `self` and `rhs`...
wrapping_divReturns a vector containing the wrapping division of `self` and `rhs`. In other words this compute...
as_dvec2Casts all elements of `self` to `f64`.
mul-1No Documentation 🚧

rem_euclid

Returns the element-wise remainder of [Euclidean division] of self by rhs.

Panics

This function will panic if any rhs element is 0 or the division results in overflow. [Euclidean division]: i64::rem_euclid

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

saturating_div

Returns a vector containing the saturating division of self and rhs. In other words this computes [self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

div-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧
arg1I64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

saturating_sub_unsigned

Returns a vector containing the saturating subtraction of self and unsigned vector rhs. In other words this computes [self.x.saturating_sub_unsigned(rhs.x), self.y.saturating_sub_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

as_u64vec2

Casts all elements of self to u64.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

cmpne

Returns a vector mask containing the result of a != comparison for each element of self and rhs. In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

wrapping_sub_unsigned

Returns a vector containing the wrapping subtraction of self and unsigned vector rhs. In other words this computes [self.x.wrapping_sub_unsigned(rhs.x), self.y.wrapping_sub_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

cmpgt

Returns a vector mask containing the result of a > comparison for each element of self and rhs. In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

max_element

Returns the horizontal maximum of self. In other words this computes max(x, y, ..).

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

rem-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧
arg1I64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

wrapping_sub

Returns a vector containing the wrapping subtraction of self and rhs. In other words this computes [self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

wrapping_add

Returns a vector containing the wrapping addition of self and rhs. In other words this computes [self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

as_uvec2

Casts all elements of self to u32.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

dot_into_vec

Returns a vector where every component is the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

wrapping_mul

Returns a vector containing the wrapping multiplication of self and rhs. In other words this computes [self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

from_array

Creates a new vector from an array.

Arguments

NameTypeDocumentation
a[i64; 2]No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

saturating_add

Returns a vector containing the saturating addition of self and rhs. In other words this computes [self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

with_x

Creates a 2D vector from self with the given value of x.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
xi64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

select

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self. A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

Arguments

NameTypeDocumentation
maskBVec2No Documentation 🚧
if_trueI64Vec2No Documentation 🚧
if_falseI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

cmple

Returns a vector mask containing the result of a <= comparison for each element of self and rhs. In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

perp_dot

The perpendicular dot product of self and rhs. Also known as the wedge product, 2D cross product, and determinant.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧
arg1i64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

div-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧
arg1i64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧
arg1I64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

saturating_mul

Returns a vector containing the saturating multiplication of self and rhs. In other words this computes [self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

dot

Computes the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

rotate

Returns rhs rotated by the angle of self. If self is normalized, then this just rotation. This is what you usually want. Otherwise, it will be like a rotation with a multiplication by self's length.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

cmpge

Returns a vector mask containing the result of a >= comparison for each element of self and rhs. In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

saturating_sub

Returns a vector containing the saturating subtraction of self and rhs. In other words this computes [self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

wrapping_add_unsigned

Returns a vector containing the wrapping addition of self and unsigned vector rhs. In other words this computes [self.x.wrapping_add_unsigned(rhs.x), self.y.wrapping_add_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

min

Returns a vector containing the minimum values for each element of self and rhs. In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

distance_squared

Compute the squared euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

perp

Returns a vector that is equal to self rotated by 90 degrees.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

max

Returns a vector containing the maximum values for each element of self and rhs. In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

element_product

Returns the product of all elements of self. In other words, this computes self.x * self.y * ...

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

extend

Creates a 3D vector from self and the given z value.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
zi64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

rem-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧
arg1i64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

element_sum

Returns the sum of all elements of self. In other words, this computes self.x + self.y + ...

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

as_ivec2

Casts all elements of self to i32.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

abs

Returns a vector containing the absolute value of each element of self.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

min_element

Returns the horizontal minimum of self. In other words this computes min(x, y, ..).

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

splat

Creates a vector with all elements set to v.

Arguments

NameTypeDocumentation
vi64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

is_negative_bitmask

Returns a bitmask with the lowest 2 bits set to the sign bits from the elements of self. A negative element results in a 1 bit and a positive element in a 0 bit. Element x goes into the first lowest bit, element y into the second, etc.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

saturating_add_unsigned

In other words this computes [self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

signum

Returns a vector with elements representing the sign of self.

  • 0 if the number is zero
  • 1 if the number is positive
  • -1 if the number is negative

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xi64No Documentation 🚧
yi64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

clamp

Component-wise clamping of values, similar to [i64::clamp]. Each element in min must be less-or-equal to the corresponding element in max.

Panics

Will panic if min is greater than max when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
minI64Vec2No Documentation 🚧
maxI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

cmplt

Returns a vector mask containing the result of a < comparison for each element of self and rhs. In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

with_y

Creates a 2D vector from self with the given value of y.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
yi64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

sub-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧
arg1i64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

length_squared

Computes the squared length of self.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

div_euclid

Returns the element-wise quotient of [Euclidean division] of self by rhs.

Panics

This function will panic if any rhs element is 0 or the division results in overflow.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
otherI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

as_vec2

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

add-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧
arg1I64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

rem

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

add-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧
arg1i64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

to_array

[x, y]

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0[i64; 2]No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

cmpeq

Returns a vector mask containing the result of a == comparison for each element of self and rhs. In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

wrapping_div

Returns a vector containing the wrapping division of self and rhs. In other words this computes [self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

as_dvec2

Casts all elements of self to f64.

Arguments

NameTypeDocumentation
_selfI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧
arg1I64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

I64Vec3

I64Vec3

  • x:i64
  • y:i64
  • z:i64

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
maxReturns a vector containing the maximum values for each element of `self` and `rhs`. In other word...
cmpleReturns a vector mask containing the result of a `<=` comparison for each element of `self` and `rhs`...
saturating_subReturns a vector containing the saturating subtraction of `self` and `rhs`. In other words this co...
cmpeqReturns a vector mask containing the result of a `==` comparison for each element of `self` and `rhs`...
as_ivec3Casts all elements of `self` to `i32`.
cmpgtReturns a vector mask containing the result of a `>` comparison for each element of `self` and `rhs`...
rem-2No Documentation 🚧
as_u64vec3Casts all elements of `self` to `u64`.
wrapping_addReturns a vector containing the wrapping addition of `self` and `rhs`. In other words this compute...
div-1No Documentation 🚧
mulNo Documentation 🚧
min_elementReturns the horizontal minimum of `self`. In other words this computes `min(x, y, ..)`.
with_zCreates a 3D vector from `self` with the given value of `z`.
mul-2No Documentation 🚧
cmpgeReturns a vector mask containing the result of a `>=` comparison for each element of `self` and `rhs`...
mul-1No Documentation 🚧
to_array`[x, y, z]`
from_arrayCreates a new vector from an array.
wrapping_sub_unsignedReturns a vector containing the wrapping subtraction of `self` and unsigned vector `rhs`. In other...
newCreates a new vector.
sub-1No Documentation 🚧
eqNo Documentation 🚧
saturating_divReturns a vector containing the saturating division of `self` and `rhs`. In other words this compu...
saturating_sub_unsignedReturns a vector containing the saturating subtraction of `self` and unsigned vector `rhs`. In oth...
clampComponent-wise clamping of values, similar to [`i64::clamp`]. Each element in `min` must be less-or-equal to the corresponding element in `max`. # Panics Will panic if `min` is greater than `max` when `glam_assert` is enabled.
crossComputes the cross product of `self` and `rhs`.
as_uvec3Casts all elements of `self` to `u32`.
cmpltReturns a vector mask containing the result of a `<` comparison for each element of `self` and `rhs`...
saturating_add_unsignedIn other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`.
wrapping_add_unsignedReturns a vector containing the wrapping addition of `self` and unsigned vector `rhs`. In other wo...
with_yCreates a 3D vector from `self` with the given value of `y`.
assert_receiver_is_total_eqNo Documentation 🚧
rem_euclidReturns the element-wise remainder of [Euclidean division] of `self` by `rhs`. # Panics This function will panic if any `rhs` element is 0 or the division results in overflow. [Euclidean division]...
as_dvec3Casts all elements of `self` to `f64`.
max_elementReturns the horizontal maximum of `self`. In other words this computes `max(x, y, ..)`.
selectCreates a vector from the elements in `if_true` and `if_false`, selecting which to use for each el...
remNo Documentation 🚧
length_squaredComputes the squared length of `self`.
rem-1No Documentation 🚧
extendCreates a 4D vector from `self` and the given `w` value.
splatCreates a vector with all elements set to `v`.
absReturns a vector containing the absolute value of each element of `self`.
dotComputes the dot product of `self` and `rhs`.
cmpneReturns a vector mask containing the result of a `!=` comparison for each element of `self` and `rhs`...
truncateCreates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. Truncation may also b...
minReturns a vector containing the minimum values for each element of `self` and `rhs`. In other word...
element_productReturns the product of all elements of `self`. In other words, this computes `self.x * self.y * .....
with_xCreates a 3D vector from `self` with the given value of `x`.
saturating_addReturns a vector containing the saturating addition of `self` and `rhs`. In other words this compu...
distance_squaredCompute the squared euclidean distance between two points in space.
subNo Documentation 🚧
addNo Documentation 🚧
add-1No Documentation 🚧
negNo Documentation 🚧
div_euclidReturns the element-wise quotient of [Euclidean division] of `self` by `rhs`. # Panics This function will panic if any `rhs` element is 0 or the division results in overflow.
dot_into_vecReturns a vector where every component is the dot product of `self` and `rhs`.
div-2No Documentation 🚧
as_vec3aCasts all elements of `self` to `f32`.
is_negative_bitmaskReturns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. A negat...
element_sumReturns the sum of all elements of `self`. In other words, this computes `self.x + self.y + ..`.
wrapping_subReturns a vector containing the wrapping subtraction of `self` and `rhs`. In other words this comp...
saturating_mulReturns a vector containing the saturating multiplication of `self` and `rhs`. In other words this...
as_vec3Casts all elements of `self` to `f32`.
add-2No Documentation 🚧
divNo Documentation 🚧
wrapping_mulReturns a vector containing the wrapping multiplication of `self` and `rhs`. In other words this c...
signumReturns a vector with elements representing the sign of `self`. - `0` if the number is zero - `1`...
wrapping_divReturns a vector containing the wrapping division of `self` and `rhs`. In other words this compute...
cloneNo Documentation 🚧
sub-2No Documentation 🚧

max

Returns a vector containing the maximum values for each element of self and rhs. In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

cmple

Returns a vector mask containing the result of a <= comparison for each element of self and rhs. In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

saturating_sub

Returns a vector containing the saturating subtraction of self and rhs. In other words this computes [self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

cmpeq

Returns a vector mask containing the result of a == comparison for each element of self and rhs. In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

as_ivec3

Casts all elements of self to i32.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

cmpgt

Returns a vector mask containing the result of a > comparison for each element of self and rhs. In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

rem-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧
arg1i64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

as_u64vec3

Casts all elements of self to u64.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

wrapping_add

Returns a vector containing the wrapping addition of self and rhs. In other words this computes [self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

div-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧
arg1I64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

min_element

Returns the horizontal minimum of self. In other words this computes min(x, y, ..).

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

with_z

Creates a 3D vector from self with the given value of z.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
zi64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧
arg1i64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

cmpge

Returns a vector mask containing the result of a >= comparison for each element of self and rhs. In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧
arg1I64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

to_array

[x, y, z]

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0[i64; 3]No Documentation 🚧

from_array

Creates a new vector from an array.

Arguments

NameTypeDocumentation
a[i64; 3]No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

wrapping_sub_unsigned

Returns a vector containing the wrapping subtraction of self and unsigned vector rhs. In other words this computes [self.x.wrapping_sub_unsigned(rhs.x), self.y.wrapping_sub_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xi64No Documentation 🚧
yi64No Documentation 🚧
zi64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧
arg1I64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
otherI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

saturating_div

Returns a vector containing the saturating division of self and rhs. In other words this computes [self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

saturating_sub_unsigned

Returns a vector containing the saturating subtraction of self and unsigned vector rhs. In other words this computes [self.x.saturating_sub_unsigned(rhs.x), self.y.saturating_sub_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

clamp

Component-wise clamping of values, similar to [i64::clamp]. Each element in min must be less-or-equal to the corresponding element in max.

Panics

Will panic if min is greater than max when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
minI64Vec3No Documentation 🚧
maxI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

cross

Computes the cross product of self and rhs.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

as_uvec3

Casts all elements of self to u32.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

cmplt

Returns a vector mask containing the result of a < comparison for each element of self and rhs. In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

saturating_add_unsigned

In other words this computes [self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

wrapping_add_unsigned

Returns a vector containing the wrapping addition of self and unsigned vector rhs. In other words this computes [self.x.wrapping_add_unsigned(rhs.x), self.y.wrapping_add_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

with_y

Creates a 3D vector from self with the given value of y.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
yi64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

rem_euclid

Returns the element-wise remainder of [Euclidean division] of self by rhs.

Panics

This function will panic if any rhs element is 0 or the division results in overflow. [Euclidean division]: i64::rem_euclid

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

as_dvec3

Casts all elements of self to f64.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

max_element

Returns the horizontal maximum of self. In other words this computes max(x, y, ..).

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

select

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self. A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

Arguments

NameTypeDocumentation
maskBVec3No Documentation 🚧
if_trueI64Vec3No Documentation 🚧
if_falseI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

rem

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

length_squared

Computes the squared length of self.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

rem-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧
arg1I64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

extend

Creates a 4D vector from self and the given w value.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
wi64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

splat

Creates a vector with all elements set to v.

Arguments

NameTypeDocumentation
vi64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

abs

Returns a vector containing the absolute value of each element of self.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

dot

Computes the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

cmpne

Returns a vector mask containing the result of a != comparison for each element of self and rhs. In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

truncate

Creates a 2D vector from the x and y elements of self, discarding z. Truncation may also be performed by using [self.xy()][crate::swizzles::Vec3Swizzles::xy()].

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

min

Returns a vector containing the minimum values for each element of self and rhs. In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

element_product

Returns the product of all elements of self. In other words, this computes self.x * self.y * ...

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

with_x

Creates a 3D vector from self with the given value of x.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
xi64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

saturating_add

Returns a vector containing the saturating addition of self and rhs. In other words this computes [self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

distance_squared

Compute the squared euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

add-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧
arg1I64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

div_euclid

Returns the element-wise quotient of [Euclidean division] of self by rhs.

Panics

This function will panic if any rhs element is 0 or the division results in overflow.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

dot_into_vec

Returns a vector where every component is the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

div-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧
arg1i64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

as_vec3a

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

is_negative_bitmask

Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of self. A negative element results in a 1 bit and a positive element in a 0 bit. Element x goes into the first lowest bit, element y into the second, etc.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

element_sum

Returns the sum of all elements of self. In other words, this computes self.x + self.y + ...

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

wrapping_sub

Returns a vector containing the wrapping subtraction of self and rhs. In other words this computes [self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

saturating_mul

Returns a vector containing the saturating multiplication of self and rhs. In other words this computes [self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

as_vec3

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

add-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧
arg1i64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

wrapping_mul

Returns a vector containing the wrapping multiplication of self and rhs. In other words this computes [self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

signum

Returns a vector with elements representing the sign of self.

  • 0 if the number is zero
  • 1 if the number is positive
  • -1 if the number is negative

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

wrapping_div

Returns a vector containing the wrapping division of self and rhs. In other words this computes [self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

sub-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧
arg1i64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

I64Vec4

I64Vec4

  • x:i64
  • y:i64
  • z:i64
  • w:i64

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
clampComponent-wise clamping of values, similar to [`i64::clamp`]. Each element in `min` must be less-or-equal to the corresponding element in `max`. # Panics Will panic if `min` is greater than `max` when `glam_assert` is enabled.
as_u64vec4Casts all elements of `self` to `u64`.
wrapping_mulReturns a vector containing the wrapping multiplication of `self` and `rhs`. In other words this c...
element_productReturns the product of all elements of `self`. In other words, this computes `self.x * self.y * .....
wrapping_subReturns a vector containing the wrapping subtraction of `self` and `rhs`. In other words this comp...
cmpleReturns a vector mask containing the result of a `<=` comparison for each element of `self` and `rhs`...
wrapping_add_unsignedReturns a vector containing the wrapping addition of `self` and unsigned vector `rhs`. In other wo...
add-1No Documentation 🚧
mul-1No Documentation 🚧
addNo Documentation 🚧
distance_squaredCompute the squared euclidean distance between two points in space.
cloneNo Documentation 🚧
cmpeqReturns a vector mask containing the result of a `==` comparison for each element of `self` and `rhs`...
saturating_sub_unsignedReturns a vector containing the saturating subtraction of `self` and unsigned vector `rhs`. In oth...
div-1No Documentation 🚧
divNo Documentation 🚧
splatCreates a vector with all elements set to `v`.
rem-1No Documentation 🚧
as_ivec4Casts all elements of `self` to `i32`.
cmpgeReturns a vector mask containing the result of a `>=` comparison for each element of `self` and `rhs`...
newCreates a new vector.
dot_into_vecReturns a vector where every component is the dot product of `self` and `rhs`.
as_dvec4Casts all elements of `self` to `f64`.
as_vec4Casts all elements of `self` to `f32`.
with_xCreates a 4D vector from `self` with the given value of `x`.
truncateCreates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. Truncation to [`I64Vec3`]...
cmpneReturns a vector mask containing the result of a `!=` comparison for each element of `self` and `rhs`...
absReturns a vector containing the absolute value of each element of `self`.
cmpgtReturns a vector mask containing the result of a `>` comparison for each element of `self` and `rhs`...
dotComputes the dot product of `self` and `rhs`.
mul-2No Documentation 🚧
to_array`[x, y, z, w]`
remNo Documentation 🚧
rem_euclidReturns the element-wise remainder of [Euclidean division] of `self` by `rhs`. # Panics This function will panic if any `rhs` element is 0 or the division results in overflow. [Euclidean division]...
max_elementReturns the horizontal maximum of `self`. In other words this computes `max(x, y, ..)`.
element_sumReturns the sum of all elements of `self`. In other words, this computes `self.x + self.y + ..`.
div_euclidReturns the element-wise quotient of [Euclidean division] of `self` by `rhs`. # Panics This function will panic if any `rhs` element is 0 or the division results in overflow.
wrapping_addReturns a vector containing the wrapping addition of `self` and `rhs`. In other words this compute...
saturating_add_unsignedIn other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`.
rem-2No Documentation 🚧
length_squaredComputes the squared length of `self`.
is_negative_bitmaskReturns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`. A negat...
selectCreates a vector from the elements in `if_true` and `if_false`, selecting which to use for each el...
div-2No Documentation 🚧
negNo Documentation 🚧
saturating_addReturns a vector containing the saturating addition of `self` and `rhs`. In other words this compu...
eqNo Documentation 🚧
signumReturns a vector with elements representing the sign of `self`. - `0` if the number is zero - `1`...
wrapping_divReturns a vector containing the wrapping division of `self` and `rhs`. In other words this compute...
subNo Documentation 🚧
from_arrayCreates a new vector from an array.
with_wCreates a 4D vector from `self` with the given value of `w`.
with_yCreates a 4D vector from `self` with the given value of `y`.
cmpltReturns a vector mask containing the result of a `<` comparison for each element of `self` and `rhs`...
with_zCreates a 4D vector from `self` with the given value of `z`.
assert_receiver_is_total_eqNo Documentation 🚧
as_uvec4Casts all elements of `self` to `u32`.
wrapping_sub_unsignedReturns a vector containing the wrapping subtraction of `self` and unsigned vector `rhs`. In other...
saturating_mulReturns a vector containing the saturating multiplication of `self` and `rhs`. In other words this...
add-2No Documentation 🚧
sub-2No Documentation 🚧
minReturns a vector containing the minimum values for each element of `self` and `rhs`. In other word...
min_elementReturns the horizontal minimum of `self`. In other words this computes `min(x, y, ..)`.
mulNo Documentation 🚧
saturating_subReturns a vector containing the saturating subtraction of `self` and `rhs`. In other words this co...
saturating_divReturns a vector containing the saturating division of `self` and `rhs`. In other words this compu...
sub-1No Documentation 🚧
maxReturns a vector containing the maximum values for each element of `self` and `rhs`. In other word...

clamp

Component-wise clamping of values, similar to [i64::clamp]. Each element in min must be less-or-equal to the corresponding element in max.

Panics

Will panic if min is greater than max when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
minI64Vec4No Documentation 🚧
maxI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

as_u64vec4

Casts all elements of self to u64.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

wrapping_mul

Returns a vector containing the wrapping multiplication of self and rhs. In other words this computes [self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

element_product

Returns the product of all elements of self. In other words, this computes self.x * self.y * ...

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

wrapping_sub

Returns a vector containing the wrapping subtraction of self and rhs. In other words this computes [self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

cmple

Returns a vector mask containing the result of a <= comparison for each element of self and rhs. In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

wrapping_add_unsigned

Returns a vector containing the wrapping addition of self and unsigned vector rhs. In other words this computes [self.x.wrapping_add_unsigned(rhs.x), self.y.wrapping_add_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

add-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧
arg1I64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧
arg1I64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

distance_squared

Compute the squared euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

cmpeq

Returns a vector mask containing the result of a == comparison for each element of self and rhs. In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

saturating_sub_unsigned

Returns a vector containing the saturating subtraction of self and unsigned vector rhs. In other words this computes [self.x.saturating_sub_unsigned(rhs.x), self.y.saturating_sub_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

div-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧
arg1I64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

splat

Creates a vector with all elements set to v.

Arguments

NameTypeDocumentation
vi64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

rem-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧
arg1I64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

as_ivec4

Casts all elements of self to i32.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

cmpge

Returns a vector mask containing the result of a >= comparison for each element of self and rhs. In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xi64No Documentation 🚧
yi64No Documentation 🚧
zi64No Documentation 🚧
wi64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

dot_into_vec

Returns a vector where every component is the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

as_dvec4

Casts all elements of self to f64.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

as_vec4

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

with_x

Creates a 4D vector from self with the given value of x.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
xi64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

truncate

Creates a 3D vector from the x, y and z elements of self, discarding w. Truncation to [I64Vec3] may also be performed by using [self.xyz()][crate::swizzles::Vec4Swizzles::xyz()].

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

cmpne

Returns a vector mask containing the result of a != comparison for each element of self and rhs. In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

abs

Returns a vector containing the absolute value of each element of self.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

cmpgt

Returns a vector mask containing the result of a > comparison for each element of self and rhs. In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

dot

Computes the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧
arg1i64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

to_array

[x, y, z, w]

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0[i64; 4]No Documentation 🚧

rem

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

rem_euclid

Returns the element-wise remainder of [Euclidean division] of self by rhs.

Panics

This function will panic if any rhs element is 0 or the division results in overflow. [Euclidean division]: i64::rem_euclid

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

max_element

Returns the horizontal maximum of self. In other words this computes max(x, y, ..).

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

element_sum

Returns the sum of all elements of self. In other words, this computes self.x + self.y + ...

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

div_euclid

Returns the element-wise quotient of [Euclidean division] of self by rhs.

Panics

This function will panic if any rhs element is 0 or the division results in overflow.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

wrapping_add

Returns a vector containing the wrapping addition of self and rhs. In other words this computes [self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

saturating_add_unsigned

In other words this computes [self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

rem-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧
arg1i64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

length_squared

Computes the squared length of self.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

is_negative_bitmask

Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of self. A negative element results in a 1 bit and a positive element in a 0 bit. Element x goes into the first lowest bit, element y into the second, etc.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

select

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self. A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

Arguments

NameTypeDocumentation
maskBVec4No Documentation 🚧
if_trueI64Vec4No Documentation 🚧
if_falseI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

div-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧
arg1i64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

saturating_add

Returns a vector containing the saturating addition of self and rhs. In other words this computes [self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
otherI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

signum

Returns a vector with elements representing the sign of self.

  • 0 if the number is zero
  • 1 if the number is positive
  • -1 if the number is negative

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

wrapping_div

Returns a vector containing the wrapping division of self and rhs. In other words this computes [self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

from_array

Creates a new vector from an array.

Arguments

NameTypeDocumentation
a[i64; 4]No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

with_w

Creates a 4D vector from self with the given value of w.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
wi64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

with_y

Creates a 4D vector from self with the given value of y.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
yi64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

cmplt

Returns a vector mask containing the result of a < comparison for each element of self and rhs. In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

with_z

Creates a 4D vector from self with the given value of z.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
zi64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

as_uvec4

Casts all elements of self to u32.

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

wrapping_sub_unsigned

Returns a vector containing the wrapping subtraction of self and unsigned vector rhs. In other words this computes [self.x.wrapping_sub_unsigned(rhs.x), self.y.wrapping_sub_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

saturating_mul

Returns a vector containing the saturating multiplication of self and rhs. In other words this computes [self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

add-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧
arg1i64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

sub-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧
arg1i64No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

min

Returns a vector containing the minimum values for each element of self and rhs. In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

min_element

Returns the horizontal minimum of self. In other words this computes min(x, y, ..).

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0i64No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

saturating_sub

Returns a vector containing the saturating subtraction of self and rhs. In other words this computes [self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

saturating_div

Returns a vector containing the saturating division of self and rhs. In other words this computes [self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧
arg1I64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

max

Returns a vector containing the maximum values for each element of self and rhs. In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfI64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

IVec2

IVec2

  • x:i32
  • y:i32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
element_productReturns the product of all elements of `self`. In other words, this computes `self.x * self.y * .....
saturating_divReturns a vector containing the saturating division of `self` and `rhs`. In other words this compu...
cloneNo Documentation 🚧
selectCreates a vector from the elements in `if_true` and `if_false`, selecting which to use for each el...
clampComponent-wise clamping of values, similar to [`i32::clamp`]. Each element in `min` must be less-or-equal to the corresponding element in `max`. # Panics Will panic if `min` is greater than `max` when `glam_assert` is enabled.
divNo Documentation 🚧
sub-2No Documentation 🚧
cmpltReturns a vector mask containing the result of a `<` comparison for each element of `self` and `rhs`...
sub-1No Documentation 🚧
cmpneReturns a vector mask containing the result of a `!=` comparison for each element of `self` and `rhs`...
perp_dotThe perpendicular dot product of `self` and `rhs`. Also known as the wedge product, 2D cross produ...
rem-2No Documentation 🚧
from_arrayCreates a new vector from an array.
distance_squaredCompute the squared euclidean distance between two points in space.
min_elementReturns the horizontal minimum of `self`. In other words this computes `min(x, y, ..)`.
addNo Documentation 🚧
assert_receiver_is_total_eqNo Documentation 🚧
negNo Documentation 🚧
length_squaredComputes the squared length of `self`.
wrapping_addReturns a vector containing the wrapping addition of `self` and `rhs`. In other words this compute...
element_sumReturns the sum of all elements of `self`. In other words, this computes `self.x + self.y + ..`.
wrapping_mulReturns a vector containing the wrapping multiplication of `self` and `rhs`. In other words this c...
as_vec2Casts all elements of `self` to `f32`.
saturating_addReturns a vector containing the saturating addition of `self` and `rhs`. In other words this compu...
wrapping_sub_unsignedReturns a vector containing the wrapping subtraction of `self` and unsigned vector `rhs`. In other...
cmpleReturns a vector mask containing the result of a `<=` comparison for each element of `self` and `rhs`...
minReturns a vector containing the minimum values for each element of `self` and `rhs`. In other word...
div-2No Documentation 🚧
as_dvec2Casts all elements of `self` to `f64`.
add-2No Documentation 🚧
as_uvec2Casts all elements of `self` to `u32`.
with_yCreates a 2D vector from `self` with the given value of `y`.
wrapping_divReturns a vector containing the wrapping division of `self` and `rhs`. In other words this compute...
signumReturns a vector with elements representing the sign of `self`. - `0` if the number is zero - `1`...
cmpeqReturns a vector mask containing the result of a `==` comparison for each element of `self` and `rhs`...
eqNo Documentation 🚧
max_elementReturns the horizontal maximum of `self`. In other words this computes `max(x, y, ..)`.
add-1No Documentation 🚧
absReturns a vector containing the absolute value of each element of `self`.
extendCreates a 3D vector from `self` and the given `z` value.
subNo Documentation 🚧
div-1No Documentation 🚧
splatCreates a vector with all elements set to `v`.
saturating_add_unsignedIn other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`.
rem_euclidReturns the element-wise remainder of [Euclidean division] of `self` by `rhs`. # Panics This function will panic if any `rhs` element is 0 or the division results in overflow. [Euclidean division]...
dot_into_vecReturns a vector where every component is the dot product of `self` and `rhs`.
mulNo Documentation 🚧
cmpgeReturns a vector mask containing the result of a `>=` comparison for each element of `self` and `rhs`...
wrapping_subReturns a vector containing the wrapping subtraction of `self` and `rhs`. In other words this comp...
newCreates a new vector.
perpReturns a vector that is equal to `self` rotated by 90 degrees.
saturating_mulReturns a vector containing the saturating multiplication of `self` and `rhs`. In other words this...
as_i64vec2Casts all elements of `self` to `i64`.
to_array`[x, y]`
mul-2No Documentation 🚧
cmpgtReturns a vector mask containing the result of a `>` comparison for each element of `self` and `rhs`...
rem-1No Documentation 🚧
with_xCreates a 2D vector from `self` with the given value of `x`.
is_negative_bitmaskReturns a bitmask with the lowest 2 bits set to the sign bits from the elements of `self`. A negat...
saturating_sub_unsignedReturns a vector containing the saturating subtraction of `self` and unsigned vector `rhs`. In oth...
remNo Documentation 🚧
wrapping_add_unsignedReturns a vector containing the wrapping addition of `self` and unsigned vector `rhs`. In other wo...
div_euclidReturns the element-wise quotient of [Euclidean division] of `self` by `rhs`. # Panics This function will panic if any `rhs` element is 0 or the division results in overflow.
as_u64vec2Casts all elements of `self` to `u64`.
maxReturns a vector containing the maximum values for each element of `self` and `rhs`. In other word...
saturating_subReturns a vector containing the saturating subtraction of `self` and `rhs`. In other words this co...
dotComputes the dot product of `self` and `rhs`.
rotateReturns `rhs` rotated by the angle of `self`. If `self` is normalized, then this just rotation. Th...
mul-1No Documentation 🚧

element_product

Returns the product of all elements of self. In other words, this computes self.x * self.y * ...

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

saturating_div

Returns a vector containing the saturating division of self and rhs. In other words this computes [self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

select

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self. A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

Arguments

NameTypeDocumentation
maskBVec2No Documentation 🚧
if_trueIVec2No Documentation 🚧
if_falseIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

clamp

Component-wise clamping of values, similar to [i32::clamp]. Each element in min must be less-or-equal to the corresponding element in max.

Panics

Will panic if min is greater than max when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
minIVec2No Documentation 🚧
maxIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

sub-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec2No Documentation 🚧
arg1i32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

cmplt

Returns a vector mask containing the result of a < comparison for each element of self and rhs. In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec2No Documentation 🚧
arg1IVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

cmpne

Returns a vector mask containing the result of a != comparison for each element of self and rhs. In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

perp_dot

The perpendicular dot product of self and rhs. Also known as the wedge product, 2D cross product, and determinant.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

rem-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec2No Documentation 🚧
arg1i32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

from_array

Creates a new vector from an array.

Arguments

NameTypeDocumentation
a[i32; 2]No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

distance_squared

Compute the squared euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

min_element

Returns the horizontal minimum of self. In other words this computes min(x, y, ..).

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

length_squared

Computes the squared length of self.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

wrapping_add

Returns a vector containing the wrapping addition of self and rhs. In other words this computes [self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

element_sum

Returns the sum of all elements of self. In other words, this computes self.x + self.y + ...

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

wrapping_mul

Returns a vector containing the wrapping multiplication of self and rhs. In other words this computes [self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

as_vec2

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

saturating_add

Returns a vector containing the saturating addition of self and rhs. In other words this computes [self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

wrapping_sub_unsigned

Returns a vector containing the wrapping subtraction of self and unsigned vector rhs. In other words this computes [self.x.wrapping_sub_unsigned(rhs.x), self.y.wrapping_sub_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

cmple

Returns a vector mask containing the result of a <= comparison for each element of self and rhs. In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

min

Returns a vector containing the minimum values for each element of self and rhs. In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

div-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec2No Documentation 🚧
arg1i32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

as_dvec2

Casts all elements of self to f64.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

add-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec2No Documentation 🚧
arg1i32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

as_uvec2

Casts all elements of self to u32.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

with_y

Creates a 2D vector from self with the given value of y.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
yi32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

wrapping_div

Returns a vector containing the wrapping division of self and rhs. In other words this computes [self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

signum

Returns a vector with elements representing the sign of self.

  • 0 if the number is zero
  • 1 if the number is positive
  • -1 if the number is negative

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

cmpeq

Returns a vector mask containing the result of a == comparison for each element of self and rhs. In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
otherIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

max_element

Returns the horizontal maximum of self. In other words this computes max(x, y, ..).

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

add-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec2No Documentation 🚧
arg1IVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

abs

Returns a vector containing the absolute value of each element of self.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

extend

Creates a 3D vector from self and the given z value.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
zi32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

div-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec2No Documentation 🚧
arg1IVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

splat

Creates a vector with all elements set to v.

Arguments

NameTypeDocumentation
vi32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

saturating_add_unsigned

In other words this computes [self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

rem_euclid

Returns the element-wise remainder of [Euclidean division] of self by rhs.

Panics

This function will panic if any rhs element is 0 or the division results in overflow. [Euclidean division]: i32::rem_euclid

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

dot_into_vec

Returns a vector where every component is the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

cmpge

Returns a vector mask containing the result of a >= comparison for each element of self and rhs. In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

wrapping_sub

Returns a vector containing the wrapping subtraction of self and rhs. In other words this computes [self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xi32No Documentation 🚧
yi32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

perp

Returns a vector that is equal to self rotated by 90 degrees.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

saturating_mul

Returns a vector containing the saturating multiplication of self and rhs. In other words this computes [self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

as_i64vec2

Casts all elements of self to i64.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

to_array

[x, y]

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0[i32; 2]No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec2No Documentation 🚧
arg1i32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

cmpgt

Returns a vector mask containing the result of a > comparison for each element of self and rhs. In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

rem-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec2No Documentation 🚧
arg1IVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

with_x

Creates a 2D vector from self with the given value of x.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
xi32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

is_negative_bitmask

Returns a bitmask with the lowest 2 bits set to the sign bits from the elements of self. A negative element results in a 1 bit and a positive element in a 0 bit. Element x goes into the first lowest bit, element y into the second, etc.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

saturating_sub_unsigned

Returns a vector containing the saturating subtraction of self and unsigned vector rhs. In other words this computes [self.x.saturating_sub_unsigned(rhs.x), self.y.saturating_sub_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

rem

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

wrapping_add_unsigned

Returns a vector containing the wrapping addition of self and unsigned vector rhs. In other words this computes [self.x.wrapping_add_unsigned(rhs.x), self.y.wrapping_add_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

div_euclid

Returns the element-wise quotient of [Euclidean division] of self by rhs.

Panics

This function will panic if any rhs element is 0 or the division results in overflow.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

as_u64vec2

Casts all elements of self to u64.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

max

Returns a vector containing the maximum values for each element of self and rhs. In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

saturating_sub

Returns a vector containing the saturating subtraction of self and rhs. In other words this computes [self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

dot

Computes the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

rotate

Returns rhs rotated by the angle of self. If self is normalized, then this just rotation. This is what you usually want. Otherwise, it will be like a rotation with a multiplication by self's length.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec2No Documentation 🚧
arg1IVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

IVec3

IVec3

  • x:i32
  • y:i32
  • z:i32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
sub-1No Documentation 🚧
wrapping_addReturns a vector containing the wrapping addition of `self` and `rhs`. In other words this compute...
cmpltReturns a vector mask containing the result of a `<` comparison for each element of `self` and `rhs`...
saturating_divReturns a vector containing the saturating division of `self` and `rhs`. In other words this compu...
element_productReturns the product of all elements of `self`. In other words, this computes `self.x * self.y * .....
mul-2No Documentation 🚧
wrapping_sub_unsignedReturns a vector containing the wrapping subtraction of `self` and unsigned vector `rhs`. In other...
min_elementReturns the horizontal minimum of `self`. In other words this computes `min(x, y, ..)`.
cmpgeReturns a vector mask containing the result of a `>=` comparison for each element of `self` and `rhs`...
dot_into_vecReturns a vector where every component is the dot product of `self` and `rhs`.
element_sumReturns the sum of all elements of `self`. In other words, this computes `self.x + self.y + ..`.
as_uvec3Casts all elements of `self` to `u32`.
rem-1No Documentation 🚧
subNo Documentation 🚧
max_elementReturns the horizontal maximum of `self`. In other words this computes `max(x, y, ..)`.
saturating_subReturns a vector containing the saturating subtraction of `self` and `rhs`. In other words this co...
minReturns a vector containing the minimum values for each element of `self` and `rhs`. In other word...
wrapping_add_unsignedReturns a vector containing the wrapping addition of `self` and unsigned vector `rhs`. In other wo...
div-1No Documentation 🚧
signumReturns a vector with elements representing the sign of `self`. - `0` if the number is zero - `1`...
addNo Documentation 🚧
eqNo Documentation 🚧
cmpeqReturns a vector mask containing the result of a `==` comparison for each element of `self` and `rhs`...
splatCreates a vector with all elements set to `v`.
as_vec3Casts all elements of `self` to `f32`.
cloneNo Documentation 🚧
as_i64vec3Casts all elements of `self` to `i64`.
cmpneReturns a vector mask containing the result of a `!=` comparison for each element of `self` and `rhs`...
clampComponent-wise clamping of values, similar to [`i32::clamp`]. Each element in `min` must be less-or-equal to the corresponding element in `max`. # Panics Will panic if `min` is greater than `max` when `glam_assert` is enabled.
mulNo Documentation 🚧
saturating_addReturns a vector containing the saturating addition of `self` and `rhs`. In other words this compu...
newCreates a new vector.
as_vec3aCasts all elements of `self` to `f32`.
rem_euclidReturns the element-wise remainder of [Euclidean division] of `self` by `rhs`. # Panics This function will panic if any `rhs` element is 0 or the division results in overflow. [Euclidean division]...
add-1No Documentation 🚧
saturating_sub_unsignedReturns a vector containing the saturating subtraction of `self` and unsigned vector `rhs`. In oth...
divNo Documentation 🚧
to_array`[x, y, z]`
length_squaredComputes the squared length of `self`.
selectCreates a vector from the elements in `if_true` and `if_false`, selecting which to use for each el...
as_u64vec3Casts all elements of `self` to `u64`.
as_dvec3Casts all elements of `self` to `f64`.
div_euclidReturns the element-wise quotient of [Euclidean division] of `self` by `rhs`. # Panics This function will panic if any `rhs` element is 0 or the division results in overflow.
cmpgtReturns a vector mask containing the result of a `>` comparison for each element of `self` and `rhs`...
with_zCreates a 3D vector from `self` with the given value of `z`.
crossComputes the cross product of `self` and `rhs`.
remNo Documentation 🚧
with_xCreates a 3D vector from `self` with the given value of `x`.
maxReturns a vector containing the maximum values for each element of `self` and `rhs`. In other word...
assert_receiver_is_total_eqNo Documentation 🚧
extendCreates a 4D vector from `self` and the given `w` value.
wrapping_divReturns a vector containing the wrapping division of `self` and `rhs`. In other words this compute...
with_yCreates a 3D vector from `self` with the given value of `y`.
saturating_add_unsignedIn other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`.
rem-2No Documentation 🚧
saturating_mulReturns a vector containing the saturating multiplication of `self` and `rhs`. In other words this...
mul-1No Documentation 🚧
truncateCreates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. Truncation may also b...
add-2No Documentation 🚧
from_arrayCreates a new vector from an array.
negNo Documentation 🚧
wrapping_subReturns a vector containing the wrapping subtraction of `self` and `rhs`. In other words this comp...
dotComputes the dot product of `self` and `rhs`.
absReturns a vector containing the absolute value of each element of `self`.
cmpleReturns a vector mask containing the result of a `<=` comparison for each element of `self` and `rhs`...
sub-2No Documentation 🚧
distance_squaredCompute the squared euclidean distance between two points in space.
wrapping_mulReturns a vector containing the wrapping multiplication of `self` and `rhs`. In other words this c...
is_negative_bitmaskReturns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. A negat...
div-2No Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec3No Documentation 🚧
arg1IVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

wrapping_add

Returns a vector containing the wrapping addition of self and rhs. In other words this computes [self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

cmplt

Returns a vector mask containing the result of a < comparison for each element of self and rhs. In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

saturating_div

Returns a vector containing the saturating division of self and rhs. In other words this computes [self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

element_product

Returns the product of all elements of self. In other words, this computes self.x * self.y * ...

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec3No Documentation 🚧
arg1i32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

wrapping_sub_unsigned

Returns a vector containing the wrapping subtraction of self and unsigned vector rhs. In other words this computes [self.x.wrapping_sub_unsigned(rhs.x), self.y.wrapping_sub_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

min_element

Returns the horizontal minimum of self. In other words this computes min(x, y, ..).

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

cmpge

Returns a vector mask containing the result of a >= comparison for each element of self and rhs. In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

dot_into_vec

Returns a vector where every component is the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

element_sum

Returns the sum of all elements of self. In other words, this computes self.x + self.y + ...

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

as_uvec3

Casts all elements of self to u32.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

rem-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec3No Documentation 🚧
arg1IVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

max_element

Returns the horizontal maximum of self. In other words this computes max(x, y, ..).

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

saturating_sub

Returns a vector containing the saturating subtraction of self and rhs. In other words this computes [self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

min

Returns a vector containing the minimum values for each element of self and rhs. In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

wrapping_add_unsigned

Returns a vector containing the wrapping addition of self and unsigned vector rhs. In other words this computes [self.x.wrapping_add_unsigned(rhs.x), self.y.wrapping_add_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

div-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec3No Documentation 🚧
arg1IVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

signum

Returns a vector with elements representing the sign of self.

  • 0 if the number is zero
  • 1 if the number is positive
  • -1 if the number is negative

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
otherIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

cmpeq

Returns a vector mask containing the result of a == comparison for each element of self and rhs. In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

splat

Creates a vector with all elements set to v.

Arguments

NameTypeDocumentation
vi32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

as_vec3

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

as_i64vec3

Casts all elements of self to i64.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

cmpne

Returns a vector mask containing the result of a != comparison for each element of self and rhs. In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

clamp

Component-wise clamping of values, similar to [i32::clamp]. Each element in min must be less-or-equal to the corresponding element in max.

Panics

Will panic if min is greater than max when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
minIVec3No Documentation 🚧
maxIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

saturating_add

Returns a vector containing the saturating addition of self and rhs. In other words this computes [self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xi32No Documentation 🚧
yi32No Documentation 🚧
zi32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

as_vec3a

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

rem_euclid

Returns the element-wise remainder of [Euclidean division] of self by rhs.

Panics

This function will panic if any rhs element is 0 or the division results in overflow. [Euclidean division]: i32::rem_euclid

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

add-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec3No Documentation 🚧
arg1IVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

saturating_sub_unsigned

Returns a vector containing the saturating subtraction of self and unsigned vector rhs. In other words this computes [self.x.saturating_sub_unsigned(rhs.x), self.y.saturating_sub_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

to_array

[x, y, z]

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0[i32; 3]No Documentation 🚧

length_squared

Computes the squared length of self.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

select

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self. A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

Arguments

NameTypeDocumentation
maskBVec3No Documentation 🚧
if_trueIVec3No Documentation 🚧
if_falseIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

as_u64vec3

Casts all elements of self to u64.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

as_dvec3

Casts all elements of self to f64.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

div_euclid

Returns the element-wise quotient of [Euclidean division] of self by rhs.

Panics

This function will panic if any rhs element is 0 or the division results in overflow.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

cmpgt

Returns a vector mask containing the result of a > comparison for each element of self and rhs. In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

with_z

Creates a 3D vector from self with the given value of z.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
zi32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

cross

Computes the cross product of self and rhs.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

rem

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

with_x

Creates a 3D vector from self with the given value of x.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
xi32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

max

Returns a vector containing the maximum values for each element of self and rhs. In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

extend

Creates a 4D vector from self and the given w value.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
wi32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

wrapping_div

Returns a vector containing the wrapping division of self and rhs. In other words this computes [self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

with_y

Creates a 3D vector from self with the given value of y.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
yi32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

saturating_add_unsigned

In other words this computes [self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

rem-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec3No Documentation 🚧
arg1i32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

saturating_mul

Returns a vector containing the saturating multiplication of self and rhs. In other words this computes [self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec3No Documentation 🚧
arg1IVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

truncate

Creates a 2D vector from the x and y elements of self, discarding z. Truncation may also be performed by using [self.xy()][crate::swizzles::Vec3Swizzles::xy()].

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

add-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec3No Documentation 🚧
arg1i32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

from_array

Creates a new vector from an array.

Arguments

NameTypeDocumentation
a[i32; 3]No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

wrapping_sub

Returns a vector containing the wrapping subtraction of self and rhs. In other words this computes [self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

dot

Computes the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

abs

Returns a vector containing the absolute value of each element of self.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

cmple

Returns a vector mask containing the result of a <= comparison for each element of self and rhs. In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

sub-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec3No Documentation 🚧
arg1i32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

distance_squared

Compute the squared euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

wrapping_mul

Returns a vector containing the wrapping multiplication of self and rhs. In other words this computes [self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

is_negative_bitmask

Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of self. A negative element results in a 1 bit and a positive element in a 0 bit. Element x goes into the first lowest bit, element y into the second, etc.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

div-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec3No Documentation 🚧
arg1i32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

IVec4

IVec4

  • x:i32
  • y:i32
  • z:i32
  • w:i32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
selectCreates a vector from the elements in `if_true` and `if_false`, selecting which to use for each el...
from_arrayCreates a new vector from an array.
cloneNo Documentation 🚧
as_dvec4Casts all elements of `self` to `f64`.
sub-1No Documentation 🚧
newCreates a new vector.
wrapping_addReturns a vector containing the wrapping addition of `self` and `rhs`. In other words this compute...
length_squaredComputes the squared length of `self`.
addNo Documentation 🚧
assert_receiver_is_total_eqNo Documentation 🚧
rem_euclidReturns the element-wise remainder of [Euclidean division] of `self` by `rhs`. # Panics This function will panic if any `rhs` element is 0 or the division results in overflow. [Euclidean division]...
with_yCreates a 4D vector from `self` with the given value of `y`.
clampComponent-wise clamping of values, similar to [`i32::clamp`]. Each element in `min` must be less-or-equal to the corresponding element in `max`. # Panics Will panic if `min` is greater than `max` when `glam_assert` is enabled.
saturating_mulReturns a vector containing the saturating multiplication of `self` and `rhs`. In other words this...
add-1No Documentation 🚧
rem-2No Documentation 🚧
wrapping_add_unsignedReturns a vector containing the wrapping addition of `self` and unsigned vector `rhs`. In other wo...
element_sumReturns the sum of all elements of `self`. In other words, this computes `self.x + self.y + ..`.
element_productReturns the product of all elements of `self`. In other words, this computes `self.x * self.y * .....
wrapping_mulReturns a vector containing the wrapping multiplication of `self` and `rhs`. In other words this c...
saturating_addReturns a vector containing the saturating addition of `self` and `rhs`. In other words this compu...
div-1No Documentation 🚧
max_elementReturns the horizontal maximum of `self`. In other words this computes `max(x, y, ..)`.
add-2No Documentation 🚧
cmpgtReturns a vector mask containing the result of a `>` comparison for each element of `self` and `rhs`...
wrapping_divReturns a vector containing the wrapping division of `self` and `rhs`. In other words this compute...
distance_squaredCompute the squared euclidean distance between two points in space.
signumReturns a vector with elements representing the sign of `self`. - `0` if the number is zero - `1`...
divNo Documentation 🚧
mulNo Documentation 🚧
sub-2No Documentation 🚧
as_u64vec4Casts all elements of `self` to `u64`.
cmpltReturns a vector mask containing the result of a `<` comparison for each element of `self` and `rhs`...
div-2No Documentation 🚧
rem-1No Documentation 🚧
as_i64vec4Casts all elements of `self` to `i64`.
with_xCreates a 4D vector from `self` with the given value of `x`.
wrapping_sub_unsignedReturns a vector containing the wrapping subtraction of `self` and unsigned vector `rhs`. In other...
mul-2No Documentation 🚧
cmpgeReturns a vector mask containing the result of a `>=` comparison for each element of `self` and `rhs`...
cmpeqReturns a vector mask containing the result of a `==` comparison for each element of `self` and `rhs`...
absReturns a vector containing the absolute value of each element of `self`.
cmpleReturns a vector mask containing the result of a `<=` comparison for each element of `self` and `rhs`...
remNo Documentation 🚧
splatCreates a vector with all elements set to `v`.
truncateCreates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. Truncation to [`IVec3`]...
saturating_add_unsignedIn other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`.
as_vec4Casts all elements of `self` to `f32`.
saturating_divReturns a vector containing the saturating division of `self` and `rhs`. In other words this compu...
cmpneReturns a vector mask containing the result of a `!=` comparison for each element of `self` and `rhs`...
as_uvec4Casts all elements of `self` to `u32`.
with_wCreates a 4D vector from `self` with the given value of `w`.
dotComputes the dot product of `self` and `rhs`.
maxReturns a vector containing the maximum values for each element of `self` and `rhs`. In other word...
saturating_subReturns a vector containing the saturating subtraction of `self` and `rhs`. In other words this co...
negNo Documentation 🚧
dot_into_vecReturns a vector where every component is the dot product of `self` and `rhs`.
mul-1No Documentation 🚧
eqNo Documentation 🚧
minReturns a vector containing the minimum values for each element of `self` and `rhs`. In other word...
wrapping_subReturns a vector containing the wrapping subtraction of `self` and `rhs`. In other words this comp...
div_euclidReturns the element-wise quotient of [Euclidean division] of `self` by `rhs`. # Panics This function will panic if any `rhs` element is 0 or the division results in overflow.
to_array`[x, y, z, w]`
is_negative_bitmaskReturns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`. A negat...
subNo Documentation 🚧
saturating_sub_unsignedReturns a vector containing the saturating subtraction of `self` and unsigned vector `rhs`. In oth...
min_elementReturns the horizontal minimum of `self`. In other words this computes `min(x, y, ..)`.
with_zCreates a 4D vector from `self` with the given value of `z`.

select

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self. A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

Arguments

NameTypeDocumentation
maskBVec4No Documentation 🚧
if_trueIVec4No Documentation 🚧
if_falseIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

from_array

Creates a new vector from an array.

Arguments

NameTypeDocumentation
a[i32; 4]No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

as_dvec4

Casts all elements of self to f64.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec4No Documentation 🚧
arg1IVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xi32No Documentation 🚧
yi32No Documentation 🚧
zi32No Documentation 🚧
wi32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

wrapping_add

Returns a vector containing the wrapping addition of self and rhs. In other words this computes [self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

length_squared

Computes the squared length of self.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

rem_euclid

Returns the element-wise remainder of [Euclidean division] of self by rhs.

Panics

This function will panic if any rhs element is 0 or the division results in overflow. [Euclidean division]: i32::rem_euclid

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

with_y

Creates a 4D vector from self with the given value of y.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
yi32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

clamp

Component-wise clamping of values, similar to [i32::clamp]. Each element in min must be less-or-equal to the corresponding element in max.

Panics

Will panic if min is greater than max when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
minIVec4No Documentation 🚧
maxIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

saturating_mul

Returns a vector containing the saturating multiplication of self and rhs. In other words this computes [self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

add-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec4No Documentation 🚧
arg1IVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

rem-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec4No Documentation 🚧
arg1i32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

wrapping_add_unsigned

Returns a vector containing the wrapping addition of self and unsigned vector rhs. In other words this computes [self.x.wrapping_add_unsigned(rhs.x), self.y.wrapping_add_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

element_sum

Returns the sum of all elements of self. In other words, this computes self.x + self.y + ...

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

element_product

Returns the product of all elements of self. In other words, this computes self.x * self.y * ...

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

wrapping_mul

Returns a vector containing the wrapping multiplication of self and rhs. In other words this computes [self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

saturating_add

Returns a vector containing the saturating addition of self and rhs. In other words this computes [self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

div-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec4No Documentation 🚧
arg1IVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

max_element

Returns the horizontal maximum of self. In other words this computes max(x, y, ..).

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

add-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec4No Documentation 🚧
arg1i32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

cmpgt

Returns a vector mask containing the result of a > comparison for each element of self and rhs. In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

wrapping_div

Returns a vector containing the wrapping division of self and rhs. In other words this computes [self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

distance_squared

Compute the squared euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

signum

Returns a vector with elements representing the sign of self.

  • 0 if the number is zero
  • 1 if the number is positive
  • -1 if the number is negative

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

sub-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec4No Documentation 🚧
arg1i32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

as_u64vec4

Casts all elements of self to u64.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

cmplt

Returns a vector mask containing the result of a < comparison for each element of self and rhs. In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

div-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec4No Documentation 🚧
arg1i32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

rem-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec4No Documentation 🚧
arg1IVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

as_i64vec4

Casts all elements of self to i64.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

with_x

Creates a 4D vector from self with the given value of x.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
xi32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

wrapping_sub_unsigned

Returns a vector containing the wrapping subtraction of self and unsigned vector rhs. In other words this computes [self.x.wrapping_sub_unsigned(rhs.x), self.y.wrapping_sub_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec4No Documentation 🚧
arg1i32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

cmpge

Returns a vector mask containing the result of a >= comparison for each element of self and rhs. In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

cmpeq

Returns a vector mask containing the result of a == comparison for each element of self and rhs. In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

abs

Returns a vector containing the absolute value of each element of self.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

cmple

Returns a vector mask containing the result of a <= comparison for each element of self and rhs. In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

rem

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

splat

Creates a vector with all elements set to v.

Arguments

NameTypeDocumentation
vi32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

truncate

Creates a 3D vector from the x, y and z elements of self, discarding w. Truncation to [IVec3] may also be performed by using [self.xyz()][crate::swizzles::Vec4Swizzles::xyz()].

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

saturating_add_unsigned

In other words this computes [self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

as_vec4

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

saturating_div

Returns a vector containing the saturating division of self and rhs. In other words this computes [self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

cmpne

Returns a vector mask containing the result of a != comparison for each element of self and rhs. In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

as_uvec4

Casts all elements of self to u32.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

with_w

Creates a 4D vector from self with the given value of w.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
wi32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

dot

Computes the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

max

Returns a vector containing the maximum values for each element of self and rhs. In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

saturating_sub

Returns a vector containing the saturating subtraction of self and rhs. In other words this computes [self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

dot_into_vec

Returns a vector where every component is the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0IVec4No Documentation 🚧
arg1IVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
otherIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

min

Returns a vector containing the minimum values for each element of self and rhs. In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

wrapping_sub

Returns a vector containing the wrapping subtraction of self and rhs. In other words this computes [self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

div_euclid

Returns the element-wise quotient of [Euclidean division] of self by rhs.

Panics

This function will panic if any rhs element is 0 or the division results in overflow.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

to_array

[x, y, z, w]

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0[i32; 4]No Documentation 🚧

is_negative_bitmask

Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of self. A negative element results in a 1 bit and a positive element in a 0 bit. Element x goes into the first lowest bit, element y into the second, etc.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

saturating_sub_unsigned

Returns a vector containing the saturating subtraction of self and unsigned vector rhs. In other words this computes [self.x.saturating_sub_unsigned(rhs.x), self.y.saturating_sub_unsigned(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

min_element

Returns the horizontal minimum of self. In other words this computes min(x, y, ..).

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0i32No Documentation 🚧

with_z

Creates a 4D vector from self with the given value of z.

Arguments

NameTypeDocumentation
_selfIVec4No Documentation 🚧
zi32No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

Mat2

Mat2

  • x_axis:glam::Vec2
  • y_axis:glam::Vec2

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
determinantReturns the determinant of `self`.
negNo Documentation 🚧
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive ...
mul-2No Documentation 🚧
from_diagonalCreates a 2x2 matrix with its diagonal set to `diagonal` and all other entries set to 0.
cloneNo Documentation 🚧
mul-1No Documentation 🚧
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...
div_scalarDivides a 2x2 matrix by a scalar.
inverseReturns the inverse of `self`. If the matrix is not invertible the returned matrix will be invalid...
absTakes the absolute value of each element in `self`
colReturns the matrix column for the given `index`. # Panics Panics if `index` is greater than 1.
from_scale_angleCreates a 2x2 matrix containing the combining non-uniform `scale` and rotation of `angle` (in radi...
mul_mat2Multiplies two 2x2 matrices.
add_mat2Adds two 2x2 matrices.
rowReturns the matrix row for the given `index`. # Panics Panics if `index` is greater than 1.
sub_mat2Subtracts two 2x2 matrices.
eqNo Documentation 🚧
addNo Documentation 🚧
is_nanReturns `true` if any elements are `NaN`.
as_dmat2No Documentation 🚧
mul_scalarMultiplies a 2x2 matrix by a scalar.
from_mat3_minorCreates a 2x2 matrix from the minor of the given 3x3 matrix, discarding the `i`th column and `j`th...
from_mat3a_minorCreates a 2x2 matrix from the minor of the given 3x3 matrix, discarding the `i`th column and `j`th...
subNo Documentation 🚧
transposeReturns the transpose of `self`.
divNo Documentation 🚧
from_mat3aCreates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column.
from_colsCreates a 2x2 matrix from two column vectors.
to_cols_arrayCreates a `[f32; 4]` array storing data in column major order. If you require data in row major order `transpose` the matrix first.
mulNo Documentation 🚧
mul_vec2Transforms a 2D vector.
from_angleCreates a 2x2 matrix containing a rotation of `angle` (in radians).
to_cols_array_2dCreates a `[[f32; 2]; 2]` 2D array storing data in column major order. If you require data in row ...
from_mat3Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column.

determinant

Returns the determinant of self.

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Mat2No Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

from_diagonal

Creates a 2x2 matrix with its diagonal set to diagonal and all other entries set to 0.

Arguments

NameTypeDocumentation
diagonalVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Mat2No Documentation 🚧
arg1Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two matrices contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧
rhsMat2No Documentation 🚧
max_abs_difff32No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

div_scalar

Divides a 2x2 matrix by a scalar.

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧
rhsf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

inverse

Returns the inverse of self. If the matrix is not invertible the returned matrix will be invalid.

Panics

Will panic if the determinant of self is zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

abs

Takes the absolute value of each element in self

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

col

Returns the matrix column for the given index.

Panics

Panics if index is greater than 1.

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

from_scale_angle

Creates a 2x2 matrix containing the combining non-uniform scale and rotation of angle (in radians).

Arguments

NameTypeDocumentation
scaleVec2No Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

mul_mat2

Multiplies two 2x2 matrices.

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧
rhsMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

add_mat2

Adds two 2x2 matrices.

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧
rhsMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

row

Returns the matrix row for the given index.

Panics

Panics if index is greater than 1.

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

sub_mat2

Subtracts two 2x2 matrices.

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧
rhsMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧
rhsMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧
rhsMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

is_nan

Returns true if any elements are NaN.

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

as_dmat2

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat2No Documentation 🚧

mul_scalar

Multiplies a 2x2 matrix by a scalar.

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧
rhsf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

from_mat3_minor

Creates a 2x2 matrix from the minor of the given 3x3 matrix, discarding the ith column and jth row.

Panics

Panics if i or j is greater than 2.

Arguments

NameTypeDocumentation
mMat3No Documentation 🚧
iusizeNo Documentation 🚧
jusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

from_mat3a_minor

Creates a 2x2 matrix from the minor of the given 3x3 matrix, discarding the ith column and jth row.

Panics

Panics if i or j is greater than 2.

Arguments

NameTypeDocumentation
mMat3ANo Documentation 🚧
iusizeNo Documentation 🚧
jusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧
rhsMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

transpose

Returns the transpose of self.

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧
rhsf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

from_mat3a

Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column.

Arguments

NameTypeDocumentation
mMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

from_cols

Creates a 2x2 matrix from two column vectors.

Arguments

NameTypeDocumentation
x_axisVec2No Documentation 🚧
y_axisVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

to_cols_array

Creates a [f32; 4] array storing data in column major order. If you require data in row major order transpose the matrix first.

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0[f32; 4]No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧
rhsMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

mul_vec2

Transforms a 2D vector.

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

from_angle

Creates a 2x2 matrix containing a rotation of angle (in radians).

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

to_cols_array_2d

Creates a [[f32; 2]; 2] 2D array storing data in column major order. If you require data in row major order transpose the matrix first.

Arguments

NameTypeDocumentation
_selfMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0[[f32; 2]; 2]No Documentation 🚧

from_mat3

Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column.

Arguments

NameTypeDocumentation
mMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat2No Documentation 🚧

Mat3

Mat3

  • x_axis:glam::Vec3
  • y_axis:glam::Vec3
  • z_axis:glam::Vec3

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_rotation_yCreates a 3D rotation matrix from `angle` (in radians) around the y axis.
mul_scalarMultiplies a 3x3 matrix by a scalar.
absTakes the absolute value of each element in `self`
mul_vec3aTransforms a [`Vec3A`].
from_scaleCreates an affine transformation matrix from the given non-uniform 2D `scale`. The resulting matri...
from_rotation_zCreates a 3D rotation matrix from `angle` (in radians) around the z axis.
inverseReturns the inverse of `self`. If the matrix is not invertible the returned matrix will be invalid...
add_mat3Adds two 3x3 matrices.
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...
from_mat2Creates an affine transformation matrix from the given 2x2 matrix. The resulting matrix can be use...
from_quatCreates a 3D rotation matrix from the given quaternion. # Panics Will panic if `rotation` is not ...
eqNo Documentation 🚧
transposeReturns the transpose of `self`.
rowReturns the matrix row for the given `index`. # Panics Panics if `index` is greater than 2.
mul-1No Documentation 🚧
to_eulerExtract Euler angles with the given Euler rotation order. Note if the input matrix contains scales...
mul_mat3Multiplies two 3x3 matrices.
divNo Documentation 🚧
from_mat4Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column.
mulNo Documentation 🚧
from_rotation_xCreates a 3D rotation matrix from `angle` (in radians) around the x axis.
to_cols_arrayCreates a `[f32; 9]` array storing data in column major order. If you require data in row major order `transpose` the matrix first.
to_cols_array_2dCreates a `[[f32; 3]; 3]` 3D array storing data in column major order. If you require data in row ...
from_translationCreates an affine transformation matrix from the given 2D `translation`. The resulting matrix can ...
mul-2No Documentation 🚧
addNo Documentation 🚧
from_axis_angleCreates a 3D rotation matrix from a normalized rotation `axis` and `angle` (in radians). # Panics...
from_eulerCreates a 3D rotation matrix from the given euler rotation sequence and the angles (in radians).
mul-4No Documentation 🚧
from_angleCreates an affine transformation matrix from the given 2D rotation `angle` (in radians). The resu...
cloneNo Documentation 🚧
from_colsCreates a 3x3 matrix from three column vectors.
colReturns the matrix column for the given `index`. # Panics Panics if `index` is greater than 2.
subNo Documentation 🚧
from_mat4_minorCreates a 3x3 matrix from the minor of the given 4x4 matrix, discarding the `i`th column and `j`th...
sub_mat3Subtracts two 3x3 matrices.
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive ...
div_scalarDivides a 3x3 matrix by a scalar.
mul_vec3Transforms a 3D vector.
from_scale_angle_translationCreates an affine transformation matrix from the given 2D `scale`, rotation `angle` (in radians) a...
as_dmat3No Documentation 🚧
determinantReturns the determinant of `self`.
from_diagonalCreates a 3x3 matrix with its diagonal set to `diagonal` and all other entries set to 0.
transform_point2Transforms the given 2D vector as a point. This is the equivalent of multiplying `rhs` as a 3D vec...
mul-3No Documentation 🚧
is_nanReturns `true` if any elements are `NaN`.
negNo Documentation 🚧
transform_vector2Rotates the given 2D vector. This is the equivalent of multiplying `rhs` as a 3D vector where `z` ...

from_rotation_y

Creates a 3D rotation matrix from angle (in radians) around the y axis.

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

mul_scalar

Multiplies a 3x3 matrix by a scalar.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
rhsf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

abs

Takes the absolute value of each element in self

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

mul_vec3a

Transforms a [Vec3A].

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

from_scale

Creates an affine transformation matrix from the given non-uniform 2D scale. The resulting matrix can be used to transform 2D points and vectors. See [Self::transform_point2()] and [Self::transform_vector2()].

Panics

Will panic if all elements of scale are zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
scaleVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

from_rotation_z

Creates a 3D rotation matrix from angle (in radians) around the z axis.

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

inverse

Returns the inverse of self. If the matrix is not invertible the returned matrix will be invalid.

Panics

Will panic if the determinant of self is zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

add_mat3

Adds two 3x3 matrices.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
rhsMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two matrices contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
rhsMat3No Documentation 🚧
max_abs_difff32No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_mat2

Creates an affine transformation matrix from the given 2x2 matrix. The resulting matrix can be used to transform 2D points and vectors. See [Self::transform_point2()] and [Self::transform_vector2()].

Arguments

NameTypeDocumentation
mMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

from_quat

Creates a 3D rotation matrix from the given quaternion.

Panics

Will panic if rotation is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
rotationQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
rhsMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

transpose

Returns the transpose of self.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

row

Returns the matrix row for the given index.

Panics

Panics if index is greater than 2.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Mat3No Documentation 🚧
arg1Mat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

to_euler

Extract Euler angles with the given Euler rotation order. Note if the input matrix contains scales, shears, or other non-rotation transformations then the resulting Euler angles will be ill-defined.

Panics

Will panic if any input matrix column is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
orderEulerRotNo Documentation 🚧

Returns

NameTypeDocumentation
arg0(f32, f32, f32)No Documentation 🚧

mul_mat3

Multiplies two 3x3 matrices.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
rhsMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
rhsf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

from_mat4

Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column.

Arguments

NameTypeDocumentation
mMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
rhsAffine2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

from_rotation_x

Creates a 3D rotation matrix from angle (in radians) around the x axis.

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

to_cols_array

Creates a [f32; 9] array storing data in column major order. If you require data in row major order transpose the matrix first.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0[f32; 9]No Documentation 🚧

to_cols_array_2d

Creates a [[f32; 3]; 3] 3D array storing data in column major order. If you require data in row major order transpose the matrix first.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0[[f32; 3]; 3]No Documentation 🚧

from_translation

Creates an affine transformation matrix from the given 2D translation. The resulting matrix can be used to transform 2D points and vectors. See [Self::transform_point2()] and [Self::transform_vector2()].

Arguments

NameTypeDocumentation
translationVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Mat3No Documentation 🚧
arg1Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
rhsMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

from_axis_angle

Creates a 3D rotation matrix from a normalized rotation axis and angle (in radians).

Panics

Will panic if axis is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
axisVec3No Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

from_euler

Creates a 3D rotation matrix from the given euler rotation sequence and the angles (in radians).

Arguments

NameTypeDocumentation
orderEulerRotNo Documentation 🚧
af32No Documentation 🚧
bf32No Documentation 🚧
cf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

mul-4

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Mat3No Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

from_angle

Creates an affine transformation matrix from the given 2D rotation angle (in radians). The resulting matrix can be used to transform 2D points and vectors. See [Self::transform_point2()] and [Self::transform_vector2()].

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

from_cols

Creates a 3x3 matrix from three column vectors.

Arguments

NameTypeDocumentation
x_axisVec3No Documentation 🚧
y_axisVec3No Documentation 🚧
z_axisVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

col

Returns the matrix column for the given index.

Panics

Panics if index is greater than 2.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
rhsMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

from_mat4_minor

Creates a 3x3 matrix from the minor of the given 4x4 matrix, discarding the ith column and jth row.

Panics

Panics if i or j is greater than 3.

Arguments

NameTypeDocumentation
mMat4No Documentation 🚧
iusizeNo Documentation 🚧
jusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

sub_mat3

Subtracts two 3x3 matrices.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
rhsMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

div_scalar

Divides a 3x3 matrix by a scalar.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
rhsf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

mul_vec3

Transforms a 3D vector.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

from_scale_angle_translation

Creates an affine transformation matrix from the given 2D scale, rotation angle (in radians) and translation. The resulting matrix can be used to transform 2D points and vectors. See [Self::transform_point2()] and [Self::transform_vector2()].

Arguments

NameTypeDocumentation
scaleVec2No Documentation 🚧
anglef32No Documentation 🚧
translationVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

as_dmat3

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

determinant

Returns the determinant of self.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

from_diagonal

Creates a 3x3 matrix with its diagonal set to diagonal and all other entries set to 0.

Arguments

NameTypeDocumentation
diagonalVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

transform_point2

Transforms the given 2D vector as a point. This is the equivalent of multiplying rhs as a 3D vector where z is 1. This method assumes that self contains a valid affine transform.

Panics

Will panic if the 2nd row of self is not (0, 0, 1) when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

mul-3

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Mat3No Documentation 🚧
arg1Vec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

is_nan

Returns true if any elements are NaN.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3No Documentation 🚧

transform_vector2

Rotates the given 2D vector. This is the equivalent of multiplying rhs as a 3D vector where z is 0. This method assumes that self contains a valid affine transform.

Panics

Will panic if the 2nd row of self is not (0, 0, 1) when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

Mat3A

Mat3A

  • x_axis:glam::Vec3A
  • y_axis:glam::Vec3A
  • z_axis:glam::Vec3A

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
determinantReturns the determinant of `self`.
mul-4No Documentation 🚧
absTakes the absolute value of each element in `self`
inverseReturns the inverse of `self`. If the matrix is not invertible the returned matrix will be invalid...
from_scale_angle_translationCreates an affine transformation matrix from the given 2D `scale`, rotation `angle` (in radians) a...
from_mat2Creates an affine transformation matrix from the given 2x2 matrix. The resulting matrix can be use...
from_rotation_yCreates a 3D rotation matrix from `angle` (in radians) around the y axis.
to_eulerExtract Euler angles with the given Euler rotation order. Note if the input matrix contains scales...
mul_vec3Transforms a 3D vector.
from_angleCreates an affine transformation matrix from the given 2D rotation `angle` (in radians). The resu...
from_eulerCreates a 3D rotation matrix from the given euler rotation sequence and the angles (in radians).
eqNo Documentation 🚧
as_dmat3No Documentation 🚧
mul-3No Documentation 🚧
cloneNo Documentation 🚧
mulNo Documentation 🚧
negNo Documentation 🚧
colReturns the matrix column for the given `index`. # Panics Panics if `index` is greater than 2.
from_rotation_xCreates a 3D rotation matrix from `angle` (in radians) around the x axis.
is_nanReturns `true` if any elements are `NaN`.
rowReturns the matrix row for the given `index`. # Panics Panics if `index` is greater than 2.
sub_mat3Subtracts two 3x3 matrices.
add_mat3Adds two 3x3 matrices.
from_colsCreates a 3x3 matrix from three column vectors.
div_scalarDivides a 3x3 matrix by a scalar.
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive ...
mul_mat3Multiplies two 3x3 matrices.
subNo Documentation 🚧
from_translationCreates an affine transformation matrix from the given 2D `translation`. The resulting matrix can ...
mul-2No Documentation 🚧
from_mat4Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column.
transform_vector2Rotates the given 2D vector. This is the equivalent of multiplying `rhs` as a 3D vector where `z` ...
mul_scalarMultiplies a 3x3 matrix by a scalar.
to_cols_arrayCreates a `[f32; 9]` array storing data in column major order. If you require data in row major order `transpose` the matrix first.
from_diagonalCreates a 3x3 matrix with its diagonal set to `diagonal` and all other entries set to 0.
from_quatCreates a 3D rotation matrix from the given quaternion. # Panics Will panic if `rotation` is not ...
transform_point2Transforms the given 2D vector as a point. This is the equivalent of multiplying `rhs` as a 3D vec...
divNo Documentation 🚧
mul-1No Documentation 🚧
from_mat4_minorCreates a 3x3 matrix from the minor of the given 4x4 matrix, discarding the `i`th column and `j`th...
from_rotation_zCreates a 3D rotation matrix from `angle` (in radians) around the z axis.
from_scaleCreates an affine transformation matrix from the given non-uniform 2D `scale`. The resulting matri...
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...
from_axis_angleCreates a 3D rotation matrix from a normalized rotation `axis` and `angle` (in radians). # Panics...
addNo Documentation 🚧
to_cols_array_2dCreates a `[[f32; 3]; 3]` 3D array storing data in column major order. If you require data in row ...
mul_vec3aTransforms a [`Vec3A`].
transposeReturns the transpose of `self`.

determinant

Returns the determinant of self.

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

mul-4

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

abs

Takes the absolute value of each element in self

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

inverse

Returns the inverse of self. If the matrix is not invertible the returned matrix will be invalid.

Panics

Will panic if the determinant of self is zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

from_scale_angle_translation

Creates an affine transformation matrix from the given 2D scale, rotation angle (in radians) and translation. The resulting matrix can be used to transform 2D points and vectors. See [Self::transform_point2()] and [Self::transform_vector2()].

Arguments

NameTypeDocumentation
scaleVec2No Documentation 🚧
anglef32No Documentation 🚧
translationVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

from_mat2

Creates an affine transformation matrix from the given 2x2 matrix. The resulting matrix can be used to transform 2D points and vectors. See [Self::transform_point2()] and [Self::transform_vector2()].

Arguments

NameTypeDocumentation
mMat2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

from_rotation_y

Creates a 3D rotation matrix from angle (in radians) around the y axis.

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

to_euler

Extract Euler angles with the given Euler rotation order. Note if the input matrix contains scales, shears, or other non-rotation transformations then the resulting Euler angles will be ill-defined.

Panics

Will panic if any input matrix column is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧
orderEulerRotNo Documentation 🚧

Returns

NameTypeDocumentation
arg0(f32, f32, f32)No Documentation 🚧

mul_vec3

Transforms a 3D vector.

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

from_angle

Creates an affine transformation matrix from the given 2D rotation angle (in radians). The resulting matrix can be used to transform 2D points and vectors. See [Self::transform_point2()] and [Self::transform_vector2()].

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

from_euler

Creates a 3D rotation matrix from the given euler rotation sequence and the angles (in radians).

Arguments

NameTypeDocumentation
orderEulerRotNo Documentation 🚧
af32No Documentation 🚧
bf32No Documentation 🚧
cf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧
rhsMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

as_dmat3

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat3No Documentation 🚧

mul-3

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧
arg1Vec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧
rhsAffine2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

col

Returns the matrix column for the given index.

Panics

Panics if index is greater than 2.

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

from_rotation_x

Creates a 3D rotation matrix from angle (in radians) around the x axis.

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

is_nan

Returns true if any elements are NaN.

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

row

Returns the matrix row for the given index.

Panics

Panics if index is greater than 2.

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

sub_mat3

Subtracts two 3x3 matrices.

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧
rhsMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

add_mat3

Adds two 3x3 matrices.

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧
rhsMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

from_cols

Creates a 3x3 matrix from three column vectors.

Arguments

NameTypeDocumentation
x_axisVec3ANo Documentation 🚧
y_axisVec3ANo Documentation 🚧
z_axisVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

div_scalar

Divides a 3x3 matrix by a scalar.

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧
rhsf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

mul_mat3

Multiplies two 3x3 matrices.

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧
rhsMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧
rhsMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

from_translation

Creates an affine transformation matrix from the given 2D translation. The resulting matrix can be used to transform 2D points and vectors. See [Self::transform_point2()] and [Self::transform_vector2()].

Arguments

NameTypeDocumentation
translationVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧
arg1Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

from_mat4

Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column.

Arguments

NameTypeDocumentation
mMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

transform_vector2

Rotates the given 2D vector. This is the equivalent of multiplying rhs as a 3D vector where z is 0. This method assumes that self contains a valid affine transform.

Panics

Will panic if the 2nd row of self is not (0, 0, 1) when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

mul_scalar

Multiplies a 3x3 matrix by a scalar.

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧
rhsf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

to_cols_array

Creates a [f32; 9] array storing data in column major order. If you require data in row major order transpose the matrix first.

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0[f32; 9]No Documentation 🚧

from_diagonal

Creates a 3x3 matrix with its diagonal set to diagonal and all other entries set to 0.

Arguments

NameTypeDocumentation
diagonalVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

from_quat

Creates a 3D rotation matrix from the given quaternion.

Panics

Will panic if rotation is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
rotationQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

transform_point2

Transforms the given 2D vector as a point. This is the equivalent of multiplying rhs as a 3D vector where z is 1. This method assumes that self contains a valid affine transform.

Panics

Will panic if the 2nd row of self is not (0, 0, 1) when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧
rhsf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧
arg1Mat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

from_mat4_minor

Creates a 3x3 matrix from the minor of the given 4x4 matrix, discarding the ith column and jth row.

Panics

Panics if i or j is greater than 3.

Arguments

NameTypeDocumentation
mMat4No Documentation 🚧
iusizeNo Documentation 🚧
jusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

from_rotation_z

Creates a 3D rotation matrix from angle (in radians) around the z axis.

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

from_scale

Creates an affine transformation matrix from the given non-uniform 2D scale. The resulting matrix can be used to transform 2D points and vectors. See [Self::transform_point2()] and [Self::transform_vector2()].

Panics

Will panic if all elements of scale are zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
scaleVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two matrices contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧
rhsMat3ANo Documentation 🚧
max_abs_difff32No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_axis_angle

Creates a 3D rotation matrix from a normalized rotation axis and angle (in radians).

Panics

Will panic if axis is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
axisVec3No Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧
rhsMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

to_cols_array_2d

Creates a [[f32; 3]; 3] 3D array storing data in column major order. If you require data in row major order transpose the matrix first.

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0[[f32; 3]; 3]No Documentation 🚧

mul_vec3a

Transforms a [Vec3A].

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

transpose

Returns the transpose of self.

Arguments

NameTypeDocumentation
_selfMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat3ANo Documentation 🚧

Mat4

Mat4

  • x_axis:glam::Vec4
  • y_axis:glam::Vec4
  • z_axis:glam::Vec4
  • w_axis:glam::Vec4

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_rotation_zCreates an affine transformation matrix containing a 3D rotation around the z axis of `angle` (in ...
orthographic_rhCreates a right-handed orthographic projection matrix with `[0,1]` depth range. Useful to map a right-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect.
from_scale_rotation_translationCreates an affine transformation matrix from the given 3D `scale`, `rotation` and `translation`. ...
perspective_infinite_reverse_lhCreates an infinite reverse left-handed perspective projection matrix with `[0,1]` depth range. Similar to `perspective_infinite_lh`, but maps `Z = z_near` to a depth of `1` and `Z = infinity` to a depth of `0`. # Panics Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled.
from_translationCreates an affine transformation matrix from the given 3D `translation`. The resulting matrix can ...
transform_vector3aTransforms the give [`Vec3A`] as 3D vector. This is the equivalent of multiplying the [`Vec3A`] as...
mul_vec4Transforms a 4D vector.
perspective_infinite_lhCreates an infinite left-handed perspective projection matrix with `[0,1]` depth range. Like `perspective_lh`, but with an infinite value for `z_far`. The result is that points near `z_near` are mapped to depth `0`, and as they move towards infinity the depth approaches `1`. # Panics Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is enabled.
mul-3No Documentation 🚧
transform_point3aTransforms the given [`Vec3A`] as 3D point. This is the equivalent of multiplying the [`Vec3A`] as...
from_mat3Creates an affine transformation matrix from the given 3x3 linear transformation matrix. The resu...
as_dmat4No Documentation 🚧
add_mat4Adds two 4x4 matrices.
negNo Documentation 🚧
project_point3Transforms the given 3D vector as a point, applying perspective correction. This is the equivalent...
from_rotation_yCreates an affine transformation matrix containing a 3D rotation around the y axis of `angle` (in ...
perspective_rh_glCreates a right-handed perspective projection matrix with `[-1,1]` depth range. Useful to map the standard right-handed coordinate system into what OpenGL expects. This is the same as the OpenGL `gluPerspective` function. See https://www\.khronos\.org/registry/OpenGL\-Refpages/gl2\.1/xhtml/gluPerspective\.xml
div_scalarDivides a 4x4 matrix by a scalar.
from_mat3aCreates an affine transformation matrix from the given 3x3 linear transformation matrix. The resu...
eqNo Documentation 🚧
colReturns the matrix column for the given `index`. # Panics Panics if `index` is greater than 3.
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...
determinantReturns the determinant of `self`.
mul-2No Documentation 🚧
orthographic_rh_glCreates a right-handed orthographic projection matrix with `[-1,1]` depth range. This is the same as the OpenGL `glOrtho` function in OpenGL. See https://www\.khronos\.org/registry/OpenGL\-Refpages/gl2\.1/xhtml/glOrtho\.xml Useful to map a right-handed coordinate system to the normalized device coordinates that OpenGL expects.
to_eulerExtract Euler angles with the given Euler rotation order. Note if the upper 3x3 matrix contain sca...
look_to_lhCreates a left-handed view matrix using a camera position, an up direction, and a facing direction...
orthographic_lhCreates a left-handed orthographic projection matrix with `[0,1]` depth range. Useful to map a left-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect.
to_cols_array_2dCreates a `[[f32; 4]; 4]` 4D array storing data in column major order. If you require data in row ...
from_diagonalCreates a 4x4 matrix with its diagonal set to `diagonal` and all other entries set to 0.
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive ...
from_quatCreates an affine transformation matrix from the given `rotation` quaternion. The resulting matrix...
divNo Documentation 🚧
cloneNo Documentation 🚧
from_rotation_xCreates an affine transformation matrix containing a 3D rotation around the x axis of `angle` (in ...
mul_mat4Multiplies two 4x4 matrices.
absTakes the absolute value of each element in `self`
perspective_infinite_rhCreates an infinite right-handed perspective projection matrix with `[0,1]` depth range. Like `perspective_rh`, but with an infinite value for `z_far`. The result is that points near `z_near` are mapped to depth `0`, and as they move towards infinity the depth approaches `1`. # Panics Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is enabled.
inverseReturns the inverse of `self`. If the matrix is not invertible the returned matrix will be invalid...
look_to_rhCreates a right-handed view matrix using a camera position, an up direction, and a facing directio...
transform_point3Transforms the given 3D vector as a point. This is the equivalent of multiplying the 3D vector as ...
mul-1No Documentation 🚧
mulNo Documentation 🚧
look_at_rhCreates a right-handed view matrix using a camera position, an up direction, and a focal point. F...
perspective_infinite_reverse_rhCreates an infinite reverse right-handed perspective projection matrix with `[0,1]` depth range. Similar to `perspective_infinite_rh`, but maps `Z = z_near` to a depth of `1` and `Z = infinity` to a depth of `0`. # Panics Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled.
mul_scalarMultiplies a 4x4 matrix by a scalar.
from_rotation_translationCreates an affine transformation matrix from the given 3D `translation`. The resulting matrix can ...
transposeReturns the transpose of `self`.
look_at_lhCreates a left-handed view matrix using a camera position, an up direction, and a focal point. Fo...
addNo Documentation 🚧
from_colsCreates a 4x4 matrix from four column vectors.
perspective_rhCreates a right-handed perspective projection matrix with `[0,1]` depth range. Useful to map the standard right-handed coordinate system into what WebGPU/Metal/Direct3D expect. # Panics Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is enabled.
perspective_lhCreates a left-handed perspective projection matrix with `[0,1]` depth range. Useful to map the standard left-handed coordinate system into what WebGPU/Metal/Direct3D expect. # Panics Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is enabled.
from_scaleCreates an affine transformation matrix containing the given 3D non-uniform `scale`. The resulting...
rowReturns the matrix row for the given `index`. # Panics Panics if `index` is greater than 3.
transform_vector3Transforms the give 3D vector as a direction. This is the equivalent of multiplying the 3D vector ...
to_cols_arrayCreates a `[f32; 16]` array storing data in column major order. If you require data in row major order `transpose` the matrix first.
from_eulerCreates a affine transformation matrix containing a rotation from the given euler rotation sequenc...
project_point3aTransforms the given [`Vec3A`] as a 3D point, applying perspective correction. This is the equivalent of multiplying the [`Vec3A`]...
from_axis_angleCreates an affine transformation matrix containing a 3D rotation around a normalized rotation `axis`...
subNo Documentation 🚧
sub_mat4Subtracts two 4x4 matrices.
is_nanReturns `true` if any elements are `NaN`.

from_rotation_z

Creates an affine transformation matrix containing a 3D rotation around the z axis of angle (in radians). The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

orthographic_rh

Creates a right-handed orthographic projection matrix with [0,1] depth range. Useful to map a right-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect.

Arguments

NameTypeDocumentation
leftf32No Documentation 🚧
rightf32No Documentation 🚧
bottomf32No Documentation 🚧
topf32No Documentation 🚧
nearf32No Documentation 🚧
farf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

from_scale_rotation_translation

Creates an affine transformation matrix from the given 3D scale, rotation and translation. The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Panics

Will panic if rotation is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
scaleVec3No Documentation 🚧
rotationQuatNo Documentation 🚧
translationVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

perspective_infinite_reverse_lh

Creates an infinite reverse left-handed perspective projection matrix with [0,1] depth range. Similar to perspective_infinite_lh, but maps Z = z_near to a depth of 1 and Z = infinity to a depth of 0.

Panics

Will panic if z_near is less than or equal to zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
fov_y_radiansf32No Documentation 🚧
aspect_ratiof32No Documentation 🚧
z_nearf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

from_translation

Creates an affine transformation matrix from the given 3D translation. The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Arguments

NameTypeDocumentation
translationVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

transform_vector3a

Transforms the give [Vec3A] as 3D vector. This is the equivalent of multiplying the [Vec3A] as a 4D vector where w is 0.0.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

mul_vec4

Transforms a 4D vector.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

perspective_infinite_lh

Creates an infinite left-handed perspective projection matrix with [0,1] depth range. Like perspective_lh, but with an infinite value for z_far. The result is that points near z_near are mapped to depth 0, and as they move towards infinity the depth approaches 1.

Panics

Will panic if z_near or z_far are less than or equal to zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
fov_y_radiansf32No Documentation 🚧
aspect_ratiof32No Documentation 🚧
z_nearf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

mul-3

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Mat4No Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

transform_point3a

Transforms the given [Vec3A] as 3D point. This is the equivalent of multiplying the [Vec3A] as a 4D vector where w is 1.0.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

from_mat3

Creates an affine transformation matrix from the given 3x3 linear transformation matrix. The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Arguments

NameTypeDocumentation
mMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

as_dmat4

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DMat4No Documentation 🚧

add_mat4

Adds two 4x4 matrices.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

project_point3

Transforms the given 3D vector as a point, applying perspective correction. This is the equivalent of multiplying the 3D vector as a 4D vector where w is 1.0. The perspective divide is performed meaning the resulting 3D vector is divided by w. This method assumes that self contains a projective transform.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

from_rotation_y

Creates an affine transformation matrix containing a 3D rotation around the y axis of angle (in radians). The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

perspective_rh_gl

Creates a right-handed perspective projection matrix with [-1,1] depth range. Useful to map the standard right-handed coordinate system into what OpenGL expects. This is the same as the OpenGL gluPerspective function. See https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluPerspective.xml

Arguments

NameTypeDocumentation
fov_y_radiansf32No Documentation 🚧
aspect_ratiof32No Documentation 🚧
z_nearf32No Documentation 🚧
z_farf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

div_scalar

Divides a 4x4 matrix by a scalar.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

from_mat3a

Creates an affine transformation matrix from the given 3x3 linear transformation matrix. The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Arguments

NameTypeDocumentation
mMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

col

Returns the matrix column for the given index.

Panics

Panics if index is greater than 3.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two matrices contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsMat4No Documentation 🚧
max_abs_difff32No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

determinant

Returns the determinant of self.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Mat4No Documentation 🚧
arg1Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

orthographic_rh_gl

Creates a right-handed orthographic projection matrix with [-1,1] depth range. This is the same as the OpenGL glOrtho function in OpenGL. See https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glOrtho.xml Useful to map a right-handed coordinate system to the normalized device coordinates that OpenGL expects.

Arguments

NameTypeDocumentation
leftf32No Documentation 🚧
rightf32No Documentation 🚧
bottomf32No Documentation 🚧
topf32No Documentation 🚧
nearf32No Documentation 🚧
farf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

to_euler

Extract Euler angles with the given Euler rotation order. Note if the upper 3x3 matrix contain scales, shears, or other non-rotation transformations then the resulting Euler angles will be ill-defined.

Panics

Will panic if any column of the upper 3x3 rotation matrix is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
orderEulerRotNo Documentation 🚧

Returns

NameTypeDocumentation
arg0(f32, f32, f32)No Documentation 🚧

look_to_lh

Creates a left-handed view matrix using a camera position, an up direction, and a facing direction. For a view coordinate system with +X=right, +Y=up and +Z=forward.

Arguments

NameTypeDocumentation
eyeVec3No Documentation 🚧
dirVec3No Documentation 🚧
upVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

orthographic_lh

Creates a left-handed orthographic projection matrix with [0,1] depth range. Useful to map a left-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect.

Arguments

NameTypeDocumentation
leftf32No Documentation 🚧
rightf32No Documentation 🚧
bottomf32No Documentation 🚧
topf32No Documentation 🚧
nearf32No Documentation 🚧
farf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

to_cols_array_2d

Creates a [[f32; 4]; 4] 4D array storing data in column major order. If you require data in row major order transpose the matrix first.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0[[f32; 4]; 4]No Documentation 🚧

from_diagonal

Creates a 4x4 matrix with its diagonal set to diagonal and all other entries set to 0.

Arguments

NameTypeDocumentation
diagonalVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_quat

Creates an affine transformation matrix from the given rotation quaternion. The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Panics

Will panic if rotation is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
rotationQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

from_rotation_x

Creates an affine transformation matrix containing a 3D rotation around the x axis of angle (in radians). The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

mul_mat4

Multiplies two 4x4 matrices.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

abs

Takes the absolute value of each element in self

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

perspective_infinite_rh

Creates an infinite right-handed perspective projection matrix with [0,1] depth range. Like perspective_rh, but with an infinite value for z_far. The result is that points near z_near are mapped to depth 0, and as they move towards infinity the depth approaches 1.

Panics

Will panic if z_near or z_far are less than or equal to zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
fov_y_radiansf32No Documentation 🚧
aspect_ratiof32No Documentation 🚧
z_nearf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

inverse

Returns the inverse of self. If the matrix is not invertible the returned matrix will be invalid.

Panics

Will panic if the determinant of self is zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

look_to_rh

Creates a right-handed view matrix using a camera position, an up direction, and a facing direction. For a view coordinate system with +X=right, +Y=up and +Z=back.

Arguments

NameTypeDocumentation
eyeVec3No Documentation 🚧
dirVec3No Documentation 🚧
upVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

transform_point3

Transforms the given 3D vector as a point. This is the equivalent of multiplying the 3D vector as a 4D vector where w is 1.0. This method assumes that self contains a valid affine transform. It does not perform a perspective divide, if self contains a perspective transform, or if you are unsure, the [Self::project_point3()] method should be used instead.

Panics

Will panic if the 3rd row of self is not (0, 0, 0, 1) when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Mat4No Documentation 🚧
arg1Mat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsAffine3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

look_at_rh

Creates a right-handed view matrix using a camera position, an up direction, and a focal point. For a view coordinate system with +X=right, +Y=up and +Z=back.

Panics

Will panic if up is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
eyeVec3No Documentation 🚧
centerVec3No Documentation 🚧
upVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

perspective_infinite_reverse_rh

Creates an infinite reverse right-handed perspective projection matrix with [0,1] depth range. Similar to perspective_infinite_rh, but maps Z = z_near to a depth of 1 and Z = infinity to a depth of 0.

Panics

Will panic if z_near is less than or equal to zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
fov_y_radiansf32No Documentation 🚧
aspect_ratiof32No Documentation 🚧
z_nearf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

mul_scalar

Multiplies a 4x4 matrix by a scalar.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

from_rotation_translation

Creates an affine transformation matrix from the given 3D translation. The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Panics

Will panic if rotation is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
rotationQuatNo Documentation 🚧
translationVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

transpose

Returns the transpose of self.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

look_at_lh

Creates a left-handed view matrix using a camera position, an up direction, and a focal point. For a view coordinate system with +X=right, +Y=up and +Z=forward.

Panics

Will panic if up is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
eyeVec3No Documentation 🚧
centerVec3No Documentation 🚧
upVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

from_cols

Creates a 4x4 matrix from four column vectors.

Arguments

NameTypeDocumentation
x_axisVec4No Documentation 🚧
y_axisVec4No Documentation 🚧
z_axisVec4No Documentation 🚧
w_axisVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

perspective_rh

Creates a right-handed perspective projection matrix with [0,1] depth range. Useful to map the standard right-handed coordinate system into what WebGPU/Metal/Direct3D expect.

Panics

Will panic if z_near or z_far are less than or equal to zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
fov_y_radiansf32No Documentation 🚧
aspect_ratiof32No Documentation 🚧
z_nearf32No Documentation 🚧
z_farf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

perspective_lh

Creates a left-handed perspective projection matrix with [0,1] depth range. Useful to map the standard left-handed coordinate system into what WebGPU/Metal/Direct3D expect.

Panics

Will panic if z_near or z_far are less than or equal to zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
fov_y_radiansf32No Documentation 🚧
aspect_ratiof32No Documentation 🚧
z_nearf32No Documentation 🚧
z_farf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

from_scale

Creates an affine transformation matrix containing the given 3D non-uniform scale. The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Panics

Will panic if all elements of scale are zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
scaleVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

row

Returns the matrix row for the given index.

Panics

Panics if index is greater than 3.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
indexusizeNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

transform_vector3

Transforms the give 3D vector as a direction. This is the equivalent of multiplying the 3D vector as a 4D vector where w is 0.0. This method assumes that self contains a valid affine transform.

Panics

Will panic if the 3rd row of self is not (0, 0, 0, 1) when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

to_cols_array

Creates a [f32; 16] array storing data in column major order. If you require data in row major order transpose the matrix first.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0[f32; 16]No Documentation 🚧

from_euler

Creates a affine transformation matrix containing a rotation from the given euler rotation sequence and angles (in radians). The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Arguments

NameTypeDocumentation
orderEulerRotNo Documentation 🚧
af32No Documentation 🚧
bf32No Documentation 🚧
cf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

project_point3a

Transforms the given [Vec3A] as a 3D point, applying perspective correction. This is the equivalent of multiplying the [Vec3A] as a 4D vector where w is 1.0. The perspective divide is performed meaning the resulting 3D vector is divided by w. This method assumes that self contains a projective transform.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

from_axis_angle

Creates an affine transformation matrix containing a 3D rotation around a normalized rotation axis of angle (in radians). The resulting matrix can be used to transform 3D points and vectors. See [Self::transform_point3()] and [Self::transform_vector3()].

Panics

Will panic if axis is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
axisVec3No Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

sub_mat4

Subtracts two 4x4 matrices.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Mat4No Documentation 🚧

is_nan

Returns true if any elements are NaN.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

Quat

Quat

  • x:f32
  • y:f32
  • z:f32
  • w:f32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_affine3Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. Note if the input af...
cloneNo Documentation 🚧
from_mat3Creates a quaternion from a 3x3 rotation matrix. Note if the input matrix contain scales, shears, ...
mul-1No Documentation 🚧
from_vec4Creates a new rotation quaternion from a 4D vector. # Preconditions This function does not check ...
normalizeReturns `self` normalized to length 1.0. For valid results, `self` must _not_ be of length zero. ...
lengthComputes the length of `self`.
to_array`[x, y, z, w]`
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive ...
to_eulerReturns the rotation angles for the given euler rotation sequence.
mulMultiplies two quaternions. If they each represent a rotation, the result will represent the combi...
from_rotation_zCreates a quaternion from the `angle` (in radians) around the z axis.
from_rotation_arcGets the minimal rotation for transforming `from` to `to`. The rotation is in the plane spanned b...
inverseReturns the inverse of a normalized quaternion. Typically quaternion inverse returns the conjugate...
is_nanReturns `true` if any elements are `NAN`.
dotComputes the dot product of `self` and `rhs`. The dot product is equal to the cosine of the angle ...
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...
from_rotation_yCreates a quaternion from the `angle` (in radians) around the y axis.
to_scaled_axisReturns the rotation axis scaled by the rotation in radians.
xyzReturns the vector part of the quaternion.
length_recipComputes `1.0 / length()`. For valid results, `self` must _not_ be of length zero.
angle_betweenReturns the angle (in radians) for the minimal rotation for transforming this quaternion into anot...
from_xyzwCreates a new rotation quaternion. This should generally not be called manually unless you know wh...
mul_vec3aMultiplies a quaternion and a 3D vector, returning the rotated vector.
is_normalizedReturns whether `self` of length `1.0` or not. Uses a precision threshold of `1e-6`.
from_rotation_arc_2dGets the minimal rotation for transforming `from` to `to`. The resulting rotation is around the z...
from_axis_angleCreate a quaternion for a normalized rotation `axis` and `angle` (in radians). The axis must be a ...
mul_quatMultiplies two quaternions. If they each represent a rotation, the result will represent the combi...
eqNo Documentation 🚧
conjugateReturns the quaternion conjugate of `self`. For a unit quaternion the conjugate is also the invers...
as_dquatNo Documentation 🚧
subSubtracts the `rhs` quaternion from `self`. The difference is not guaranteed to be normalized.
addAdds two quaternions. The sum is not guaranteed to be normalized. Note that addition is not the s...
lerpPerforms a linear interpolation between `self` and `rhs` based on the value `s`. When `s` is `0.0...
from_scaled_axisCreate a quaternion that rotates `v.length()` radians around `v.normalize()`. `from_scaled_axis(Vec3::ZERO)`...
length_squaredComputes the squared length of `self`. This is generally faster than `length()` as it avoids a squ...
from_arrayCreates a rotation quaternion from an array. # Preconditions This function does not check if the ...
from_mat3aCreates a quaternion from a 3x3 SIMD aligned rotation matrix. Note if the input matrix contain sca...
negNo Documentation 🚧
rotate_towardsRotates towards `rhs` up to `max_angle` (in radians). When `max_angle` is `0.0`, the result will b...
divDivides a quaternion by a scalar value. The quotient is not guaranteed to be normalized.
mul-2No Documentation 🚧
from_mat4Creates a quaternion from the upper 3x3 rotation matrix inside a homogeneous 4x4 matrix. Note if t...
is_near_identityNo Documentation 🚧
mul_vec3Multiplies a quaternion and a 3D vector, returning the rotated vector. # Panics Will panic if `self`...
from_rotation_arc_colinearGets the minimal rotation for transforming `from` to either `to` or `-to`. This means that the re...
mul-3No Documentation 🚧
from_rotation_xCreates a quaternion from the `angle` (in radians) around the x axis.
from_eulerCreates a quaternion from the given Euler rotation sequence and the angles (in radians).
slerpPerforms a spherical linear interpolation between `self` and `end` based on the value `s`. When `s`...

from_affine3

Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. Note if the input affine matrix contain scales, shears, or other non-rotation transformations then the resulting quaternion will be ill-defined.

Panics

Will panic if any input affine matrix column is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
aAffine3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

from_mat3

Creates a quaternion from a 3x3 rotation matrix. Note if the input matrix contain scales, shears, or other non-rotation transformations then the resulting quaternion will be ill-defined.

Panics

Will panic if any input matrix column is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
matMat3No Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0QuatNo Documentation 🚧
arg1Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

from_vec4

Creates a new rotation quaternion from a 4D vector.

Preconditions

This function does not check if the input is normalized, it is up to the user to provide normalized input or to normalized the resulting quaternion.

Arguments

NameTypeDocumentation
vVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

normalize

Returns self normalized to length 1.0. For valid results, self must not be of length zero. Panics Will panic if self is zero length when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

length

Computes the length of self.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

to_array

[x, y, z, w]

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0[f32; 4]No Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

to_euler

Returns the rotation angles for the given euler rotation sequence.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
orderEulerRotNo Documentation 🚧

Returns

NameTypeDocumentation
arg0(f32, f32, f32)No Documentation 🚧

mul

Multiplies two quaternions. If they each represent a rotation, the result will represent the combined rotation. Note that due to floating point rounding the result may not be perfectly normalized.

Panics

Will panic if self or rhs are not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
rhsQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

from_rotation_z

Creates a quaternion from the angle (in radians) around the z axis.

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

from_rotation_arc

Gets the minimal rotation for transforming from to to. The rotation is in the plane spanned by the two vectors. Will rotate at most 180 degrees. The inputs must be unit vectors. from_rotation_arc(from, to) * from ≈ to. For near-singular cases (from≈to and from≈-to) the current implementation is only accurate to about 0.001 (for f32).

Panics

Will panic if from or to are not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
fromVec3No Documentation 🚧
toVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

inverse

Returns the inverse of a normalized quaternion. Typically quaternion inverse returns the conjugate of a normalized quaternion. Because self is assumed to already be unit length this method does not normalize before returning the conjugate.

Panics

Will panic if self is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

is_nan

Returns true if any elements are NAN.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

dot

Computes the dot product of self and rhs. The dot product is equal to the cosine of the angle between two quaternion rotations.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
rhsQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two quaternions contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
rhsQuatNo Documentation 🚧
max_abs_difff32No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_rotation_y

Creates a quaternion from the angle (in radians) around the y axis.

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

to_scaled_axis

Returns the rotation axis scaled by the rotation in radians.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

xyz

Returns the vector part of the quaternion.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

length_recip

Computes 1.0 / length(). For valid results, self must not be of length zero.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

angle_between

Returns the angle (in radians) for the minimal rotation for transforming this quaternion into another. Both quaternions must be normalized.

Panics

Will panic if self or rhs are not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
rhsQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

from_xyzw

Creates a new rotation quaternion. This should generally not be called manually unless you know what you are doing. Use one of the other constructors instead such as identity or from_axis_angle. from_xyzw is mostly used by unit tests and serde deserialization.

Preconditions

This function does not check if the input is normalized, it is up to the user to provide normalized input or to normalized the resulting quaternion.

Arguments

NameTypeDocumentation
xf32No Documentation 🚧
yf32No Documentation 🚧
zf32No Documentation 🚧
wf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

mul_vec3a

Multiplies a quaternion and a 3D vector, returning the rotated vector.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

is_normalized

Returns whether self of length 1.0 or not. Uses a precision threshold of 1e-6.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_rotation_arc_2d

Gets the minimal rotation for transforming from to to. The resulting rotation is around the z axis. Will rotate at most 180 degrees. The inputs must be unit vectors. from_rotation_arc_2d(from, to) * from ≈ to. For near-singular cases (from≈to and from≈-to) the current implementation is only accurate to about 0.001 (for f32).

Panics

Will panic if from or to are not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
fromVec2No Documentation 🚧
toVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

from_axis_angle

Create a quaternion for a normalized rotation axis and angle (in radians). The axis must be a unit vector.

Panics

Will panic if axis is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
axisVec3No Documentation 🚧
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

mul_quat

Multiplies two quaternions. If they each represent a rotation, the result will represent the combined rotation. Note that due to floating point rounding the result may not be perfectly normalized.

Panics

Will panic if self or rhs are not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
rhsQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
rhsQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

conjugate

Returns the quaternion conjugate of self. For a unit quaternion the conjugate is also the inverse.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

as_dquat

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0DQuatNo Documentation 🚧

sub

Subtracts the rhs quaternion from self. The difference is not guaranteed to be normalized.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
rhsQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

add

Adds two quaternions. The sum is not guaranteed to be normalized. Note that addition is not the same as combining the rotations represented by the two quaternions! That corresponds to multiplication.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
rhsQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

lerp

Performs a linear interpolation between self and rhs based on the value s. When s is 0.0, the result will be equal to self. When s is 1.0, the result will be equal to rhs.

Panics

Will panic if self or end are not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
endQuatNo Documentation 🚧
sf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

from_scaled_axis

Create a quaternion that rotates v.length() radians around v.normalize(). from_scaled_axis(Vec3::ZERO) results in the identity quaternion.

Arguments

NameTypeDocumentation
vVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

length_squared

Computes the squared length of self. This is generally faster than length() as it avoids a square root operation.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

from_array

Creates a rotation quaternion from an array.

Preconditions

This function does not check if the input is normalized, it is up to the user to provide normalized input or to normalized the resulting quaternion.

Arguments

NameTypeDocumentation
a[f32; 4]No Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

from_mat3a

Creates a quaternion from a 3x3 SIMD aligned rotation matrix. Note if the input matrix contain scales, shears, or other non-rotation transformations then the resulting quaternion will be ill-defined.

Panics

Will panic if any input matrix column is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
matMat3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

rotate_towards

Rotates towards rhs up to max_angle (in radians). When max_angle is 0.0, the result will be equal to self. When max_angle is equal to self.angle_between(rhs), the result will be equal to rhs. If max_angle is negative, rotates towards the exact opposite of rhs. Will not go past the target. Both quaternions must be normalized.

Panics

Will panic if self or rhs are not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
rhsQuatNo Documentation 🚧
max_anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

div

Divides a quaternion by a scalar value. The quotient is not guaranteed to be normalized.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
rhsf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0QuatNo Documentation 🚧
arg1Vec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

from_mat4

Creates a quaternion from the upper 3x3 rotation matrix inside a homogeneous 4x4 matrix. Note if the upper 3x3 matrix contain scales, shears, or other non-rotation transformations then the resulting quaternion will be ill-defined.

Panics

Will panic if any column of the upper 3x3 rotation matrix is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
matMat4No Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

is_near_identity

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

mul_vec3

Multiplies a quaternion and a 3D vector, returning the rotated vector.

Panics

Will panic if self is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

from_rotation_arc_colinear

Gets the minimal rotation for transforming from to either to or -to. This means that the resulting quaternion will rotate from so that it is colinear with to. The rotation is in the plane spanned by the two vectors. Will rotate at most 90 degrees. The inputs must be unit vectors. to.dot(from_rotation_arc_colinear(from, to) * from).abs() ≈ 1.

Panics

Will panic if from or to are not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
fromVec3No Documentation 🚧
toVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

mul-3

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0QuatNo Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

from_rotation_x

Creates a quaternion from the angle (in radians) around the x axis.

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

from_euler

Creates a quaternion from the given Euler rotation sequence and the angles (in radians).

Arguments

NameTypeDocumentation
eulerEulerRotNo Documentation 🚧
af32No Documentation 🚧
bf32No Documentation 🚧
cf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

slerp

Performs a spherical linear interpolation between self and end based on the value s. When s is 0.0, the result will be equal to self. When s is 1.0, the result will be equal to end.

Panics

Will panic if self or end are not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
endQuatNo Documentation 🚧
sf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0QuatNo Documentation 🚧

U64Vec2

U64Vec2

  • x:u64
  • y:u64

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
with_yCreates a 2D vector from `self` with the given value of `y`.
min_elementReturns the horizontal minimum of `self`. In other words this computes `min(x, y, ..)`.
selectCreates a vector from the elements in `if_true` and `if_false`, selecting which to use for each el...
saturating_subReturns a vector containing the saturating subtraction of `self` and `rhs`. In other words this co...
cmpgtReturns a vector mask containing the result of a `>` comparison for each element of `self` and `rhs`...
splatCreates a vector with all elements set to `v`.
saturating_add_signedReturns a vector containing the saturating addition of `self` and signed vector `rhs`. In other wo...
with_xCreates a 2D vector from `self` with the given value of `x`.
dotComputes the dot product of `self` and `rhs`.
as_i64vec2Casts all elements of `self` to `i64`.
cmpneReturns a vector mask containing the result of a `!=` comparison for each element of `self` and `rhs`...
saturating_divReturns a vector containing the saturating division of `self` and `rhs`. In other words this compu...
minReturns a vector containing the minimum values for each element of `self` and `rhs`. In other word...
sub-2No Documentation 🚧
clampComponent-wise clamping of values, similar to [`u64::clamp`]. Each element in `min` must be less-or-equal to the corresponding element in `max`. # Panics Will panic if `min` is greater than `max` when `glam_assert` is enabled.
assert_receiver_is_total_eqNo Documentation 🚧
subNo Documentation 🚧
div-2No Documentation 🚧
as_vec2Casts all elements of `self` to `f32`.
wrapping_addReturns a vector containing the wrapping addition of `self` and `rhs`. In other words this compute...
element_productReturns the product of all elements of `self`. In other words, this computes `self.x * self.y * .....
wrapping_mulReturns a vector containing the wrapping multiplication of `self` and `rhs`. In other words this c...
mulNo Documentation 🚧
addNo Documentation 🚧
maxReturns a vector containing the maximum values for each element of `self` and `rhs`. In other word...
wrapping_subReturns a vector containing the wrapping subtraction of `self` and `rhs`. In other words this comp...
cmpgeReturns a vector mask containing the result of a `>=` comparison for each element of `self` and `rhs`...
cloneNo Documentation 🚧
remNo Documentation 🚧
newCreates a new vector.
sub-1No Documentation 🚧
mul-1No Documentation 🚧
divNo Documentation 🚧
to_array`[x, y]`
max_elementReturns the horizontal maximum of `self`. In other words this computes `max(x, y, ..)`.
cmpltReturns a vector mask containing the result of a `<` comparison for each element of `self` and `rhs`...
length_squaredComputes the squared length of `self`.
rem-1No Documentation 🚧
wrapping_divReturns a vector containing the wrapping division of `self` and `rhs`. In other words this compute...
eqNo Documentation 🚧
as_ivec2Casts all elements of `self` to `i32`.
as_uvec2Casts all elements of `self` to `u32`.
wrapping_add_signedReturns a vector containing the wrapping addition of `self` and signed vector `rhs`. In other word...
cmpleReturns a vector mask containing the result of a `<=` comparison for each element of `self` and `rhs`...
add-2No Documentation 🚧
add-1No Documentation 🚧
dot_into_vecReturns a vector where every component is the dot product of `self` and `rhs`.
div-1No Documentation 🚧
as_dvec2Casts all elements of `self` to `f64`.
mul-2No Documentation 🚧
element_sumReturns the sum of all elements of `self`. In other words, this computes `self.x + self.y + ..`.
saturating_addReturns a vector containing the saturating addition of `self` and `rhs`. In other words this compu...
rem-2No Documentation 🚧
from_arrayCreates a new vector from an array.
extendCreates a 3D vector from `self` and the given `z` value.
cmpeqReturns a vector mask containing the result of a `==` comparison for each element of `self` and `rhs`...
saturating_mulReturns a vector containing the saturating multiplication of `self` and `rhs`. In other words this...

with_y

Creates a 2D vector from self with the given value of y.

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
yu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

min_element

Returns the horizontal minimum of self. In other words this computes min(x, y, ..).

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

select

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self. A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

Arguments

NameTypeDocumentation
maskBVec2No Documentation 🚧
if_trueU64Vec2No Documentation 🚧
if_falseU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

saturating_sub

Returns a vector containing the saturating subtraction of self and rhs. In other words this computes [self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

cmpgt

Returns a vector mask containing the result of a > comparison for each element of self and rhs. In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

splat

Creates a vector with all elements set to v.

Arguments

NameTypeDocumentation
vu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

saturating_add_signed

Returns a vector containing the saturating addition of self and signed vector rhs. In other words this computes [self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

with_x

Creates a 2D vector from self with the given value of x.

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
xu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

dot

Computes the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

as_i64vec2

Casts all elements of self to i64.

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

cmpne

Returns a vector mask containing the result of a != comparison for each element of self and rhs. In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

saturating_div

Returns a vector containing the saturating division of self and rhs. In other words this computes [self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

min

Returns a vector containing the minimum values for each element of self and rhs. In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

sub-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧
arg1u64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

clamp

Component-wise clamping of values, similar to [u64::clamp]. Each element in min must be less-or-equal to the corresponding element in max.

Panics

Will panic if min is greater than max when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
minU64Vec2No Documentation 🚧
maxU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

div-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧
arg1u64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

as_vec2

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

wrapping_add

Returns a vector containing the wrapping addition of self and rhs. In other words this computes [self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

element_product

Returns the product of all elements of self. In other words, this computes self.x * self.y * ...

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

wrapping_mul

Returns a vector containing the wrapping multiplication of self and rhs. In other words this computes [self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

max

Returns a vector containing the maximum values for each element of self and rhs. In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

wrapping_sub

Returns a vector containing the wrapping subtraction of self and rhs. In other words this computes [self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

cmpge

Returns a vector mask containing the result of a >= comparison for each element of self and rhs. In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

rem

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xu64No Documentation 🚧
yu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧
arg1U64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧
arg1U64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

to_array

[x, y]

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0[u64; 2]No Documentation 🚧

max_element

Returns the horizontal maximum of self. In other words this computes max(x, y, ..).

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

cmplt

Returns a vector mask containing the result of a < comparison for each element of self and rhs. In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

length_squared

Computes the squared length of self.

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

rem-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧
arg1U64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

wrapping_div

Returns a vector containing the wrapping division of self and rhs. In other words this computes [self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
otherU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

as_ivec2

Casts all elements of self to i32.

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

as_uvec2

Casts all elements of self to u32.

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

wrapping_add_signed

Returns a vector containing the wrapping addition of self and signed vector rhs. In other words this computes [self.x.wrapping_add_signed(rhs.x), self.y.wrapping_add_signed(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsI64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

cmple

Returns a vector mask containing the result of a <= comparison for each element of self and rhs. In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

add-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧
arg1u64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

add-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧
arg1U64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

dot_into_vec

Returns a vector where every component is the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

div-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧
arg1U64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

as_dvec2

Casts all elements of self to f64.

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧
arg1u64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

element_sum

Returns the sum of all elements of self. In other words, this computes self.x + self.y + ...

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

saturating_add

Returns a vector containing the saturating addition of self and rhs. In other words this computes [self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

rem-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧
arg1u64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

from_array

Creates a new vector from an array.

Arguments

NameTypeDocumentation
a[u64; 2]No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

extend

Creates a 3D vector from self and the given z value.

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
zu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

cmpeq

Returns a vector mask containing the result of a == comparison for each element of self and rhs. In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

saturating_mul

Returns a vector containing the saturating multiplication of self and rhs. In other words this computes [self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec2No Documentation 🚧
rhsU64Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

U64Vec3

U64Vec3

  • x:u64
  • y:u64
  • z:u64

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
divNo Documentation 🚧
as_i64vec3Casts all elements of `self` to `i64`.
min_elementReturns the horizontal minimum of `self`. In other words this computes `min(x, y, ..)`.
element_sumReturns the sum of all elements of `self`. In other words, this computes `self.x + self.y + ..`.
cmpleReturns a vector mask containing the result of a `<=` comparison for each element of `self` and `rhs`...
as_vec3aCasts all elements of `self` to `f32`.
div-2No Documentation 🚧
saturating_mulReturns a vector containing the saturating multiplication of `self` and `rhs`. In other words this...
cmpgtReturns a vector mask containing the result of a `>` comparison for each element of `self` and `rhs`...
maxReturns a vector containing the maximum values for each element of `self` and `rhs`. In other word...
subNo Documentation 🚧
eqNo Documentation 🚧
cmpltReturns a vector mask containing the result of a `<` comparison for each element of `self` and `rhs`...
cmpneReturns a vector mask containing the result of a `!=` comparison for each element of `self` and `rhs`...
wrapping_mulReturns a vector containing the wrapping multiplication of `self` and `rhs`. In other words this c...
splatCreates a vector with all elements set to `v`.
saturating_add_signedReturns a vector containing the saturating addition of `self` and signed vector `rhs`. In other wo...
rem-1No Documentation 🚧
as_uvec3Casts all elements of `self` to `u32`.
sub-2No Documentation 🚧
wrapping_addReturns a vector containing the wrapping addition of `self` and `rhs`. In other words this compute...
with_zCreates a 3D vector from `self` with the given value of `z`.
wrapping_subReturns a vector containing the wrapping subtraction of `self` and `rhs`. In other words this comp...
saturating_subReturns a vector containing the saturating subtraction of `self` and `rhs`. In other words this co...
as_dvec3Casts all elements of `self` to `f64`.
length_squaredComputes the squared length of `self`.
to_array`[x, y, z]`
cloneNo Documentation 🚧
with_yCreates a 3D vector from `self` with the given value of `y`.
assert_receiver_is_total_eqNo Documentation 🚧
as_ivec3Casts all elements of `self` to `i32`.
div-1No Documentation 🚧
mul-1No Documentation 🚧
sub-1No Documentation 🚧
from_arrayCreates a new vector from an array.
with_xCreates a 3D vector from `self` with the given value of `x`.
selectCreates a vector from the elements in `if_true` and `if_false`, selecting which to use for each el...
wrapping_divReturns a vector containing the wrapping division of `self` and `rhs`. In other words this compute...
remNo Documentation 🚧
cmpgeReturns a vector mask containing the result of a `>=` comparison for each element of `self` and `rhs`...
rem-2No Documentation 🚧
mul-2No Documentation 🚧
wrapping_add_signedReturns a vector containing the wrapping addition of `self` and signed vector `rhs`. In other word...
add-1No Documentation 🚧
newCreates a new vector.
saturating_divReturns a vector containing the saturating division of `self` and `rhs`. In other words this compu...
truncateCreates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. Truncation may also b...
dot_into_vecReturns a vector where every component is the dot product of `self` and `rhs`.
clampComponent-wise clamping of values, similar to [`u64::clamp`]. Each element in `min` must be less-or-equal to the corresponding element in `max`. # Panics Will panic if `min` is greater than `max` when `glam_assert` is enabled.
max_elementReturns the horizontal maximum of `self`. In other words this computes `max(x, y, ..)`.
dotComputes the dot product of `self` and `rhs`.
cmpeqReturns a vector mask containing the result of a `==` comparison for each element of `self` and `rhs`...
mulNo Documentation 🚧
as_vec3Casts all elements of `self` to `f32`.
add-2No Documentation 🚧
addNo Documentation 🚧
minReturns a vector containing the minimum values for each element of `self` and `rhs`. In other word...
extendCreates a 4D vector from `self` and the given `w` value.
crossComputes the cross product of `self` and `rhs`.
element_productReturns the product of all elements of `self`. In other words, this computes `self.x * self.y * .....
saturating_addReturns a vector containing the saturating addition of `self` and `rhs`. In other words this compu...

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

as_i64vec3

Casts all elements of self to i64.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

min_element

Returns the horizontal minimum of self. In other words this computes min(x, y, ..).

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

element_sum

Returns the sum of all elements of self. In other words, this computes self.x + self.y + ...

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

cmple

Returns a vector mask containing the result of a <= comparison for each element of self and rhs. In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

as_vec3a

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

div-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧
arg1u64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

saturating_mul

Returns a vector containing the saturating multiplication of self and rhs. In other words this computes [self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

cmpgt

Returns a vector mask containing the result of a > comparison for each element of self and rhs. In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

max

Returns a vector containing the maximum values for each element of self and rhs. In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
otherU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

cmplt

Returns a vector mask containing the result of a < comparison for each element of self and rhs. In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

cmpne

Returns a vector mask containing the result of a != comparison for each element of self and rhs. In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

wrapping_mul

Returns a vector containing the wrapping multiplication of self and rhs. In other words this computes [self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

splat

Creates a vector with all elements set to v.

Arguments

NameTypeDocumentation
vu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

saturating_add_signed

Returns a vector containing the saturating addition of self and signed vector rhs. In other words this computes [self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

rem-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧
arg1U64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

as_uvec3

Casts all elements of self to u32.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

sub-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧
arg1u64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

wrapping_add

Returns a vector containing the wrapping addition of self and rhs. In other words this computes [self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

with_z

Creates a 3D vector from self with the given value of z.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
zu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

wrapping_sub

Returns a vector containing the wrapping subtraction of self and rhs. In other words this computes [self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

saturating_sub

Returns a vector containing the saturating subtraction of self and rhs. In other words this computes [self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

as_dvec3

Casts all elements of self to f64.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

length_squared

Computes the squared length of self.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

to_array

[x, y, z]

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0[u64; 3]No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

with_y

Creates a 3D vector from self with the given value of y.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
yu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

as_ivec3

Casts all elements of self to i32.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

div-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧
arg1U64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧
arg1U64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧
arg1U64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

from_array

Creates a new vector from an array.

Arguments

NameTypeDocumentation
a[u64; 3]No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

with_x

Creates a 3D vector from self with the given value of x.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
xu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

select

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self. A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

Arguments

NameTypeDocumentation
maskBVec3No Documentation 🚧
if_trueU64Vec3No Documentation 🚧
if_falseU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

wrapping_div

Returns a vector containing the wrapping division of self and rhs. In other words this computes [self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

rem

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

cmpge

Returns a vector mask containing the result of a >= comparison for each element of self and rhs. In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

rem-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧
arg1u64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧
arg1u64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

wrapping_add_signed

Returns a vector containing the wrapping addition of self and signed vector rhs. In other words this computes [self.x.wrapping_add_signed(rhs.x), self.y.wrapping_add_signed(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsI64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

add-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧
arg1U64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xu64No Documentation 🚧
yu64No Documentation 🚧
zu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

saturating_div

Returns a vector containing the saturating division of self and rhs. In other words this computes [self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

truncate

Creates a 2D vector from the x and y elements of self, discarding z. Truncation may also be performed by using [self.xy()][crate::swizzles::Vec3Swizzles::xy()].

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

dot_into_vec

Returns a vector where every component is the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

clamp

Component-wise clamping of values, similar to [u64::clamp]. Each element in min must be less-or-equal to the corresponding element in max.

Panics

Will panic if min is greater than max when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
minU64Vec3No Documentation 🚧
maxU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

max_element

Returns the horizontal maximum of self. In other words this computes max(x, y, ..).

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

dot

Computes the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

cmpeq

Returns a vector mask containing the result of a == comparison for each element of self and rhs. In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

as_vec3

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

add-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧
arg1u64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

min

Returns a vector containing the minimum values for each element of self and rhs. In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

extend

Creates a 4D vector from self and the given w value.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
wu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

cross

Computes the cross product of self and rhs.

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

element_product

Returns the product of all elements of self. In other words, this computes self.x * self.y * ...

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

saturating_add

Returns a vector containing the saturating addition of self and rhs. In other words this computes [self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec3No Documentation 🚧
rhsU64Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

U64Vec4

U64Vec4

  • x:u64
  • y:u64
  • z:u64
  • w:u64

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
wrapping_addReturns a vector containing the wrapping addition of `self` and `rhs`. In other words this compute...
saturating_mulReturns a vector containing the saturating multiplication of `self` and `rhs`. In other words this...
addNo Documentation 🚧
cmpleReturns a vector mask containing the result of a `<=` comparison for each element of `self` and `rhs`...
cmpgtReturns a vector mask containing the result of a `>` comparison for each element of `self` and `rhs`...
sub-1No Documentation 🚧
splatCreates a vector with all elements set to `v`.
element_productReturns the product of all elements of `self`. In other words, this computes `self.x * self.y * .....
wrapping_subReturns a vector containing the wrapping subtraction of `self` and `rhs`. In other words this comp...
mul-1No Documentation 🚧
wrapping_add_signedReturns a vector containing the wrapping addition of `self` and signed vector `rhs`. In other word...
as_ivec4Casts all elements of `self` to `i32`.
assert_receiver_is_total_eqNo Documentation 🚧
cmpgeReturns a vector mask containing the result of a `>=` comparison for each element of `self` and `rhs`...
with_yCreates a 4D vector from `self` with the given value of `y`.
clampComponent-wise clamping of values, similar to [`u64::clamp`]. Each element in `min` must be less-or-equal to the corresponding element in `max`. # Panics Will panic if `min` is greater than `max` when `glam_assert` is enabled.
as_uvec4Casts all elements of `self` to `u32`.
mul-2No Documentation 🚧
add-2No Documentation 🚧
divNo Documentation 🚧
cmpltReturns a vector mask containing the result of a `<` comparison for each element of `self` and `rhs`...
max_elementReturns the horizontal maximum of `self`. In other words this computes `max(x, y, ..)`.
selectCreates a vector from the elements in `if_true` and `if_false`, selecting which to use for each el...
with_xCreates a 4D vector from `self` with the given value of `x`.
sub-2No Documentation 🚧
element_sumReturns the sum of all elements of `self`. In other words, this computes `self.x + self.y + ..`.
rem-2No Documentation 🚧
dot_into_vecReturns a vector where every component is the dot product of `self` and `rhs`.
with_wCreates a 4D vector from `self` with the given value of `w`.
saturating_addReturns a vector containing the saturating addition of `self` and `rhs`. In other words this compu...
maxReturns a vector containing the maximum values for each element of `self` and `rhs`. In other word...
newCreates a new vector.
div-1No Documentation 🚧
saturating_subReturns a vector containing the saturating subtraction of `self` and `rhs`. In other words this co...
dotComputes the dot product of `self` and `rhs`.
as_dvec4Casts all elements of `self` to `f64`.
as_vec4Casts all elements of `self` to `f32`.
minReturns a vector containing the minimum values for each element of `self` and `rhs`. In other word...
add-1No Documentation 🚧
as_i64vec4Casts all elements of `self` to `i64`.
div-2No Documentation 🚧
eqNo Documentation 🚧
subNo Documentation 🚧
cmpneReturns a vector mask containing the result of a `!=` comparison for each element of `self` and `rhs`...
saturating_divReturns a vector containing the saturating division of `self` and `rhs`. In other words this compu...
wrapping_divReturns a vector containing the wrapping division of `self` and `rhs`. In other words this compute...
to_array`[x, y, z, w]`
rem-1No Documentation 🚧
length_squaredComputes the squared length of `self`.
truncateCreates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. Truncation to [`U64Vec3`]...
with_zCreates a 4D vector from `self` with the given value of `z`.
min_elementReturns the horizontal minimum of `self`. In other words this computes `min(x, y, ..)`.
from_arrayCreates a new vector from an array.
remNo Documentation 🚧
saturating_add_signedReturns a vector containing the saturating addition of `self` and signed vector `rhs`. In other wo...
wrapping_mulReturns a vector containing the wrapping multiplication of `self` and `rhs`. In other words this c...
mulNo Documentation 🚧
cmpeqReturns a vector mask containing the result of a `==` comparison for each element of `self` and `rhs`...
cloneNo Documentation 🚧

wrapping_add

Returns a vector containing the wrapping addition of self and rhs. In other words this computes [self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

saturating_mul

Returns a vector containing the saturating multiplication of self and rhs. In other words this computes [self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

cmple

Returns a vector mask containing the result of a <= comparison for each element of self and rhs. In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

cmpgt

Returns a vector mask containing the result of a > comparison for each element of self and rhs. In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧
arg1U64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

splat

Creates a vector with all elements set to v.

Arguments

NameTypeDocumentation
vu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

element_product

Returns the product of all elements of self. In other words, this computes self.x * self.y * ...

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

wrapping_sub

Returns a vector containing the wrapping subtraction of self and rhs. In other words this computes [self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧
arg1U64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

wrapping_add_signed

Returns a vector containing the wrapping addition of self and signed vector rhs. In other words this computes [self.x.wrapping_add_signed(rhs.x), self.y.wrapping_add_signed(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

as_ivec4

Casts all elements of self to i32.

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

cmpge

Returns a vector mask containing the result of a >= comparison for each element of self and rhs. In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

with_y

Creates a 4D vector from self with the given value of y.

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
yu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

clamp

Component-wise clamping of values, similar to [u64::clamp]. Each element in min must be less-or-equal to the corresponding element in max.

Panics

Will panic if min is greater than max when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
minU64Vec4No Documentation 🚧
maxU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

as_uvec4

Casts all elements of self to u32.

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧
arg1u64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

add-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧
arg1u64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

cmplt

Returns a vector mask containing the result of a < comparison for each element of self and rhs. In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

max_element

Returns the horizontal maximum of self. In other words this computes max(x, y, ..).

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

select

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self. A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

Arguments

NameTypeDocumentation
maskBVec4No Documentation 🚧
if_trueU64Vec4No Documentation 🚧
if_falseU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

with_x

Creates a 4D vector from self with the given value of x.

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
xu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

sub-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧
arg1u64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

element_sum

Returns the sum of all elements of self. In other words, this computes self.x + self.y + ...

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

rem-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧
arg1u64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

dot_into_vec

Returns a vector where every component is the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

with_w

Creates a 4D vector from self with the given value of w.

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
wu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

saturating_add

Returns a vector containing the saturating addition of self and rhs. In other words this computes [self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

max

Returns a vector containing the maximum values for each element of self and rhs. In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xu64No Documentation 🚧
yu64No Documentation 🚧
zu64No Documentation 🚧
wu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

div-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧
arg1U64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

saturating_sub

Returns a vector containing the saturating subtraction of self and rhs. In other words this computes [self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

dot

Computes the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

as_dvec4

Casts all elements of self to f64.

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

as_vec4

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

min

Returns a vector containing the minimum values for each element of self and rhs. In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

add-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧
arg1U64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

as_i64vec4

Casts all elements of self to i64.

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

div-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧
arg1u64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
otherU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

cmpne

Returns a vector mask containing the result of a != comparison for each element of self and rhs. In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

saturating_div

Returns a vector containing the saturating division of self and rhs. In other words this computes [self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

wrapping_div

Returns a vector containing the wrapping division of self and rhs. In other words this computes [self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

to_array

[x, y, z, w]

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0[u64; 4]No Documentation 🚧

rem-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧
arg1U64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

length_squared

Computes the squared length of self.

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

truncate

Creates a 3D vector from the x, y and z elements of self, discarding w. Truncation to [U64Vec3] may also be performed by using [self.xyz()][crate::swizzles::Vec4Swizzles::xyz()].

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

with_z

Creates a 4D vector from self with the given value of z.

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
zu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

min_element

Returns the horizontal minimum of self. In other words this computes min(x, y, ..).

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0u64No Documentation 🚧

from_array

Creates a new vector from an array.

Arguments

NameTypeDocumentation
a[u64; 4]No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

rem

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

saturating_add_signed

Returns a vector containing the saturating addition of self and signed vector rhs. In other words this computes [self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsI64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

wrapping_mul

Returns a vector containing the wrapping multiplication of self and rhs. In other words this computes [self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

cmpeq

Returns a vector mask containing the result of a == comparison for each element of self and rhs. In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧
rhsU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfU64Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

UVec2

UVec2

  • x:u32
  • y:u32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cmpgeReturns a vector mask containing the result of a `>=` comparison for each element of `self` and `rhs`...
cmpgtReturns a vector mask containing the result of a `>` comparison for each element of `self` and `rhs`...
mulNo Documentation 🚧
mul-2No Documentation 🚧
rem-2No Documentation 🚧
add-1No Documentation 🚧
max_elementReturns the horizontal maximum of `self`. In other words this computes `max(x, y, ..)`.
cmpeqReturns a vector mask containing the result of a `==` comparison for each element of `self` and `rhs`...
with_xCreates a 2D vector from `self` with the given value of `x`.
saturating_divReturns a vector containing the saturating division of `self` and `rhs`. In other words this compu...
as_dvec2Casts all elements of `self` to `f64`.
add-2No Documentation 🚧
rem-1No Documentation 🚧
with_yCreates a 2D vector from `self` with the given value of `y`.
wrapping_mulReturns a vector containing the wrapping multiplication of `self` and `rhs`. In other words this c...
length_squaredComputes the squared length of `self`.
minReturns a vector containing the minimum values for each element of `self` and `rhs`. In other word...
newCreates a new vector.
eqNo Documentation 🚧
addNo Documentation 🚧
extendCreates a 3D vector from `self` and the given `z` value.
remNo Documentation 🚧
saturating_add_signedReturns a vector containing the saturating addition of `self` and signed vector `rhs`. In other wo...
cmpleReturns a vector mask containing the result of a `<=` comparison for each element of `self` and `rhs`...
as_i64vec2Casts all elements of `self` to `i64`.
sub-1No Documentation 🚧
from_arrayCreates a new vector from an array.
wrapping_subReturns a vector containing the wrapping subtraction of `self` and `rhs`. In other words this comp...
cloneNo Documentation 🚧
wrapping_divReturns a vector containing the wrapping division of `self` and `rhs`. In other words this compute...
element_productReturns the product of all elements of `self`. In other words, this computes `self.x * self.y * .....
divNo Documentation 🚧
as_vec2Casts all elements of `self` to `f32`.
maxReturns a vector containing the maximum values for each element of `self` and `rhs`. In other word...
element_sumReturns the sum of all elements of `self`. In other words, this computes `self.x + self.y + ..`.
min_elementReturns the horizontal minimum of `self`. In other words this computes `min(x, y, ..)`.
saturating_addReturns a vector containing the saturating addition of `self` and `rhs`. In other words this compu...
selectCreates a vector from the elements in `if_true` and `if_false`, selecting which to use for each el...
cmpltReturns a vector mask containing the result of a `<` comparison for each element of `self` and `rhs`...
clampComponent-wise clamping of values, similar to [`u32::clamp`]. Each element in `min` must be less-or-equal to the corresponding element in `max`. # Panics Will panic if `min` is greater than `max` when `glam_assert` is enabled.
dotComputes the dot product of `self` and `rhs`.
subNo Documentation 🚧
wrapping_add_signedReturns a vector containing the wrapping addition of `self` and signed vector `rhs`. In other word...
to_array`[x, y]`
cmpneReturns a vector mask containing the result of a `!=` comparison for each element of `self` and `rhs`...
wrapping_addReturns a vector containing the wrapping addition of `self` and `rhs`. In other words this compute...
div-2No Documentation 🚧
splatCreates a vector with all elements set to `v`.
as_u64vec2Casts all elements of `self` to `u64`.
assert_receiver_is_total_eqNo Documentation 🚧
dot_into_vecReturns a vector where every component is the dot product of `self` and `rhs`.
sub-2No Documentation 🚧
saturating_subReturns a vector containing the saturating subtraction of `self` and `rhs`. In other words this co...
saturating_mulReturns a vector containing the saturating multiplication of `self` and `rhs`. In other words this...
div-1No Documentation 🚧
mul-1No Documentation 🚧
as_ivec2Casts all elements of `self` to `i32`.

cmpge

Returns a vector mask containing the result of a >= comparison for each element of self and rhs. In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

cmpgt

Returns a vector mask containing the result of a > comparison for each element of self and rhs. In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec2No Documentation 🚧
arg1u32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

rem-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec2No Documentation 🚧
arg1u32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

add-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec2No Documentation 🚧
arg1UVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

max_element

Returns the horizontal maximum of self. In other words this computes max(x, y, ..).

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

cmpeq

Returns a vector mask containing the result of a == comparison for each element of self and rhs. In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

with_x

Creates a 2D vector from self with the given value of x.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
xu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

saturating_div

Returns a vector containing the saturating division of self and rhs. In other words this computes [self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

as_dvec2

Casts all elements of self to f64.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

add-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec2No Documentation 🚧
arg1u32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

rem-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec2No Documentation 🚧
arg1UVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

with_y

Creates a 2D vector from self with the given value of y.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
yu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

wrapping_mul

Returns a vector containing the wrapping multiplication of self and rhs. In other words this computes [self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

length_squared

Computes the squared length of self.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

min

Returns a vector containing the minimum values for each element of self and rhs. In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xu32No Documentation 🚧
yu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
otherUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

extend

Creates a 3D vector from self and the given z value.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
zu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

rem

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

saturating_add_signed

Returns a vector containing the saturating addition of self and signed vector rhs. In other words this computes [self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

cmple

Returns a vector mask containing the result of a <= comparison for each element of self and rhs. In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

as_i64vec2

Casts all elements of self to i64.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec2No Documentation 🚧
arg1UVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

from_array

Creates a new vector from an array.

Arguments

NameTypeDocumentation
a[u32; 2]No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

wrapping_sub

Returns a vector containing the wrapping subtraction of self and rhs. In other words this computes [self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

wrapping_div

Returns a vector containing the wrapping division of self and rhs. In other words this computes [self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

element_product

Returns the product of all elements of self. In other words, this computes self.x * self.y * ...

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

as_vec2

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

max

Returns a vector containing the maximum values for each element of self and rhs. In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

element_sum

Returns the sum of all elements of self. In other words, this computes self.x + self.y + ...

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

min_element

Returns the horizontal minimum of self. In other words this computes min(x, y, ..).

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

saturating_add

Returns a vector containing the saturating addition of self and rhs. In other words this computes [self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

select

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self. A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

Arguments

NameTypeDocumentation
maskBVec2No Documentation 🚧
if_trueUVec2No Documentation 🚧
if_falseUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

cmplt

Returns a vector mask containing the result of a < comparison for each element of self and rhs. In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

clamp

Component-wise clamping of values, similar to [u32::clamp]. Each element in min must be less-or-equal to the corresponding element in max.

Panics

Will panic if min is greater than max when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
minUVec2No Documentation 🚧
maxUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

dot

Computes the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

wrapping_add_signed

Returns a vector containing the wrapping addition of self and signed vector rhs. In other words this computes [self.x.wrapping_add_signed(rhs.x), self.y.wrapping_add_signed(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsIVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

to_array

[x, y]

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0[u32; 2]No Documentation 🚧

cmpne

Returns a vector mask containing the result of a != comparison for each element of self and rhs. In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

wrapping_add

Returns a vector containing the wrapping addition of self and rhs. In other words this computes [self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

div-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec2No Documentation 🚧
arg1u32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

splat

Creates a vector with all elements set to v.

Arguments

NameTypeDocumentation
vu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

as_u64vec2

Casts all elements of self to u64.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

dot_into_vec

Returns a vector where every component is the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

sub-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec2No Documentation 🚧
arg1u32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

saturating_sub

Returns a vector containing the saturating subtraction of self and rhs. In other words this computes [self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

saturating_mul

Returns a vector containing the saturating multiplication of self and rhs. In other words this computes [self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

div-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec2No Documentation 🚧
arg1UVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec2No Documentation 🚧
arg1UVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

as_ivec2

Casts all elements of self to i32.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

UVec3

UVec3

  • x:u32
  • y:u32
  • z:u32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
clampComponent-wise clamping of values, similar to [`u32::clamp`]. Each element in `min` must be less-or-equal to the corresponding element in `max`. # Panics Will panic if `min` is greater than `max` when `glam_assert` is enabled.
add-2No Documentation 🚧
with_xCreates a 3D vector from `self` with the given value of `x`.
remNo Documentation 🚧
crossComputes the cross product of `self` and `rhs`.
saturating_divReturns a vector containing the saturating division of `self` and `rhs`. In other words this compu...
sub-2No Documentation 🚧
element_productReturns the product of all elements of `self`. In other words, this computes `self.x * self.y * .....
cloneNo Documentation 🚧
wrapping_mulReturns a vector containing the wrapping multiplication of `self` and `rhs`. In other words this c...
as_ivec3Casts all elements of `self` to `i32`.
as_i64vec3Casts all elements of `self` to `i64`.
addNo Documentation 🚧
mul-1No Documentation 🚧
div-1No Documentation 🚧
maxReturns a vector containing the maximum values for each element of `self` and `rhs`. In other word...
selectCreates a vector from the elements in `if_true` and `if_false`, selecting which to use for each el...
as_dvec3Casts all elements of `self` to `f64`.
wrapping_add_signedReturns a vector containing the wrapping addition of `self` and signed vector `rhs`. In other word...
div-2No Documentation 🚧
wrapping_subReturns a vector containing the wrapping subtraction of `self` and `rhs`. In other words this comp...
extendCreates a 4D vector from `self` and the given `w` value.
min_elementReturns the horizontal minimum of `self`. In other words this computes `min(x, y, ..)`.
splatCreates a vector with all elements set to `v`.
cmpltReturns a vector mask containing the result of a `<` comparison for each element of `self` and `rhs`...
divNo Documentation 🚧
cmpgeReturns a vector mask containing the result of a `>=` comparison for each element of `self` and `rhs`...
from_arrayCreates a new vector from an array.
as_u64vec3Casts all elements of `self` to `u64`.
cmpgtReturns a vector mask containing the result of a `>` comparison for each element of `self` and `rhs`...
dotComputes the dot product of `self` and `rhs`.
minReturns a vector containing the minimum values for each element of `self` and `rhs`. In other word...
sub-1No Documentation 🚧
truncateCreates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. Truncation may also b...
element_sumReturns the sum of all elements of `self`. In other words, this computes `self.x + self.y + ..`.
mul-2No Documentation 🚧
assert_receiver_is_total_eqNo Documentation 🚧
saturating_subReturns a vector containing the saturating subtraction of `self` and `rhs`. In other words this co...
cmpeqReturns a vector mask containing the result of a `==` comparison for each element of `self` and `rhs`...
length_squaredComputes the squared length of `self`.
to_array`[x, y, z]`
eqNo Documentation 🚧
as_vec3Casts all elements of `self` to `f32`.
rem-1No Documentation 🚧
saturating_mulReturns a vector containing the saturating multiplication of `self` and `rhs`. In other words this...
subNo Documentation 🚧
mulNo Documentation 🚧
with_zCreates a 3D vector from `self` with the given value of `z`.
cmpleReturns a vector mask containing the result of a `<=` comparison for each element of `self` and `rhs`...
as_vec3aCasts all elements of `self` to `f32`.
newCreates a new vector.
dot_into_vecReturns a vector where every component is the dot product of `self` and `rhs`.
cmpneReturns a vector mask containing the result of a `!=` comparison for each element of `self` and `rhs`...
add-1No Documentation 🚧
wrapping_addReturns a vector containing the wrapping addition of `self` and `rhs`. In other words this compute...
saturating_addReturns a vector containing the saturating addition of `self` and `rhs`. In other words this compu...
with_yCreates a 3D vector from `self` with the given value of `y`.
wrapping_divReturns a vector containing the wrapping division of `self` and `rhs`. In other words this compute...
rem-2No Documentation 🚧
max_elementReturns the horizontal maximum of `self`. In other words this computes `max(x, y, ..)`.
saturating_add_signedReturns a vector containing the saturating addition of `self` and signed vector `rhs`. In other wo...

clamp

Component-wise clamping of values, similar to [u32::clamp]. Each element in min must be less-or-equal to the corresponding element in max.

Panics

Will panic if min is greater than max when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
minUVec3No Documentation 🚧
maxUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

add-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec3No Documentation 🚧
arg1u32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

with_x

Creates a 3D vector from self with the given value of x.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
xu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

rem

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

cross

Computes the cross product of self and rhs.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

saturating_div

Returns a vector containing the saturating division of self and rhs. In other words this computes [self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

sub-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec3No Documentation 🚧
arg1u32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

element_product

Returns the product of all elements of self. In other words, this computes self.x * self.y * ...

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

wrapping_mul

Returns a vector containing the wrapping multiplication of self and rhs. In other words this computes [self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

as_ivec3

Casts all elements of self to i32.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

as_i64vec3

Casts all elements of self to i64.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec3No Documentation 🚧
arg1UVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

div-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec3No Documentation 🚧
arg1UVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

max

Returns a vector containing the maximum values for each element of self and rhs. In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

select

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self. A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

Arguments

NameTypeDocumentation
maskBVec3No Documentation 🚧
if_trueUVec3No Documentation 🚧
if_falseUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

as_dvec3

Casts all elements of self to f64.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

wrapping_add_signed

Returns a vector containing the wrapping addition of self and signed vector rhs. In other words this computes [self.x.wrapping_add_signed(rhs.x), self.y.wrapping_add_signed(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

div-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec3No Documentation 🚧
arg1u32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

wrapping_sub

Returns a vector containing the wrapping subtraction of self and rhs. In other words this computes [self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

extend

Creates a 4D vector from self and the given w value.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
wu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

min_element

Returns the horizontal minimum of self. In other words this computes min(x, y, ..).

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

splat

Creates a vector with all elements set to v.

Arguments

NameTypeDocumentation
vu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

cmplt

Returns a vector mask containing the result of a < comparison for each element of self and rhs. In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

cmpge

Returns a vector mask containing the result of a >= comparison for each element of self and rhs. In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

from_array

Creates a new vector from an array.

Arguments

NameTypeDocumentation
a[u32; 3]No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

as_u64vec3

Casts all elements of self to u64.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

cmpgt

Returns a vector mask containing the result of a > comparison for each element of self and rhs. In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

dot

Computes the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

min

Returns a vector containing the minimum values for each element of self and rhs. In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec3No Documentation 🚧
arg1UVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

truncate

Creates a 2D vector from the x and y elements of self, discarding z. Truncation may also be performed by using [self.xy()][crate::swizzles::Vec3Swizzles::xy()].

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

element_sum

Returns the sum of all elements of self. In other words, this computes self.x + self.y + ...

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec3No Documentation 🚧
arg1u32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

saturating_sub

Returns a vector containing the saturating subtraction of self and rhs. In other words this computes [self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

cmpeq

Returns a vector mask containing the result of a == comparison for each element of self and rhs. In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

length_squared

Computes the squared length of self.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

to_array

[x, y, z]

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0[u32; 3]No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
otherUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

as_vec3

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

rem-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec3No Documentation 🚧
arg1UVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

saturating_mul

Returns a vector containing the saturating multiplication of self and rhs. In other words this computes [self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

with_z

Creates a 3D vector from self with the given value of z.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
zu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

cmple

Returns a vector mask containing the result of a <= comparison for each element of self and rhs. In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

as_vec3a

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xu32No Documentation 🚧
yu32No Documentation 🚧
zu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

dot_into_vec

Returns a vector where every component is the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

cmpne

Returns a vector mask containing the result of a != comparison for each element of self and rhs. In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

add-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec3No Documentation 🚧
arg1UVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

wrapping_add

Returns a vector containing the wrapping addition of self and rhs. In other words this computes [self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

saturating_add

Returns a vector containing the saturating addition of self and rhs. In other words this computes [self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

with_y

Creates a 3D vector from self with the given value of y.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
yu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

wrapping_div

Returns a vector containing the wrapping division of self and rhs. In other words this computes [self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

rem-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec3No Documentation 🚧
arg1u32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

max_element

Returns the horizontal maximum of self. In other words this computes max(x, y, ..).

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

saturating_add_signed

Returns a vector containing the saturating addition of self and signed vector rhs. In other words this computes [self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsIVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

UVec4

UVec4

  • x:u32
  • y:u32
  • z:u32
  • w:u32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
truncateCreates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. Truncation to [`UVec3`]...
with_xCreates a 4D vector from `self` with the given value of `x`.
min_elementReturns the horizontal minimum of `self`. In other words this computes `min(x, y, ..)`.
addNo Documentation 🚧
with_zCreates a 4D vector from `self` with the given value of `z`.
wrapping_add_signedReturns a vector containing the wrapping addition of `self` and signed vector `rhs`. In other word...
wrapping_divReturns a vector containing the wrapping division of `self` and `rhs`. In other words this compute...
saturating_add_signedReturns a vector containing the saturating addition of `self` and signed vector `rhs`. In other wo...
divNo Documentation 🚧
saturating_subReturns a vector containing the saturating subtraction of `self` and `rhs`. In other words this co...
as_i64vec4Casts all elements of `self` to `i64`.
as_dvec4Casts all elements of `self` to `f64`.
eqNo Documentation 🚧
add-1No Documentation 🚧
element_sumReturns the sum of all elements of `self`. In other words, this computes `self.x + self.y + ..`.
with_wCreates a 4D vector from `self` with the given value of `w`.
cmpltReturns a vector mask containing the result of a `<` comparison for each element of `self` and `rhs`...
assert_receiver_is_total_eqNo Documentation 🚧
cmpleReturns a vector mask containing the result of a `<=` comparison for each element of `self` and `rhs`...
saturating_mulReturns a vector containing the saturating multiplication of `self` and `rhs`. In other words this...
subNo Documentation 🚧
cmpeqReturns a vector mask containing the result of a `==` comparison for each element of `self` and `rhs`...
splatCreates a vector with all elements set to `v`.
clampComponent-wise clamping of values, similar to [`u32::clamp`]. Each element in `min` must be less-or-equal to the corresponding element in `max`. # Panics Will panic if `min` is greater than `max` when `glam_assert` is enabled.
dotComputes the dot product of `self` and `rhs`.
saturating_divReturns a vector containing the saturating division of `self` and `rhs`. In other words this compu...
as_u64vec4Casts all elements of `self` to `u64`.
wrapping_subReturns a vector containing the wrapping subtraction of `self` and `rhs`. In other words this comp...
sub-1No Documentation 🚧
rem-2No Documentation 🚧
rem-1No Documentation 🚧
saturating_addReturns a vector containing the saturating addition of `self` and `rhs`. In other words this compu...
dot_into_vecReturns a vector where every component is the dot product of `self` and `rhs`.
as_ivec4Casts all elements of `self` to `i32`.
as_vec4Casts all elements of `self` to `f32`.
length_squaredComputes the squared length of `self`.
add-2No Documentation 🚧
cmpneReturns a vector mask containing the result of a `!=` comparison for each element of `self` and `rhs`...
cmpgeReturns a vector mask containing the result of a `>=` comparison for each element of `self` and `rhs`...
remNo Documentation 🚧
newCreates a new vector.
mul-1No Documentation 🚧
to_array`[x, y, z, w]`
mulNo Documentation 🚧
cmpgtReturns a vector mask containing the result of a `>` comparison for each element of `self` and `rhs`...
maxReturns a vector containing the maximum values for each element of `self` and `rhs`. In other word...
wrapping_mulReturns a vector containing the wrapping multiplication of `self` and `rhs`. In other words this c...
cloneNo Documentation 🚧
with_yCreates a 4D vector from `self` with the given value of `y`.
from_arrayCreates a new vector from an array.
div-2No Documentation 🚧
selectCreates a vector from the elements in `if_true` and `if_false`, selecting which to use for each el...
sub-2No Documentation 🚧
max_elementReturns the horizontal maximum of `self`. In other words this computes `max(x, y, ..)`.
element_productReturns the product of all elements of `self`. In other words, this computes `self.x * self.y * .....
minReturns a vector containing the minimum values for each element of `self` and `rhs`. In other word...
div-1No Documentation 🚧
mul-2No Documentation 🚧
wrapping_addReturns a vector containing the wrapping addition of `self` and `rhs`. In other words this compute...

truncate

Creates a 3D vector from the x, y and z elements of self, discarding w. Truncation to [UVec3] may also be performed by using [self.xyz()][crate::swizzles::Vec4Swizzles::xyz()].

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

with_x

Creates a 4D vector from self with the given value of x.

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
xu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

min_element

Returns the horizontal minimum of self. In other words this computes min(x, y, ..).

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

with_z

Creates a 4D vector from self with the given value of z.

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
zu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

wrapping_add_signed

Returns a vector containing the wrapping addition of self and signed vector rhs. In other words this computes [self.x.wrapping_add_signed(rhs.x), self.y.wrapping_add_signed(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

wrapping_div

Returns a vector containing the wrapping division of self and rhs. In other words this computes [self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

saturating_add_signed

Returns a vector containing the saturating addition of self and signed vector rhs. In other words this computes [self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsIVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

saturating_sub

Returns a vector containing the saturating subtraction of self and rhs. In other words this computes [self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

as_i64vec4

Casts all elements of self to i64.

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

as_dvec4

Casts all elements of self to f64.

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
otherUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

add-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec4No Documentation 🚧
arg1UVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

element_sum

Returns the sum of all elements of self. In other words, this computes self.x + self.y + ...

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

with_w

Creates a 4D vector from self with the given value of w.

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
wu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

cmplt

Returns a vector mask containing the result of a < comparison for each element of self and rhs. In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

cmple

Returns a vector mask containing the result of a <= comparison for each element of self and rhs. In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

saturating_mul

Returns a vector containing the saturating multiplication of self and rhs. In other words this computes [self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

cmpeq

Returns a vector mask containing the result of a == comparison for each element of self and rhs. In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

splat

Creates a vector with all elements set to v.

Arguments

NameTypeDocumentation
vu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

clamp

Component-wise clamping of values, similar to [u32::clamp]. Each element in min must be less-or-equal to the corresponding element in max.

Panics

Will panic if min is greater than max when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
minUVec4No Documentation 🚧
maxUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

dot

Computes the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

saturating_div

Returns a vector containing the saturating division of self and rhs. In other words this computes [self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

as_u64vec4

Casts all elements of self to u64.

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

wrapping_sub

Returns a vector containing the wrapping subtraction of self and rhs. In other words this computes [self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec4No Documentation 🚧
arg1UVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

rem-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec4No Documentation 🚧
arg1u32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

rem-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec4No Documentation 🚧
arg1UVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

saturating_add

Returns a vector containing the saturating addition of self and rhs. In other words this computes [self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

dot_into_vec

Returns a vector where every component is the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

as_ivec4

Casts all elements of self to i32.

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

as_vec4

Casts all elements of self to f32.

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

length_squared

Computes the squared length of self.

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

add-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec4No Documentation 🚧
arg1u32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

cmpne

Returns a vector mask containing the result of a != comparison for each element of self and rhs. In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

cmpge

Returns a vector mask containing the result of a >= comparison for each element of self and rhs. In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

rem

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xu32No Documentation 🚧
yu32No Documentation 🚧
zu32No Documentation 🚧
wu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec4No Documentation 🚧
arg1UVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

to_array

[x, y, z, w]

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0[u32; 4]No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

cmpgt

Returns a vector mask containing the result of a > comparison for each element of self and rhs. In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4No Documentation 🚧

max

Returns a vector containing the maximum values for each element of self and rhs. In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

wrapping_mul

Returns a vector containing the wrapping multiplication of self and rhs. In other words this computes [self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

with_y

Creates a 4D vector from self with the given value of y.

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
yu32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

from_array

Creates a new vector from an array.

Arguments

NameTypeDocumentation
a[u32; 4]No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

div-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec4No Documentation 🚧
arg1u32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

select

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self. A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

Arguments

NameTypeDocumentation
maskBVec4No Documentation 🚧
if_trueUVec4No Documentation 🚧
if_falseUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

sub-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec4No Documentation 🚧
arg1u32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

max_element

Returns the horizontal maximum of self. In other words this computes max(x, y, ..).

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

element_product

Returns the product of all elements of self. In other words, this computes self.x * self.y * ...

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

min

Returns a vector containing the minimum values for each element of self and rhs. In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

div-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec4No Documentation 🚧
arg1UVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0UVec4No Documentation 🚧
arg1u32No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

wrapping_add

Returns a vector containing the wrapping addition of self and rhs. In other words this computes [self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfUVec4No Documentation 🚧
rhsUVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

Vec2

Vec2

  • x:f32
  • y:f32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
fract_glReturns a vector containing the fractional part of the vector as `self - self.floor()`. Note that ...
fractReturns a vector containing the fractional part of the vector as `self - self.trunc()`. Note that ...
as_uvec2Casts all elements of `self` to `u32`.
project_ontoReturns the vector projection of `self` onto `rhs`. `rhs` must be of non-zero length. # Panics W...
perp_dotThe perpendicular dot product of `self` and `rhs`. Also known as the wedge product, 2D cross produ...
cloneNo Documentation 🚧
mul-2No Documentation 🚧
with_yCreates a 2D vector from `self` with the given value of `y`.
div-2No Documentation 🚧
cmpltReturns a vector mask containing the result of a `<` comparison for each element of `self` and `rhs`...
angle_betweenNo Documentation 🚧
selectCreates a vector from the elements in `if_true` and `if_false`, selecting which to use for each el...
truncReturns a vector containing the integer part each element of `self`. This means numbers are always...
refractReturns the refraction direction for a given incident vector `self`, surface normal `normal` and r...
min_elementReturns the horizontal minimum of `self`. In other words this computes `min(x, y, ..)`.
lengthComputes the length of `self`.
as_u64vec2Casts all elements of `self` to `u64`.
angle_toReturns the angle of rotation (in radians) from `self` to `rhs` in the range `[-π, +π]`. The inputs do not need to be unit vectors however they must be non-zero.
as_dvec2Casts all elements of `self` to `f64`.
div_euclidReturns the element-wise quotient of [Euclidean division] of `self` by `rhs`.
to_array`[x, y]`
is_normalizedReturns whether `self` is length `1.0` or not. Uses a precision threshold of approximately `1e-4`.
element_sumReturns the sum of all elements of `self`. In other words, this computes `self.x + self.y + ..`.
absReturns a vector containing the absolute value of each element of `self`.
ceilReturns a vector containing the smallest integer greater than or equal to a number for each elemen...
dotComputes the dot product of `self` and `rhs`.
from_angleCreates a 2D vector containing `[angle.cos(), angle.sin()]`. This can be used in conjunction with the [`rotate()`]...
rem-1No Documentation 🚧
add-2No Documentation 🚧
add-1No Documentation 🚧
recipReturns a vector containing the reciprocal `1.0/n` of each element of `self`.
distanceComputes the Euclidean distance between two points in space.
cmpgeReturns a vector mask containing the result of a `>=` comparison for each element of `self` and `rhs`...
from_arrayCreates a new vector from an array.
midpointCalculates the midpoint between `self` and `rhs`. The midpoint is the average of, or halfway point...
div-1No Documentation 🚧
as_i64vec2Casts all elements of `self` to `i64`.
extendCreates a 3D vector from `self` and the given `z` value.
reflectReturns the reflection vector for a given incident vector `self` and surface normal `normal`. `normal`...
newCreates a new vector.
lerpPerforms a linear interpolation between `self` and `rhs` based on the value `s`. When `s` is `0.0`...
project_onto_normalizedReturns the vector projection of `self` onto `rhs`. `rhs` must be normalized. # Panics Will pani...
divNo Documentation 🚧
max_elementReturns the horizontal maximum of `self`. In other words this computes `max(x, y, ..)`.
rotateReturns `rhs` rotated by the angle of `self`. If `self` is normalized, then this just rotation. Th...
move_towardsMoves towards `rhs` based on the value `d`. When `d` is `0.0`, the result will be equal to `self`....
negNo Documentation 🚧
element_productReturns the product of all elements of `self`. In other words, this computes `self.x * self.y * .....
dot_into_vecReturns a vector where every component is the dot product of `self` and `rhs`.
rem_euclidReturns the element-wise remainder of [Euclidean division] of `self` by `rhs`. [Euclidean division...
normalize_orReturns `self` normalized to length 1.0 if possible, else returns a fallback value. In particular...
normalizeReturns `self` normalized to length 1.0. For valid results, `self` must be finite and _not_ of len...
roundReturns a vector containing the nearest integer to a number for each element of `self`. Round half...
remNo Documentation 🚧
normalize_or_zeroReturns `self` normalized to length 1.0 if possible, else returns zero. In particular, if the inpu...
rotate_towardsRotates towards `rhs` up to `max_angle` (in radians). When `max_angle` is `0.0`, the result will b...
is_nan_maskPerforms `is_nan` on each element of self, returning a vector mask of the results. In other words, this computes `[x.is_nan(), y.is_nan(), ...]...
copysignReturns a vector with signs of `rhs` and the magnitudes of `self`.
sub-2No Documentation 🚧
length_recipComputes `1.0 / length()`. For valid results, `self` must _not_ be of length zero.
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive...
with_xCreates a 2D vector from `self` with the given value of `x`.
expReturns a vector containing `e^self` (the exponential function) for each element of `self`.
addNo Documentation 🚧
as_ivec2Casts all elements of `self` to `i32`.
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...
distance_squaredCompute the squared euclidean distance between two points in space.
clamp_lengthReturns a vector with a length no less than `min` and no more than `max`. # Panics Will panic if `min`...
is_nanReturns `true` if any elements are `NaN`.
powfReturns a vector containing each element of `self` raised to the power of `n`.
eqNo Documentation 🚧
cmpneReturns a vector mask containing the result of a `!=` comparison for each element of `self` and `rhs`...
clamp_length_maxReturns a vector with a length no more than `max`. # Panics Will panic if `max` is negative when `glam_assert` is enabled.
minReturns a vector containing the minimum values for each element of `self` and `rhs`. In other word...
length_squaredComputes the squared length of `self`. This is faster than `length()` as it avoids a square root o...
cmpleReturns a vector mask containing the result of a `<=` comparison for each element of `self` and `rhs`...
to_angleReturns the angle (in radians) of this vector in the range `[-π, +π]`. The input does not need to be a unit vector however it must be non-zero.
cmpeqReturns a vector mask containing the result of a `==` comparison for each element of `self` and `rhs`...
mulNo Documentation 🚧
clampComponent-wise clamping of values, similar to [`f32::clamp`]. Each element in `min` must be less-or-equal to the corresponding element in `max`. # Panics Will panic if `min` is greater than `max` when `glam_assert` is enabled.
cmpgtReturns a vector mask containing the result of a `>` comparison for each element of `self` and `rhs`...
mul-1No Documentation 🚧
splatCreates a vector with all elements set to `v`.
mul_addFused multiply-add. Computes `(self * a) + b` element-wise with only one rounding error, yielding a more accurate result than an unfused multiply-add. Using `mul_add` *may* be more performant than an unfused multiply-add if the target architecture has a dedicated fma CPU instruction. However, this is not always true, and will be heavily dependant on designing algorithms with specific target hardware in mind.
clamp_length_minReturns a vector with a length no less than `min`. # Panics Will panic if `min` is negative when `glam_assert` is enabled.
sub-1No Documentation 🚧
floorReturns a vector containing the largest integer less than or equal to a number for each element of...
subNo Documentation 🚧
rem-2No Documentation 🚧
reject_from_normalizedReturns the vector rejection of `self` from `rhs`. The vector rejection is the vector perpendicula...
is_negative_bitmaskReturns a bitmask with the lowest 2 bits set to the sign bits from the elements of `self`. A negat...
is_finite_maskPerforms `is_finite` on each element of self, returning a vector mask of the results. In other words, this computes `[x.is_finite(), y.is_finite(), ...]...
maxReturns a vector containing the maximum values for each element of `self` and `rhs`. In other word...
reject_fromReturns the vector rejection of `self` from `rhs`. The vector rejection is the vector perpendicula...
perpReturns a vector that is equal to `self` rotated by 90 degrees.
signumReturns a vector with elements representing the sign of `self`. - `1.0` if the number is positive,...

fract_gl

Returns a vector containing the fractional part of the vector as self - self.floor(). Note that this differs from the Rust implementation of fract which returns self - self.trunc(). Note that this is fast but not precise for large numbers.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

fract

Returns a vector containing the fractional part of the vector as self - self.trunc(). Note that this differs from the GLSL implementation of fract which returns self - self.floor(). Note that this is fast but not precise for large numbers.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

as_uvec2

Casts all elements of self to u32.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec2No Documentation 🚧

project_onto

Returns the vector projection of self onto rhs. rhs must be of non-zero length.

Panics

Will panic if rhs is zero length when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

perp_dot

The perpendicular dot product of self and rhs. Also known as the wedge product, 2D cross product, and determinant.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec2No Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

with_y

Creates a 2D vector from self with the given value of y.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
yf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

div-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec2No Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

cmplt

Returns a vector mask containing the result of a < comparison for each element of self and rhs. In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

angle_between

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

select

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self. A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

Arguments

NameTypeDocumentation
maskBVec2No Documentation 🚧
if_trueVec2No Documentation 🚧
if_falseVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

trunc

Returns a vector containing the integer part each element of self. This means numbers are always truncated towards zero.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

refract

Returns the refraction direction for a given incident vector self, surface normal normal and ratio of indices of refraction, eta. When total internal reflection occurs, a zero vector will be returned. self and normal must be normalized.

Panics

Will panic if self or normal is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
normalVec2No Documentation 🚧
etaf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

min_element

Returns the horizontal minimum of self. In other words this computes min(x, y, ..).

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

length

Computes the length of self.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

as_u64vec2

Casts all elements of self to u64.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec2No Documentation 🚧

angle_to

Returns the angle of rotation (in radians) from self to rhs in the range [-π, +π]. The inputs do not need to be unit vectors however they must be non-zero.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

as_dvec2

Casts all elements of self to f64.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec2No Documentation 🚧

div_euclid

Returns the element-wise quotient of [Euclidean division] of self by rhs.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

to_array

[x, y]

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0[f32; 2]No Documentation 🚧

is_normalized

Returns whether self is length 1.0 or not. Uses a precision threshold of approximately 1e-4.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

element_sum

Returns the sum of all elements of self. In other words, this computes self.x + self.y + ...

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

abs

Returns a vector containing the absolute value of each element of self.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

ceil

Returns a vector containing the smallest integer greater than or equal to a number for each element of self.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

dot

Computes the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

from_angle

Creates a 2D vector containing [angle.cos(), angle.sin()]. This can be used in conjunction with the [rotate()][Self::rotate()] method, e.g. Vec2::from_angle(PI).rotate(Vec2::Y) will create the vector [-1, 0] and rotate [Vec2::Y] around it returning -Vec2::Y.

Arguments

NameTypeDocumentation
anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

rem-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec2No Documentation 🚧
arg1Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

add-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec2No Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

add-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec2No Documentation 🚧
arg1Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

recip

Returns a vector containing the reciprocal 1.0/n of each element of self.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

distance

Computes the Euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

cmpge

Returns a vector mask containing the result of a >= comparison for each element of self and rhs. In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

from_array

Creates a new vector from an array.

Arguments

NameTypeDocumentation
a[f32; 2]No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

midpoint

Calculates the midpoint between self and rhs. The midpoint is the average of, or halfway point between, two vectors. a.midpoint(b) should yield the same result as a.lerp(b, 0.5) while being slightly cheaper to compute.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

div-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec2No Documentation 🚧
arg1Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

as_i64vec2

Casts all elements of self to i64.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec2No Documentation 🚧

extend

Creates a 3D vector from self and the given z value.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
zf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

reflect

Returns the reflection vector for a given incident vector self and surface normal normal. normal must be normalized.

Panics

Will panic if normal is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
normalVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xf32No Documentation 🚧
yf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

lerp

Performs a linear interpolation between self and rhs based on the value s. When s is 0.0, the result will be equal to self. When s is 1.0, the result will be equal to rhs. When s is outside of range [0, 1], the result is linearly extrapolated.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧
sf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

project_onto_normalized

Returns the vector projection of self onto rhs. rhs must be normalized.

Panics

Will panic if rhs is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

max_element

Returns the horizontal maximum of self. In other words this computes max(x, y, ..).

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

rotate

Returns rhs rotated by the angle of self. If self is normalized, then this just rotation. This is what you usually want. Otherwise, it will be like a rotation with a multiplication by self's length.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

move_towards

Moves towards rhs based on the value d. When d is 0.0, the result will be equal to self. When d is equal to self.distance(rhs), the result will be equal to rhs. Will not go past rhs.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧
df32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

element_product

Returns the product of all elements of self. In other words, this computes self.x * self.y * ...

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

dot_into_vec

Returns a vector where every component is the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

rem_euclid

Returns the element-wise remainder of [Euclidean division] of self by rhs. [Euclidean division]: f32::rem_euclid

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

normalize_or

Returns self normalized to length 1.0 if possible, else returns a fallback value. In particular, if the input is zero (or very close to zero), or non-finite, the result of this operation will be the fallback value. See also [Self::try_normalize()].

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
fallbackVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

normalize

Returns self normalized to length 1.0. For valid results, self must be finite and not of length zero, nor very close to zero. See also [Self::try_normalize()] and [Self::normalize_or_zero()]. Panics Will panic if the resulting normalized vector is not finite when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

round

Returns a vector containing the nearest integer to a number for each element of self. Round half-way cases away from 0.0.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

rem

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

normalize_or_zero

Returns self normalized to length 1.0 if possible, else returns zero. In particular, if the input is zero (or very close to zero), or non-finite, the result of this operation will be zero. See also [Self::try_normalize()].

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

rotate_towards

Rotates towards rhs up to max_angle (in radians). When max_angle is 0.0, the result will be equal to self. When max_angle is equal to self.angle_between(rhs), the result will be equal to rhs. If max_angle is negative, rotates towards the exact opposite of rhs. Will not go past the target.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧
max_anglef32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

is_nan_mask

Performs is_nan on each element of self, returning a vector mask of the results. In other words, this computes [x.is_nan(), y.is_nan(), ...].

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

copysign

Returns a vector with signs of rhs and the magnitudes of self.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

sub-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec2No Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

length_recip

Computes 1.0 / length(). For valid results, self must not be of length zero.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

with_x

Creates a 2D vector from self with the given value of x.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
xf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

exp

Returns a vector containing e^self (the exponential function) for each element of self.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

as_ivec2

Casts all elements of self to i32.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec2No Documentation 🚧

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two vectors contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧
max_abs_difff32No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

distance_squared

Compute the squared euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

clamp_length

Returns a vector with a length no less than min and no more than max.

Panics

Will panic if min is greater than max, or if either min or max is negative, when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
minf32No Documentation 🚧
maxf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

is_nan

Returns true if any elements are NaN.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

powf

Returns a vector containing each element of self raised to the power of n.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
nf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
otherVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

cmpne

Returns a vector mask containing the result of a != comparison for each element of self and rhs. In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

clamp_length_max

Returns a vector with a length no more than max.

Panics

Will panic if max is negative when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
maxf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

min

Returns a vector containing the minimum values for each element of self and rhs. In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

length_squared

Computes the squared length of self. This is faster than length() as it avoids a square root operation.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

cmple

Returns a vector mask containing the result of a <= comparison for each element of self and rhs. In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

to_angle

Returns the angle (in radians) of this vector in the range [-π, +π]. The input does not need to be a unit vector however it must be non-zero.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

cmpeq

Returns a vector mask containing the result of a == comparison for each element of self and rhs. In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

clamp

Component-wise clamping of values, similar to [f32::clamp]. Each element in min must be less-or-equal to the corresponding element in max.

Panics

Will panic if min is greater than max when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
minVec2No Documentation 🚧
maxVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

cmpgt

Returns a vector mask containing the result of a > comparison for each element of self and rhs. In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec2No Documentation 🚧
arg1Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

splat

Creates a vector with all elements set to v.

Arguments

NameTypeDocumentation
vf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

mul_add

Fused multiply-add. Computes (self * a) + b element-wise with only one rounding error, yielding a more accurate result than an unfused multiply-add. Using mul_add may be more performant than an unfused multiply-add if the target architecture has a dedicated fma CPU instruction. However, this is not always true, and will be heavily dependant on designing algorithms with specific target hardware in mind.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
aVec2No Documentation 🚧
bVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

clamp_length_min

Returns a vector with a length no less than min.

Panics

Will panic if min is negative when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
minf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec2No Documentation 🚧
arg1Vec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

floor

Returns a vector containing the largest integer less than or equal to a number for each element of self.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

rem-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec2No Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

reject_from_normalized

Returns the vector rejection of self from rhs. The vector rejection is the vector perpendicular to the projection of self onto rhs, in rhs words the result of self - self.project_onto(rhs). rhs must be normalized.

Panics

Will panic if rhs is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

is_negative_bitmask

Returns a bitmask with the lowest 2 bits set to the sign bits from the elements of self. A negative element results in a 1 bit and a positive element in a 0 bit. Element x goes into the first lowest bit, element y into the second, etc.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

is_finite_mask

Performs is_finite on each element of self, returning a vector mask of the results. In other words, this computes [x.is_finite(), y.is_finite(), ...].

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec2No Documentation 🚧

max

Returns a vector containing the maximum values for each element of self and rhs. In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

reject_from

Returns the vector rejection of self from rhs. The vector rejection is the vector perpendicular to the projection of self onto rhs, in rhs words the result of self - self.project_onto(rhs). rhs must be of non-zero length.

Panics

Will panic if rhs has a length of zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

perp

Returns a vector that is equal to self rotated by 90 degrees.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

signum

Returns a vector with elements representing the sign of self.

  • 1.0 if the number is positive, +0.0 or INFINITY
  • -1.0 if the number is negative, -0.0 or NEG_INFINITY
  • NAN if the number is NAN

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

Vec3

Vec3

  • x:f32
  • y:f32
  • z:f32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
as_u64vec3Casts all elements of `self` to `u64`.
truncReturns a vector containing the integer part each element of `self`. This means numbers are always...
mul-2No Documentation 🚧
reflectReturns the reflection vector for a given incident vector `self` and surface normal `normal`. `normal`...
recipReturns a vector containing the reciprocal `1.0/n` of each element of `self`.
fract_glReturns a vector containing the fractional part of the vector as `self - self.floor()`. Note that ...
as_i64vec3Casts all elements of `self` to `i64`.
newCreates a new vector.
signumReturns a vector with elements representing the sign of `self`. - `1.0` if the number is positive,...
distanceComputes the Euclidean distance between two points in space.
project_ontoReturns the vector projection of `self` onto `rhs`. `rhs` must be of non-zero length. # Panics W...
negNo Documentation 🚧
add-1No Documentation 🚧
div_euclidReturns the element-wise quotient of [Euclidean division] of `self` by `rhs`.
cmpltReturns a vector mask containing the result of a `<` comparison for each element of `self` and `rhs`...
element_productReturns the product of all elements of `self`. In other words, this computes `self.x * self.y * .....
move_towardsMoves towards `rhs` based on the value `d`. When `d` is `0.0`, the result will be equal to `self`....
powfReturns a vector containing each element of `self` raised to the power of `n`.
cmpgtReturns a vector mask containing the result of a `>` comparison for each element of `self` and `rhs`...
mul_addFused multiply-add. Computes `(self * a) + b` element-wise with only one rounding error, yielding a more accurate result than an unfused multiply-add. Using `mul_add` *may* be more performant than an unfused multiply-add if the target architecture has a dedicated fma CPU instruction. However, this is not always true, and will be heavily dependant on designing algorithms with specific target hardware in mind.
sub-1No Documentation 🚧
reject_from_normalizedReturns the vector rejection of `self` from `rhs`. The vector rejection is the vector perpendicula...
mulNo Documentation 🚧
with_yCreates a 3D vector from `self` with the given value of `y`.
cloneNo Documentation 🚧
to_array`[x, y, z]`
splatCreates a vector with all elements set to `v`.
is_negative_bitmaskReturns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. A negat...
from_arrayCreates a new vector from an array.
expReturns a vector containing `e^self` (the exponential function) for each element of `self`.
floorReturns a vector containing the largest integer less than or equal to a number for each element of...
normalize_orReturns `self` normalized to length 1.0 if possible, else returns a fallback value. In particular...
clampComponent-wise clamping of values, similar to [`f32::clamp`]. Each element in `min` must be less-or-equal to the corresponding element in `max`. # Panics Will panic if `min` is greater than `max` when `glam_assert` is enabled.
normalize_or_zeroReturns `self` normalized to length 1.0 if possible, else returns zero. In particular, if the inpu...
project_onto_normalizedReturns the vector projection of `self` onto `rhs`. `rhs` must be normalized. # Panics Will pani...
clamp_length_maxReturns a vector with a length no more than `max`. # Panics Will panic if `max` is negative when `glam_assert` is enabled.
dotComputes the dot product of `self` and `rhs`.
midpointCalculates the midpoint between `self` and `rhs`. The midpoint is the average of, or halfway point...
as_dvec3Casts all elements of `self` to `f64`.
roundReturns a vector containing the nearest integer to a number for each element of `self`. Round half...
lengthComputes the length of `self`.
cmpneReturns a vector mask containing the result of a `!=` comparison for each element of `self` and `rhs`...
eqNo Documentation 🚧
copysignReturns a vector with signs of `rhs` and the magnitudes of `self`.
is_nanReturns `true` if any elements are `NaN`.
is_normalizedReturns whether `self` is length `1.0` or not. Uses a precision threshold of approximately `1e-4`.
is_finite_maskPerforms `is_finite` on each element of self, returning a vector mask of the results. In other words, this computes `[x.is_finite(), y.is_finite(), ...]...
ceilReturns a vector containing the smallest integer greater than or equal to a number for each elemen...
length_squaredComputes the squared length of `self`. This is faster than `length()` as it avoids a square root o...
maxReturns a vector containing the maximum values for each element of `self` and `rhs`. In other word...
cmpleReturns a vector mask containing the result of a `<=` comparison for each element of `self` and `rhs`...
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...
addNo Documentation 🚧
minReturns a vector containing the minimum values for each element of `self` and `rhs`. In other word...
dot_into_vecReturns a vector where every component is the dot product of `self` and `rhs`.
truncateCreates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. Truncation may also b...
distance_squaredCompute the squared euclidean distance between two points in space.
length_recipComputes `1.0 / length()`. For valid results, `self` must _not_ be of length zero.
any_orthogonal_vectorReturns some vector that is orthogonal to the given one. The input vector must be finite and non-z...
element_sumReturns the sum of all elements of `self`. In other words, this computes `self.x + self.y + ..`.
min_elementReturns the horizontal minimum of `self`. In other words this computes `min(x, y, ..)`.
crossComputes the cross product of `self` and `rhs`.
with_zCreates a 3D vector from `self` with the given value of `z`.
divNo Documentation 🚧
cmpgeReturns a vector mask containing the result of a `>=` comparison for each element of `self` and `rhs`...
as_ivec3Casts all elements of `self` to `i32`.
any_orthonormal_vectorReturns any unit vector that is orthogonal to the given one. The input vector must be unit length....
cmpeqReturns a vector mask containing the result of a `==` comparison for each element of `self` and `rhs`...
clamp_lengthReturns a vector with a length no less than `min` and no more than `max`. # Panics Will panic if `min`...
absReturns a vector containing the absolute value of each element of `self`.
angle_betweenReturns the angle (in radians) between two vectors in the range `[0, +π]`. The inputs do not need to be unit vectors however they must be non-zero.
rem_euclidReturns the element-wise remainder of [Euclidean division] of `self` by `rhs`. [Euclidean division...
rem-1No Documentation 🚧
mul-1No Documentation 🚧
refractReturns the refraction direction for a given incident vector `self`, surface normal `normal` and r...
clamp_length_minReturns a vector with a length no less than `min`. # Panics Will panic if `min` is negative when `glam_assert` is enabled.
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive...
remNo Documentation 🚧
with_xCreates a 3D vector from `self` with the given value of `x`.
max_elementReturns the horizontal maximum of `self`. In other words this computes `max(x, y, ..)`.
add-2No Documentation 🚧
div-1No Documentation 🚧
subNo Documentation 🚧
extendCreates a 4D vector from `self` and the given `w` value.
reject_fromReturns the vector rejection of `self` from `rhs`. The vector rejection is the vector perpendicula...
sub-2No Documentation 🚧
as_uvec3Casts all elements of `self` to `u32`.
fractReturns a vector containing the fractional part of the vector as `self - self.trunc()`. Note that ...
div-2No Documentation 🚧
selectCreates a vector from the elements in `if_true` and `if_false`, selecting which to use for each el...
rem-2No Documentation 🚧
is_nan_maskPerforms `is_nan` on each element of self, returning a vector mask of the results. In other words, this computes `[x.is_nan(), y.is_nan(), ...]...
normalizeReturns `self` normalized to length 1.0. For valid results, `self` must be finite and _not_ of len...
lerpPerforms a linear interpolation between `self` and `rhs` based on the value `s`. When `s` is `0.0`...

as_u64vec3

Casts all elements of self to u64.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

trunc

Returns a vector containing the integer part each element of self. This means numbers are always truncated towards zero.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3No Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

reflect

Returns the reflection vector for a given incident vector self and surface normal normal. normal must be normalized.

Panics

Will panic if normal is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
normalVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

recip

Returns a vector containing the reciprocal 1.0/n of each element of self.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

fract_gl

Returns a vector containing the fractional part of the vector as self - self.floor(). Note that this differs from the Rust implementation of fract which returns self - self.trunc(). Note that this is fast but not precise for large numbers.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

as_i64vec3

Casts all elements of self to i64.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xf32No Documentation 🚧
yf32No Documentation 🚧
zf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

signum

Returns a vector with elements representing the sign of self.

  • 1.0 if the number is positive, +0.0 or INFINITY
  • -1.0 if the number is negative, -0.0 or NEG_INFINITY
  • NAN if the number is NAN

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

distance

Computes the Euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

project_onto

Returns the vector projection of self onto rhs. rhs must be of non-zero length.

Panics

Will panic if rhs is zero length when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

add-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3No Documentation 🚧
arg1Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

div_euclid

Returns the element-wise quotient of [Euclidean division] of self by rhs.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

cmplt

Returns a vector mask containing the result of a < comparison for each element of self and rhs. In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

element_product

Returns the product of all elements of self. In other words, this computes self.x * self.y * ...

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

move_towards

Moves towards rhs based on the value d. When d is 0.0, the result will be equal to self. When d is equal to self.distance(rhs), the result will be equal to rhs. Will not go past rhs.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧
df32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

powf

Returns a vector containing each element of self raised to the power of n.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
nf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

cmpgt

Returns a vector mask containing the result of a > comparison for each element of self and rhs. In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

mul_add

Fused multiply-add. Computes (self * a) + b element-wise with only one rounding error, yielding a more accurate result than an unfused multiply-add. Using mul_add may be more performant than an unfused multiply-add if the target architecture has a dedicated fma CPU instruction. However, this is not always true, and will be heavily dependant on designing algorithms with specific target hardware in mind.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
aVec3No Documentation 🚧
bVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3No Documentation 🚧
arg1Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

reject_from_normalized

Returns the vector rejection of self from rhs. The vector rejection is the vector perpendicular to the projection of self onto rhs, in rhs words the result of self - self.project_onto(rhs). rhs must be normalized.

Panics

Will panic if rhs is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

with_y

Creates a 3D vector from self with the given value of y.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
yf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

to_array

[x, y, z]

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0[f32; 3]No Documentation 🚧

splat

Creates a vector with all elements set to v.

Arguments

NameTypeDocumentation
vf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

is_negative_bitmask

Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of self. A negative element results in a 1 bit and a positive element in a 0 bit. Element x goes into the first lowest bit, element y into the second, etc.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

from_array

Creates a new vector from an array.

Arguments

NameTypeDocumentation
a[f32; 3]No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

exp

Returns a vector containing e^self (the exponential function) for each element of self.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

floor

Returns a vector containing the largest integer less than or equal to a number for each element of self.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

normalize_or

Returns self normalized to length 1.0 if possible, else returns a fallback value. In particular, if the input is zero (or very close to zero), or non-finite, the result of this operation will be the fallback value. See also [Self::try_normalize()].

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
fallbackVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

clamp

Component-wise clamping of values, similar to [f32::clamp]. Each element in min must be less-or-equal to the corresponding element in max.

Panics

Will panic if min is greater than max when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
minVec3No Documentation 🚧
maxVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

normalize_or_zero

Returns self normalized to length 1.0 if possible, else returns zero. In particular, if the input is zero (or very close to zero), or non-finite, the result of this operation will be zero. See also [Self::try_normalize()].

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

project_onto_normalized

Returns the vector projection of self onto rhs. rhs must be normalized.

Panics

Will panic if rhs is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

clamp_length_max

Returns a vector with a length no more than max.

Panics

Will panic if max is negative when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
maxf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

dot

Computes the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

midpoint

Calculates the midpoint between self and rhs. The midpoint is the average of, or halfway point between, two vectors. a.midpoint(b) should yield the same result as a.lerp(b, 0.5) while being slightly cheaper to compute.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

as_dvec3

Casts all elements of self to f64.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

round

Returns a vector containing the nearest integer to a number for each element of self. Round half-way cases away from 0.0.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

length

Computes the length of self.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

cmpne

Returns a vector mask containing the result of a != comparison for each element of self and rhs. In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
otherVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

copysign

Returns a vector with signs of rhs and the magnitudes of self.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

is_nan

Returns true if any elements are NaN.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_normalized

Returns whether self is length 1.0 or not. Uses a precision threshold of approximately 1e-4.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_finite_mask

Performs is_finite on each element of self, returning a vector mask of the results. In other words, this computes [x.is_finite(), y.is_finite(), ...].

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

ceil

Returns a vector containing the smallest integer greater than or equal to a number for each element of self.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

length_squared

Computes the squared length of self. This is faster than length() as it avoids a square root operation.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

max

Returns a vector containing the maximum values for each element of self and rhs. In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

cmple

Returns a vector mask containing the result of a <= comparison for each element of self and rhs. In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two vectors contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧
max_abs_difff32No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

min

Returns a vector containing the minimum values for each element of self and rhs. In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

dot_into_vec

Returns a vector where every component is the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

truncate

Creates a 2D vector from the x and y elements of self, discarding z. Truncation may also be performed by using [self.xy()][crate::swizzles::Vec3Swizzles::xy()].

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

distance_squared

Compute the squared euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

length_recip

Computes 1.0 / length(). For valid results, self must not be of length zero.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

any_orthogonal_vector

Returns some vector that is orthogonal to the given one. The input vector must be finite and non-zero. The output vector is not necessarily unit length. For that use [Self::any_orthonormal_vector()] instead.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

element_sum

Returns the sum of all elements of self. In other words, this computes self.x + self.y + ...

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

min_element

Returns the horizontal minimum of self. In other words this computes min(x, y, ..).

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

cross

Computes the cross product of self and rhs.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

with_z

Creates a 3D vector from self with the given value of z.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
zf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

cmpge

Returns a vector mask containing the result of a >= comparison for each element of self and rhs. In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

as_ivec3

Casts all elements of self to i32.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

any_orthonormal_vector

Returns any unit vector that is orthogonal to the given one. The input vector must be unit length.

Panics

Will panic if self is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

cmpeq

Returns a vector mask containing the result of a == comparison for each element of self and rhs. In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

clamp_length

Returns a vector with a length no less than min and no more than max.

Panics

Will panic if min is greater than max, or if either min or max is negative, when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
minf32No Documentation 🚧
maxf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

abs

Returns a vector containing the absolute value of each element of self.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

angle_between

Returns the angle (in radians) between two vectors in the range [0, +π]. The inputs do not need to be unit vectors however they must be non-zero.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

rem_euclid

Returns the element-wise remainder of [Euclidean division] of self by rhs. [Euclidean division]: f32::rem_euclid

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

rem-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3No Documentation 🚧
arg1Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3No Documentation 🚧
arg1Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

refract

Returns the refraction direction for a given incident vector self, surface normal normal and ratio of indices of refraction, eta. When total internal reflection occurs, a zero vector will be returned. self and normal must be normalized.

Panics

Will panic if self or normal is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
normalVec3No Documentation 🚧
etaf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

clamp_length_min

Returns a vector with a length no less than min.

Panics

Will panic if min is negative when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
minf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

rem

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

with_x

Creates a 3D vector from self with the given value of x.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
xf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

max_element

Returns the horizontal maximum of self. In other words this computes max(x, y, ..).

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

add-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3No Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

div-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3No Documentation 🚧
arg1Vec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

extend

Creates a 4D vector from self and the given w value.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
wf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

reject_from

Returns the vector rejection of self from rhs. The vector rejection is the vector perpendicular to the projection of self onto rhs, in rhs words the result of self - self.project_onto(rhs). rhs must be of non-zero length.

Panics

Will panic if rhs has a length of zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

sub-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3No Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

as_uvec3

Casts all elements of self to u32.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

fract

Returns a vector containing the fractional part of the vector as self - self.trunc(). Note that this differs from the GLSL implementation of fract which returns self - self.floor(). Note that this is fast but not precise for large numbers.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

div-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3No Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

select

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self. A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

Arguments

NameTypeDocumentation
maskBVec3No Documentation 🚧
if_trueVec3No Documentation 🚧
if_falseVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

rem-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3No Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

is_nan_mask

Performs is_nan on each element of self, returning a vector mask of the results. In other words, this computes [x.is_nan(), y.is_nan(), ...].

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3No Documentation 🚧

normalize

Returns self normalized to length 1.0. For valid results, self must be finite and not of length zero, nor very close to zero. See also [Self::try_normalize()] and [Self::normalize_or_zero()]. Panics Will panic if the resulting normalized vector is not finite when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

lerp

Performs a linear interpolation between self and rhs based on the value s. When s is 0.0, the result will be equal to self. When s is 1.0, the result will be equal to rhs. When s is outside of range [0, 1], the result is linearly extrapolated.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3No Documentation 🚧
sf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

Vec3A

Vec3A

  • x:f32
  • y:f32
  • z:f32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
as_i64vec3Casts all elements of `self` to `i64`.
to_array`[x, y, z]`
maxReturns a vector containing the maximum values for each element of `self` and `rhs`. In other word...
dotComputes the dot product of `self` and `rhs`.
add-1No Documentation 🚧
any_orthogonal_vectorReturns some vector that is orthogonal to the given one. The input vector must be finite and non-z...
with_zCreates a 3D vector from `self` with the given value of `z`.
normalize_orReturns `self` normalized to length 1.0 if possible, else returns a fallback value. In particular...
is_negative_bitmaskReturns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. A negat...
midpointCalculates the midpoint between `self` and `rhs`. The midpoint is the average of, or halfway point...
rem_euclidReturns the element-wise remainder of [Euclidean division] of `self` by `rhs`. [Euclidean division...
truncateCreates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. Truncation may also b...
fractReturns a vector containing the fractional part of the vector as `self - self.trunc()`. Note that ...
cmpgeReturns a vector mask containing the result of a `>=` comparison for each element of `self` and `rhs`...
remNo Documentation 🚧
mul_addFused multiply-add. Computes `(self * a) + b` element-wise with only one rounding error, yielding a more accurate result than an unfused multiply-add. Using `mul_add` *may* be more performant than an unfused multiply-add if the target architecture has a dedicated fma CPU instruction. However, this is not always true, and will be heavily dependant on designing algorithms with specific target hardware in mind.
project_ontoReturns the vector projection of `self` onto `rhs`. `rhs` must be of non-zero length. # Panics W...
max_elementReturns the horizontal maximum of `self`. In other words this computes `max(x, y, ..)`.
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...
cmpeqReturns a vector mask containing the result of a `==` comparison for each element of `self` and `rhs`...
lengthComputes the length of `self`.
lerpPerforms a linear interpolation between `self` and `rhs` based on the value `s`. When `s` is `0.0`...
crossComputes the cross product of `self` and `rhs`.
length_recipComputes `1.0 / length()`. For valid results, `self` must _not_ be of length zero.
floorReturns a vector containing the largest integer less than or equal to a number for each element of...
as_u64vec3Casts all elements of `self` to `u64`.
newCreates a new vector.
project_onto_normalizedReturns the vector projection of `self` onto `rhs`. `rhs` must be normalized. # Panics Will pani...
length_squaredComputes the squared length of `self`. This is faster than `length()` as it avoids a square root o...
reflectReturns the reflection vector for a given incident vector `self` and surface normal `normal`. `normal`...
subNo Documentation 🚧
cmpltReturns a vector mask containing the result of a `<` comparison for each element of `self` and `rhs`...
element_productReturns the product of all elements of `self`. In other words, this computes `self.x * self.y * .....
move_towardsMoves towards `rhs` based on the value `d`. When `d` is `0.0`, the result will be equal to `self`....
from_arrayCreates a new vector from an array.
cmpneReturns a vector mask containing the result of a `!=` comparison for each element of `self` and `rhs`...
cloneNo Documentation 🚧
powfReturns a vector containing each element of `self` raised to the power of `n`.
as_dvec3Casts all elements of `self` to `f64`.
truncReturns a vector containing the integer part each element of `self`. This means numbers are always...
div-2No Documentation 🚧
expReturns a vector containing `e^self` (the exponential function) for each element of `self`.
reject_fromReturns the vector rejection of `self` from `rhs`. The vector rejection is the vector perpendicula...
is_nanReturns `true` if any elements are `NaN`.
div_euclidReturns the element-wise quotient of [Euclidean division] of `self` by `rhs`.
as_uvec3Casts all elements of `self` to `u32`.
cmpgtReturns a vector mask containing the result of a `>` comparison for each element of `self` and `rhs`...
clampComponent-wise clamping of values, similar to [`f32::clamp`]. Each element in `min` must be less-or-equal to the corresponding element in `max`. # Panics Will panic if `min` is greater than `max` when `glam_assert` is enabled.
cmpleReturns a vector mask containing the result of a `<=` comparison for each element of `self` and `rhs`...
mul-1No Documentation 🚧
with_xCreates a 3D vector from `self` with the given value of `x`.
any_orthonormal_vectorReturns any unit vector that is orthogonal to the given one. The input vector must be unit length....
is_nan_maskPerforms `is_nan` on each element of self, returning a vector mask of the results. In other words, this computes `[x.is_nan(), y.is_nan(), ...]...
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive...
clamp_length_maxReturns a vector with a length no more than `max`. # Panics Will panic if `max` is negative when `glam_assert` is enabled.
refractReturns the refraction direction for a given incident vector `self`, surface normal `normal` and r...
distanceComputes the Euclidean distance between two points in space.
negNo Documentation 🚧
sub-2No Documentation 🚧
add-2No Documentation 🚧
absReturns a vector containing the absolute value of each element of `self`.
recipReturns a vector containing the reciprocal `1.0/n` of each element of `self`.
is_finite_maskPerforms `is_finite` on each element of self, returning a vector mask of the results. In other words, this computes `[x.is_finite(), y.is_finite(), ...]...
addNo Documentation 🚧
selectCreates a vector from the elements in `if_true` and `if_false`, selecting which to use for each el...
mul-2No Documentation 🚧
rem-1No Documentation 🚧
divNo Documentation 🚧
normalizeReturns `self` normalized to length 1.0. For valid results, `self` must be finite and _not_ of len...
distance_squaredCompute the squared euclidean distance between two points in space.
minReturns a vector containing the minimum values for each element of `self` and `rhs`. In other word...
min_elementReturns the horizontal minimum of `self`. In other words this computes `min(x, y, ..)`.
fract_glReturns a vector containing the fractional part of the vector as `self - self.floor()`. Note that ...
clamp_lengthReturns a vector with a length no less than `min` and no more than `max`. # Panics Will panic if `min`...
copysignReturns a vector with signs of `rhs` and the magnitudes of `self`.
angle_betweenReturns the angle (in radians) between two vectors in the range `[0, +π]`. The inputs do not need to be unit vectors however they must be non-zero.
ceilReturns a vector containing the smallest integer greater than or equal to a number for each elemen...
rem-2No Documentation 🚧
splatCreates a vector with all elements set to `v`.
eqNo Documentation 🚧
div-1No Documentation 🚧
signumReturns a vector with elements representing the sign of `self`. - `1.0` if the number is positive,...
roundReturns a vector containing the nearest integer to a number for each element of `self`. Round half...
with_yCreates a 3D vector from `self` with the given value of `y`.
normalize_or_zeroReturns `self` normalized to length 1.0 if possible, else returns zero. In particular, if the inpu...
reject_from_normalizedReturns the vector rejection of `self` from `rhs`. The vector rejection is the vector perpendicula...
mulNo Documentation 🚧
element_sumReturns the sum of all elements of `self`. In other words, this computes `self.x + self.y + ..`.
is_normalizedReturns whether `self` is length `1.0` or not. Uses a precision threshold of approximately `1e-4`.
clamp_length_minReturns a vector with a length no less than `min`. # Panics Will panic if `min` is negative when `glam_assert` is enabled.
dot_into_vecReturns a vector where every component is the dot product of `self` and `rhs`.
extendCreates a 4D vector from `self` and the given `w` value.
sub-1No Documentation 🚧
from_vec4Creates a [`Vec3A`] from the `x`, `y` and `z` elements of `self` discarding `w`. On architectures where SIMD is supported such as SSE2 on `x86_64` this conversion is a noop.
as_ivec3Casts all elements of `self` to `i32`.

as_i64vec3

Casts all elements of self to i64.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec3No Documentation 🚧

to_array

[x, y, z]

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0[f32; 3]No Documentation 🚧

max

Returns a vector containing the maximum values for each element of self and rhs. In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

dot

Computes the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

add-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧
arg1Vec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

any_orthogonal_vector

Returns some vector that is orthogonal to the given one. The input vector must be finite and non-zero. The output vector is not necessarily unit length. For that use [Self::any_orthonormal_vector()] instead.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

with_z

Creates a 3D vector from self with the given value of z.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
zf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

normalize_or

Returns self normalized to length 1.0 if possible, else returns a fallback value. In particular, if the input is zero (or very close to zero), or non-finite, the result of this operation will be the fallback value. See also [Self::try_normalize()].

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
fallbackVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

is_negative_bitmask

Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of self. A negative element results in a 1 bit and a positive element in a 0 bit. Element x goes into the first lowest bit, element y into the second, etc.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

midpoint

Calculates the midpoint between self and rhs. The midpoint is the average of, or halfway point between, two vectors. a.midpoint(b) should yield the same result as a.lerp(b, 0.5) while being slightly cheaper to compute.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

rem_euclid

Returns the element-wise remainder of [Euclidean division] of self by rhs. [Euclidean division]: f32::rem_euclid

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

truncate

Creates a 2D vector from the x and y elements of self, discarding z. Truncation may also be performed by using [self.xy()][crate::swizzles::Vec3Swizzles::xy()].

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec2No Documentation 🚧

fract

Returns a vector containing the fractional part of the vector as self - self.trunc(). Note that this differs from the GLSL implementation of fract which returns self - self.floor(). Note that this is fast but not precise for large numbers.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

cmpge

Returns a vector mask containing the result of a >= comparison for each element of self and rhs. In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3ANo Documentation 🚧

rem

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

mul_add

Fused multiply-add. Computes (self * a) + b element-wise with only one rounding error, yielding a more accurate result than an unfused multiply-add. Using mul_add may be more performant than an unfused multiply-add if the target architecture has a dedicated fma CPU instruction. However, this is not always true, and will be heavily dependant on designing algorithms with specific target hardware in mind.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
aVec3ANo Documentation 🚧
bVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

project_onto

Returns the vector projection of self onto rhs. rhs must be of non-zero length.

Panics

Will panic if rhs is zero length when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

max_element

Returns the horizontal maximum of self. In other words this computes max(x, y, ..).

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two vectors contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧
max_abs_difff32No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

cmpeq

Returns a vector mask containing the result of a == comparison for each element of self and rhs. In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3ANo Documentation 🚧

length

Computes the length of self.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

lerp

Performs a linear interpolation between self and rhs based on the value s. When s is 0.0, the result will be equal to self. When s is 1.0, the result will be equal to rhs. When s is outside of range [0, 1], the result is linearly extrapolated.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧
sf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

cross

Computes the cross product of self and rhs.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

length_recip

Computes 1.0 / length(). For valid results, self must not be of length zero.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

floor

Returns a vector containing the largest integer less than or equal to a number for each element of self.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

as_u64vec3

Casts all elements of self to u64.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec3No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xf32No Documentation 🚧
yf32No Documentation 🚧
zf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

project_onto_normalized

Returns the vector projection of self onto rhs. rhs must be normalized.

Panics

Will panic if rhs is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

length_squared

Computes the squared length of self. This is faster than length() as it avoids a square root operation.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

reflect

Returns the reflection vector for a given incident vector self and surface normal normal. normal must be normalized.

Panics

Will panic if normal is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
normalVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

cmplt

Returns a vector mask containing the result of a < comparison for each element of self and rhs. In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3ANo Documentation 🚧

element_product

Returns the product of all elements of self. In other words, this computes self.x * self.y * ...

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

move_towards

Moves towards rhs based on the value d. When d is 0.0, the result will be equal to self. When d is equal to self.distance(rhs), the result will be equal to rhs. Will not go past rhs.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧
df32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

from_array

Creates a new vector from an array.

Arguments

NameTypeDocumentation
a[f32; 3]No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

cmpne

Returns a vector mask containing the result of a != comparison for each element of self and rhs. In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3ANo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

powf

Returns a vector containing each element of self raised to the power of n.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
nf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

as_dvec3

Casts all elements of self to f64.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec3No Documentation 🚧

trunc

Returns a vector containing the integer part each element of self. This means numbers are always truncated towards zero.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

div-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

exp

Returns a vector containing e^self (the exponential function) for each element of self.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

reject_from

Returns the vector rejection of self from rhs. The vector rejection is the vector perpendicular to the projection of self onto rhs, in rhs words the result of self - self.project_onto(rhs). rhs must be of non-zero length.

Panics

Will panic if rhs has a length of zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

is_nan

Returns true if any elements are NaN.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

div_euclid

Returns the element-wise quotient of [Euclidean division] of self by rhs.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

as_uvec3

Casts all elements of self to u32.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec3No Documentation 🚧

cmpgt

Returns a vector mask containing the result of a > comparison for each element of self and rhs. In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3ANo Documentation 🚧

clamp

Component-wise clamping of values, similar to [f32::clamp]. Each element in min must be less-or-equal to the corresponding element in max.

Panics

Will panic if min is greater than max when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
minVec3ANo Documentation 🚧
maxVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

cmple

Returns a vector mask containing the result of a <= comparison for each element of self and rhs. In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3ANo Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧
arg1Vec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

with_x

Creates a 3D vector from self with the given value of x.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
xf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

any_orthonormal_vector

Returns any unit vector that is orthogonal to the given one. The input vector must be unit length.

Panics

Will panic if self is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

is_nan_mask

Performs is_nan on each element of self, returning a vector mask of the results. In other words, this computes [x.is_nan(), y.is_nan(), ...].

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3ANo Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clamp_length_max

Returns a vector with a length no more than max.

Panics

Will panic if max is negative when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
maxf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

refract

Returns the refraction direction for a given incident vector self, surface normal normal and ratio of indices of refraction, eta. When total internal reflection occurs, a zero vector will be returned. self and normal must be normalized.

Panics

Will panic if self or normal is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
normalVec3ANo Documentation 🚧
etaf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

distance

Computes the Euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

sub-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

add-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

abs

Returns a vector containing the absolute value of each element of self.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

recip

Returns a vector containing the reciprocal 1.0/n of each element of self.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

is_finite_mask

Performs is_finite on each element of self, returning a vector mask of the results. In other words, this computes [x.is_finite(), y.is_finite(), ...].

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec3ANo Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

select

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self. A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

Arguments

NameTypeDocumentation
maskBVec3ANo Documentation 🚧
if_trueVec3ANo Documentation 🚧
if_falseVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

rem-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧
arg1Vec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

normalize

Returns self normalized to length 1.0. For valid results, self must be finite and not of length zero, nor very close to zero. See also [Self::try_normalize()] and [Self::normalize_or_zero()]. Panics Will panic if the resulting normalized vector is not finite when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

distance_squared

Compute the squared euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

min

Returns a vector containing the minimum values for each element of self and rhs. In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

min_element

Returns the horizontal minimum of self. In other words this computes min(x, y, ..).

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

fract_gl

Returns a vector containing the fractional part of the vector as self - self.floor(). Note that this differs from the Rust implementation of fract which returns self - self.trunc(). Note that this is fast but not precise for large numbers.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

clamp_length

Returns a vector with a length no less than min and no more than max.

Panics

Will panic if min is greater than max, or if either min or max is negative, when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
minf32No Documentation 🚧
maxf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

copysign

Returns a vector with signs of rhs and the magnitudes of self.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

angle_between

Returns the angle (in radians) between two vectors in the range [0, +π]. The inputs do not need to be unit vectors however they must be non-zero.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

ceil

Returns a vector containing the smallest integer greater than or equal to a number for each element of self.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

rem-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

splat

Creates a vector with all elements set to v.

Arguments

NameTypeDocumentation
vf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

div-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧
arg1Vec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

signum

Returns a vector with elements representing the sign of self.

  • 1.0 if the number is positive, +0.0 or INFINITY
  • -1.0 if the number is negative, -0.0 or NEG_INFINITY
  • NAN if the number is NAN

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

round

Returns a vector containing the nearest integer to a number for each element of self. Round half-way cases away from 0.0.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

with_y

Creates a 3D vector from self with the given value of y.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
yf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

normalize_or_zero

Returns self normalized to length 1.0 if possible, else returns zero. In particular, if the input is zero (or very close to zero), or non-finite, the result of this operation will be zero. See also [Self::try_normalize()].

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

reject_from_normalized

Returns the vector rejection of self from rhs. The vector rejection is the vector perpendicular to the projection of self onto rhs, in rhs words the result of self - self.project_onto(rhs). rhs must be normalized.

Panics

Will panic if rhs is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

element_sum

Returns the sum of all elements of self. In other words, this computes self.x + self.y + ...

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

is_normalized

Returns whether self is length 1.0 or not. Uses a precision threshold of approximately 1e-4.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

clamp_length_min

Returns a vector with a length no less than min.

Panics

Will panic if min is negative when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
minf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

dot_into_vec

Returns a vector where every component is the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
rhsVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

extend

Creates a 4D vector from self and the given w value.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧
wf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧
arg1Vec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

from_vec4

Creates a [Vec3A] from the x, y and z elements of self discarding w. On architectures where SIMD is supported such as SSE2 on x86_64 this conversion is a noop.

Arguments

NameTypeDocumentation
vVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3ANo Documentation 🚧

as_ivec3

Casts all elements of self to i32.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec3No Documentation 🚧

Vec4

Vec4

  • x:f32
  • y:f32
  • z:f32
  • w:f32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
is_nanReturns `true` if any elements are `NaN`.
is_finite_maskPerforms `is_finite` on each element of self, returning a vector mask of the results. In other words, this computes `[x.is_finite(), y.is_finite(), ...]...
to_array`[x, y, z, w]`
cmpltReturns a vector mask containing the result of a `<` comparison for each element of `self` and `rhs`...
divNo Documentation 🚧
cmpleReturns a vector mask containing the result of a `<=` comparison for each element of `self` and `rhs`...
as_i64vec4Casts all elements of `self` to `i64`.
move_towardsMoves towards `rhs` based on the value `d`. When `d` is `0.0`, the result will be equal to `self`....
newCreates a new vector.
rem-2No Documentation 🚧
cmpeqReturns a vector mask containing the result of a `==` comparison for each element of `self` and `rhs`...
as_uvec4Casts all elements of `self` to `u32`.
addNo Documentation 🚧
remNo Documentation 🚧
floorReturns a vector containing the largest integer less than or equal to a number for each element of...
sub-1No Documentation 🚧
distanceComputes the Euclidean distance between two points in space.
div_euclidReturns the element-wise quotient of [Euclidean division] of `self` by `rhs`.
copysignReturns a vector with signs of `rhs` and the magnitudes of `self`.
is_normalizedReturns whether `self` is length `1.0` or not. Uses a precision threshold of approximately `1e-4`.
dot_into_vecReturns a vector where every component is the dot product of `self` and `rhs`.
clamp_length_minReturns a vector with a length no less than `min`. # Panics Will panic if `min` is negative when `glam_assert` is enabled.
div-2No Documentation 🚧
expReturns a vector containing `e^self` (the exponential function) for each element of `self`.
with_wCreates a 4D vector from `self` with the given value of `w`.
eqNo Documentation 🚧
element_productReturns the product of all elements of `self`. In other words, this computes `self.x * self.y * .....
sub-2No Documentation 🚧
rem_euclidReturns the element-wise remainder of [Euclidean division] of `self` by `rhs`. [Euclidean division...
cloneNo Documentation 🚧
from_arrayCreates a new vector from an array.
normalizeReturns `self` normalized to length 1.0. For valid results, `self` must be finite and _not_ of len...
add-1No Documentation 🚧
as_ivec4Casts all elements of `self` to `i32`.
truncateCreates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. Truncation to [`Vec3`]...
fract_glReturns a vector containing the fractional part of the vector as `self - self.floor()`. Note that ...
is_negative_bitmaskReturns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`. A negat...
div-1No Documentation 🚧
splatCreates a vector with all elements set to `v`.
maxReturns a vector containing the maximum values for each element of `self` and `rhs`. In other word...
rem-1No Documentation 🚧
normalize_or_zeroReturns `self` normalized to length 1.0 if possible, else returns zero. In particular, if the inpu...
recipReturns a vector containing the reciprocal `1.0/n` of each element of `self`.
reject_from_normalizedReturns the vector rejection of `self` from `rhs`. The vector rejection is the vector perpendicula...
project_ontoReturns the vector projection of `self` onto `rhs`. `rhs` must be of non-zero length. # Panics W...
lengthComputes the length of `self`.
refractReturns the refraction direction for a given incident vector `self`, surface normal `normal` and r...
is_finiteReturns `true` if, and only if, all elements are finite. If any element is either `NaN`, positive...
element_sumReturns the sum of all elements of `self`. In other words, this computes `self.x + self.y + ..`.
selectCreates a vector from the elements in `if_true` and `if_false`, selecting which to use for each el...
midpointCalculates the midpoint between `self` and `rhs`. The midpoint is the average of, or halfway point...
signumReturns a vector with elements representing the sign of `self`. - `1.0` if the number is positive,...
clamp_lengthReturns a vector with a length no less than `min` and no more than `max`. # Panics Will panic if `min`...
with_zCreates a 4D vector from `self` with the given value of `z`.
cmpneReturns a vector mask containing the result of a `!=` comparison for each element of `self` and `rhs`...
length_recipComputes `1.0 / length()`. For valid results, `self` must _not_ be of length zero.
mul-1No Documentation 🚧
mul_addFused multiply-add. Computes `(self * a) + b` element-wise with only one rounding error, yielding a more accurate result than an unfused multiply-add. Using `mul_add` *may* be more performant than an unfused multiply-add if the target architecture has a dedicated fma CPU instruction. However, this is not always true, and will be heavily dependant on designing algorithms with specific target hardware in mind.
mulNo Documentation 🚧
length_squaredComputes the squared length of `self`. This is faster than `length()` as it avoids a square root o...
add-2No Documentation 🚧
as_dvec4Casts all elements of `self` to `f64`.
negNo Documentation 🚧
cmpgeReturns a vector mask containing the result of a `>=` comparison for each element of `self` and `rhs`...
reject_fromReturns the vector rejection of `self` from `rhs`. The vector rejection is the vector perpendicula...
as_u64vec4Casts all elements of `self` to `u64`.
distance_squaredCompute the squared euclidean distance between two points in space.
dotComputes the dot product of `self` and `rhs`.
absReturns a vector containing the absolute value of each element of `self`.
lerpPerforms a linear interpolation between `self` and `rhs` based on the value `s`. When `s` is `0.0`...
with_xCreates a 4D vector from `self` with the given value of `x`.
abs_diff_eqReturns true if the absolute difference of all elements between `self` and `rhs` is less than or e...
reflectReturns the reflection vector for a given incident vector `self` and surface normal `normal`. `normal`...
roundReturns a vector containing the nearest integer to a number for each element of `self`. Round half...
with_yCreates a 4D vector from `self` with the given value of `y`.
mul-2No Documentation 🚧
subNo Documentation 🚧
is_nan_maskPerforms `is_nan` on each element of self, returning a vector mask of the results. In other words, this computes `[x.is_nan(), y.is_nan(), ...]...
clampComponent-wise clamping of values, similar to [`f32::clamp`]. Each element in `min` must be less-or-equal to the corresponding element in `max`. # Panics Will panic if `min` is greater than `max` when `glam_assert` is enabled.
cmpgtReturns a vector mask containing the result of a `>` comparison for each element of `self` and `rhs`...
truncReturns a vector containing the integer part each element of `self`. This means numbers are always...
fractReturns a vector containing the fractional part of the vector as `self - self.trunc()`. Note that ...
clamp_length_maxReturns a vector with a length no more than `max`. # Panics Will panic if `max` is negative when `glam_assert` is enabled.
project_onto_normalizedReturns the vector projection of `self` onto `rhs`. `rhs` must be normalized. # Panics Will pani...
min_elementReturns the horizontal minimum of `self`. In other words this computes `min(x, y, ..)`.
normalize_orReturns `self` normalized to length 1.0 if possible, else returns a fallback value. In particular...
powfReturns a vector containing each element of `self` raised to the power of `n`.
ceilReturns a vector containing the smallest integer greater than or equal to a number for each elemen...
minReturns a vector containing the minimum values for each element of `self` and `rhs`. In other word...
max_elementReturns the horizontal maximum of `self`. In other words this computes `max(x, y, ..)`.

is_nan

Returns true if any elements are NaN.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_finite_mask

Performs is_finite on each element of self, returning a vector mask of the results. In other words, this computes [x.is_finite(), y.is_finite(), ...].

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4ANo Documentation 🚧

to_array

[x, y, z, w]

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0[f32; 4]No Documentation 🚧

cmplt

Returns a vector mask containing the result of a < comparison for each element of self and rhs. In other words this computes [self.x < rhs.x, self.y < rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4ANo Documentation 🚧

div

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

cmple

Returns a vector mask containing the result of a <= comparison for each element of self and rhs. In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4ANo Documentation 🚧

as_i64vec4

Casts all elements of self to i64.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0I64Vec4No Documentation 🚧

move_towards

Moves towards rhs based on the value d. When d is 0.0, the result will be equal to self. When d is equal to self.distance(rhs), the result will be equal to rhs. Will not go past rhs.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧
df32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xf32No Documentation 🚧
yf32No Documentation 🚧
zf32No Documentation 🚧
wf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

rem-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec4No Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

cmpeq

Returns a vector mask containing the result of a == comparison for each element of self and rhs. In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4ANo Documentation 🚧

as_uvec4

Casts all elements of self to u32.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0UVec4No Documentation 🚧

add

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

rem

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

floor

Returns a vector containing the largest integer less than or equal to a number for each element of self.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

sub-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec4No Documentation 🚧
arg1Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

distance

Computes the Euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

div_euclid

Returns the element-wise quotient of [Euclidean division] of self by rhs.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

copysign

Returns a vector with signs of rhs and the magnitudes of self.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

is_normalized

Returns whether self is length 1.0 or not. Uses a precision threshold of approximately 1e-4.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

dot_into_vec

Returns a vector where every component is the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

clamp_length_min

Returns a vector with a length no less than min.

Panics

Will panic if min is negative when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
minf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

div-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec4No Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

exp

Returns a vector containing e^self (the exponential function) for each element of self.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

with_w

Creates a 4D vector from self with the given value of w.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
wf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

element_product

Returns the product of all elements of self. In other words, this computes self.x * self.y * ...

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

sub-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec4No Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

rem_euclid

Returns the element-wise remainder of [Euclidean division] of self by rhs. [Euclidean division]: f32::rem_euclid

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

from_array

Creates a new vector from an array.

Arguments

NameTypeDocumentation
a[f32; 4]No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

normalize

Returns self normalized to length 1.0. For valid results, self must be finite and not of length zero, nor very close to zero. See also [Self::try_normalize()] and [Self::normalize_or_zero()]. Panics Will panic if the resulting normalized vector is not finite when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

add-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec4No Documentation 🚧
arg1Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

as_ivec4

Casts all elements of self to i32.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0IVec4No Documentation 🚧

truncate

Creates a 3D vector from the x, y and z elements of self, discarding w. Truncation to [Vec3] may also be performed by using [self.xyz()][crate::swizzles::Vec4Swizzles::xyz()]. To truncate to [Vec3A] use [Vec3A::from()].

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec3No Documentation 🚧

fract_gl

Returns a vector containing the fractional part of the vector as self - self.floor(). Note that this differs from the Rust implementation of fract which returns self - self.trunc(). Note that this is fast but not precise for large numbers.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

is_negative_bitmask

Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of self. A negative element results in a 1 bit and a positive element in a 0 bit. Element x goes into the first lowest bit, element y into the second, etc.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0u32No Documentation 🚧

div-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec4No Documentation 🚧
arg1Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

splat

Creates a vector with all elements set to v.

Arguments

NameTypeDocumentation
vf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

max

Returns a vector containing the maximum values for each element of self and rhs. In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

rem-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec4No Documentation 🚧
arg1Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

normalize_or_zero

Returns self normalized to length 1.0 if possible, else returns zero. In particular, if the input is zero (or very close to zero), or non-finite, the result of this operation will be zero. See also [Self::try_normalize()].

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

recip

Returns a vector containing the reciprocal 1.0/n of each element of self.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

reject_from_normalized

Returns the vector rejection of self from rhs. The vector rejection is the vector perpendicular to the projection of self onto rhs, in rhs words the result of self - self.project_onto(rhs). rhs must be normalized.

Panics

Will panic if rhs is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

project_onto

Returns the vector projection of self onto rhs. rhs must be of non-zero length.

Panics

Will panic if rhs is zero length when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

length

Computes the length of self.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

refract

Returns the refraction direction for a given incident vector self, surface normal normal and ratio of indices of refraction, eta. When total internal reflection occurs, a zero vector will be returned. self and normal must be normalized.

Panics

Will panic if self or normal is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
normalVec4No Documentation 🚧
etaf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

is_finite

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

element_sum

Returns the sum of all elements of self. In other words, this computes self.x + self.y + ...

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

select

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self. A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

Arguments

NameTypeDocumentation
maskBVec4ANo Documentation 🚧
if_trueVec4No Documentation 🚧
if_falseVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

midpoint

Calculates the midpoint between self and rhs. The midpoint is the average of, or halfway point between, two vectors. a.midpoint(b) should yield the same result as a.lerp(b, 0.5) while being slightly cheaper to compute.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

signum

Returns a vector with elements representing the sign of self.

  • 1.0 if the number is positive, +0.0 or INFINITY
  • -1.0 if the number is negative, -0.0 or NEG_INFINITY
  • NAN if the number is NAN

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

clamp_length

Returns a vector with a length no less than min and no more than max.

Panics

Will panic if min is greater than max, or if either min or max is negative, when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
minf32No Documentation 🚧
maxf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

with_z

Creates a 4D vector from self with the given value of z.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
zf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

cmpne

Returns a vector mask containing the result of a != comparison for each element of self and rhs. In other words this computes [self.x != rhs.x, self.y != rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4ANo Documentation 🚧

length_recip

Computes 1.0 / length(). For valid results, self must not be of length zero.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

mul-1

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec4No Documentation 🚧
arg1Vec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

mul_add

Fused multiply-add. Computes (self * a) + b element-wise with only one rounding error, yielding a more accurate result than an unfused multiply-add. Using mul_add may be more performant than an unfused multiply-add if the target architecture has a dedicated fma CPU instruction. However, this is not always true, and will be heavily dependant on designing algorithms with specific target hardware in mind.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
aVec4No Documentation 🚧
bVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

mul

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

length_squared

Computes the squared length of self. This is faster than length() as it avoids a square root operation.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

add-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec4No Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

as_dvec4

Casts all elements of self to f64.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0DVec4No Documentation 🚧

neg

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

cmpge

Returns a vector mask containing the result of a >= comparison for each element of self and rhs. In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4ANo Documentation 🚧

reject_from

Returns the vector rejection of self from rhs. The vector rejection is the vector perpendicular to the projection of self onto rhs, in rhs words the result of self - self.project_onto(rhs). rhs must be of non-zero length.

Panics

Will panic if rhs has a length of zero when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

as_u64vec4

Casts all elements of self to u64.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0U64Vec4No Documentation 🚧

distance_squared

Compute the squared euclidean distance between two points in space.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

dot

Computes the dot product of self and rhs.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

abs

Returns a vector containing the absolute value of each element of self.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

lerp

Performs a linear interpolation between self and rhs based on the value s. When s is 0.0, the result will be equal to self. When s is 1.0, the result will be equal to rhs. When s is outside of range [0, 1], the result is linearly extrapolated.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧
sf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

with_x

Creates a 4D vector from self with the given value of x.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
xf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

abs_diff_eq

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff. This can be used to compare if two vectors contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against. For more see comparing floating point numbers.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧
max_abs_difff32No Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

reflect

Returns the reflection vector for a given incident vector self and surface normal normal. normal must be normalized.

Panics

Will panic if normal is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
normalVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

round

Returns a vector containing the nearest integer to a number for each element of self. Round half-way cases away from 0.0.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

with_y

Creates a 4D vector from self with the given value of y.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
yf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

mul-2

No Documentation 🚧

Arguments

NameTypeDocumentation
arg0Vec4No Documentation 🚧
arg1f32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

sub

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

is_nan_mask

Performs is_nan on each element of self, returning a vector mask of the results. In other words, this computes [x.is_nan(), y.is_nan(), ...].

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4ANo Documentation 🚧

clamp

Component-wise clamping of values, similar to [f32::clamp]. Each element in min must be less-or-equal to the corresponding element in max.

Panics

Will panic if min is greater than max when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
minVec4No Documentation 🚧
maxVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

cmpgt

Returns a vector mask containing the result of a > comparison for each element of self and rhs. In other words this computes [self.x > rhs.x, self.y > rhs.y, ..] for all elements.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0BVec4ANo Documentation 🚧

trunc

Returns a vector containing the integer part each element of self. This means numbers are always truncated towards zero.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

fract

Returns a vector containing the fractional part of the vector as self - self.trunc(). Note that this differs from the GLSL implementation of fract which returns self - self.floor(). Note that this is fast but not precise for large numbers.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

clamp_length_max

Returns a vector with a length no more than max.

Panics

Will panic if max is negative when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
maxf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

project_onto_normalized

Returns the vector projection of self onto rhs. rhs must be normalized.

Panics

Will panic if rhs is not normalized when glam_assert is enabled.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

min_element

Returns the horizontal minimum of self. In other words this computes min(x, y, ..).

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

normalize_or

Returns self normalized to length 1.0 if possible, else returns a fallback value. In particular, if the input is zero (or very close to zero), or non-finite, the result of this operation will be the fallback value. See also [Self::try_normalize()].

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
fallbackVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

powf

Returns a vector containing each element of self raised to the power of n.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
nf32No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

ceil

Returns a vector containing the smallest integer greater than or equal to a number for each element of self.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

min

Returns a vector containing the minimum values for each element of self and rhs. In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..].

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0Vec4No Documentation 🚧

max_element

Returns the horizontal maximum of self. In other words this computes max(x, y, ..).

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
arg0f32No Documentation 🚧

SmolStr

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
is_heap_allocatedNo Documentation 🚧
eqNo Documentation 🚧
is_emptyNo Documentation 🚧
to_stringNo Documentation 🚧
lenNo Documentation 🚧
cloneNo Documentation 🚧

is_heap_allocated

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfSmolStrNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfSmolStrNo Documentation 🚧
otherSmolStrNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

is_empty

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfSmolStrNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

to_string

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfSmolStrNo Documentation 🚧

Returns

NameTypeDocumentation
arg0StringNo Documentation 🚧

len

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfSmolStrNo Documentation 🚧

Returns

NameTypeDocumentation
arg0usizeNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfSmolStrNo Documentation 🚧

Returns

NameTypeDocumentation
arg0SmolStrNo Documentation 🚧

Uuid

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
to_bytes_leReturns the bytes of the UUID in little-endian order. The bytes will be flipped to convert into li...
assert_receiver_is_total_eqNo Documentation 🚧
to_u128_leReturns a 128bit little-endian value containing the value. The bytes in the `u128` will be flipped...
get_node_idIf the UUID is the correct version (v1, or v6) this will return the node value as a 6-byte array. ...
as_u128Returns a 128bit value containing the value. The bytes in the UUID will be packed directly into a `u128`...
new_v4Creates a random UUID. This uses the [`getrandom`] crate to utilise the operating system's RNG as the source of random numbers. If you'd like to use a custom generator, don't use this method: generate random bytes using your custom generator and pass them to the [`uuid::Builder::from_random_bytes`]...
is_nilTests if the UUID is nil (all zeros).
eqNo Documentation 🚧
from_u128Creates a UUID from a 128bit value. # Examples Basic usage: ``` # use uuid::Uuid; let v = 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8u128; let uuid = Uuid::from_u128(v); assert_eq!( "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8", uuid.hyphenated().to_string(), ); ```
maxThe 'max UUID' (all ones). The max UUID is a special form of UUID that is specified to have all 1...
as_u64_pairReturns two 64bit values containing the value. The bytes in the UUID will be split into two `u64`....
from_u128_leCreates a UUID from a 128bit value in little-endian order. The entire value will be flipped to con...
from_bytesCreates a UUID using the supplied bytes. # Examples Basic usage: ``` # fn main() -> Result<(), uuid::Error> { # use uuid::Uuid; let bytes = [ 0xa1, 0xa2, 0xa3, 0xa4, 0xb1, 0xb2, 0xc1, 0xc2, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, ]; let uuid = Uuid::from_bytes(bytes); assert_eq!( uuid.hyphenated().to_string(), "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8" ); # Ok(()) # } ```
encode_bufferA buffer that can be used for `encode_...` calls, that is guaranteed to be long enough for any of the format adapters. # Examples ``` # use uuid::Uuid; let uuid = Uuid::nil(); assert_...
is_maxTests if the UUID is max (all ones).
from_u64_pairCreates a UUID from two 64bit values. # Examples Basic usage: ``` # use uuid::Uuid; let hi = 0xa1a2a3a4b1b2c1c2u64; let lo = 0xd1d2d3d4d5d6d7d8u64; let uuid = Uuid::from_u64_pair(hi, lo); assert_eq!( "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8", uuid.hyphenated().to_string(), ); `...
nilThe 'nil UUID' (all zeros). The nil UUID is a special form of UUID that is specified to have all ...
into_bytesConsumes self and returns the underlying byte value of the UUID. # Examples ``` # use uuid::Uuid; let bytes = [ 0xa1, 0xa2, 0xa3, 0xa4, 0xb1, 0xb2, 0xc1, 0xc2, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, ]; let uuid = Uuid::from_bytes(bytes); assert_eq!(bytes, uuid.into_bytes()); ```
from_bytes_leCreates a UUID using the supplied bytes in little endian order. The individual fields encoded in t...
get_version_numReturns the version number of the UUID. This represents the algorithm used to generate the value. ...
cloneNo Documentation 🚧

to_bytes_le

Returns the bytes of the UUID in little-endian order. The bytes will be flipped to convert into little-endian order. This is based on the endianness of the UUID, rather than the target environment so bytes will be flipped on both big and little endian machines.

Examples

use uuid::Uuid;
# fn main() -> Result<(), uuid::Error> {
let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?;
assert_eq!(
    uuid.to_bytes_le(),
    ([
        0xa4, 0xa3, 0xa2, 0xa1, 0xb2, 0xb1, 0xc2, 0xc1, 0xd1, 0xd2,
        0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8
    ])
);
# Ok(())
# }

Arguments

NameTypeDocumentation
_selfUuidNo Documentation 🚧

Returns

NameTypeDocumentation
arg0[u8; 16]No Documentation 🚧

assert_receiver_is_total_eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUuidNo Documentation 🚧

Returns

NameTypeDocumentation
arg0()No Documentation 🚧

to_u128_le

Returns a 128bit little-endian value containing the value. The bytes in the u128 will be flipped to convert into big-endian order. This is based on the endianness of the UUID, rather than the target environment so bytes will be flipped on both big and little endian machines. Note that this will produce a different result than [Uuid::to_fields_le], because the entire UUID is reversed, rather than reversing the individual fields in-place.

Examples

# use uuid::Uuid;
# fn main() -> Result<(), uuid::Error> {
let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?;
assert_eq!(
    uuid.to_u128_le(),
    0xd8d7d6d5d4d3d2d1c2c1b2b1a4a3a2a1,
);
# Ok(())
# }

Arguments

NameTypeDocumentation
_selfUuidNo Documentation 🚧

Returns

NameTypeDocumentation
arg0u128No Documentation 🚧

get_node_id

If the UUID is the correct version (v1, or v6) this will return the node value as a 6-byte array. For other versions this will return None.

Arguments

NameTypeDocumentation
_selfUuidNo Documentation 🚧

Returns

NameTypeDocumentation
arg0Optional<[u8; 6]>No Documentation 🚧

as_u128

Returns a 128bit value containing the value. The bytes in the UUID will be packed directly into a u128.

Examples

# use uuid::Uuid;
# fn main() -> Result<(), uuid::Error> {
let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?;
assert_eq!(
    uuid.as_u128(),
    0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8,
);
# Ok(())
# }

Arguments

NameTypeDocumentation
_selfUuidNo Documentation 🚧

Returns

NameTypeDocumentation
arg0u128No Documentation 🚧

new_v4

Creates a random UUID. This uses the [getrandom] crate to utilise the operating system's RNG as the source of random numbers. If you'd like to use a custom generator, don't use this method: generate random bytes using your custom generator and pass them to the [uuid::Builder::from_random_bytes][from_random_bytes] function instead. Note that usage of this method requires the v4 feature of this crate to be enabled.

Examples

Basic usage:

# use uuid::{Uuid, Version};
let uuid = Uuid::new_v4();
assert_eq!(Some(Version::Random), uuid.get_version());

References

  • UUID Version 4 in RFC 9562 [getrandom]: https://crates.io/crates/getrandom [from_random_bytes]: struct.Builder.html#method.from_random_bytes

Arguments

Returns

NameTypeDocumentation
arg0UuidNo Documentation 🚧

is_nil

Tests if the UUID is nil (all zeros).

Arguments

NameTypeDocumentation
_selfUuidNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

eq

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUuidNo Documentation 🚧
otherUuidNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_u128

Creates a UUID from a 128bit value.

Examples

Basic usage:

# use uuid::Uuid;
let v = 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8u128;
let uuid = Uuid::from_u128(v);
assert_eq!(
    "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8",
    uuid.hyphenated().to_string(),
);

Arguments

NameTypeDocumentation
vu128No Documentation 🚧

Returns

NameTypeDocumentation
arg0UuidNo Documentation 🚧

max

The 'max UUID' (all ones). The max UUID is a special form of UUID that is specified to have all 128 bits set to one.

References

Examples

Basic usage:

# use uuid::Uuid;
let uuid = Uuid::max();
assert_eq!(
    "ffffffff-ffff-ffff-ffff-ffffffffffff",
    uuid.hyphenated().to_string(),
);

Arguments

Returns

NameTypeDocumentation
arg0UuidNo Documentation 🚧

as_u64_pair

Returns two 64bit values containing the value. The bytes in the UUID will be split into two u64. The first u64 represents the 64 most significant bits, the second one represents the 64 least significant.

Examples

# use uuid::Uuid;
# fn main() -> Result<(), uuid::Error> {
let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?;
assert_eq!(
    uuid.as_u64_pair(),
    (0xa1a2a3a4b1b2c1c2, 0xd1d2d3d4d5d6d7d8),
);
# Ok(())
# }

Arguments

NameTypeDocumentation
_selfUuidNo Documentation 🚧

Returns

NameTypeDocumentation
arg0(u64, u64)No Documentation 🚧

from_u128_le

Creates a UUID from a 128bit value in little-endian order. The entire value will be flipped to convert into big-endian order. This is based on the endianness of the UUID, rather than the target environment so bytes will be flipped on both big and little endian machines.

Examples

Basic usage:

# use uuid::Uuid;
let v = 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8u128;
let uuid = Uuid::from_u128_le(v);
assert_eq!(
    "d8d7d6d5-d4d3-d2d1-c2c1-b2b1a4a3a2a1",
    uuid.hyphenated().to_string(),
);

Arguments

NameTypeDocumentation
vu128No Documentation 🚧

Returns

NameTypeDocumentation
arg0UuidNo Documentation 🚧

from_bytes

Creates a UUID using the supplied bytes.

Examples

Basic usage:

# fn main() -> Result<(), uuid::Error> {
# use uuid::Uuid;
let bytes = [
    0xa1, 0xa2, 0xa3, 0xa4,
    0xb1, 0xb2,
    0xc1, 0xc2,
    0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
];
let uuid = Uuid::from_bytes(bytes);
assert_eq!(
    uuid.hyphenated().to_string(),
    "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8"
);
# Ok(())
# }

Arguments

NameTypeDocumentation
bytes[u8; 16]No Documentation 🚧

Returns

NameTypeDocumentation
arg0UuidNo Documentation 🚧

encode_buffer

A buffer that can be used for encode_... calls, that is guaranteed to be long enough for any of the format adapters.

Examples

# use uuid::Uuid;
let uuid = Uuid::nil();
assert_eq!(
    uuid.simple().encode_lower(&mut Uuid::encode_buffer()),
    "00000000000000000000000000000000"
);
assert_eq!(
    uuid.hyphenated()
        .encode_lower(&mut Uuid::encode_buffer()),
    "00000000-0000-0000-0000-000000000000"
);
assert_eq!(
    uuid.urn().encode_lower(&mut Uuid::encode_buffer()),
    "urn:uuid:00000000-0000-0000-0000-000000000000"
);

Arguments

Returns

NameTypeDocumentation
arg0[u8; 45]No Documentation 🚧

is_max

Tests if the UUID is max (all ones).

Arguments

NameTypeDocumentation
_selfUuidNo Documentation 🚧

Returns

NameTypeDocumentation
arg0boolNo Documentation 🚧

from_u64_pair

Creates a UUID from two 64bit values.

Examples

Basic usage:

# use uuid::Uuid;
let hi = 0xa1a2a3a4b1b2c1c2u64;
let lo = 0xd1d2d3d4d5d6d7d8u64;
let uuid = Uuid::from_u64_pair(hi, lo);
assert_eq!(
    "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8",
    uuid.hyphenated().to_string(),
);

Arguments

NameTypeDocumentation
high_bitsu64No Documentation 🚧
low_bitsu64No Documentation 🚧

Returns

NameTypeDocumentation
arg0UuidNo Documentation 🚧

nil

The 'nil UUID' (all zeros). The nil UUID is a special form of UUID that is specified to have all 128 bits set to zero.

References

Examples

Basic usage:

# use uuid::Uuid;
let uuid = Uuid::nil();
assert_eq!(
    "00000000-0000-0000-0000-000000000000",
    uuid.hyphenated().to_string(),
);

Arguments

Returns

NameTypeDocumentation
arg0UuidNo Documentation 🚧

into_bytes

Consumes self and returns the underlying byte value of the UUID.

Examples

# use uuid::Uuid;
let bytes = [
    0xa1, 0xa2, 0xa3, 0xa4,
    0xb1, 0xb2,
    0xc1, 0xc2,
    0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
];
let uuid = Uuid::from_bytes(bytes);
assert_eq!(bytes, uuid.into_bytes());

Arguments

NameTypeDocumentation
_selfUuidNo Documentation 🚧

Returns

NameTypeDocumentation
arg0[u8; 16]No Documentation 🚧

from_bytes_le

Creates a UUID using the supplied bytes in little endian order. The individual fields encoded in the buffer will be flipped.

Examples

Basic usage:

# fn main() -> Result<(), uuid::Error> {
# use uuid::Uuid;
let bytes = [
    0xa1, 0xa2, 0xa3, 0xa4,
    0xb1, 0xb2,
    0xc1, 0xc2,
    0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
];
let uuid = Uuid::from_bytes_le(bytes);
assert_eq!(
    "a4a3a2a1-b2b1-c2c1-d1d2-d3d4d5d6d7d8",
    uuid.hyphenated().to_string(),
);
# Ok(())
# }

Arguments

NameTypeDocumentation
b[u8; 16]No Documentation 🚧

Returns

NameTypeDocumentation
arg0UuidNo Documentation 🚧

get_version_num

Returns the version number of the UUID. This represents the algorithm used to generate the value. This method is the future-proof alternative to [Uuid::get_version].

Examples

Basic usage:

# use uuid::Uuid;
# fn main() -> Result<(), uuid::Error> {
let my_uuid = Uuid::parse_str("02f09a3f-1624-3b1d-8409-44eff7708208")?;
assert_eq!(3, my_uuid.get_version_num());
# Ok(())
# }

References

Arguments

NameTypeDocumentation
_selfUuidNo Documentation 🚧

Returns

NameTypeDocumentation
arg0usizeNo Documentation 🚧

clone

No Documentation 🚧

Arguments

NameTypeDocumentation
_selfUuidNo Documentation 🚧

Returns

NameTypeDocumentation
arg0UuidNo Documentation 🚧

DynamicFunctionMut

Opaque Type. 🔒

Description

A dynamic mutable script function.

Associated Functions

For function details and documentation, click on the function link.

FunctionCallContext

Opaque Type. 🔒

Description

The caller context when calling a script function. Functions can choose to react to caller preferences such as converting 1-indexed numbers to 0-indexed numbers

Associated Functions

For function details and documentation, click on the function link.

PathBuf

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

String

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Focus

Focus

  1. core::option::Option<bevy_ecs::entity::Entity>

Description

Resource representing which entity has keyboard focus, if any.

Associated Functions

For function details and documentation, click on the function link.

ActiveAnimation

ActiveAnimation

  • weight:f32
  • repeat:bevy_animation::RepeatAnimation
  • speed:f32
  • elapsed:f32
  • seek_time:f32
  • last_seek_time:core::option::Option
  • completions:u32
  • just_completed:bool
  • paused:bool

Description

An animation that an [AnimationPlayer] is currently either playing or was playing, but is presently paused.

An stopped animation is considered no longer active.

Associated Functions

For function details and documentation, click on the function link.

AnimationClip

AnimationClip

  • events:bevy_utils::hashbrown::HashMap<bevy_animation::AnimationEventTarget, alloc::vec::Vec<bevy_animation::TimedAnimationEvent>, bevy_utils::hashbrown::hash_map::DefaultHashBuilder>
  • duration:f32

Description

A list of [VariableCurve]s and the [AnimationTargetId]s to which they apply.

Because animation clips refer to targets by UUID, they can target any [AnimationTarget] with that ID.

Associated Functions

For function details and documentation, click on the function link.

AnimationEvent

AnimationEvent

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

AnimationEventTarget

Root

Node

  1. bevy_animation::AnimationTargetId

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

AnimationPlayer

AnimationPlayer

  • active_animations:bevy_utils::hashbrown::HashMap<petgraph::graph::NodeIndex, bevy_animation::ActiveAnimation, bevy_utils::hashbrown::hash_map::DefaultHashBuilder>
  • blend_weights:bevy_utils::hashbrown::HashMap<petgraph::graph::NodeIndex, f32, bevy_utils::hashbrown::hash_map::DefaultHashBuilder>

Description

Animation controls.

Automatically added to any root animations of a scene when it is spawned.

Associated Functions

For function details and documentation, click on the function link.

AnimationTarget

AnimationTarget

  • id:bevy_animation::AnimationTargetId
  • player:bevy_ecs::entity::Entity

Description

An entity that can be animated by an [AnimationPlayer].

These are frequently referred to as bones or joints, because they often refer to individually-animatable parts of an armature.

Asset loaders for armatures are responsible for adding these as necessary. Typically, they're generated from hashed versions of the entire name path from the root of the armature to the bone. See the [AnimationTargetId] documentation for more details.

By convention, asset loaders add [AnimationTarget] components to the descendants of an [AnimationPlayer], as well as to the [AnimationPlayer] entity itself, but Bevy doesn't require this in any way. So, for example, it's entirely possible for an [AnimationPlayer] to animate a target that it isn't an ancestor of. If you add a new bone to or delete a bone from an armature at runtime, you may want to update the [AnimationTarget] component as appropriate, as Bevy won't do this automatically.

Note that each entity can only be animated by one animation player at a time. However, you can change [AnimationTarget]'s player property at runtime to change which player is responsible for animating the entity.

Associated Functions

For function details and documentation, click on the function link.

AnimationTargetId

AnimationTargetId

  1. uuid::Uuid

Description

A unique UUID for an animation target (e.g. bone in a skinned mesh).

The [AnimationClip] asset and the [AnimationTarget] component both use this to refer to targets (e.g. bones in a skinned mesh) to be animated.

When importing an armature or an animation clip, asset loaders typically use the full path name from the armature to the bone to generate these UUIDs. The ID is unique to the full path name and based only on the names. So, for example, any imported armature with a bone at the root named Hips will assign the same [AnimationTargetId] to its root bone. Likewise, any imported animation clip that animates a root bone named Hips will reference the same [AnimationTargetId]. Any animation is playable on any armature as long as the bone names match, which allows for easy animation retargeting.

Note that asset loaders generally use the full path name to generate the [AnimationTargetId]. Thus a bone named Chest directly connected to a bone named Hips will have a different ID from a bone named Chest that's connected to a bone named Stomach.

Associated Functions

For function details and documentation, click on the function link.

RepeatAnimation

Never

Count

  1. u32

Forever

Description

Repetition behavior of an animation.

Associated Functions

For function details and documentation, click on the function link.

TimedAnimationEvent

TimedAnimationEvent

  • time:f32
  • event:bevy_animation::AnimationEvent

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

AnimationGraph

AnimationGraph

  • graph:petgraph::graph::DiGraph<bevy_animation::graph::AnimationGraphNode, (), u32>
  • root:petgraph::graph::NodeIndex
  • mask_groups:bevy_utils::hashbrown::HashMap<bevy_animation::AnimationTargetId, u64, bevy_utils::hashbrown::hash_map::DefaultHashBuilder>

Description

A graph structure that describes how animation clips are to be blended together.

Applications frequently want to be able to play multiple animations at once and to fine-tune the influence that animations have on a skinned mesh. Bevy uses an animation graph to store this information. Animation graphs are a directed acyclic graph (DAG) that describes how animations are to be weighted and combined together. Every frame, Bevy evaluates the graph from the root and blends the animations together in a bottom-up fashion to produce the final pose.

There are three types of nodes: blend nodes, add nodes, and clip nodes, all of which can have an associated weight. Blend nodes and add nodes have no associated animation clip and combine the animations of their children according to those children's weights. Clip nodes specify an animation clip to play. When a graph is created, it starts with only a single blend node, the root node.

For example, consider the following graph:

┌────────────┐                                      
│            │                                      
│    Idle    ├─────────────────────┐                
│            │                     │                
└────────────┘                     │                
                                   │                
┌────────────┐                     │  ┌────────────┐
│            │                     │  │            │
│    Run     ├──┐                  ├──┤    Root    │
│            │  │  ┌────────────┐  │  │            │
└────────────┘  │  │   Blend    │  │  └────────────┘
                ├──┤            ├──┘                
┌────────────┐  │  │    0.5     │                   
│            │  │  └────────────┘                   
│    Walk    ├──┘                                   
│            │                                      
└────────────┘                                      

In this case, assuming that Idle, Run, and Walk are all playing with weight 1.0, the Run and Walk animations will be equally blended together, then their weights will be halved and finally blended with the Idle animation. Thus the weight of Run and Walk are effectively half of the weight of Idle.

Nodes can optionally have a mask, a bitfield that restricts the set of animation targets that the node and its descendants affect. Each bit in the mask corresponds to a mask group, which is a set of animation targets (bones). An animation target can belong to any number of mask groups within the context of an animation graph.

When the appropriate bit is set in a node's mask, neither the node nor its descendants will animate any animation targets belonging to that mask group. That is, setting a mask bit to 1 disables the animation targets in that group. If an animation target belongs to multiple mask groups, masking any one of the mask groups that it belongs to will mask that animation target. (Thus an animation target will only be animated if all of its mask groups are unmasked.)

A common use of masks is to allow characters to hold objects. For this, the typical workflow is to assign each character's hand to a mask group. Then, when the character picks up an object, the application masks out the hand that the object is held in for the character's animation set, then positions the hand's digits as necessary to grasp the object. The character's animations will continue to play but will not affect the hand, which will continue to be depicted as holding the object.

Animation graphs are assets and can be serialized to and loaded from RON files. Canonically, such files have an .animgraph.ron extension.

The animation graph implements RFC 51. See that document for more information.

Associated Functions

For function details and documentation, click on the function link.

AnimationGraphHandle

AnimationGraphHandle

  1. bevy_asset::handle::Handle<bevy_animation::graph::AnimationGraph>

Description

A [Handle] to the [AnimationGraph] to be used by the AnimationPlayer on the same entity.

Associated Functions

For function details and documentation, click on the function link.

ThreadedAnimationGraph

ThreadedAnimationGraph

Description

An acceleration structure for an animation graph that allows Bevy to evaluate it quickly.

This is kept up to date as the associated [AnimationGraph] instance is added, modified, or removed.

Associated Functions

For function details and documentation, click on the function link.

ThreadedAnimationGraphs

ThreadedAnimationGraphs

  1. bevy_utils::hashbrown::HashMap<bevy_asset::id::AssetId<bevy_animation::graph::AnimationGraph>, bevy_animation::graph::ThreadedAnimationGraph, bevy_utils::hashbrown::hash_map::DefaultHashBuilder>

Description

Acceleration structures for animation graphs that allows Bevy to evaluate them quickly.

These are kept up to date as [AnimationGraph] instances are added, modified, and removed.

Associated Functions

For function details and documentation, click on the function link.

AnimationTransition

AnimationTransition

  • current_weight:f32
  • weight_decline_per_sec:f32
  • animation:petgraph::graph::NodeIndex

Description

An animation that is being faded out as part of a transition

Associated Functions

For function details and documentation, click on the function link.

AnimationTransitions

AnimationTransitions

  • main_animation:core::option::Optionpetgraph::graph::NodeIndex
  • transitions:alloc::vec::Vec<bevy_animation::transition::AnimationTransition>

Description

Manages fade-out of animation blend factors, allowing for smooth transitions between animations.

To use this component, place it on the same entity as the [AnimationPlayer] and AnimationGraphHandle. It'll take responsibility for adjusting the weight on the [ActiveAnimation] in order to fade out animations smoothly.

When using an [AnimationTransitions] component, you should play all animations through the [AnimationTransitions::play] method, rather than by directly manipulating the [AnimationPlayer]. Playing animations through the [AnimationPlayer] directly will cause the [AnimationTransitions] component to get confused about which animation is the "main" animation, and transitions will usually be incorrect as a result.

Associated Functions

For function details and documentation, click on the function link.

AssetIndex

AssetIndex

  • generation:u32
  • index:u32

Description

A generational runtime-only identifier for a specific [Asset] stored in [Assets]. This is optimized for efficient runtime usage and is not suitable for identifying assets across app runs.

Associated Functions

For function details and documentation, click on the function link.

AssetPath

Opaque Type. 🔒

Description

Represents a path to an asset in a "virtual filesystem".

Asset paths consist of three main parts:

  • [AssetPath::source]: The name of the AssetSource to load the asset from. This is optional. If one is not set the default source will be used (which is the assets folder by default).
  • [AssetPath::path]: The "virtual filesystem path" pointing to an asset source file.
  • [AssetPath::label]: An optional "named sub asset". When assets are loaded, they are allowed to load "sub assets" of any type, which are identified by a named "label".

Asset paths are generally constructed (and visualized) as strings:

# use bevy_asset::{Asset, AssetServer, Handle};
# use bevy_reflect::TypePath;
#
# #[derive(Asset, TypePath, Default)]
# struct Mesh;
#
# #[derive(Asset, TypePath, Default)]
# struct Scene;
#
# let asset_server: AssetServer = panic!();
// This loads the `my_scene.scn` base asset from the default asset source.
let scene: Handle<Scene> = asset_server.load("my_scene.scn");

// This loads the `PlayerMesh` labeled asset from the `my_scene.scn` base asset in the default asset source.
let mesh: Handle<Mesh> = asset_server.load("my_scene.scn#PlayerMesh");

// This loads the `my_scene.scn` base asset from a custom 'remote' asset source.
let scene: Handle<Scene> = asset_server.load("remote://my_scene.scn");

[AssetPath] implements [From] for &'static str, &'static Path, and &'a String, which allows us to optimize the static cases. This means that the common case of asset_server.load("my_scene.scn") when it creates and clones internal owned AssetPaths. This also means that you should use [AssetPath::parse] in cases where &str is the explicit type.

Associated Functions

For function details and documentation, click on the function link.

RenderAssetUsages

Opaque Type. 🔒

Description

Defines where the asset will be used.

If an asset is set to the RENDER_WORLD but not the MAIN_WORLD, the asset will be unloaded from the asset server once it's been extracted and prepared in the render world.

Unloading the asset saves on memory, as for most cases it is no longer necessary to keep it in RAM once it's been uploaded to the GPU's VRAM. However, this means you can no longer access the asset from the CPU (via the Assets<T> resource) once unloaded (without re-loading it).

If you never need access to the asset from the CPU past the first frame it's loaded on, or only need very infrequent access, then set this to RENDER_WORLD. Otherwise, set this to RENDER_WORLD | MAIN_WORLD.

If you have an asset that doesn't actually need to end up in the render world, like an Image that will be decoded into another Image asset, use MAIN_WORLD only.

Platform-specific

On Wasm, it is not possible for now to free reserved memory. To control memory usage, load assets in sequence and unload one before loading the next. See this discussion about memory management for more details.

Associated Functions

For function details and documentation, click on the function link.

DefaultSpatialScale

DefaultSpatialScale

  1. bevy_audio::audio::SpatialScale

Description

The default scale factor applied to the positions of audio sources and listeners for spatial audio. Can be overridden for individual sounds in [PlaybackSettings].

You may need to adjust this scale to fit your world's units.

Default is Vec3::ONE.

Associated Functions

For function details and documentation, click on the function link.

GlobalVolume

GlobalVolume

  • volume:bevy_audio::audio::Volume

Description

Use this [Resource] to control the global volume of all audio.

Note: changing this value will not affect already playing audio.

Associated Functions

For function details and documentation, click on the function link.

PlaybackMode

Once

Loop

Despawn

Remove

Description

The way Bevy manages the sound playback.

Associated Functions

For function details and documentation, click on the function link.

PlaybackSettings

PlaybackSettings

  • mode:bevy_audio::audio::PlaybackMode
  • volume:bevy_audio::audio::Volume
  • speed:f32
  • paused:bool
  • spatial:bool
  • spatial_scale:core::option::Option<bevy_audio::audio::SpatialScale>

Description

Initial settings to be used when audio starts playing.

If you would like to control the audio while it is playing, query for the [AudioSink][crate::AudioSink] or [SpatialAudioSink][crate::SpatialAudioSink] components. Changes to this component will not be applied to already-playing audio.

Associated Functions

For function details and documentation, click on the function link.

SpatialListener

SpatialListener

  • left_ear_offset:glam::Vec3
  • right_ear_offset:glam::Vec3

Description

Settings for the listener for spatial audio sources.

This must be accompanied by Transform and GlobalTransform. Only one entity with a SpatialListener should be present at any given time.

Associated Functions

For function details and documentation, click on the function link.

SpatialScale

SpatialScale

  1. glam::Vec3

Description

A scale factor applied to the positions of audio sources and listeners for spatial audio.

Default is Vec3::ONE.

Associated Functions

For function details and documentation, click on the function link.

Volume

Volume

  1. f32

Description

A volume level equivalent to a non-negative float.

Associated Functions

For function details and documentation, click on the function link.

Color

Srgba

  1. bevy_color::srgba::Srgba

LinearRgba

  1. bevy_color::linear_rgba::LinearRgba

Hsla

  1. bevy_color::hsla::Hsla

Hsva

  1. bevy_color::hsva::Hsva

Hwba

  1. bevy_color::hwba::Hwba

Laba

  1. bevy_color::laba::Laba

Lcha

  1. bevy_color::lcha::Lcha

Oklaba

  1. bevy_color::oklaba::Oklaba

Oklcha

  1. bevy_color::oklcha::Oklcha

Xyza

  1. bevy_color::xyza::Xyza

Description

An enumerated type that can represent any of the color types in this crate.

This is useful when you need to store a color in a data structure that can't be generic over the color type.

Operations

[Color] supports all the standard color operations, such as mixing, luminance and hue adjustment, and diffing. These operations delegate to the concrete color space contained by [Color], but will convert to Oklch for operations which aren't supported in the current space. After performing the operation, if a conversion was required, the result will be converted back into the original color space.

#![allow(unused)]
fn main() {
use bevy_color::{Hue, Color};
let red_hsv = Color::hsv(0., 1., 1.);
let red_srgb = Color::srgb(1., 0., 0.);

// HSV has a definition of hue, so it will be returned.
red_hsv.hue();

// SRGB doesn't have a native definition for hue.
// Converts to Oklch and returns that result.
red_srgb.hue();
}

Oklch has been chosen as the intermediary space in cases where conversion is required due to its perceptual uniformity and broad support for Bevy's color operations. To avoid the cost of repeated conversion, and ensure consistent results where that is desired, first convert this [Color] into your desired color space.

Associated Functions

For function details and documentation, click on the function link.

Hsla

Hsla

  • hue:f32
  • saturation:f32
  • lightness:f32
  • alpha:f32

Description

Color in Hue-Saturation-Lightness (HSL) color space with alpha. Further information on this color model can be found on Wikipedia.

Associated Functions

For function details and documentation, click on the function link.

Hsva

Hsva

  • hue:f32
  • saturation:f32
  • value:f32
  • alpha:f32

Description

Color in Hue-Saturation-Value (HSV) color space with alpha. Further information on this color model can be found on Wikipedia.

Associated Functions

For function details and documentation, click on the function link.

Hwba

Hwba

  • hue:f32
  • whiteness:f32
  • blackness:f32
  • alpha:f32

Description

Color in Hue-Whiteness-Blackness (HWB) color space with alpha. Further information on this color model can be found on Wikipedia.

Associated Functions

For function details and documentation, click on the function link.

Laba

Laba

  • lightness:f32
  • a:f32
  • b:f32
  • alpha:f32

Description

Color in LAB color space, with alpha

Associated Functions

For function details and documentation, click on the function link.

Lcha

Lcha

  • lightness:f32
  • chroma:f32
  • hue:f32
  • alpha:f32

Description

Color in LCH color space, with alpha

Associated Functions

For function details and documentation, click on the function link.

LinearRgba

LinearRgba

  • red:f32
  • green:f32
  • blue:f32
  • alpha:f32

Description

Linear RGB color with alpha.

Associated Functions

For function details and documentation, click on the function link.

Oklaba

Oklaba

  • lightness:f32
  • a:f32
  • b:f32
  • alpha:f32

Description

Color in Oklab color space, with alpha

Associated Functions

For function details and documentation, click on the function link.

Oklcha

Oklcha

  • lightness:f32
  • chroma:f32
  • hue:f32
  • alpha:f32

Description

Color in Oklch color space, with alpha

Associated Functions

For function details and documentation, click on the function link.

Srgba

Srgba

  • red:f32
  • green:f32
  • blue:f32
  • alpha:f32

Description

Non-linear standard RGB with alpha.

Associated Functions

For function details and documentation, click on the function link.

Xyza

Xyza

  • x:f32
  • y:f32
  • z:f32
  • alpha:f32

Description

CIE 1931 color space, also known as XYZ, with an alpha channel.

Associated Functions

For function details and documentation, click on the function link.

Bloom

Bloom

  • intensity:f32
  • low_frequency_boost:f32
  • low_frequency_boost_curvature:f32
  • high_pass_frequency:f32
  • prefilter:bevy_core_pipeline::bloom::settings::BloomPrefilter
  • composite_mode:bevy_core_pipeline::bloom::settings::BloomCompositeMode
  • max_mip_dimension:u32
  • uv_offset:f32

Description

Applies a bloom effect to an HDR-enabled 2d or 3d camera.

Bloom emulates an effect found in real cameras and the human eye, causing halos to appear around very bright parts of the scene.

See also https://en.wikipedia.org/wiki/Bloom_(shader_effect).

Usage Notes

Bloom is currently not compatible with WebGL2.

Often used in conjunction with bevy_pbr::StandardMaterial::emissive for 3d meshes.

Bloom is best used alongside a tonemapping function that desaturates bright colors, such as [crate::tonemapping::Tonemapping::TonyMcMapface].

Bevy's implementation uses a parametric curve to blend between a set of blurred (lower frequency) images generated from the camera's view. See https://starlederer.github.io/bloom/ for a visualization of the parametric curve used in Bevy as well as a visualization of the curve's respective scattering profile.

Associated Functions

For function details and documentation, click on the function link.

BloomCompositeMode

EnergyConserving

Additive

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

BloomPrefilter

BloomPrefilter

  • threshold:f32
  • threshold_softness:f32

Description

Applies a threshold filter to the input image to extract the brightest regions before blurring them and compositing back onto the original image. These settings are useful when emulating the 1990s-2000s game look.

Considerations

  • Changing these settings creates a physically inaccurate image
  • Changing these settings makes it easy to make the final result look worse
  • Non-default prefilter settings should be used in conjunction with [BloomCompositeMode::Additive]

Associated Functions

For function details and documentation, click on the function link.

ContrastAdaptiveSharpening

ContrastAdaptiveSharpening

  • enabled:bool
  • sharpening_strength:f32
  • denoise:bool

Description

Applies a contrast adaptive sharpening (CAS) filter to the camera.

CAS is usually used in combination with shader based anti-aliasing methods such as FXAA or TAA to regain some of the lost detail from the blurring that they introduce.

CAS is designed to adjust the amount of sharpening applied to different areas of an image based on the local contrast. This can help avoid over-sharpening areas with high contrast and under-sharpening areas with low contrast.

To use this, add the [ContrastAdaptiveSharpening] component to a 2D or 3D camera.

Associated Functions

For function details and documentation, click on the function link.

Camera2d

Camera2d

Description

A 2D camera component. Enables the 2D render graph for a [Camera].

Associated Functions

For function details and documentation, click on the function link.

Camera3d

Camera3d

  • depth_load_op:bevy_core_pipeline::core_3d::camera_3d::Camera3dDepthLoadOp
  • depth_texture_usages:bevy_core_pipeline::core_3d::camera_3d::Camera3dDepthTextureUsage
  • screen_space_specular_transmission_steps:usize
  • screen_space_specular_transmission_quality:bevy_core_pipeline::core_3d::camera_3d::ScreenSpaceTransmissionQuality

Description

A 3D camera component. Enables the main 3D render graph for a [Camera].

The camera coordinate space is right-handed X-right, Y-up, Z-back. This means "forward" is -Z.

Associated Functions

For function details and documentation, click on the function link.

Camera3dDepthLoadOp

Clear

  1. f32

Load

Description

The depth clear operation to perform for the main 3d pass.

Associated Functions

For function details and documentation, click on the function link.

Camera3dDepthTextureUsage

Camera3dDepthTextureUsage

  1. u32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

ScreenSpaceTransmissionQuality

Low

Medium

High

Ultra

Description

The quality of the screen space transmission blur effect, applied to whatever's “behind” transmissive objects when their roughness is greater than 0.0.

Higher qualities are more GPU-intensive.

Note: You can get better-looking results at any quality level by enabling TAA. See: TemporalAntiAliasPlugin.

Associated Functions

For function details and documentation, click on the function link.

DepthOfField

DepthOfField

  • mode:bevy_core_pipeline::dof::DepthOfFieldMode
  • focal_distance:f32
  • sensor_height:f32
  • aperture_f_stops:f32
  • max_circle_of_confusion_diameter:f32
  • max_depth:f32

Description

A component that enables a depth of field postprocessing effect when attached to a [Camera3d], simulating the focus of a camera lens.

Associated Functions

For function details and documentation, click on the function link.

DepthOfFieldMode

Bokeh

Gaussian

Description

Controls the appearance of the effect.

Associated Functions

For function details and documentation, click on the function link.

Fxaa

Fxaa

  • enabled:bool
  • edge_threshold:bevy_core_pipeline::fxaa::Sensitivity
  • edge_threshold_min:bevy_core_pipeline::fxaa::Sensitivity

Description

A component for enabling Fast Approximate Anti-Aliasing (FXAA) for a [bevy_render::camera::Camera].

Associated Functions

For function details and documentation, click on the function link.

Sensitivity

Low

Medium

High

Ultra

Extreme

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

OrderIndependentTransparencySettings

OrderIndependentTransparencySettings

  • layer_count:i32
  • alpha_threshold:f32

Description

Used to identify which camera will use OIT to render transparent meshes and to configure OIT.

Associated Functions

For function details and documentation, click on the function link.

ChromaticAberration

ChromaticAberration

  • color_lut:bevy_asset::handle::Handle<bevy_image::image::Image>
  • intensity:f32
  • max_samples:u32

Description

Adds colored fringes to the edges of objects in the scene.

Chromatic aberration simulates the effect when lenses fail to focus all colors of light toward a single point. It causes rainbow-colored streaks to appear, which are especially apparent on the edges of objects. Chromatic aberration is commonly used for collision effects, especially in horror games.

Bevy's implementation is based on that of Inside (Gjøl & Svendsen 2016). It's based on a customizable lookup texture, which allows for changing the color pattern. By default, the color pattern is simply a 3×1 pixel texture consisting of red, green, and blue, in that order, but you can change it to any image in order to achieve different effects.

Associated Functions

For function details and documentation, click on the function link.

DeferredPrepass

DeferredPrepass

Description

If added to a [crate::prelude::Camera3d] then deferred materials will be rendered to the deferred gbuffer texture and will be available to subsequent passes. Note the default deferred lighting plugin also requires DepthPrepass to work correctly.

Associated Functions

For function details and documentation, click on the function link.

DepthPrepass

DepthPrepass

Description

If added to a [crate::prelude::Camera3d] then depth values will be copied to a separate texture available to the main pass.

Associated Functions

For function details and documentation, click on the function link.

MotionVectorPrepass

MotionVectorPrepass

Description

If added to a [crate::prelude::Camera3d] then screen space motion vectors will be copied to a separate texture available to the main pass.

Associated Functions

For function details and documentation, click on the function link.

NormalPrepass

NormalPrepass

Description

If added to a [crate::prelude::Camera3d] then vertex world normals will be copied to a separate texture available to the main pass. Normals will have normal map textures already applied.

Associated Functions

For function details and documentation, click on the function link.

Smaa

Smaa

  • preset:bevy_core_pipeline::smaa::SmaaPreset

Description

A component for enabling Subpixel Morphological Anti-Aliasing (SMAA) for a [bevy_render::camera::Camera].

Associated Functions

For function details and documentation, click on the function link.

SmaaPreset

Low

Medium

High

Ultra

Description

A preset quality level for SMAA.

Higher values are slower but result in a higher-quality image.

The default value is high.

Associated Functions

For function details and documentation, click on the function link.

DebandDither

Disabled

Enabled

Description

Enables a debanding shader that applies dithering to mitigate color banding in the final image for a given [Camera] entity.

Associated Functions

For function details and documentation, click on the function link.

Tonemapping

None

Reinhard

ReinhardLuminance

AcesFitted

AgX

SomewhatBoringDisplayTransform

TonyMcMapface

BlenderFilmic

Description

Optionally enables a tonemapping shader that attempts to map linear input stimulus into a perceptually uniform image for a given [Camera] entity.

Associated Functions

For function details and documentation, click on the function link.

SystemIdMarker

SystemIdMarker

Description

Marker Component for identifying [SystemId] [Entity]s.

Associated Functions

For function details and documentation, click on the function link.

OnAdd

OnAdd

Description

Trigger emitted when a component is added to an entity. See [crate::component::ComponentHooks::on_add] for more information.

Associated Functions

For function details and documentation, click on the function link.

OnInsert

OnInsert

Description

Trigger emitted when a component is inserted onto an entity. See [crate::component::ComponentHooks::on_insert] for more information.

Associated Functions

For function details and documentation, click on the function link.

OnRemove

OnRemove

Description

Trigger emitted when a component is removed from an entity. See [crate::component::ComponentHooks::on_remove] for more information.

Associated Functions

For function details and documentation, click on the function link.

OnReplace

OnReplace

Description

Trigger emitted when a component is replaced on an entity. See [crate::component::ComponentHooks::on_replace] for more information.

Associated Functions

For function details and documentation, click on the function link.

AabbGizmoConfigGroup

AabbGizmoConfigGroup

  • draw_all:bool
  • default_color:core::option::Option<bevy_color::color::Color>

Description

The [GizmoConfigGroup] used for debug visualizations of [Aabb] components on entities

Associated Functions

For function details and documentation, click on the function link.

GizmoConfig

GizmoConfig

  • enabled:bool
  • line_width:f32
  • line_perspective:bool
  • line_style:bevy_gizmos::config::GizmoLineStyle
  • depth_bias:f32
  • render_layers:bevy_render::view::visibility::render_layers::RenderLayers
  • line_joints:bevy_gizmos::config::GizmoLineJoint

Description

A struct that stores configuration for gizmos.

Associated Functions

For function details and documentation, click on the function link.

GizmoConfigStore

GizmoConfigStore

Description

A [Resource] storing [GizmoConfig] and [GizmoConfigGroup] structs

Use app.init_gizmo_group::<T>() to register a custom config group.

Associated Functions

For function details and documentation, click on the function link.

GizmoLineJoint

None

Miter

Round

  1. u32

Bevel

Description

An enum configuring how line joints will be drawn.

Associated Functions

For function details and documentation, click on the function link.

GizmoLineStyle

Solid

Dotted

Description

An enum used to configure the style of gizmo lines, similar to CSS line-style

Associated Functions

For function details and documentation, click on the function link.

LightGizmoColor

Manual

  1. bevy_color::color::Color

Varied

MatchLightColor

ByLightType

Description

Configures how a color is attributed to a light gizmo.

Associated Functions

For function details and documentation, click on the function link.

LightGizmoConfigGroup

LightGizmoConfigGroup

  • draw_all:bool
  • color:bevy_gizmos::light::LightGizmoColor
  • point_light_color:bevy_color::color::Color
  • spot_light_color:bevy_color::color::Color
  • directional_light_color:bevy_color::color::Color

Description

The [GizmoConfigGroup] used to configure the visualization of lights.

Associated Functions

For function details and documentation, click on the function link.

GltfExtras

GltfExtras

  • value:String

Description

Additional untyped data that can be present on most glTF types at the primitive level.

See the relevant glTF specification section.

Associated Functions

For function details and documentation, click on the function link.

GltfMaterialExtras

GltfMaterialExtras

  • value:String

Description

Additional untyped data that can be present on most glTF types at the material level.

See the relevant glTF specification section.

Associated Functions

For function details and documentation, click on the function link.

GltfMaterialName

GltfMaterialName

  1. String

Description

The material name of a glTF primitive.

See the relevant glTF specification section.

Associated Functions

For function details and documentation, click on the function link.

GltfMeshExtras

GltfMeshExtras

  • value:String

Description

Additional untyped data that can be present on most glTF types at the mesh level.

See the relevant glTF specification section.

Associated Functions

For function details and documentation, click on the function link.

GltfSceneExtras

GltfSceneExtras

  • value:String

Description

Additional untyped data that can be present on most glTF types at the scene level.

See the relevant glTF specification section.

Associated Functions

For function details and documentation, click on the function link.

Image

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Affine3

Affine3

  • matrix3:glam::Mat3
  • translation:glam::Vec3

Description

Reduced-size version of glam::Affine3A for use when storage has significant performance impact. Convert to glam::Affine3A to do non-trivial calculations.

Associated Functions

For function details and documentation, click on the function link.

Indices

U16

  1. alloc::vec::Vec

U32

  1. alloc::vec::Vec

Description

An array of indices into the VertexAttributeValues for a mesh.

It describes the order in which the vertex attributes should be joined into faces.

Associated Functions

For function details and documentation, click on the function link.

Mesh

Mesh

  • indices:core::option::Option<bevy_mesh::index::Indices>
  • morph_targets:core::option::Option<bevy_asset::handle::Handle<bevy_image::image::Image>>
  • morph_target_names:core::option::Option<alloc::vec::Vecalloc::string::String>
  • asset_usage:bevy_asset::render_asset::RenderAssetUsages

Description

A 3D object made out of vertices representing triangles, lines, or points, with "attribute" values for each vertex.

Meshes can be automatically generated by a bevy AssetLoader (generally by loading a Gltf file), or by converting a primitive using into. It is also possible to create one manually. They can be edited after creation.

Meshes can be rendered with a Mesh2d and MeshMaterial2d or Mesh3d and MeshMaterial3d for 2D and 3D respectively.

A [Mesh] in Bevy is equivalent to a "primitive" in the glTF format, for a glTF Mesh representation, see GltfMesh.

Manual creation

The following function will construct a flat mesh, to be rendered with a StandardMaterial or ColorMaterial:

# use bevy_mesh::{Mesh, Indices, PrimitiveTopology};
# use bevy_asset::RenderAssetUsages;
fn create_simple_parallelogram() -> Mesh {
    // Create a new mesh using a triangle list topology, where each set of 3 vertices composes a triangle.
    Mesh::new(PrimitiveTopology::TriangleList, RenderAssetUsages::default())
        // Add 4 vertices, each with its own position attribute (coordinate in
        // 3D space), for each of the corners of the parallelogram.
        .with_inserted_attribute(
            Mesh::ATTRIBUTE_POSITION,
            vec![[0.0, 0.0, 0.0], [1.0, 2.0, 0.0], [2.0, 2.0, 0.0], [1.0, 0.0, 0.0]]
        )
        // Assign a UV coordinate to each vertex.
        .with_inserted_attribute(
            Mesh::ATTRIBUTE_UV_0,
            vec![[0.0, 1.0], [0.5, 0.0], [1.0, 0.0], [0.5, 1.0]]
        )
        // Assign normals (everything points outwards)
        .with_inserted_attribute(
            Mesh::ATTRIBUTE_NORMAL,
            vec![[0.0, 0.0, 1.0], [0.0, 0.0, 1.0], [0.0, 0.0, 1.0], [0.0, 0.0, 1.0]]
        )
        // After defining all the vertices and their attributes, build each triangle using the
        // indices of the vertices that make it up in a counter-clockwise order.
        .with_inserted_indices(Indices::U32(vec![
            // First triangle
            0, 3, 1,
            // Second triangle
            1, 3, 2
        ]))
}

You can see how it looks like here, used in a Mesh3d with a square bevy logo texture, with added axis, points, lines and text for clarity.

Other examples

For further visualization, explanation, and examples, see the built-in Bevy examples, and the implementation of the built-in shapes. In particular, generate_custom_mesh teaches you to access and modify the attributes of a [Mesh] after creating it.

Common points of confusion

  • UV maps in Bevy start at the top-left, see ATTRIBUTE_UV_0, other APIs can have other conventions, OpenGL starts at bottom-left.
  • It is possible and sometimes useful for multiple vertices to have the same position attribute value, it's a common technique in 3D modeling for complex UV mapping or other calculations.
  • Bevy performs frustum culling based on the Aabb of meshes, which is calculated and added automatically for new meshes only. If a mesh is modified, the entity's Aabb needs to be updated manually or deleted so that it is re-calculated.

Use with StandardMaterial

To render correctly with StandardMaterial, a mesh needs to have properly defined:

  • UVs: Bevy needs to know how to map a texture onto the mesh (also true for ColorMaterial).
  • Normals: Bevy needs to know how light interacts with your mesh. [0.0, 0.0, 1.0] is very common for simple flat meshes on the XY plane, because simple meshes are smooth and they don't require complex light calculations.
  • Vertex winding order: by default, StandardMaterial.cull_mode is Some(Face::Back), which means that Bevy would only render the "front" of each triangle, which is the side of the triangle from where the vertices appear in a counter-clockwise order.

Associated Functions

For function details and documentation, click on the function link.

MeshMorphWeights

MeshMorphWeights

  • weights:alloc::vec::Vec

Description

Control a specific [Mesh] instance's morph targets. These control the weights of specific "mesh primitives" in scene formats like GLTF. They can be set manually, but in most cases they should "automatically" synced by setting the [MorphWeights] component on a parent entity.

See [MorphWeights] for more details on Bevy's morph target implementation.

Add this to an [Entity] with a Mesh3d with a [MorphAttributes] set to control individual weights of each morph target.

Associated Functions

For function details and documentation, click on the function link.

MorphWeights

MorphWeights

  • weights:alloc::vec::Vec
  • first_mesh:core::option::Option<bevy_asset::handle::Handle<bevy_mesh::mesh::Mesh>>

Description

Controls the morph targets for all child Mesh3d entities. In most cases, [MorphWeights] should be considered the "source of truth" when writing morph targets for meshes. However you can choose to write child [MeshMorphWeights] if your situation requires more granularity. Just note that if you set [MorphWeights], it will overwrite child [MeshMorphWeights] values.

This exists because Bevy's [Mesh] corresponds to a single surface / material, whereas morph targets as defined in the GLTF spec exist on "multi-primitive meshes" (where each primitive is its own surface with its own material). Therefore in Bevy [MorphWeights] an a parent entity are the "canonical weights" from a GLTF perspective, which then synchronized to child Mesh3d / [MeshMorphWeights] (which correspond to "primitives" / "surfaces" from a GLTF perspective).

Add this to the parent of one or more Entities with a Mesh3d with a [MeshMorphWeights].

Associated Functions

For function details and documentation, click on the function link.

SkinnedMesh

SkinnedMesh

  • inverse_bindposes:bevy_asset::handle::Handle<bevy_mesh::skinning::SkinnedMeshInverseBindposes>
  • joints:alloc::vec::Vec<bevy_ecs::entity::Entity>

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Namespace

Global

OnType

  1. core::any::TypeId

Description

A namespace for functions

Associated Functions

For function details and documentation, click on the function link.

ScriptValue

Opaque Type. 🔒

Description

An abstraction of values that can be passed to and from scripts. This allows us to re-use logic between scripting languages.

Associated Functions

For function details and documentation, click on the function link.

FunctionArgInfo

FunctionArgInfo

  • name:core::option::Option<alloc::borrow::Cow>
  • arg_index:usize
  • type_id:core::any::TypeId

Description

Information about a function argument.

Associated Functions

For function details and documentation, click on the function link.

FunctionInfo

FunctionInfo

  • name:alloc::borrow::Cow
  • namespace:bevy_mod_scripting_core::bindings::function::namespace::Namespace
  • arg_info:alloc::vec::Vec<bevy_mod_scripting_core::docgen::info::FunctionArgInfo>
  • return_info:bevy_mod_scripting_core::docgen::info::FunctionReturnInfo
  • docs:core::option::Option<alloc::borrow::Cow>

Description

Information about a function.

Associated Functions

For function details and documentation, click on the function link.

FunctionReturnInfo

FunctionReturnInfo

  • type_id:core::any::TypeId

Description

Information about a function return value.

Associated Functions

For function details and documentation, click on the function link.

InteropError

Opaque Type. 🔒

Description

An error thrown when interoperating with scripting languages.

Associated Functions

For function details and documentation, click on the function link.

CascadesVisibleEntities

CascadesVisibleEntities

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

CubemapVisibleEntities

CubemapVisibleEntities

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

VisibleMeshEntities

VisibleMeshEntities

Description

Collection of mesh entities visible for 3D lighting.

This component contains all mesh entities visible from the current light view. The collection is updated automatically by [crate::SimulationLightSystems].

Associated Functions

For function details and documentation, click on the function link.

ClusterConfig

None

Single

XYZ

  • dimensions:glam::UVec3
  • z_config:bevy_pbr::cluster::ClusterZConfig
  • dynamic_resizing:bool

FixedZ

  • total:u32
  • z_slices:u32
  • z_config:bevy_pbr::cluster::ClusterZConfig
  • dynamic_resizing:bool

Description

Configuration of the clustering strategy for clustered forward rendering

Associated Functions

For function details and documentation, click on the function link.

ClusterFarZMode

MaxClusterableObjectRange

Constant

  1. f32

Description

Configure the far z-plane mode used for the furthest depth slice for clustered forward rendering

Associated Functions

For function details and documentation, click on the function link.

ClusterZConfig

ClusterZConfig

  • first_slice_depth:f32
  • far_z_mode:bevy_pbr::cluster::ClusterFarZMode

Description

Configure the depth-slicing strategy for clustered forward rendering

Associated Functions

For function details and documentation, click on the function link.

DistanceFog

DistanceFog

  • color:bevy_color::color::Color
  • directional_light_color:bevy_color::color::Color
  • directional_light_exponent:f32
  • falloff:bevy_pbr::fog::FogFalloff

Description

Configures the “classic” computer graphics distance fog effect, in which objects appear progressively more covered in atmospheric haze the further away they are from the camera. Affects meshes rendered via the PBR StandardMaterial.

Falloff

The rate at which fog intensity increases with distance is controlled by the falloff mode. Currently, the following fog falloff modes are supported:

  • [FogFalloff::Linear]
  • [FogFalloff::Exponential]
  • [FogFalloff::ExponentialSquared]
  • [FogFalloff::Atmospheric]

Example

# use bevy_ecs::prelude::*;
# use bevy_render::prelude::*;
# use bevy_core_pipeline::prelude::*;
# use bevy_pbr::prelude::*;
# use bevy_color::Color;
# fn system(mut commands: Commands) {
commands.spawn((
    // Setup your camera as usual
    Camera3d::default(),
    // Add fog to the same entity
    DistanceFog {
        color: Color::WHITE,
        falloff: FogFalloff::Exponential { density: 1e-3 },
        ..Default::default()
    },
));
# }
# bevy_ecs::system::assert_is_system(system);

Material Override

Once enabled for a specific camera, the fog effect can also be disabled for individual StandardMaterial instances via the fog_enabled flag.

Associated Functions

For function details and documentation, click on the function link.

FogFalloff

Linear

  • start:f32
  • end:f32

Exponential

  • density:f32

ExponentialSquared

  • density:f32

Atmospheric

  • extinction:glam::Vec3
  • inscattering:glam::Vec3

Description

Allows switching between different fog falloff modes, and configuring their parameters.

Convenience Methods

When using non-linear fog modes it can be hard to determine the right parameter values for a given scene.

For easier artistic control, instead of creating the enum variants directly, you can use the visibility-based convenience methods:

  • For FogFalloff::Exponential:

    • [FogFalloff::from_visibility()]
    • [FogFalloff::from_visibility_contrast()]
  • For FogFalloff::ExponentialSquared:

    • [FogFalloff::from_visibility_squared()]
    • [FogFalloff::from_visibility_contrast_squared()]
  • For FogFalloff::Atmospheric:

    • [FogFalloff::from_visibility_color()]
    • [FogFalloff::from_visibility_colors()]
    • [FogFalloff::from_visibility_contrast_color()]
    • [FogFalloff::from_visibility_contrast_colors()]

Associated Functions

For function details and documentation, click on the function link.

Cascade

Cascade

  • world_from_cascade:glam::Mat4
  • clip_from_cascade:glam::Mat4
  • clip_from_world:glam::Mat4
  • texel_size:f32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

CascadeShadowConfig

CascadeShadowConfig

  • bounds:alloc::vec::Vec
  • overlap_proportion:f32
  • minimum_distance:f32

Description

Controls how cascaded shadow mapping works. Prefer using [CascadeShadowConfigBuilder] to construct an instance.

# use bevy_pbr::CascadeShadowConfig;
# use bevy_pbr::CascadeShadowConfigBuilder;
# use bevy_utils::default;
#
let config: CascadeShadowConfig = CascadeShadowConfigBuilder {
  maximum_distance: 100.0,
  ..default()
}.into();

Associated Functions

For function details and documentation, click on the function link.

Cascades

Cascades

  • cascades:bevy_utils::hashbrown::HashMap<bevy_ecs::entity::Entity, alloc::vec::Vec<bevy_pbr::light::Cascade>, bevy_ecs::entity::hash::EntityHash>

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

DirectionalLightShadowMap

DirectionalLightShadowMap

  • size:usize

Description

Controls the resolution of [DirectionalLight] shadow maps.

Associated Functions

For function details and documentation, click on the function link.

NotShadowCaster

NotShadowCaster

Description

Add this component to make a [Mesh3d] not cast shadows.

Associated Functions

For function details and documentation, click on the function link.

NotShadowReceiver

NotShadowReceiver

Description

Add this component to make a [Mesh3d] not receive shadows.

Note: If you're using diffuse transmission, setting [NotShadowReceiver] will cause both “regular” shadows as well as diffusely transmitted shadows to be disabled, even when [TransmittedShadowReceiver] is being used.

Associated Functions

For function details and documentation, click on the function link.

PointLightShadowMap

PointLightShadowMap

  • size:usize

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

ShadowFilteringMethod

Hardware2x2

Gaussian

Temporal

Description

Add this component to a Camera3d to control how to anti-alias shadow edges.

The different modes use different approaches to Percentage Closer Filtering.

Associated Functions

For function details and documentation, click on the function link.

AmbientLight

AmbientLight

  • color:bevy_color::color::Color
  • brightness:f32

Description

An ambient light, which lights the entire scene equally.

This resource is inserted by the [PbrPlugin] and by default it is set to a low ambient light.

Examples

Make ambient light slightly brighter:

# use bevy_ecs::system::ResMut;
# use bevy_pbr::AmbientLight;
fn setup_ambient_light(mut ambient_light: ResMut<AmbientLight>) {
   ambient_light.brightness = 100.0;
}

Associated Functions

For function details and documentation, click on the function link.

DirectionalLight

DirectionalLight

  • color:bevy_color::color::Color
  • illuminance:f32
  • shadows_enabled:bool
  • shadow_depth_bias:f32
  • shadow_normal_bias:f32

Description

A Directional light.

Directional lights don't exist in reality but they are a good approximation for light sources VERY far away, like the sun or the moon.

The light shines along the forward direction of the entity's transform. With a default transform this would be along the negative-Z axis.

Valid values for illuminance are:

Illuminance (lux)Surfaces illuminated by
0.0001Moonless, overcast night sky (starlight)
0.002Moonless clear night sky with airglow
0.05–0.3Full moon on a clear night
3.4Dark limit of civil twilight under a clear sky
20–50Public areas with dark surroundings
50Family living room lights
80Office building hallway/toilet lighting
100Very dark overcast day
150Train station platforms
320–500Office lighting
400Sunrise or sunset on a clear day.
1000Overcast day; typical TV studio lighting
10,000–25,000Full daylight (not direct sun)
32,000–100,000Direct sunlight

Source: Wikipedia

Shadows

To enable shadows, set the shadows_enabled property to true.

Shadows are produced via cascaded shadow maps.

To modify the cascade setup, such as the number of cascades or the maximum shadow distance, change the [CascadeShadowConfig] component of the entity with the [DirectionalLight].

To control the resolution of the shadow maps, use the [DirectionalLightShadowMap] resource:

# use bevy_app::prelude::*;
# use bevy_pbr::DirectionalLightShadowMap;
App::new()
    .insert_resource(DirectionalLightShadowMap { size: 2048 });

Associated Functions

For function details and documentation, click on the function link.

PointLight

PointLight

  • color:bevy_color::color::Color
  • intensity:f32
  • range:f32
  • radius:f32
  • shadows_enabled:bool
  • shadow_depth_bias:f32
  • shadow_normal_bias:f32
  • shadow_map_near_z:f32

Description

A light that emits light in all directions from a central point.

Real-world values for intensity (luminous power in lumens) based on the electrical power consumption of the type of real-world light are:

Luminous Power (lumen) (i.e. the intensity member)Incandescent non-halogen (Watts)Incandescent halogen (Watts)Compact fluorescent (Watts)LED (Watts)
200253-53
45040299-115-8
8006013-158-12
1100755318-2010-16
16001007224-2814-17
240015030-5224-30
310020049-7532
400030075-10040.5

Source: Wikipedia

Associated Functions

For function details and documentation, click on the function link.

SpotLight

SpotLight

  • color:bevy_color::color::Color
  • intensity:f32
  • range:f32
  • radius:f32
  • shadows_enabled:bool
  • shadow_depth_bias:f32
  • shadow_normal_bias:f32
  • shadow_map_near_z:f32
  • outer_angle:f32
  • inner_angle:f32

Description

A light that emits light in a given direction from a central point.

Behaves like a point light in a perfectly absorbent housing that shines light only in a given direction. The direction is taken from the transform, and can be specified with Transform::looking_at.

Associated Functions

For function details and documentation, click on the function link.

LightProbe

LightProbe

Description

A marker component for a light probe, which is a cuboid region that provides global illumination to all fragments inside it.

Note that a light probe will have no effect unless the entity contains some kind of illumination, which can either be an [EnvironmentMapLight] or an [IrradianceVolume].

The light probe range is conceptually a unit cube (1×1×1) centered on the origin. The [Transform] applied to this entity can scale, rotate, or translate that cube so that it contains all fragments that should take this light probe into account.

When multiple sources of indirect illumination can be applied to a fragment, the highest-quality one is chosen. Diffuse and specular illumination are considered separately, so, for example, Bevy may decide to sample the diffuse illumination from an irradiance volume and the specular illumination from a reflection probe. From highest priority to lowest priority, the ranking is as follows:

RankDiffuseSpecular
1LightmapLightmap
2Irradiance volumeReflection probe
3Reflection probeView environment map
4View environment map

Note that ambient light is always added to the diffuse component and does not participate in the ranking. That is, ambient light is applied in addition to, not instead of, the light sources above.

A terminology note: Unfortunately, there is little agreement across game and graphics engines as to what to call the various techniques that Bevy groups under the term light probe. In Bevy, a light probe is the generic term that encompasses both reflection probes and irradiance volumes. In object-oriented terms, light probe is the superclass, and reflection probe and irradiance volume are subclasses. In other engines, you may see the term light probe refer to an irradiance volume with a single voxel, or perhaps some other technique, while in Bevy light probe refers not to a specific technique but rather to a class of techniques. Developers familiar with other engines should be aware of this terminology difference.

Associated Functions

For function details and documentation, click on the function link.

EnvironmentMapLight

EnvironmentMapLight

  • diffuse_map:bevy_asset::handle::Handle<bevy_image::image::Image>
  • specular_map:bevy_asset::handle::Handle<bevy_image::image::Image>
  • intensity:f32
  • rotation:glam::Quat

Description

A pair of cubemap textures that represent the surroundings of a specific area in space.

See [crate::environment_map] for detailed information.

Associated Functions

For function details and documentation, click on the function link.

IrradianceVolume

IrradianceVolume

  • voxels:bevy_asset::handle::Handle<bevy_image::image::Image>
  • intensity:f32

Description

The component that defines an irradiance volume.

See [crate::irradiance_volume] for detailed information.

Associated Functions

For function details and documentation, click on the function link.

DefaultOpaqueRendererMethod

DefaultOpaqueRendererMethod

  1. bevy_pbr::material::OpaqueRendererMethod

Description

Default render method used for opaque materials.

Associated Functions

For function details and documentation, click on the function link.

OpaqueRendererMethod

Forward

Deferred

Auto

Description

Render method used for opaque materials.

The forward rendering main pass draws each mesh entity and shades it according to its corresponding material and the lights that affect it. Some render features like Screen Space Ambient Occlusion require running depth and normal prepasses, that are 'deferred'-like prepasses over all mesh entities to populate depth and normal textures. This means that when using render features that require running prepasses, multiple passes over all visible geometry are required. This can be slow if there is a lot of geometry that cannot be batched into few draws.

Deferred rendering runs a prepass to gather not only geometric information like depth and normals, but also all the material properties like base color, emissive color, reflectance, metalness, etc, and writes them into a deferred 'g-buffer' texture. The deferred main pass is then a fullscreen pass that reads data from these textures and executes shading. This allows for one pass over geometry, but is at the cost of not being able to use MSAA, and has heavier bandwidth usage which can be unsuitable for low end mobile or other bandwidth-constrained devices.

If a material indicates OpaqueRendererMethod::Auto, DefaultOpaqueRendererMethod will be used.

Associated Functions

For function details and documentation, click on the function link.

ParallaxMappingMethod

Occlusion

Relief

  • max_steps:u32

Description

The parallax mapping method to use to compute depth based on the material's depth_map.

Parallax Mapping uses a depth map texture to give the illusion of depth variation on a mesh surface that is geometrically flat.

See the parallax_mapping.wgsl shader code for implementation details and explanation of the methods used.

Associated Functions

For function details and documentation, click on the function link.

StandardMaterial

StandardMaterial

  • base_color:bevy_color::color::Color
  • base_color_channel:bevy_pbr::pbr_material::UvChannel
  • base_color_texture:core::option::Option<bevy_asset::handle::Handle<bevy_image::image::Image>>
  • emissive:bevy_color::linear_rgba::LinearRgba
  • emissive_exposure_weight:f32
  • emissive_channel:bevy_pbr::pbr_material::UvChannel
  • emissive_texture:core::option::Option<bevy_asset::handle::Handle<bevy_image::image::Image>>
  • perceptual_roughness:f32
  • metallic:f32
  • metallic_roughness_channel:bevy_pbr::pbr_material::UvChannel
  • metallic_roughness_texture:core::option::Option<bevy_asset::handle::Handle<bevy_image::image::Image>>
  • reflectance:f32
  • diffuse_transmission:f32
  • specular_transmission:f32
  • thickness:f32
  • ior:f32
  • attenuation_distance:f32
  • attenuation_color:bevy_color::color::Color
  • normal_map_channel:bevy_pbr::pbr_material::UvChannel
  • normal_map_texture:core::option::Option<bevy_asset::handle::Handle<bevy_image::image::Image>>
  • flip_normal_map_y:bool
  • occlusion_channel:bevy_pbr::pbr_material::UvChannel
  • occlusion_texture:core::option::Option<bevy_asset::handle::Handle<bevy_image::image::Image>>
  • clearcoat:f32
  • clearcoat_perceptual_roughness:f32
  • anisotropy_strength:f32
  • anisotropy_rotation:f32
  • double_sided:bool
  • unlit:bool
  • fog_enabled:bool
  • alpha_mode:bevy_render::alpha::AlphaMode
  • depth_bias:f32
  • depth_map:core::option::Option<bevy_asset::handle::Handle<bevy_image::image::Image>>
  • parallax_depth_scale:f32
  • parallax_mapping_method:bevy_pbr::parallax::ParallaxMappingMethod
  • max_parallax_layer_count:f32
  • lightmap_exposure:f32
  • opaque_render_method:bevy_pbr::material::OpaqueRendererMethod
  • deferred_lighting_pass_id:u8
  • uv_transform:glam::Affine2

Description

A material with "standard" properties used in PBR lighting Standard property values with pictures here https://google.github.io/filament/Material%20Properties.pdf.

May be created directly from a [Color] or an [Image].

Associated Functions

For function details and documentation, click on the function link.

UvChannel

Uv0

Uv1

Description

An enum to define which UV attribute to use for a texture.

It is used for every texture in the [StandardMaterial]. It only supports two UV attributes, [bevy_render::mesh::Mesh::ATTRIBUTE_UV_0] and [bevy_render::mesh::Mesh::ATTRIBUTE_UV_1]. The default is [UvChannel::Uv0].

Associated Functions

For function details and documentation, click on the function link.

ScreenSpaceAmbientOcclusion

ScreenSpaceAmbientOcclusion

  • quality_level:bevy_pbr::ssao::ScreenSpaceAmbientOcclusionQualityLevel
  • constant_object_thickness:f32

Description

Component to apply screen space ambient occlusion to a 3d camera.

Screen space ambient occlusion (SSAO) approximates small-scale, local occlusion of indirect diffuse light between objects, based on what's visible on-screen. SSAO does not apply to direct lighting, such as point or directional lights.

This darkens creases, e.g. on staircases, and gives nice contact shadows where objects meet, giving entities a more "grounded" feel.

Usage Notes

Requires that you add [ScreenSpaceAmbientOcclusionPlugin] to your app.

It strongly recommended that you use SSAO in conjunction with TAA ([bevy_core_pipeline::experimental::taa::TemporalAntiAliasing]). Doing so greatly reduces SSAO noise.

SSAO is not supported on WebGL2, and is not currently supported on WebGPU.

Associated Functions

For function details and documentation, click on the function link.

ScreenSpaceAmbientOcclusionQualityLevel

Low

Medium

High

Ultra

Custom

  • slice_count:u32
  • samples_per_slice_side:u32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

ScreenSpaceReflections

ScreenSpaceReflections

  • perceptual_roughness_threshold:f32
  • thickness:f32
  • linear_steps:u32
  • linear_march_exponent:f32
  • bisection_steps:u32
  • use_secant:bool

Description

Add this component to a camera to enable screen-space reflections (SSR).

Screen-space reflections currently require deferred rendering in order to appear. Therefore, they also need the [DepthPrepass] and [DeferredPrepass] components, which are inserted automatically.

SSR currently performs no roughness filtering for glossy reflections, so only very smooth surfaces will reflect objects in screen space. You can adjust the perceptual_roughness_threshold in order to tune the threshold below which screen-space reflections will be traced.

As with all screen-space techniques, SSR can only reflect objects on screen. When objects leave the camera, they will disappear from reflections. An alternative that doesn't suffer from this problem is the combination of a LightProbe and [EnvironmentMapLight]. The advantage of SSR is that it can reflect all objects, not just static ones.

SSR is an approximation technique and produces artifacts in some situations. Hand-tuning the settings in this component will likely be useful.

Screen-space reflections are presently unsupported on WebGL 2 because of a bug whereby Naga doesn't generate correct GLSL when sampling depth buffers, which is required for screen-space raymarching.

Associated Functions

For function details and documentation, click on the function link.

VolumetricFog

VolumetricFog

  • ambient_color:bevy_color::color::Color
  • ambient_intensity:f32
  • jitter:f32
  • step_count:u32

Description

When placed on a [bevy_core_pipeline::core_3d::Camera3d], enables volumetric fog and volumetric lighting, also known as light shafts or god rays.

Associated Functions

For function details and documentation, click on the function link.

VolumetricLight

VolumetricLight

Description

Add this component to a DirectionalLight with a shadow map (shadows_enabled: true) to make volumetric fog interact with it.

This allows the light to generate light shafts/god rays.

Associated Functions

For function details and documentation, click on the function link.

PickingBehavior

PickingBehavior

  • should_block_lower:bool
  • is_hoverable:bool

Description

An optional component that overrides default picking behavior for an entity, allowing you to make an entity non-hoverable, or allow items below it to be hovered. See the documentation on the fields for more details.

Associated Functions

For function details and documentation, click on the function link.

PickingPlugin

PickingPlugin

  • is_enabled:bool
  • is_input_enabled:bool
  • is_focus_enabled:bool

Description

This plugin sets up the core picking infrastructure. It receives input events, and provides the shared types used by other picking plugins.

This plugin contains several settings, and is added to the wrold as a resource after initialization. You can configure picking settings at runtime through the resource.

Associated Functions

For function details and documentation, click on the function link.

HitData

HitData

  • camera:bevy_ecs::entity::Entity
  • depth:f32
  • position:core::option::Optionglam::Vec3
  • normal:core::option::Optionglam::Vec3

Description

Holds data from a successful pointer hit test. See [HitData::depth] for important details.

Associated Functions

For function details and documentation, click on the function link.

RayId

RayId

  • camera:bevy_ecs::entity::Entity
  • pointer:bevy_picking::pointer::PointerId

Description

Identifies a ray constructed from some (pointer, camera) combination. A pointer can be over multiple cameras, which is why a single pointer may have multiple rays.

Associated Functions

For function details and documentation, click on the function link.

PickingInteraction

Pressed

Hovered

None

Description

A component that aggregates picking interaction state of this entity across all pointers.

Unlike bevy's Interaction component, this is an aggregate of the state of all pointers interacting with this entity. Aggregation is done by taking the interaction with the highest precedence.

For example, if we have an entity that is being hovered by one pointer, and pressed by another, the entity will be considered pressed. If that entity is instead being hovered by both pointers, it will be considered hovered.

Associated Functions

For function details and documentation, click on the function link.

PointerInputPlugin

PointerInputPlugin

  • is_touch_enabled:bool
  • is_mouse_enabled:bool

Description

Adds mouse and touch inputs for picking pointers to your app. This is a default input plugin, that you can replace with your own plugin as needed.

[crate::PickingPlugin::is_input_enabled] can be used to toggle whether the core picking plugin processes the inputs sent by this, or other input plugins, in one place.

This plugin contains several settings, and is added to the world as a resource after initialization. You can configure pointer input settings at runtime by accessing the resource.

Associated Functions

For function details and documentation, click on the function link.

PointerId

Mouse

Touch

  1. u64

Custom

  1. uuid::Uuid

Description

Identifies a unique pointer entity. Mouse and Touch pointers are automatically spawned.

This component is needed because pointers can be spawned and despawned, but they need to have a stable ID that persists regardless of the Entity they are associated with.

Associated Functions

For function details and documentation, click on the function link.

PointerInteraction

PointerInteraction

  • sorted_entities:alloc::vec::Vec<(bevy_ecs::entity::Entity, bevy_picking::backend::HitData)>

Description

Holds a list of entities this pointer is currently interacting with, sorted from nearest to farthest.

Associated Functions

For function details and documentation, click on the function link.

PointerLocation

PointerLocation

Description

Component that tracks a pointer's current [Location].

Associated Functions

For function details and documentation, click on the function link.

PointerPress

PointerPress

  • primary:bool
  • secondary:bool
  • middle:bool

Description

Tracks the state of the pointer's buttons in response to [PointerInput] events.

Associated Functions

For function details and documentation, click on the function link.

AlphaMode

Opaque

Mask

  1. f32

Blend

Premultiplied

AlphaToCoverage

Add

Multiply

Description

Sets how a material's base color alpha channel is used for transparency.

Associated Functions

For function details and documentation, click on the function link.

Camera

Camera

  • viewport:core::option::Option<bevy_render::camera::camera::Viewport>
  • order:isize
  • is_active:bool
  • target:bevy_render::camera::camera::RenderTarget
  • hdr:bool
  • msaa_writeback:bool
  • clear_color:bevy_render::camera::clear_color::ClearColorConfig
  • sub_camera_view:core::option::Option<bevy_render::camera::camera::SubCameraView>

Description

The defining [Component] for camera entities, storing information about how and what to render through this camera.

The [Camera] component is added to an entity to define the properties of the viewpoint from which rendering occurs. It defines the position of the view to render, the projection method to transform the 3D objects into a 2D image, as well as the render target into which that image is produced.

Note that a [Camera] needs a [CameraRenderGraph] to render anything. This is typically provided by adding a Camera2d or Camera3d component, but custom render graphs can also be defined. Inserting a [Camera] with no render graph will emit an error at runtime.

Associated Functions

For function details and documentation, click on the function link.

CameraMainTextureUsages

Opaque Type. 🔒

Description

This component lets you control the [TextureUsages] field of the main texture generated for the camera

Associated Functions

For function details and documentation, click on the function link.

CameraRenderGraph

Opaque Type. 🔒

Description

Configures the RenderGraph name assigned to be run for a given [Camera] entity.

Associated Functions

For function details and documentation, click on the function link.

Exposure

Opaque Type. 🔒

Description

How much energy a Camera3d absorbs from incoming light.

https://en.wikipedia.org/wiki/Exposure_(photography)

Associated Functions

For function details and documentation, click on the function link.

MipBias

MipBias

  1. f32

Description

Camera component specifying a mip bias to apply when sampling from material textures.

Often used in conjunction with antialiasing post-process effects to reduce textures blurriness.

Associated Functions

For function details and documentation, click on the function link.

RenderTarget

Window

  1. bevy_window::window::WindowRef

Image

  1. bevy_asset::handle::Handle<bevy_image::image::Image>

TextureView

  1. bevy_render::camera::manual_texture_view::ManualTextureViewHandle

Description

The "target" that a [Camera] will render to. For example, this could be a [Window] swapchain or an [Image].

Associated Functions

For function details and documentation, click on the function link.

SubCameraView

SubCameraView

  • full_size:glam::UVec2
  • offset:glam::Vec2
  • size:glam::UVec2

Description

Settings to define a camera sub view.

When [Camera::sub_camera_view] is Some, only the sub-section of the image defined by size and offset (relative to the full_size of the whole image) is projected to the cameras viewport.

Take the example of the following multi-monitor setup:

┌───┬───┐
│ A │ B │
├───┼───┤
│ C │ D │
└───┴───┘

If each monitor is 1920x1080, the whole image will have a resolution of 3840x2160. For each monitor we can use a single camera with a viewport of the same size as the monitor it corresponds to. To ensure that the image is cohesive, we can use a different sub view on each camera:

  • Camera A: full_size = 3840x2160, size = 1920x1080, offset = 0,0
  • Camera B: full_size = 3840x2160, size = 1920x1080, offset = 1920,0
  • Camera C: full_size = 3840x2160, size = 1920x1080, offset = 0,1080
  • Camera D: full_size = 3840x2160, size = 1920x1080, offset = 1920,1080

However since only the ratio between the values is important, they could all be divided by 120 and still produce the same image. Camera D would for example have the following values: full_size = 32x18, size = 16x9, offset = 16,9

Associated Functions

For function details and documentation, click on the function link.

TemporalJitter

TemporalJitter

  • offset:glam::Vec2

Description

A subpixel offset to jitter a perspective camera's frustum by.

Useful for temporal rendering techniques.

Do not use with OrthographicProjection.

Associated Functions

For function details and documentation, click on the function link.

Viewport

Viewport

  • physical_position:glam::UVec2
  • physical_size:glam::UVec2
  • depth:core::ops::Range

Description

Render viewport configuration for the [Camera] component.

The viewport defines the area on the render target to which the camera renders its image. You can overlay multiple cameras in a single window using viewports to create effects like split screen, minimaps, and character viewers.

Associated Functions

For function details and documentation, click on the function link.

ClearColor

ClearColor

  1. bevy_color::color::Color

Description

A [Resource] that stores the color that is used to clear the screen between frames.

This color appears as the "background" color for simple apps, when there are portions of the screen with nothing rendered.

Associated Functions

For function details and documentation, click on the function link.

ClearColorConfig

Default

Custom

  1. bevy_color::color::Color

None

Description

For a camera, specifies the color used to clear the viewport before rendering.

Associated Functions

For function details and documentation, click on the function link.

ManualTextureViewHandle

ManualTextureViewHandle

  1. u32

Description

A unique id that corresponds to a specific [ManualTextureView] in the [ManualTextureViews] collection.

Associated Functions

For function details and documentation, click on the function link.

OrthographicProjection

OrthographicProjection

  • near:f32
  • far:f32
  • viewport_origin:glam::Vec2
  • scaling_mode:bevy_render::camera::projection::ScalingMode
  • scale:f32
  • area:bevy_math::rects::rect::Rect

Description

Project a 3D space onto a 2D surface using parallel lines, i.e., unlike [PerspectiveProjection], the size of objects remains the same regardless of their distance to the camera.

The volume contained in the projection is called the view frustum. Since the viewport is rectangular and projection lines are parallel, the view frustum takes the shape of a cuboid.

Note that the scale of the projection and the apparent size of objects are inversely proportional. As the size of the projection increases, the size of objects decreases.

Examples

Configure the orthographic projection to one world unit per 100 window pixels:

# use bevy_render::camera::{OrthographicProjection, Projection, ScalingMode};
let projection = Projection::Orthographic(OrthographicProjection {
    scaling_mode: ScalingMode::WindowSize,
    scale: 0.01,
    ..OrthographicProjection::default_2d()
});

Associated Functions

For function details and documentation, click on the function link.

PerspectiveProjection

PerspectiveProjection

  • fov:f32
  • aspect_ratio:f32
  • near:f32
  • far:f32

Description

A 3D camera projection in which distant objects appear smaller than close objects.

Associated Functions

For function details and documentation, click on the function link.

Projection

Perspective

  1. bevy_render::camera::projection::PerspectiveProjection

Orthographic

  1. bevy_render::camera::projection::OrthographicProjection

Description

A configurable [CameraProjection] that can select its projection type at runtime.

Associated Functions

For function details and documentation, click on the function link.

ScalingMode

WindowSize

Fixed

  • width:f32
  • height:f32

AutoMin

  • min_width:f32
  • min_height:f32

AutoMax

  • max_width:f32
  • max_height:f32

FixedVertical

  • viewport_height:f32

FixedHorizontal

  • viewport_width:f32

Description

Scaling mode for [OrthographicProjection].

The effect of these scaling modes are combined with the [OrthographicProjection::scale] property.

For example, if the scaling mode is ScalingMode::Fixed { width: 100.0, height: 300 } and the scale is 2.0, the projection will be 200 world units wide and 600 world units tall.

Examples

Configure the orthographic projection to two world units per window height:

# use bevy_render::camera::{OrthographicProjection, Projection, ScalingMode};
let projection = Projection::Orthographic(OrthographicProjection {
   scaling_mode: ScalingMode::FixedVertical { viewport_height: 2.0 },
   ..OrthographicProjection::default_2d()
});

Associated Functions

For function details and documentation, click on the function link.

GlobalsUniform

GlobalsUniform

  • time:f32
  • delta_time:f32
  • frame_count:u32

Description

Contains global values useful when writing shaders. Currently only contains values related to time.

Associated Functions

For function details and documentation, click on the function link.

Mesh2d

Mesh2d

  1. bevy_asset::handle::Handle<bevy_mesh::mesh::Mesh>

Description

A component for 2D meshes. Requires a MeshMaterial2d to be rendered, commonly using a ColorMaterial.

Example

# use bevy_sprite::{ColorMaterial, Mesh2d, MeshMaterial2d};
# use bevy_ecs::prelude::*;
# use bevy_render::mesh::Mesh;
# use bevy_color::palettes::basic::RED;
# use bevy_asset::Assets;
# use bevy_math::primitives::Circle;
#
// Spawn an entity with a mesh using `ColorMaterial`.
fn setup(
    mut commands: Commands,
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<ColorMaterial>>,
) {
    commands.spawn((
        Mesh2d(meshes.add(Circle::new(50.0))),
        MeshMaterial2d(materials.add(ColorMaterial::from_color(RED))),
    ));
}

Associated Functions

For function details and documentation, click on the function link.

Mesh3d

Mesh3d

  1. bevy_asset::handle::Handle<bevy_mesh::mesh::Mesh>

Description

A component for 3D meshes. Requires a MeshMaterial3d to be rendered, commonly using a StandardMaterial.

Example

# use bevy_pbr::{Material, MeshMaterial3d, StandardMaterial};
# use bevy_ecs::prelude::*;
# use bevy_render::mesh::{Mesh, Mesh3d};
# use bevy_color::palettes::basic::RED;
# use bevy_asset::Assets;
# use bevy_math::primitives::Capsule3d;
#
// Spawn an entity with a mesh using `StandardMaterial`.
fn setup(
    mut commands: Commands,
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<StandardMaterial>>,
) {
    commands.spawn((
        Mesh3d(meshes.add(Capsule3d::default())),
        MeshMaterial3d(materials.add(StandardMaterial {
            base_color: RED.into(),
            ..Default::default()
        })),
    ));
}

Associated Functions

For function details and documentation, click on the function link.

Aabb

Aabb

  • center:glam::Vec3A
  • half_extents:glam::Vec3A

Description

An axis-aligned bounding box, defined by:

  • a center,
  • the distances from the center to each faces along the axis, the faces are orthogonal to the axis.

It is typically used as a component on an entity to represent the local space occupied by this entity, with faces orthogonal to its local axis.

This component is notably used during "frustum culling", a process to determine if an entity should be rendered by a Camera if its bounding box intersects with the camera's [Frustum].

It will be added automatically by the systems in CalculateBounds to entities that:

  • could be subject to frustum culling, for example with a Mesh3d or Sprite component,
  • don't have the NoFrustumCulling component.

It won't be updated automatically if the space occupied by the entity changes, for example if the vertex positions of a Mesh3d are updated.

Associated Functions

For function details and documentation, click on the function link.

CascadesFrusta

CascadesFrusta

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

CubemapFrusta

CubemapFrusta

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Frustum

Frustum

Description

A region of 3D space defined by the intersection of 6 [HalfSpace]s.

Frustums are typically an apex-truncated square pyramid (a pyramid without the top) or a cuboid.

Half spaces are ordered left, right, top, bottom, near, far. The normal vectors of the half-spaces point towards the interior of the frustum.

A frustum component is used on an entity with a Camera component to determine which entities will be considered for rendering by this camera. All entities with an [Aabb] component that are not contained by (or crossing the boundary of) the frustum will not be rendered, and not be used in rendering computations.

This process is called frustum culling, and entities can opt out of it using the NoFrustumCulling component.

The frustum component is typically added automatically for cameras, either Camera2d or Camera3d. It is usually updated automatically by update_frusta from the CameraProjection component and GlobalTransform of the camera entity.

Associated Functions

For function details and documentation, click on the function link.

ShaderStorageBuffer

Opaque Type. 🔒

Description

A storage buffer that is prepared as a [RenderAsset] and uploaded to the GPU.

Associated Functions

For function details and documentation, click on the function link.

SyncToRenderWorld

SyncToRenderWorld

Description

Marker component that indicates that its entity needs to be synchronized to the render world.

This component is automatically added as a required component by ExtractComponentPlugin and SyncComponentPlugin. For more information see [SyncWorldPlugin].

NOTE: This component should persist throughout the entity's entire lifecycle. If this component is removed from its entity, the entity will be despawned.

Associated Functions

For function details and documentation, click on the function link.

ColorGrading

ColorGrading

  • global:bevy_render::view::ColorGradingGlobal
  • shadows:bevy_render::view::ColorGradingSection
  • midtones:bevy_render::view::ColorGradingSection
  • highlights:bevy_render::view::ColorGradingSection

Description

Configures filmic color grading parameters to adjust the image appearance.

Color grading is applied just before tonemapping for a given Camera entity, with the sole exception of the post_saturation value in [ColorGradingGlobal], which is applied after tonemapping.

Associated Functions

For function details and documentation, click on the function link.

ColorGradingGlobal

ColorGradingGlobal

  • exposure:f32
  • temperature:f32
  • tint:f32
  • hue:f32
  • post_saturation:f32
  • midtones_range:core::ops::Range

Description

Filmic color grading values applied to the image as a whole (as opposed to individual sections, like shadows and highlights).

Associated Functions

For function details and documentation, click on the function link.

ColorGradingSection

ColorGradingSection

  • saturation:f32
  • contrast:f32
  • gamma:f32
  • gain:f32
  • lift:f32

Description

A section of color grading values that can be selectively applied to shadows, midtones, and highlights.

Associated Functions

For function details and documentation, click on the function link.

Msaa

Off

Sample2

Sample4

Sample8

Description

Component for configuring the number of samples for Multi-Sample Anti-Aliasing for a Camera.

Defaults to 4 samples. A higher number of samples results in smoother edges.

Some advanced rendering features may require that MSAA is disabled.

Note that the web currently only supports 1 or 4 samples.

Associated Functions

For function details and documentation, click on the function link.

InheritedVisibility

InheritedVisibility

  1. bool

Description

Whether or not an entity is visible in the hierarchy. This will not be accurate until VisibilityPropagate runs in the [PostUpdate] schedule.

If this is false, then [ViewVisibility] should also be false.

Associated Functions

For function details and documentation, click on the function link.

NoFrustumCulling

NoFrustumCulling

Description

Use this component to opt-out of built-in frustum culling for entities, see [Frustum].

It can be used for example:

  • when a [Mesh] is updated but its [Aabb] is not, which might happen with animations,
  • when using some light effects, like wanting a [Mesh] out of the [Frustum] to appear in the reflection of a [Mesh] within.

Associated Functions

For function details and documentation, click on the function link.

ViewVisibility

ViewVisibility

  1. bool

Description

Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering.

Each frame, this will be reset to false during VisibilityPropagate systems in [PostUpdate]. Later in the frame, systems in CheckVisibility will mark any visible entities using [ViewVisibility::set]. Because of this, values of this type will be marked as changed every frame, even when they do not change.

If you wish to add custom visibility system that sets this value, make sure you add it to the CheckVisibility set.

Associated Functions

For function details and documentation, click on the function link.

Visibility

Inherited

Hidden

Visible

Description

User indication of whether an entity is visible. Propagates down the entity hierarchy.

If an entity is hidden in this way, all [Children] (and all of their children and so on) who are set to Inherited will also be hidden.

This is done by the visibility_propagate_system which uses the entity hierarchy and Visibility to set the values of each entity's [InheritedVisibility] component.

Associated Functions

For function details and documentation, click on the function link.

VisibleEntities

VisibleEntities

Description

Collection of entities visible from the current view.

This component contains all entities which are visible from the currently rendered view. The collection is updated automatically by the [VisibilitySystems::CheckVisibility] system set. Renderers can use the equivalent [RenderVisibleEntities] to optimize rendering of a particular view, to prevent drawing items not visible from that view.

This component is intended to be attached to the same entity as the [Camera] and the [Frustum] defining the view.

Associated Functions

For function details and documentation, click on the function link.

VisibilityRange

VisibilityRange

  • start_margin:core::ops::Range
  • end_margin:core::ops::Range
  • use_aabb:bool

Description

Specifies the range of distances that this entity must be from the camera in order to be rendered.

This is also known as hierarchical level of detail or HLOD.

Use this component when you want to render a high-polygon mesh when the camera is close and a lower-polygon mesh when the camera is far away. This is a common technique for improving performance, because fine details are hard to see in a mesh at a distance. To avoid an artifact known as popping between levels, each level has a margin, within which the object transitions gradually from invisible to visible using a dithering effect.

You can also use this feature to replace multiple meshes with a single mesh when the camera is distant. This is the reason for the term "hierarchical level of detail". Reducing the number of meshes can be useful for reducing drawcall count. Note that you must place the [VisibilityRange] component on each entity you want to be part of a LOD group, as [VisibilityRange] isn't automatically propagated down to children.

A typical use of this feature might look like this:

Entitystart_marginend_margin
RootN/AN/A
├─ High-poly mesh[0, 0)[20, 25)
├─ Low-poly mesh[20, 25)[70, 75)
└─ Billboard imposter[70, 75)[150, 160)

With this setup, the user will see a high-poly mesh when the camera is closer than 20 units. As the camera zooms out, between 20 units to 25 units, the high-poly mesh will gradually fade to a low-poly mesh. When the camera is 70 to 75 units away, the low-poly mesh will fade to a single textured quad. And between 150 and 160 units, the object fades away entirely. Note that the end_margin of a higher LOD is always identical to the start_margin of the next lower LOD; this is important for the crossfade effect to function properly.

Associated Functions

For function details and documentation, click on the function link.

RenderLayers

RenderLayers

  1. smallvec::SmallVec<[u64; 1]>

Description

Describes which rendering layers an entity belongs to.

Cameras with this component will only render entities with intersecting layers.

Entities may belong to one or more layers, or no layer at all.

The [Default] instance of RenderLayers contains layer 0, the first layer.

An entity with this component without any layers is invisible.

Entities without this component belong to layer 0.

Associated Functions

For function details and documentation, click on the function link.

Screenshot

Screenshot

  1. bevy_render::camera::camera::RenderTarget

Description

A component that signals to the renderer to capture a screenshot this frame.

This component should be spawned on a new entity with an observer that will trigger with [ScreenshotCaptured] when the screenshot is ready.

Screenshots are captured asynchronously and may not be available immediately after the frame that the component is spawned on. The observer should be used to handle the screenshot when it is ready.

Note that the screenshot entity will be despawned after the screenshot is captured and the observer is triggered.

Usage

# use bevy_ecs::prelude::*;
# use bevy_render::view::screenshot::{save_to_disk, Screenshot};

fn take_screenshot(mut commands: Commands) {
   commands.spawn(Screenshot::primary_window())
      .observe(save_to_disk("screenshot.png"));
}

Associated Functions

For function details and documentation, click on the function link.

ScreenshotCaptured

ScreenshotCaptured

  1. bevy_image::image::Image

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

DynamicSceneRoot

DynamicSceneRoot

  1. bevy_asset::handle::Handle<bevy_scene::dynamic_scene::DynamicScene>

Description

Adding this component will spawn the scene as a child of that entity. Once it's spawned, the entity will have a SceneInstance component.

Associated Functions

For function details and documentation, click on the function link.

SceneRoot

SceneRoot

  1. bevy_asset::handle::Handle<bevy_scene::scene::Scene>

Description

Adding this component will spawn the scene as a child of that entity. Once it's spawned, the entity will have a SceneInstance component.

Associated Functions

For function details and documentation, click on the function link.

SpriteSource

SpriteSource

Description

A component that marks entities that aren't themselves sprites but become sprites during rendering.

Right now, this is used for Text.

Associated Functions

For function details and documentation, click on the function link.

ColorMaterial

ColorMaterial

  • color:bevy_color::color::Color
  • alpha_mode:bevy_sprite::mesh2d::material::AlphaMode2d
  • texture:core::option::Option<bevy_asset::handle::Handle<bevy_image::image::Image>>

Description

A 2d material that renders 2d meshes with a texture tinted by a uniform color

Associated Functions

For function details and documentation, click on the function link.

AlphaMode2d

Opaque

Mask

  1. f32

Blend

Description

Sets how a 2d material's base color alpha channel is used for transparency. Currently, this only works with [Mesh2d]. Sprites are always transparent.

This is very similar to AlphaMode but this only applies to 2d meshes. We use a separate type because 2d doesn't support all the transparency modes that 3d does.

Associated Functions

For function details and documentation, click on the function link.

Anchor

Center

BottomLeft

BottomCenter

BottomRight

CenterLeft

CenterRight

TopLeft

TopCenter

TopRight

Custom

  1. glam::Vec2

Description

How a sprite is positioned relative to its [Transform]. It defaults to Anchor::Center.

Associated Functions

For function details and documentation, click on the function link.

Sprite

Sprite

  • image:bevy_asset::handle::Handle<bevy_image::image::Image>
  • texture_atlas:core::option::Option<bevy_sprite::texture_atlas::TextureAtlas>
  • color:bevy_color::color::Color
  • flip_x:bool
  • flip_y:bool
  • custom_size:core::option::Optionglam::Vec2
  • rect:core::option::Option<bevy_math::rects::rect::Rect>
  • anchor:bevy_sprite::sprite::Anchor
  • image_mode:bevy_sprite::sprite::SpriteImageMode

Description

Describes a sprite to be rendered to a 2D camera

Associated Functions

For function details and documentation, click on the function link.

SpriteImageMode

Auto

Sliced

  1. bevy_sprite::texture_slice::slicer::TextureSlicer

Tiled

  • tile_x:bool
  • tile_y:bool
  • stretch_value:f32

Description

Controls how the image is altered when scaled.

Associated Functions

For function details and documentation, click on the function link.

TextureAtlas

TextureAtlas

  • layout:bevy_asset::handle::Handle<bevy_sprite::texture_atlas::TextureAtlasLayout>
  • index:usize

Description

An index into a [TextureAtlasLayout], which corresponds to a specific section of a texture.

It stores a handle to [TextureAtlasLayout] and the index of the current section of the atlas. The texture atlas contains various sections of a given texture, allowing users to have a single image file for either sprite animation or global mapping. You can change the texture index of the atlas to animate the sprite or display only a section of the texture for efficient rendering of related game objects.

Check the following examples for usage:

Associated Functions

For function details and documentation, click on the function link.

TextureAtlasLayout

TextureAtlasLayout

  • size:glam::UVec2
  • textures:alloc::vec::Vec<bevy_math::rects::urect::URect>

Description

Stores a map used to lookup the position of a texture in a [TextureAtlas]. This can be used to either use and look up a specific section of a texture, or animate frame-by-frame as a sprite sheet.

Optionally it can store a mapping from sub texture handles to the related area index (see TextureAtlasBuilder).

Example usage animating sprite. Example usage animating sprite in response to an event. Example usage loading sprite sheet.

Associated Functions

For function details and documentation, click on the function link.

BorderRect

BorderRect

  • left:f32
  • right:f32
  • top:f32
  • bottom:f32

Description

Struct defining a Sprite border with padding values

Associated Functions

For function details and documentation, click on the function link.

SliceScaleMode

Stretch

Tile

  • stretch_value:f32

Description

Defines how a texture slice scales when resized

Associated Functions

For function details and documentation, click on the function link.

TextureSlicer

TextureSlicer

  • border:bevy_sprite::texture_slice::border_rect::BorderRect
  • center_scale_mode:bevy_sprite::texture_slice::slicer::SliceScaleMode
  • sides_scale_mode:bevy_sprite::texture_slice::slicer::SliceScaleMode
  • max_corner_scale:f32

Description

Slices a texture using the 9-slicing technique. This allows to reuse an image at various sizes without needing to prepare multiple assets. The associated texture will be split into nine portions, so that on resize the different portions scale or tile in different ways to keep the texture in proportion.

For example, when resizing a 9-sliced texture the corners will remain unscaled while the other sections will be scaled or tiled.

See 9-sliced textures.

Associated Functions

For function details and documentation, click on the function link.

ReflectableScheduleLabel

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

TextBounds

TextBounds

  • width:core::option::Option
  • height:core::option::Option

Description

The maximum width and height of text. The text will wrap according to the specified size.

Characters out of the bounds after wrapping will be truncated. Text is aligned according to the specified JustifyText.

Note: only characters that are completely out of the bounds will be truncated, so this is not a reliable limit if it is necessary to contain the text strictly in the bounds. Currently this component is mainly useful for text wrapping only.

Associated Functions

For function details and documentation, click on the function link.

GlyphAtlasInfo

GlyphAtlasInfo

  • texture:bevy_asset::handle::Handle<bevy_image::image::Image>
  • texture_atlas:bevy_asset::handle::Handle<bevy_sprite::texture_atlas::TextureAtlasLayout>
  • location:bevy_text::glyph::GlyphAtlasLocation

Description

Information about a glyph in an atlas.

Rasterized glyphs are stored as rectangles in one or more FontAtlases.

Used in [PositionedGlyph] and FontAtlasSet.

Associated Functions

For function details and documentation, click on the function link.

GlyphAtlasLocation

GlyphAtlasLocation

  • glyph_index:usize
  • offset:glam::IVec2

Description

The location of a glyph in an atlas, and how it should be positioned when placed.

Used in [GlyphAtlasInfo] and FontAtlas.

Associated Functions

For function details and documentation, click on the function link.

PositionedGlyph

PositionedGlyph

  • position:glam::Vec2
  • size:glam::Vec2
  • atlas_info:bevy_text::glyph::GlyphAtlasInfo
  • span_index:usize
  • byte_index:usize

Description

A glyph of a font, typically representing a single character, positioned in screen space.

Contains information about how and where to render a glyph.

Used in TextPipeline::queue_text and [crate::TextLayoutInfo] for rendering glyphs.

Associated Functions

For function details and documentation, click on the function link.

TextLayoutInfo

TextLayoutInfo

  • glyphs:alloc::vec::Vec<bevy_text::glyph::PositionedGlyph>
  • size:glam::Vec2

Description

Render information for a corresponding text block.

Contains scaled glyphs and their size. Generated via [TextPipeline::queue_text] when an entity has [TextLayout] and [ComputedTextBlock] components.

Associated Functions

For function details and documentation, click on the function link.

Text2d

Text2d

  1. String

Description

The top-level 2D text component.

Adding Text2d to an entity will pull in required components for setting up 2d text. Example usage.

The string in this component is the first 'text span' in a hierarchy of text spans that are collected into a [ComputedTextBlock]. See TextSpan for the component used by children of entities with [Text2d].

With Text2d the justify field of [TextLayout] only affects the internal alignment of a block of text and not its relative position, which is controlled by the [Anchor] component. This means that for a block of text consisting of only one line that doesn't wrap, the justify field will have no effect.

# use bevy_asset::Handle;
# use bevy_color::Color;
# use bevy_color::palettes::basic::BLUE;
# use bevy_ecs::world::World;
# use bevy_text::{Font, JustifyText, Text2d, TextLayout, TextFont, TextColor};
#
# let font_handle: Handle<Font> = Default::default();
# let mut world = World::default();
#
// Basic usage.
world.spawn(Text2d::new("hello world!"));

// With non-default style.
world.spawn((
    Text2d::new("hello world!"),
    TextFont {
        font: font_handle.clone().into(),
        font_size: 60.0,
        ..Default::default()
    },
    TextColor(BLUE.into()),
));

// With text justification.
world.spawn((
    Text2d::new("hello world\nand bevy!"),
    TextLayout::new_with_justify(JustifyText::Center)
));

Associated Functions

For function details and documentation, click on the function link.

ComputedTextBlock

ComputedTextBlock

  • entities:smallvec::SmallVec<[bevy_text::text::TextEntity; 1]>
  • needs_rerender:bool

Description

Computed information for a text block.

See [TextLayout].

Automatically updated by 2d and UI text systems.

Associated Functions

For function details and documentation, click on the function link.

FontSmoothing

None

AntiAliased

Description

Determines which antialiasing method to use when rendering text. By default, text is rendered with grayscale antialiasing, but this can be changed to achieve a pixelated look.

Note: Subpixel antialiasing is not currently supported.

Associated Functions

For function details and documentation, click on the function link.

JustifyText

Left

Center

Right

Justified

Description

Describes the horizontal alignment of multiple lines of text relative to each other.

This only affects the internal positioning of the lines of text within a text entity and does not affect the text entity's position.

Has no affect on a single line text entity.

Associated Functions

For function details and documentation, click on the function link.

LineBreak

WordBoundary

AnyCharacter

WordOrCharacter

NoWrap

Description

Determines how lines will be broken when preventing text from running out of bounds.

Associated Functions

For function details and documentation, click on the function link.

TextColor

TextColor

  1. bevy_color::color::Color

Description

The color of the text for this section.

Associated Functions

For function details and documentation, click on the function link.

TextEntity

TextEntity

  • entity:bevy_ecs::entity::Entity
  • depth:usize

Description

A sub-entity of a [ComputedTextBlock].

Returned by [ComputedTextBlock::entities].

Associated Functions

For function details and documentation, click on the function link.

TextFont

TextFont

  • font:bevy_asset::handle::Handle<bevy_text::font::Font>
  • font_size:f32
  • font_smoothing:bevy_text::text::FontSmoothing

Description

TextFont determines the style of a text span within a [ComputedTextBlock], specifically the font face, the font size, and the color.

Associated Functions

For function details and documentation, click on the function link.

TextLayout

TextLayout

  • justify:bevy_text::text::JustifyText
  • linebreak:bevy_text::text::LineBreak

Description

Component with text format settings for a block of text.

A block of text is composed of text spans, which each have a separate string value and [TextFont]. Text spans associated with a text block are collected into [ComputedTextBlock] for layout, and then inserted to [TextLayoutInfo] for rendering.

See Text2d for the core component of 2d text, and Text in bevy_ui for UI text.

Associated Functions

For function details and documentation, click on the function link.

TextSpan

TextSpan

  1. String

Description

A span of UI text in a tree of spans under an entity with [TextLayout] and Text or Text2d.

Spans are collected in hierarchy traversal order into a [ComputedTextBlock] for layout.

# use bevy_asset::Handle;
# use bevy_color::Color;
# use bevy_color::palettes::basic::{RED, BLUE};
# use bevy_ecs::world::World;
# use bevy_text::{Font, TextLayout, TextFont, TextSpan, TextColor};
# use bevy_hierarchy::BuildChildren;

# let font_handle: Handle<Font> = Default::default();
# let mut world = World::default();
#
world.spawn((
    TextLayout::default(),
    TextFont {
        font: font_handle.clone().into(),
        font_size: 60.0,
        ..Default::default()
    },
    TextColor(BLUE.into()),
))
.with_child((
    TextSpan::new("Hello!"),
    TextFont {
        font: font_handle.into(),
        font_size: 60.0,
        ..Default::default()
    },
    TextColor(RED.into()),
));

Associated Functions

For function details and documentation, click on the function link.

UiScale

UiScale

  1. f32

Description

The current scale of the UI.

A multiplier to fixed-sized ui values. Note: This will only affect fixed ui values like [Val::Px]

Associated Functions

For function details and documentation, click on the function link.

FocusPolicy

Block

Pass

Description

Describes whether the node should block interactions with lower nodes

Associated Functions

For function details and documentation, click on the function link.

Interaction

Pressed

Hovered

None

Description

Describes what type of input interaction has occurred for a UI node.

This is commonly queried with a Changed<Interaction> filter.

Updated in [ui_focus_system].

If a UI node has both [Interaction] and [ViewVisibility] components, [Interaction] will always be [Interaction::None] when [ViewVisibility::get()] is false. This ensures that hidden UI nodes are not interactable, and do not end up stuck in an active state if hidden at the wrong time.

Note that you can also control the visibility of a node using the Display property, which fully collapses it during layout calculations.

See also

  • Button which requires this component
  • [RelativeCursorPosition] to obtain the position of the cursor relative to current node

Associated Functions

For function details and documentation, click on the function link.

RelativeCursorPosition

RelativeCursorPosition

  • normalized_visible_node_rect:bevy_math::rects::rect::Rect
  • normalized:core::option::Optionglam::Vec2

Description

A component storing the position of the mouse relative to the node, (0., 0.) being the top-left corner and (1., 1.) being the bottom-right If the mouse is not over the node, the value will go beyond the range of (0., 0.) to (1., 1.)

It can be used alongside [Interaction] to get the position of the press.

The component is updated when it is in the same entity with Node.

Associated Functions

For function details and documentation, click on the function link.

UiRect

UiRect

  • left:bevy_ui::geometry::Val
  • right:bevy_ui::geometry::Val
  • top:bevy_ui::geometry::Val
  • bottom:bevy_ui::geometry::Val

Description

A type which is commonly used to define margins, paddings and borders.

Examples

Margin

A margin is used to create space around UI elements, outside of any defined borders.

# use bevy_ui::{UiRect, Val};
#
let margin = UiRect::all(Val::Auto); // Centers the UI element

Padding

A padding is used to create space around UI elements, inside of any defined borders.

# use bevy_ui::{UiRect, Val};
#
let padding = UiRect {
    left: Val::Px(10.0),
    right: Val::Px(20.0),
    top: Val::Px(30.0),
    bottom: Val::Px(40.0),
};

Borders

A border is used to define the width of the border of a UI element.

# use bevy_ui::{UiRect, Val};
#
let border = UiRect {
    left: Val::Px(10.0),
    right: Val::Px(20.0),
    top: Val::Px(30.0),
    bottom: Val::Px(40.0),
};

Associated Functions

For function details and documentation, click on the function link.

Val

Auto

Px

  1. f32

Percent

  1. f32

Vw

  1. f32

Vh

  1. f32

VMin

  1. f32

VMax

  1. f32

Description

Represents the possible value types for layout properties.

This enum allows specifying values for various Node properties in different units, such as logical pixels, percentages, or automatically determined values.

Associated Functions

For function details and documentation, click on the function link.

ContentSize

ContentSize

Description

A node with a ContentSize component is a node where its size is based on its content.

Associated Functions

For function details and documentation, click on the function link.

AlignContent

Default

Start

End

FlexStart

FlexEnd

Center

Stretch

SpaceBetween

SpaceEvenly

SpaceAround

Description

Used to control how items are distributed.

  • For Flexbox containers, controls alignment of lines if flex_wrap is set to [FlexWrap::Wrap] and there are multiple lines of items.
  • For CSS Grid containers, controls alignment of grid rows.

https://developer.mozilla.org/en-US/docs/Web/CSS/align-content

Associated Functions

For function details and documentation, click on the function link.

AlignItems

Default

Start

End

FlexStart

FlexEnd

Center

Baseline

Stretch

Description

Used to control how each individual item is aligned by default within the space they're given.

  • For Flexbox containers, sets default cross axis alignment of the child items.
  • For CSS Grid containers, controls block (vertical) axis alignment of children of this grid container within their grid areas.

https://developer.mozilla.org/en-US/docs/Web/CSS/align-items

Associated Functions

For function details and documentation, click on the function link.

AlignSelf

Auto

Start

End

FlexStart

FlexEnd

Center

Baseline

Stretch

Description

Used to control how the specified item is aligned within the space it's given.

  • For Flexbox items, controls cross axis alignment of the item.
  • For CSS Grid items, controls block (vertical) axis alignment of a grid item within its grid area.

https://developer.mozilla.org/en-US/docs/Web/CSS/align-self

Associated Functions

For function details and documentation, click on the function link.

BackgroundColor

BackgroundColor

  1. bevy_color::color::Color

Description

The background color of the node

This serves as the "fill" color.

Associated Functions

For function details and documentation, click on the function link.

BorderColor

BorderColor

  1. bevy_color::color::Color

Description

The border color of the UI node.

Associated Functions

For function details and documentation, click on the function link.

BorderRadius

BorderRadius

  • top_left:bevy_ui::geometry::Val
  • top_right:bevy_ui::geometry::Val
  • bottom_left:bevy_ui::geometry::Val
  • bottom_right:bevy_ui::geometry::Val

Description

Used to add rounded corners to a UI node. You can set a UI node to have uniformly rounded corners or specify different radii for each corner. If a given radius exceeds half the length of the smallest dimension between the node's height or width, the radius will calculated as half the smallest dimension.

Elliptical nodes are not supported yet. Percentage values are based on the node's smallest dimension, either width or height.

Example

#![allow(unused)]
fn main() {
use bevy_ecs::prelude::*;
use bevy_ui::prelude::*;
use bevy_color::palettes::basic::{BLUE};
fn setup_ui(mut commands: Commands) {
    commands.spawn((
        Node {
            width: Val::Px(100.),
            height: Val::Px(100.),
            border: UiRect::all(Val::Px(2.)),
            ..Default::default()
        },
        BackgroundColor(BLUE.into()),
        BorderRadius::new(
            // top left
            Val::Px(10.),
            // top right
            Val::Px(20.),
            // bottom right
            Val::Px(30.),
            // bottom left
            Val::Px(40.),
        ),
    ));
}
}

https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius

Associated Functions

For function details and documentation, click on the function link.

CalculatedClip

CalculatedClip

  • clip:bevy_math::rects::rect::Rect

Description

The calculated clip of the node

Associated Functions

For function details and documentation, click on the function link.

ComputedNode

ComputedNode

  • stack_index:u32
  • size:glam::Vec2
  • outline_width:f32
  • outline_offset:f32
  • unrounded_size:glam::Vec2
  • border:bevy_sprite::texture_slice::border_rect::BorderRect
  • border_radius:bevy_ui::ui_node::ResolvedBorderRadius
  • padding:bevy_sprite::texture_slice::border_rect::BorderRect
  • inverse_scale_factor:f32

Description

Provides the computed size and layout properties of the node.

Associated Functions

For function details and documentation, click on the function link.

Display

Flex

Grid

Block

None

Description

Defines the layout model used by this node.

Part of the [Node] component.

Associated Functions

For function details and documentation, click on the function link.

FlexDirection

Row

Column

RowReverse

ColumnReverse

Description

Defines how flexbox items are ordered within a flexbox

Associated Functions

For function details and documentation, click on the function link.

FlexWrap

NoWrap

Wrap

WrapReverse

Description

Defines if flexbox items appear on a single line or on multiple lines

Associated Functions

For function details and documentation, click on the function link.

GridAutoFlow

Row

Column

RowDense

ColumnDense

Description

Controls whether grid items are placed row-wise or column-wise as well as whether the sparse or dense packing algorithm is used.

The "dense" packing algorithm attempts to fill in holes earlier in the grid, if smaller items come up later. This may cause items to appear out-of-order when doing so would fill in holes left by larger items.

Defaults to [GridAutoFlow::Row].

https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow

Associated Functions

For function details and documentation, click on the function link.

GridPlacement

GridPlacement

Description

Represents the position of a grid item in a single axis.

There are 3 fields which may be set:

  • start: which grid line the item should start at
  • end: which grid line the item should end at
  • span: how many tracks the item should span

The default span is 1. If neither start or end is set then the item will be placed automatically.

Generally, at most two fields should be set. If all three fields are specified then span will be ignored. If end specifies an earlier grid line than start then end will be ignored and the item will have a span of 1.

https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Line-based_Placement_with_CSS_Grid

Associated Functions

For function details and documentation, click on the function link.

GridTrack

GridTrack

  • min_sizing_function:bevy_ui::ui_node::MinTrackSizingFunction
  • max_sizing_function:bevy_ui::ui_node::MaxTrackSizingFunction

Description

A [GridTrack] is a Row or Column of a CSS Grid. This struct specifies what size the track should be. See below for the different "track sizing functions" you can specify.

Associated Functions

For function details and documentation, click on the function link.

GridTrackRepetition

Count

  1. u16

AutoFill

AutoFit

Description

How many times to repeat a repeated grid track

https://developer.mozilla.org/en-US/docs/Web/CSS/repeat

Associated Functions

For function details and documentation, click on the function link.

JustifyContent

Default

Start

End

FlexStart

FlexEnd

Center

Stretch

SpaceBetween

SpaceEvenly

SpaceAround

Description

Used to control how items are distributed.

  • For Flexbox containers, controls alignment of items in the main axis.
  • For CSS Grid containers, controls alignment of grid columns.

https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content

Associated Functions

For function details and documentation, click on the function link.

JustifyItems

Default

Start

End

Center

Baseline

Stretch

Description

Used to control how each individual item is aligned by default within the space they're given.

  • For Flexbox containers, this property has no effect. See justify_content for main axis alignment of flex items.
  • For CSS Grid containers, sets default inline (horizontal) axis alignment of child items within their grid areas.

https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items

Associated Functions

For function details and documentation, click on the function link.

JustifySelf

Auto

Start

End

Center

Baseline

Stretch

Description

Used to control how the specified item is aligned within the space it's given.

  • For Flexbox items, this property has no effect. See justify_content for main axis alignment of flex items.
  • For CSS Grid items, controls inline (horizontal) axis alignment of a grid item within its grid area.

https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self

Associated Functions

For function details and documentation, click on the function link.

MaxTrackSizingFunction

Px

  1. f32

Percent

  1. f32

MinContent

MaxContent

FitContentPx

  1. f32

FitContentPercent

  1. f32

Auto

Fraction

  1. f32

VMin

  1. f32

VMax

  1. f32

Vh

  1. f32

Vw

  1. f32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

MinTrackSizingFunction

Px

  1. f32

Percent

  1. f32

MinContent

MaxContent

Auto

VMin

  1. f32

VMax

  1. f32

Vh

  1. f32

Vw

  1. f32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Node

Node

  • display:bevy_ui::ui_node::Display
  • position_type:bevy_ui::ui_node::PositionType
  • overflow:bevy_ui::ui_node::Overflow
  • overflow_clip_margin:bevy_ui::ui_node::OverflowClipMargin
  • left:bevy_ui::geometry::Val
  • right:bevy_ui::geometry::Val
  • top:bevy_ui::geometry::Val
  • bottom:bevy_ui::geometry::Val
  • width:bevy_ui::geometry::Val
  • height:bevy_ui::geometry::Val
  • min_width:bevy_ui::geometry::Val
  • min_height:bevy_ui::geometry::Val
  • max_width:bevy_ui::geometry::Val
  • max_height:bevy_ui::geometry::Val
  • aspect_ratio:core::option::Option
  • align_items:bevy_ui::ui_node::AlignItems
  • justify_items:bevy_ui::ui_node::JustifyItems
  • align_self:bevy_ui::ui_node::AlignSelf
  • justify_self:bevy_ui::ui_node::JustifySelf
  • align_content:bevy_ui::ui_node::AlignContent
  • justify_content:bevy_ui::ui_node::JustifyContent
  • margin:bevy_ui::geometry::UiRect
  • padding:bevy_ui::geometry::UiRect
  • border:bevy_ui::geometry::UiRect
  • flex_direction:bevy_ui::ui_node::FlexDirection
  • flex_wrap:bevy_ui::ui_node::FlexWrap
  • flex_grow:f32
  • flex_shrink:f32
  • flex_basis:bevy_ui::geometry::Val
  • row_gap:bevy_ui::geometry::Val
  • column_gap:bevy_ui::geometry::Val
  • grid_auto_flow:bevy_ui::ui_node::GridAutoFlow
  • grid_template_rows:alloc::vec::Vec<bevy_ui::ui_node::RepeatedGridTrack>
  • grid_template_columns:alloc::vec::Vec<bevy_ui::ui_node::RepeatedGridTrack>
  • grid_auto_rows:alloc::vec::Vec<bevy_ui::ui_node::GridTrack>
  • grid_auto_columns:alloc::vec::Vec<bevy_ui::ui_node::GridTrack>
  • grid_row:bevy_ui::ui_node::GridPlacement
  • grid_column:bevy_ui::ui_node::GridPlacement

Description

The base component for UI entities. It describes UI layout and style properties.

When defining new types of UI entities, require [Node] to make them behave like UI nodes.

Nodes can be laid out using either Flexbox or CSS Grid Layout.

See below for general learning resources and for documentation on the individual style properties.

Flexbox

CSS Grid

See also

Associated Functions

For function details and documentation, click on the function link.

Outline

Outline

  • width:bevy_ui::geometry::Val
  • offset:bevy_ui::geometry::Val
  • color:bevy_color::color::Color

Description

The [Outline] component adds an outline outside the edge of a UI node. Outlines do not take up space in the layout.

To add an [Outline] to a ui node you can spawn a (Node, Outline) tuple bundle:

# use bevy_ecs::prelude::*;
# use bevy_ui::prelude::*;
# use bevy_color::palettes::basic::{RED, BLUE};
fn setup_ui(mut commands: Commands) {
    commands.spawn((
        Node {
            width: Val::Px(100.),
            height: Val::Px(100.),
            ..Default::default()
        },
        BackgroundColor(BLUE.into()),
        Outline::new(Val::Px(10.), Val::ZERO, RED.into())
    ));
}

[Outline] components can also be added later to existing UI nodes:

# use bevy_ecs::prelude::*;
# use bevy_ui::prelude::*;
# use bevy_color::Color;
fn outline_hovered_button_system(
    mut commands: Commands,
    mut node_query: Query<(Entity, &Interaction, Option<&mut Outline>), Changed<Interaction>>,
) {
    for (entity, interaction, mut maybe_outline) in node_query.iter_mut() {
        let outline_color =
            if matches!(*interaction, Interaction::Hovered) {
                Color::WHITE
            } else {
                Color::NONE
            };
        if let Some(mut outline) = maybe_outline {
            outline.color = outline_color;
        } else {
            commands.entity(entity).insert(Outline::new(Val::Px(10.), Val::ZERO, outline_color));
        }
    }
}

Inserting and removing an [Outline] component repeatedly will result in table moves, so it is generally preferable to set Outline::color to [Color::NONE] to hide an outline.

Associated Functions

For function details and documentation, click on the function link.

Overflow

Overflow

  • x:bevy_ui::ui_node::OverflowAxis
  • y:bevy_ui::ui_node::OverflowAxis

Description

Whether to show or hide overflowing items

Associated Functions

For function details and documentation, click on the function link.

OverflowAxis

Visible

Clip

Hidden

Scroll

Description

Whether to show or hide overflowing items

Associated Functions

For function details and documentation, click on the function link.

OverflowClipBox

ContentBox

PaddingBox

BorderBox

Description

Used to determine the bounds of the visible area when a UI node is clipped.

Associated Functions

For function details and documentation, click on the function link.

OverflowClipMargin

OverflowClipMargin

  • visual_box:bevy_ui::ui_node::OverflowClipBox
  • margin:f32

Description

The bounds of the visible area when a UI node is clipped.

Associated Functions

For function details and documentation, click on the function link.

PositionType

Relative

Absolute

Description

The strategy used to position this node

Associated Functions

For function details and documentation, click on the function link.

RepeatedGridTrack

RepeatedGridTrack

  • repetition:bevy_ui::ui_node::GridTrackRepetition
  • tracks:smallvec::SmallVec<[bevy_ui::ui_node::GridTrack; 1]>

Description

Represents a possibly repeated [GridTrack].

The repetition parameter can either be:

  • The integer 1, in which case the track is non-repeated.
  • a u16 count to repeat the track N times.
  • A GridTrackRepetition::AutoFit or GridTrackRepetition::AutoFill.

Note: that in the common case you want a non-repeating track (repetition count 1), you may use the constructor methods on [GridTrack] to create a RepeatedGridTrack. i.e. GridTrack::px(10.0) is equivalent to RepeatedGridTrack::px(1, 10.0).

You may only use one auto-repetition per track list. And if your track list contains an auto repetition then all tracks (in and outside of the repetition) must be fixed size (px or percent). Integer repetitions are just shorthand for writing out N tracks longhand and are not subject to the same limitations.

Associated Functions

For function details and documentation, click on the function link.

ResolvedBorderRadius

ResolvedBorderRadius

  • top_left:f32
  • top_right:f32
  • bottom_left:f32
  • bottom_right:f32

Description

Represents the resolved border radius values for a UI node.

The values are in physical pixels.

Associated Functions

For function details and documentation, click on the function link.

ScrollPosition

ScrollPosition

  • offset_x:f32
  • offset_y:f32

Description

The scroll position of the node.

Updating the values of ScrollPosition will reposition the children of the node by the offset amount. ScrollPosition may be updated by the layout system when a layout change makes a previously valid ScrollPosition invalid. Changing this does nothing on a Node without setting at least one OverflowAxis to OverflowAxis::Scroll.

Associated Functions

For function details and documentation, click on the function link.

TargetCamera

TargetCamera

  1. bevy_ecs::entity::Entity

Description

Indicates that this root [Node] entity should be rendered to a specific camera.

UI then will be laid out respecting the camera's viewport and scale factor, and rendered to this camera's [bevy_render::camera::RenderTarget].

Setting this component on a non-root node will have no effect. It will be overridden by the root node's component.

Optional if there is only one camera in the world. Required otherwise.

Associated Functions

For function details and documentation, click on the function link.

UiAntiAlias

On

Off

Description

Marker for controlling whether Ui is rendered with or without anti-aliasing in a camera. By default, Ui is always anti-aliased.

Note: This does not affect text anti-aliasing. For that, use the font_smoothing property of the TextFont component.

use bevy_core_pipeline::prelude::*;
use bevy_ecs::prelude::*;
use bevy_ui::prelude::*;

fn spawn_camera(mut commands: Commands) {
    commands.spawn((
        Camera2d,
        // This will cause all Ui in this camera to be rendered without
        // anti-aliasing
        UiAntiAlias::Off,
    ));
}

Associated Functions

For function details and documentation, click on the function link.

UiBoxShadowSamples

UiBoxShadowSamples

  1. u32

Description

Number of shadow samples. A larger value will result in higher quality shadows. Default is 4, values higher than ~10 offer diminishing returns.

use bevy_core_pipeline::prelude::*;
use bevy_ecs::prelude::*;
use bevy_ui::prelude::*;

fn spawn_camera(mut commands: Commands) {
    commands.spawn((
        Camera2d,
        UiBoxShadowSamples(6),
    ));
}

Associated Functions

For function details and documentation, click on the function link.

ZIndex

ZIndex

  1. i32

Description

Indicates that this [Node] entity's front-to-back ordering is not controlled solely by its location in the UI hierarchy. A node with a higher z-index will appear on top of sibling nodes with a lower z-index.

UI nodes that have the same z-index will appear according to the order in which they appear in the UI hierarchy. In such a case, the last node to be added to its parent will appear in front of its siblings.

Nodes without this component will be treated as if they had a value of [ZIndex(0)].

Use [GlobalZIndex] if you need to order separate UI hierarchies or nodes that are not siblings in a given UI hierarchy.

Associated Functions

For function details and documentation, click on the function link.

Button

Button

Description

Marker struct for buttons

Associated Functions

For function details and documentation, click on the function link.

ImageNode

ImageNode

  • color:bevy_color::color::Color
  • image:bevy_asset::handle::Handle<bevy_image::image::Image>
  • texture_atlas:core::option::Option<bevy_sprite::texture_atlas::TextureAtlas>
  • flip_x:bool
  • flip_y:bool
  • rect:core::option::Option<bevy_math::rects::rect::Rect>
  • image_mode:bevy_ui::widget::image::NodeImageMode

Description

A UI Node that renders an image.

Associated Functions

For function details and documentation, click on the function link.

ImageNodeSize

ImageNodeSize

  • size:glam::UVec2

Description

The size of the image's texture

This component is updated automatically by [update_image_content_size_system]

Associated Functions

For function details and documentation, click on the function link.

NodeImageMode

Auto

Stretch

Sliced

  1. bevy_sprite::texture_slice::slicer::TextureSlicer

Tiled

  • tile_x:bool
  • tile_y:bool
  • stretch_value:f32

Description

Controls how the image is altered to fit within the layout and how the layout algorithm determines the space in the layout for the image

Associated Functions

For function details and documentation, click on the function link.

Label

Label

Description

Marker struct for labels

Associated Functions

For function details and documentation, click on the function link.

Text

Text

  1. String

Description

The top-level UI text component.

Adding [Text] to an entity will pull in required components for setting up a UI text node.

The string in this component is the first 'text span' in a hierarchy of text spans that are collected into a [ComputedTextBlock]. See TextSpan for the component used by children of entities with [Text].

Note that Transform on this entity is managed automatically by the UI layout system.

# use bevy_asset::Handle;
# use bevy_color::Color;
# use bevy_color::palettes::basic::BLUE;
# use bevy_ecs::world::World;
# use bevy_text::{Font, JustifyText, TextLayout, TextFont, TextColor};
# use bevy_ui::prelude::Text;
#
# let font_handle: Handle<Font> = Default::default();
# let mut world = World::default();
#
// Basic usage.
world.spawn(Text::new("hello world!"));

// With non-default style.
world.spawn((
    Text::new("hello world!"),
    TextFont {
        font: font_handle.clone().into(),
        font_size: 60.0,
        ..Default::default()
    },
    TextColor(BLUE.into()),
));

// With text justification.
world.spawn((
    Text::new("hello world\nand bevy!"),
    TextLayout::new_with_justify(JustifyText::Center)
));

Associated Functions

For function details and documentation, click on the function link.

TextNodeFlags

TextNodeFlags

  • needs_measure_fn:bool
  • needs_recompute:bool

Description

UI text system flags.

Used internally by [measure_text_system] and [text_system] to schedule text for processing.

Associated Functions

For function details and documentation, click on the function link.

AppLifecycle

Idle

Running

WillSuspend

Suspended

WillResume

Description

Application lifetime events

Associated Functions

For function details and documentation, click on the function link.

CursorEntered

CursorEntered

  • window:bevy_ecs::entity::Entity

Description

An event that is sent whenever the user's cursor enters a window.

Associated Functions

For function details and documentation, click on the function link.

CursorLeft

CursorLeft

  • window:bevy_ecs::entity::Entity

Description

An event that is sent whenever the user's cursor leaves a window.

Associated Functions

For function details and documentation, click on the function link.

CursorMoved

CursorMoved

  • window:bevy_ecs::entity::Entity
  • position:glam::Vec2
  • delta:core::option::Optionglam::Vec2

Description

An event reporting that the mouse cursor has moved inside a window.

The event is sent only if the cursor is over one of the application's windows. It is the translated version of WindowEvent::CursorMoved from the winit crate with the addition of delta.

Not to be confused with the MouseMotion event from bevy_input.

Because the range of data is limited by the window area and it may have been transformed by the OS to implement certain effects like acceleration, you should not use it for non-cursor-like behavior such as 3D camera control. Please see MouseMotion instead.

Associated Functions

For function details and documentation, click on the function link.

FileDragAndDrop

DroppedFile

  • window:bevy_ecs::entity::Entity
  • path_buf:PathBuf

HoveredFile

  • window:bevy_ecs::entity::Entity
  • path_buf:PathBuf

HoveredFileCanceled

  • window:bevy_ecs::entity::Entity

Description

Events related to files being dragged and dropped on a window.

Associated Functions

For function details and documentation, click on the function link.

Ime

Preedit

  • window:bevy_ecs::entity::Entity
  • value:String
  • cursor:core::option::Option<(usize, usize)>

Commit

  • window:bevy_ecs::entity::Entity
  • value:String

Enabled

  • window:bevy_ecs::entity::Entity

Disabled

  • window:bevy_ecs::entity::Entity

Description

A Input Method Editor event.

This event is the translated version of the WindowEvent::Ime from the winit crate.

It is only sent if IME was enabled on the window with Window::ime_enabled.

Associated Functions

For function details and documentation, click on the function link.

RequestRedraw

RequestRedraw

Description

An event that indicates all of the application's windows should be redrawn, even if their control flow is set to Wait and there have been no window events.

Associated Functions

For function details and documentation, click on the function link.

WindowBackendScaleFactorChanged

WindowBackendScaleFactorChanged

  • window:bevy_ecs::entity::Entity
  • scale_factor:f64

Description

An event that indicates a window's OS-reported scale factor has changed.

Associated Functions

For function details and documentation, click on the function link.

WindowCloseRequested

WindowCloseRequested

  • window:bevy_ecs::entity::Entity

Description

An event that is sent whenever the operating systems requests that a window be closed. This will be sent when the close button of the window is pressed.

If the default WindowPlugin is used, these events are handled by closing the corresponding Window. To disable this behavior, set close_when_requested on the WindowPlugin to false.

Associated Functions

For function details and documentation, click on the function link.

WindowClosed

WindowClosed

  • window:bevy_ecs::entity::Entity

Description

An event that is sent whenever a window is closed. This will be sent when the window entity loses its Window component or is despawned.

Associated Functions

For function details and documentation, click on the function link.

WindowClosing

WindowClosing

  • window:bevy_ecs::entity::Entity

Description

An event that is sent whenever a window is closing. This will be sent when after a [WindowCloseRequested] event is received and the window is in the process of closing.

Associated Functions

For function details and documentation, click on the function link.

WindowCreated

WindowCreated

  • window:bevy_ecs::entity::Entity

Description

An event that is sent whenever a new window is created.

To create a new window, spawn an entity with a [crate::Window] on it.

Associated Functions

For function details and documentation, click on the function link.

WindowDestroyed

WindowDestroyed

  • window:bevy_ecs::entity::Entity

Description

An event that is sent whenever a window is destroyed by the underlying window system.

Note that if your application only has a single window, this event may be your last chance to persist state before the application terminates.

Associated Functions

For function details and documentation, click on the function link.

WindowEvent

AppLifecycle

  1. bevy_window::event::AppLifecycle

CursorEntered

  1. bevy_window::event::CursorEntered

CursorLeft

  1. bevy_window::event::CursorLeft

CursorMoved

  1. bevy_window::event::CursorMoved

FileDragAndDrop

  1. bevy_window::event::FileDragAndDrop

Ime

  1. bevy_window::event::Ime

RequestRedraw

  1. bevy_window::event::RequestRedraw

WindowBackendScaleFactorChanged

  1. bevy_window::event::WindowBackendScaleFactorChanged

WindowCloseRequested

  1. bevy_window::event::WindowCloseRequested

WindowCreated

  1. bevy_window::event::WindowCreated

WindowDestroyed

  1. bevy_window::event::WindowDestroyed

WindowFocused

  1. bevy_window::event::WindowFocused

WindowMoved

  1. bevy_window::event::WindowMoved

WindowOccluded

  1. bevy_window::event::WindowOccluded

WindowResized

  1. bevy_window::event::WindowResized

WindowScaleFactorChanged

  1. bevy_window::event::WindowScaleFactorChanged

WindowThemeChanged

  1. bevy_window::event::WindowThemeChanged

MouseButtonInput

  1. bevy_input::mouse::MouseButtonInput

MouseMotion

  1. bevy_input::mouse::MouseMotion

MouseWheel

  1. bevy_input::mouse::MouseWheel

PinchGesture

  1. bevy_input::gestures::PinchGesture

RotationGesture

  1. bevy_input::gestures::RotationGesture

DoubleTapGesture

  1. bevy_input::gestures::DoubleTapGesture

PanGesture

  1. bevy_input::gestures::PanGesture

TouchInput

  1. bevy_input::touch::TouchInput

KeyboardInput

  1. bevy_input::keyboard::KeyboardInput

KeyboardFocusLost

  1. bevy_input::keyboard::KeyboardFocusLost

Description

Wraps all bevy_window and bevy_input events in a common enum.

Read these events with EventReader<WindowEvent> if you need to access window events in the order they were received from the operating system. Otherwise, the event types are individually readable with EventReader<E> (e.g. EventReader<KeyboardInput>).

Associated Functions

For function details and documentation, click on the function link.

WindowFocused

WindowFocused

  • window:bevy_ecs::entity::Entity
  • focused:bool

Description

An event that indicates a window has received or lost focus.

Associated Functions

For function details and documentation, click on the function link.

WindowMoved

WindowMoved

  • window:bevy_ecs::entity::Entity
  • position:glam::IVec2

Description

An event that is sent when a window is repositioned in physical pixels.

Associated Functions

For function details and documentation, click on the function link.

WindowOccluded

WindowOccluded

  • window:bevy_ecs::entity::Entity
  • occluded:bool

Description

The window has been occluded (completely hidden from view).

This is different to window visibility as it depends on whether the window is closed, minimized, set invisible, or fully occluded by another window.

It is the translated version of WindowEvent::Occluded from the winit crate.

Associated Functions

For function details and documentation, click on the function link.

WindowResized

WindowResized

  • window:bevy_ecs::entity::Entity
  • width:f32
  • height:f32

Description

A window event that is sent whenever a window's logical size has changed.

Associated Functions

For function details and documentation, click on the function link.

WindowScaleFactorChanged

WindowScaleFactorChanged

  • window:bevy_ecs::entity::Entity
  • scale_factor:f64

Description

An event that indicates a window's scale factor has changed.

Associated Functions

For function details and documentation, click on the function link.

WindowThemeChanged

WindowThemeChanged

  • window:bevy_ecs::entity::Entity
  • theme:bevy_window::window::WindowTheme

Description

An event sent when the system theme changes for a window.

This event is only sent when the window is relying on the system theme to control its appearance. i.e. It is only sent when Window::window_theme is None and the system theme changes.

Associated Functions

For function details and documentation, click on the function link.

Monitor

Monitor

  • name:core::option::Optionalloc::string::String
  • physical_height:u32
  • physical_width:u32
  • physical_position:glam::IVec2
  • refresh_rate_millihertz:core::option::Option
  • scale_factor:f64
  • video_modes:alloc::vec::Vec<bevy_window::monitor::VideoMode>

Description

Represents an available monitor as reported by the user's operating system, which can be used to query information about the display, such as its size, position, and video modes.

Each monitor corresponds to an entity and can be used to position a monitor using [crate::window::MonitorSelection::Entity].

Warning

This component is synchronized with winit through bevy_winit, but is effectively read-only as winit does not support changing monitor properties.

Associated Functions

For function details and documentation, click on the function link.

VideoMode

VideoMode

  • physical_size:glam::UVec2
  • bit_depth:u16
  • refresh_rate_millihertz:u32

Description

Represents a video mode that a monitor supports

Associated Functions

For function details and documentation, click on the function link.

SystemCursorIcon

Default

ContextMenu

Help

Pointer

Progress

Wait

Cell

Crosshair

Text

VerticalText

Alias

Copy

Move

NoDrop

NotAllowed

Grab

Grabbing

EResize

NResize

NeResize

NwResize

SResize

SeResize

SwResize

WResize

EwResize

NsResize

NeswResize

NwseResize

ColResize

RowResize

AllScroll

ZoomIn

ZoomOut

Description

The icon to display for a window.

Examples of all of these cursors can be found here. This enum is simply a copy of a similar enum found in winit. winit, in turn, is based upon the CSS3 UI spec.

See the window_settings example for usage.

Associated Functions

For function details and documentation, click on the function link.

CompositeAlphaMode

Auto

Opaque

PreMultiplied

PostMultiplied

Inherit

Description

Specifies how the alpha channel of the textures should be handled during compositing, for a [Window].

Associated Functions

For function details and documentation, click on the function link.

CursorGrabMode

None

Confined

Locked

Description

Defines if and how the cursor is grabbed by a [Window].

Platform-specific

  • Windows doesn't support [CursorGrabMode::Locked]
  • macOS doesn't support [CursorGrabMode::Confined]
  • iOS/Android don't have cursors.

Since Windows and macOS have different [CursorGrabMode] support, we first try to set the grab mode that was asked for. If it doesn't work then use the alternate grab mode.

Associated Functions

For function details and documentation, click on the function link.

CursorOptions

CursorOptions

  • visible:bool
  • grab_mode:bevy_window::window::CursorGrabMode
  • hit_test:bool

Description

Cursor data for a [Window].

Associated Functions

For function details and documentation, click on the function link.

EnabledButtons

EnabledButtons

  • minimize:bool
  • maximize:bool
  • close:bool

Description

Specifies which [Window] control buttons should be enabled.

Platform-specific

iOS, Android, and the Web do not have window control buttons.

On some Linux environments these values have no effect.

Associated Functions

For function details and documentation, click on the function link.

InternalWindowState

InternalWindowState

  • minimize_request:core::option::Option
  • maximize_request:core::option::Option
  • drag_move_request:bool
  • drag_resize_request:core::option::Option<bevy_math::compass::CompassOctant>
  • physical_cursor_position:core::option::Optionglam::DVec2

Description

Stores internal [Window] state that isn't directly accessible.

Associated Functions

For function details and documentation, click on the function link.

MonitorSelection

Current

Primary

Index

  1. usize

Entity

  1. bevy_ecs::entity::Entity

Description

References a screen monitor.

Used when centering a [Window] on a monitor.

Associated Functions

For function details and documentation, click on the function link.

PresentMode

AutoVsync

AutoNoVsync

Fifo

FifoRelaxed

Immediate

Mailbox

Description

Presentation mode for a [Window].

The presentation mode specifies when a frame is presented to the window. The Fifo option corresponds to a traditional VSync, where the framerate is capped by the display refresh rate. Both Immediate and Mailbox are low-latency and are not capped by the refresh rate, but may not be available on all platforms. Tearing may be observed with Immediate mode, but will not be observed with Mailbox or Fifo.

AutoVsync or AutoNoVsync will gracefully fallback to Fifo when unavailable.

Immediate or Mailbox will panic if not supported by the platform.

Associated Functions

For function details and documentation, click on the function link.

PrimaryWindow

PrimaryWindow

Description

Marker [Component] for the window considered the primary window.

Currently this is assumed to only exist on 1 entity at a time.

WindowPlugin will spawn a [Window] entity with this component if primary_window is Some.

Associated Functions

For function details and documentation, click on the function link.

Window

Window

  • cursor_options:bevy_window::window::CursorOptions
  • present_mode:bevy_window::window::PresentMode
  • mode:bevy_window::window::WindowMode
  • position:bevy_window::window::WindowPosition
  • resolution:bevy_window::window::WindowResolution
  • title:String
  • name:core::option::Optionalloc::string::String
  • composite_alpha_mode:bevy_window::window::CompositeAlphaMode
  • resize_constraints:bevy_window::window::WindowResizeConstraints
  • resizable:bool
  • enabled_buttons:bevy_window::window::EnabledButtons
  • decorations:bool
  • transparent:bool
  • focused:bool
  • window_level:bevy_window::window::WindowLevel
  • canvas:core::option::Optionalloc::string::String
  • fit_canvas_to_parent:bool
  • prevent_default_event_handling:bool
  • internal:bevy_window::window::InternalWindowState
  • ime_enabled:bool
  • ime_position:glam::Vec2
  • window_theme:core::option::Option<bevy_window::window::WindowTheme>
  • visible:bool
  • skip_taskbar:bool
  • desired_maximum_frame_latency:core::option::Optioncore::num::NonZeroU32
  • recognize_pinch_gesture:bool
  • recognize_rotation_gesture:bool
  • recognize_doubletap_gesture:bool
  • recognize_pan_gesture:core::option::Option<(u8, u8)>
  • movable_by_window_background:bool
  • fullsize_content_view:bool
  • has_shadow:bool
  • titlebar_shown:bool
  • titlebar_transparent:bool
  • titlebar_show_title:bool
  • titlebar_show_buttons:bool

Description

The defining [Component] for window entities, storing information about how it should appear and behave.

Each window corresponds to an entity, and is uniquely identified by the value of their [Entity]. When the [Window] component is added to an entity, a new window will be opened. When it is removed or the entity is despawned, the window will close.

The primary window entity (and the corresponding window) is spawned by default by WindowPlugin and is marked with the [PrimaryWindow] component.

This component is synchronized with winit through bevy_winit: it will reflect the current state of the window and can be modified to change this state.

Example

Because this component is synchronized with winit, it can be used to perform OS-integrated windowing operations. For example, here's a simple system to change the window mode:

# use bevy_ecs::query::With;
# use bevy_ecs::system::Query;
# use bevy_window::{WindowMode, PrimaryWindow, Window, MonitorSelection};
fn change_window_mode(mut windows: Query<&mut Window, With<PrimaryWindow>>) {
    // Query returns one window typically.
    for mut window in windows.iter_mut() {
        window.mode = WindowMode::Fullscreen(MonitorSelection::Current);
    }
}

Associated Functions

For function details and documentation, click on the function link.

WindowLevel

AlwaysOnBottom

Normal

AlwaysOnTop

Description

Specifies where a [Window] should appear relative to other overlapping windows (on top or under) .

Levels are groups of windows with respect to their z-position.

The relative ordering between windows in different window levels is fixed. The z-order of windows within the same window level may change dynamically on user interaction.

Platform-specific

  • iOS / Android / Web / Wayland: Unsupported.

Associated Functions

For function details and documentation, click on the function link.

WindowMode

Windowed

BorderlessFullscreen

  1. bevy_window::window::MonitorSelection

SizedFullscreen

  1. bevy_window::window::MonitorSelection

Fullscreen

  1. bevy_window::window::MonitorSelection

Description

Defines the way a [Window] is displayed.

Associated Functions

For function details and documentation, click on the function link.

WindowPosition

Automatic

Centered

  1. bevy_window::window::MonitorSelection

At

  1. glam::IVec2

Description

Defines where a [Window] should be placed on the screen.

Associated Functions

For function details and documentation, click on the function link.

WindowRef

Primary

Entity

  1. bevy_ecs::entity::Entity

Description

Reference to a [Window], whether it be a direct link to a specific entity or a more vague defaulting choice.

Associated Functions

For function details and documentation, click on the function link.

WindowResizeConstraints

WindowResizeConstraints

  • min_width:f32
  • min_height:f32
  • max_width:f32
  • max_height:f32

Description

The size limits on a [Window].

These values are measured in logical pixels (see [WindowResolution]), so the user's scale factor does affect the size limits on the window.

Please note that if the window is resizable, then when the window is maximized it may have a size outside of these limits. The functionality required to disable maximizing is not yet exposed by winit.

Associated Functions

For function details and documentation, click on the function link.

WindowResolution

WindowResolution

  • physical_width:u32
  • physical_height:u32
  • scale_factor_override:core::option::Option
  • scale_factor:f32

Description

Controls the size of a [Window]

Physical, logical and requested sizes

There are three sizes associated with a window:

  • the physical size, which represents the actual height and width in physical pixels the window occupies on the monitor,
  • the logical size, which represents the size that should be used to scale elements inside the window, measured in logical pixels,
  • the requested size, measured in logical pixels, which is the value submitted to the API when creating the window, or requesting that it be resized.

Scale factor

The reason logical size and physical size are separated and can be different is to account for the cases where:

  • several monitors have different pixel densities,
  • the user has set up a pixel density preference in its operating system,
  • the Bevy App has specified a specific scale factor between both.

The factor between physical size and logical size can be retrieved with [WindowResolution::scale_factor].

For the first two cases, a scale factor is set automatically by the operating system through the window backend. You can get it with [WindowResolution::base_scale_factor].

For the third case, you can override this automatic scale factor with [WindowResolution::set_scale_factor_override].

Requested and obtained sizes

The logical size should be equal to the requested size after creating/resizing, when possible. The reason the requested size and logical size might be different is because the corresponding physical size might exceed limits (either the size limits of the monitor, or limits defined in [WindowResizeConstraints]).

Note: The requested size is not kept in memory, for example requesting a size too big for the screen, making the logical size different from the requested size, and then setting a scale factor that makes the previous requested size within the limits of the screen will not get back that previous requested size.

Associated Functions

For function details and documentation, click on the function link.

WindowTheme

Light

Dark

Description

The [Window] theme variant to use.

Associated Functions

For function details and documentation, click on the function link.

CursorIcon

Custom

  1. bevy_winit::cursor::CustomCursor

System

  1. bevy_window::system_cursor::SystemCursorIcon

Description

Insert into a window entity to set the cursor for that window.

Associated Functions

For function details and documentation, click on the function link.

CustomCursor

Image

  • handle:bevy_asset::handle::Handle<bevy_image::image::Image>
  • hotspot:(u16, u16)

Description

Custom cursor image data.

Associated Functions

For function details and documentation, click on the function link.

bool

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

char

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

TypeId

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

NonZeroI16

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

NonZeroU16

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

NonZeroU32

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

f32

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

f64

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

i128

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

i16

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

i32

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

i64

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

i8

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

isize

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

NodeIndex

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

u128

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

u16

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

u32

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

u64

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

u8

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

usize

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Cow

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Arc

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<String>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<TimedAnimationEvent>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<AnimationTransition>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<Entity>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<URect>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<ScriptQueryResult>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<ReflectReference>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<FunctionArgInfo>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<FunctionInfo>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<Cascade>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<ReflectSystem>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<PositionedGlyph>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<GridTrack>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<RepeatedGridTrack>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<VideoMode>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<f32>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<NodeIndex>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<u16>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<u32>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<u64>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Handle<()>

Strong

  1. alloc::sync::Arc<bevy_asset::handle::StrongHandle>

Weak

  1. bevy_asset::id::AssetId<()>

Description

A strong or weak handle to a specific [Asset]. If a [Handle] is [Handle::Strong], the [Asset] will be kept alive until the [Handle] is dropped. If a [Handle] is [Handle::Weak], it does not necessarily reference a live [Asset], nor will it keep assets alive.

[Handle] can be cloned. If a [Handle::Strong] is cloned, the referenced [Asset] will not be freed until all instances of the [Handle] are dropped.

[Handle::Strong] also provides access to useful [Asset] metadata, such as the [AssetPath] (if it exists).

Associated Functions

For function details and documentation, click on the function link.

Handle<AnimationClip>

Strong

  1. alloc::sync::Arc<bevy_asset::handle::StrongHandle>

Weak

  1. bevy_asset::id::AssetId<bevy_animation::AnimationClip>

Description

A strong or weak handle to a specific [Asset]. If a [Handle] is [Handle::Strong], the [Asset] will be kept alive until the [Handle] is dropped. If a [Handle] is [Handle::Weak], it does not necessarily reference a live [Asset], nor will it keep assets alive.

[Handle] can be cloned. If a [Handle::Strong] is cloned, the referenced [Asset] will not be freed until all instances of the [Handle] are dropped.

[Handle::Strong] also provides access to useful [Asset] metadata, such as the [AssetPath] (if it exists).

Associated Functions

For function details and documentation, click on the function link.

Handle<AnimationGraph>

Strong

  1. alloc::sync::Arc<bevy_asset::handle::StrongHandle>

Weak

  1. bevy_asset::id::AssetId<bevy_animation::graph::AnimationGraph>

Description

A strong or weak handle to a specific [Asset]. If a [Handle] is [Handle::Strong], the [Asset] will be kept alive until the [Handle] is dropped. If a [Handle] is [Handle::Weak], it does not necessarily reference a live [Asset], nor will it keep assets alive.

[Handle] can be cloned. If a [Handle::Strong] is cloned, the referenced [Asset] will not be freed until all instances of the [Handle] are dropped.

[Handle::Strong] also provides access to useful [Asset] metadata, such as the [AssetPath] (if it exists).

Associated Functions

For function details and documentation, click on the function link.

Handle<Image>

Strong

  1. alloc::sync::Arc<bevy_asset::handle::StrongHandle>

Weak

  1. bevy_asset::id::AssetId<bevy_image::image::Image>

Description

A strong or weak handle to a specific [Asset]. If a [Handle] is [Handle::Strong], the [Asset] will be kept alive until the [Handle] is dropped. If a [Handle] is [Handle::Weak], it does not necessarily reference a live [Asset], nor will it keep assets alive.

[Handle] can be cloned. If a [Handle::Strong] is cloned, the referenced [Asset] will not be freed until all instances of the [Handle] are dropped.

[Handle::Strong] also provides access to useful [Asset] metadata, such as the [AssetPath] (if it exists).

Associated Functions

For function details and documentation, click on the function link.

Handle<Mesh>

Strong

  1. alloc::sync::Arc<bevy_asset::handle::StrongHandle>

Weak

  1. bevy_asset::id::AssetId<bevy_mesh::mesh::Mesh>

Description

A strong or weak handle to a specific [Asset]. If a [Handle] is [Handle::Strong], the [Asset] will be kept alive until the [Handle] is dropped. If a [Handle] is [Handle::Weak], it does not necessarily reference a live [Asset], nor will it keep assets alive.

[Handle] can be cloned. If a [Handle::Strong] is cloned, the referenced [Asset] will not be freed until all instances of the [Handle] are dropped.

[Handle::Strong] also provides access to useful [Asset] metadata, such as the [AssetPath] (if it exists).

Associated Functions

For function details and documentation, click on the function link.

Handle<StandardMaterial>

Strong

  1. alloc::sync::Arc<bevy_asset::handle::StrongHandle>

Weak

  1. bevy_asset::id::AssetId<bevy_pbr::pbr_material::StandardMaterial>

Description

A strong or weak handle to a specific [Asset]. If a [Handle] is [Handle::Strong], the [Asset] will be kept alive until the [Handle] is dropped. If a [Handle] is [Handle::Weak], it does not necessarily reference a live [Asset], nor will it keep assets alive.

[Handle] can be cloned. If a [Handle::Strong] is cloned, the referenced [Asset] will not be freed until all instances of the [Handle] are dropped.

[Handle::Strong] also provides access to useful [Asset] metadata, such as the [AssetPath] (if it exists).

Associated Functions

For function details and documentation, click on the function link.

Handle<ShaderStorageBuffer>

Strong

  1. alloc::sync::Arc<bevy_asset::handle::StrongHandle>

Weak

  1. bevy_asset::id::AssetId<bevy_render::storage::ShaderStorageBuffer>

Description

A strong or weak handle to a specific [Asset]. If a [Handle] is [Handle::Strong], the [Asset] will be kept alive until the [Handle] is dropped. If a [Handle] is [Handle::Weak], it does not necessarily reference a live [Asset], nor will it keep assets alive.

[Handle] can be cloned. If a [Handle::Strong] is cloned, the referenced [Asset] will not be freed until all instances of the [Handle] are dropped.

[Handle::Strong] also provides access to useful [Asset] metadata, such as the [AssetPath] (if it exists).

Associated Functions

For function details and documentation, click on the function link.

Handle<ColorMaterial>

Strong

  1. alloc::sync::Arc<bevy_asset::handle::StrongHandle>

Weak

  1. bevy_asset::id::AssetId<bevy_sprite::mesh2d::color_material::ColorMaterial>

Description

A strong or weak handle to a specific [Asset]. If a [Handle] is [Handle::Strong], the [Asset] will be kept alive until the [Handle] is dropped. If a [Handle] is [Handle::Weak], it does not necessarily reference a live [Asset], nor will it keep assets alive.

[Handle] can be cloned. If a [Handle::Strong] is cloned, the referenced [Asset] will not be freed until all instances of the [Handle] are dropped.

[Handle::Strong] also provides access to useful [Asset] metadata, such as the [AssetPath] (if it exists).

Associated Functions

For function details and documentation, click on the function link.

Handle<TextureAtlasLayout>

Strong

  1. alloc::sync::Arc<bevy_asset::handle::StrongHandle>

Weak

  1. bevy_asset::id::AssetId<bevy_sprite::texture_atlas::TextureAtlasLayout>

Description

A strong or weak handle to a specific [Asset]. If a [Handle] is [Handle::Strong], the [Asset] will be kept alive until the [Handle] is dropped. If a [Handle] is [Handle::Weak], it does not necessarily reference a live [Asset], nor will it keep assets alive.

[Handle] can be cloned. If a [Handle::Strong] is cloned, the referenced [Asset] will not be freed until all instances of the [Handle] are dropped.

[Handle::Strong] also provides access to useful [Asset] metadata, such as the [AssetPath] (if it exists).

Associated Functions

For function details and documentation, click on the function link.

AssetId<()>

Index

  • index:bevy_asset::assets::AssetIndex

Uuid

  • uuid:uuid::Uuid

Description

A unique runtime-only identifier for an [Asset]. This is cheap to [Copy]/[Clone] and is not directly tied to the lifetime of the Asset. This means it can point to an [Asset] that no longer exists.

For an identifier tied to the lifetime of an asset, see Handle.

For an "untyped" / "generic-less" id, see [UntypedAssetId].

Associated Functions

For function details and documentation, click on the function link.

AssetId<AnimationClip>

Index

  • index:bevy_asset::assets::AssetIndex

Uuid

  • uuid:uuid::Uuid

Description

A unique runtime-only identifier for an [Asset]. This is cheap to [Copy]/[Clone] and is not directly tied to the lifetime of the Asset. This means it can point to an [Asset] that no longer exists.

For an identifier tied to the lifetime of an asset, see Handle.

For an "untyped" / "generic-less" id, see [UntypedAssetId].

Associated Functions

For function details and documentation, click on the function link.

AssetId<AnimationGraph>

Index

  • index:bevy_asset::assets::AssetIndex

Uuid

  • uuid:uuid::Uuid

Description

A unique runtime-only identifier for an [Asset]. This is cheap to [Copy]/[Clone] and is not directly tied to the lifetime of the Asset. This means it can point to an [Asset] that no longer exists.

For an identifier tied to the lifetime of an asset, see Handle.

For an "untyped" / "generic-less" id, see [UntypedAssetId].

Associated Functions

For function details and documentation, click on the function link.

AssetId<Image>

Index

  • index:bevy_asset::assets::AssetIndex

Uuid

  • uuid:uuid::Uuid

Description

A unique runtime-only identifier for an [Asset]. This is cheap to [Copy]/[Clone] and is not directly tied to the lifetime of the Asset. This means it can point to an [Asset] that no longer exists.

For an identifier tied to the lifetime of an asset, see Handle.

For an "untyped" / "generic-less" id, see [UntypedAssetId].

Associated Functions

For function details and documentation, click on the function link.

AssetId<Mesh>

Index

  • index:bevy_asset::assets::AssetIndex

Uuid

  • uuid:uuid::Uuid

Description

A unique runtime-only identifier for an [Asset]. This is cheap to [Copy]/[Clone] and is not directly tied to the lifetime of the Asset. This means it can point to an [Asset] that no longer exists.

For an identifier tied to the lifetime of an asset, see Handle.

For an "untyped" / "generic-less" id, see [UntypedAssetId].

Associated Functions

For function details and documentation, click on the function link.

AssetId<StandardMaterial>

Index

  • index:bevy_asset::assets::AssetIndex

Uuid

  • uuid:uuid::Uuid

Description

A unique runtime-only identifier for an [Asset]. This is cheap to [Copy]/[Clone] and is not directly tied to the lifetime of the Asset. This means it can point to an [Asset] that no longer exists.

For an identifier tied to the lifetime of an asset, see Handle.

For an "untyped" / "generic-less" id, see [UntypedAssetId].

Associated Functions

For function details and documentation, click on the function link.

AssetId<ShaderStorageBuffer>

Index

  • index:bevy_asset::assets::AssetIndex

Uuid

  • uuid:uuid::Uuid

Description

A unique runtime-only identifier for an [Asset]. This is cheap to [Copy]/[Clone] and is not directly tied to the lifetime of the Asset. This means it can point to an [Asset] that no longer exists.

For an identifier tied to the lifetime of an asset, see Handle.

For an "untyped" / "generic-less" id, see [UntypedAssetId].

Associated Functions

For function details and documentation, click on the function link.

AssetId<ColorMaterial>

Index

  • index:bevy_asset::assets::AssetIndex

Uuid

  • uuid:uuid::Uuid

Description

A unique runtime-only identifier for an [Asset]. This is cheap to [Copy]/[Clone] and is not directly tied to the lifetime of the Asset. This means it can point to an [Asset] that no longer exists.

For an identifier tied to the lifetime of an asset, see Handle.

For an "untyped" / "generic-less" id, see [UntypedAssetId].

Associated Functions

For function details and documentation, click on the function link.

AssetId<TextureAtlasLayout>

Index

  • index:bevy_asset::assets::AssetIndex

Uuid

  • uuid:uuid::Uuid

Description

A unique runtime-only identifier for an [Asset]. This is cheap to [Copy]/[Clone] and is not directly tied to the lifetime of the Asset. This means it can point to an [Asset] that no longer exists.

For an identifier tied to the lifetime of an asset, see Handle.

For an "untyped" / "generic-less" id, see [UntypedAssetId].

Associated Functions

For function details and documentation, click on the function link.

Axis<GamepadInput>

Axis

  • axis_data:bevy_utils::hashbrown::HashMap<bevy_input::gamepad::GamepadInput, f32, bevy_utils::hashbrown::hash_map::DefaultHashBuilder>

Description

Stores the position data of the input devices of type T.

The values are stored as f32s, using [Axis::set]. Use [Axis::get] to retrieve the value clamped between [Axis::MIN] and [Axis::MAX] inclusive, or unclamped using [Axis::get_unclamped].

Associated Functions

For function details and documentation, click on the function link.

ButtonInput<GamepadButton>

ButtonInput

  • pressed:bevy_utils::hashbrown::HashSet<bevy_input::gamepad::GamepadButton, bevy_utils::hashbrown::hash_map::DefaultHashBuilder>
  • just_pressed:bevy_utils::hashbrown::HashSet<bevy_input::gamepad::GamepadButton, bevy_utils::hashbrown::hash_map::DefaultHashBuilder>
  • just_released:bevy_utils::hashbrown::HashSet<bevy_input::gamepad::GamepadButton, bevy_utils::hashbrown::hash_map::DefaultHashBuilder>

Description

A "press-able" input of type T.

Usage

This type can be used as a resource to keep the current state of an input, by reacting to events from the input. For a given input value:

  • [ButtonInput::pressed] will return true between a press and a release event.
  • [ButtonInput::just_pressed] will return true for one frame after a press event.
  • [ButtonInput::just_released] will return true for one frame after a release event.

Multiple systems

In case multiple systems are checking for [ButtonInput::just_pressed] or [ButtonInput::just_released] but only one should react, for example when modifying a [Resource], you should consider clearing the input state, either by:

  • Using [ButtonInput::clear_just_pressed] or [ButtonInput::clear_just_released] instead.
  • Calling [ButtonInput::clear] or [ButtonInput::reset] immediately after the state change.

Performance

For all operations, the following conventions are used:

  • n is the number of stored inputs.
  • m is the number of input arguments passed to the method.
  • *-suffix denotes an amortized cost.
  • ~-suffix denotes an expected cost.

See Rust's std::collections doc on performance for more details on the conventions used here.

[ButtonInput] operationsComputational complexity
[ButtonInput::any_just_pressed]O(m)~
[ButtonInput::any_just_released]O(m)~
[ButtonInput::any_pressed]O(m)~
[ButtonInput::get_just_pressed]O(n)
[ButtonInput::get_just_released]O(n)
[ButtonInput::get_pressed]O(n)
[ButtonInput::just_pressed]O(1)~
[ButtonInput::just_released]O(1)~
[ButtonInput::pressed]O(1)~
[ButtonInput::press]O(1)~*
[ButtonInput::release]O(1)~*
[ButtonInput::release_all]O(n)~*
[ButtonInput::clear_just_pressed]O(1)~
[ButtonInput::clear_just_released]O(1)~
[ButtonInput::reset_all]O(n)
[ButtonInput::clear]O(n)

Window focus

ButtonInput<KeyCode> is tied to window focus. For example, if the user holds a button while the window loses focus, [ButtonInput::just_released] will be triggered. Similarly if the window regains focus, [ButtonInput::just_pressed] will be triggered.

ButtonInput<GamepadButton> is independent of window focus.

Examples

Reading and checking against the current set of pressed buttons:

# use bevy_app::{App, NoopPluginGroup as DefaultPlugins, Update};
# use bevy_ecs::{prelude::{IntoSystemConfigs, Res, Resource, resource_changed}, schedule::Condition};
# use bevy_input::{ButtonInput, prelude::{KeyCode, MouseButton}};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(
            Update,
            print_mouse.run_if(resource_changed::<ButtonInput<MouseButton>>),
        )
        .add_systems(
            Update,
            print_keyboard.run_if(resource_changed::<ButtonInput<KeyCode>>),
        )
        .run();
}

fn print_mouse(mouse: Res<ButtonInput<MouseButton>>) {
    println!("Mouse: {:?}", mouse.get_pressed().collect::<Vec<_>>());
}

fn print_keyboard(keyboard: Res<ButtonInput<KeyCode>>) {
    if keyboard.any_pressed([KeyCode::ControlLeft, KeyCode::ControlRight])
        && keyboard.any_pressed([KeyCode::AltLeft, KeyCode::AltRight])
        && keyboard.any_pressed([KeyCode::ShiftLeft, KeyCode::ShiftRight])
        && keyboard.any_pressed([KeyCode::SuperLeft, KeyCode::SuperRight])
        && keyboard.pressed(KeyCode::KeyL)
    {
        println!("On Windows this opens LinkedIn.");
    } else {
        println!("keyboard: {:?}", keyboard.get_pressed().collect::<Vec<_>>());
    }
}

Note

When adding this resource for a new input type, you should:

  • Call the [ButtonInput::press] method for each press event.
  • Call the [ButtonInput::release] method for each release event.
  • Call the [ButtonInput::clear] method at each frame start, before processing events.

Note: Calling clear from a ResMut will trigger change detection. It may be preferable to use DetectChangesMut::bypass_change_detection to avoid causing the resource to always be marked as changed.

Associated Functions

For function details and documentation, click on the function link.

MeshMaterial3d<StandardMaterial>

MeshMaterial3d

  1. bevy_asset::handle::Handle<bevy_pbr::pbr_material::StandardMaterial>

Description

A material used for rendering a Mesh3d.

See [Material] for general information about 3D materials and how to implement your own materials.

Example

# use bevy_pbr::{Material, MeshMaterial3d, StandardMaterial};
# use bevy_ecs::prelude::*;
# use bevy_render::mesh::{Mesh, Mesh3d};
# use bevy_color::palettes::basic::RED;
# use bevy_asset::Assets;
# use bevy_math::primitives::Capsule3d;
#
// Spawn an entity with a mesh using `StandardMaterial`.
fn setup(
    mut commands: Commands,
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<StandardMaterial>>,
) {
    commands.spawn((
        Mesh3d(meshes.add(Capsule3d::default())),
        MeshMaterial3d(materials.add(StandardMaterial {
            base_color: RED.into(),
            ..Default::default()
        })),
    ));
}

Associated Functions

For function details and documentation, click on the function link.

MeshMaterial2d<ColorMaterial>

MeshMaterial2d

  1. bevy_asset::handle::Handle<bevy_sprite::mesh2d::color_material::ColorMaterial>

Description

A material used for rendering a [Mesh2d].

See [Material2d] for general information about 2D materials and how to implement your own materials.

Example

# use bevy_sprite::{ColorMaterial, MeshMaterial2d};
# use bevy_ecs::prelude::*;
# use bevy_render::mesh::{Mesh, Mesh2d};
# use bevy_color::palettes::basic::RED;
# use bevy_asset::Assets;
# use bevy_math::primitives::Circle;
#
// Spawn an entity with a mesh using `ColorMaterial`.
fn setup(
    mut commands: Commands,
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<ColorMaterial>>,
) {
    commands.spawn((
        Mesh2d(meshes.add(Circle::new(50.0))),
        MeshMaterial2d(materials.add(ColorMaterial::from_color(RED))),
    ));
}

Associated Functions

For function details and documentation, click on the function link.

Time<()>

Time

  • context:()
  • wrap_period:bevy_utils::Duration
  • delta:bevy_utils::Duration
  • delta_secs:f32
  • delta_secs_f64:f64
  • elapsed:bevy_utils::Duration
  • elapsed_secs:f32
  • elapsed_secs_f64:f64
  • elapsed_wrapped:bevy_utils::Duration
  • elapsed_secs_wrapped:f32
  • elapsed_secs_wrapped_f64:f64

Description

A generic clock resource that tracks how much it has advanced since its previous update and since its creation.

Multiple instances of this resource are inserted automatically by TimePlugin:

  • Time<Real> tracks real wall-clock time elapsed.
  • Time<Virtual> tracks virtual game time that may be paused or scaled.
  • Time<Fixed> tracks fixed timesteps based on virtual time.
  • [Time] is a generic clock that corresponds to "current" or "default" time for systems. It contains Time<Virtual> except inside the FixedMain schedule when it contains Time<Fixed>.

The time elapsed since the previous time this clock was advanced is saved as delta() and the total amount of time the clock has advanced is saved as elapsed(). Both are represented as exact [Duration] values with fixed nanosecond precision. The clock does not support time moving backwards, but it can be updated with [Duration::ZERO] which will set delta() to zero.

These values are also available in seconds as f32 via delta_secs() and elapsed_secs(), and also in seconds as f64 via delta_secs_f64() and elapsed_secs_f64().

Since elapsed_secs() will grow constantly and is f32, it will exhibit gradual precision loss. For applications that require an f32 value but suffer from gradual precision loss there is elapsed_secs_wrapped() available. The same wrapped value is also available as [Duration] and f64 for consistency. The wrap period is by default 1 hour, and can be set by set_wrap_period().

Accessing clocks

By default, any systems requiring current delta() or elapsed() should use Res<Time> to access the default time configured for the program. By default, this refers to Time<Virtual> except during the FixedMain schedule when it refers to Time<Fixed>. This ensures your system can be used either in Update or FixedUpdate schedule depending on what is needed.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn ambivalent_system(time: Res<Time>) {
    println!("this how I see time: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

If your system needs to react based on real time (wall clock time), like for user interfaces, it should use Res<Time<Real>>. The delta() and elapsed() values will always correspond to real time and will not be affected by pause, time scaling or other tweaks.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn real_time_system(time: Res<Time<Real>>) {
    println!("this will always be real time: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

If your system specifically needs to access fixed timestep clock, even when placed in Update schedule, you should use Res<Time<Fixed>>. The delta() and elapsed() values will correspond to the latest fixed timestep that has been run.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn fixed_time_system(time: Res<Time<Fixed>>) {
    println!("this will always be the last executed fixed timestep: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

Finally, if your system specifically needs to know the current virtual game time, even if placed inside FixedUpdate, for example to know if the game is was_paused() or to use effective_speed(), you can use Res<Time<Virtual>>. However, if the system is placed in FixedUpdate, extra care must be used because your system might be run multiple times with the same delta() and elapsed() values as the virtual game time has not changed between the iterations.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn fixed_time_system(time: Res<Time<Virtual>>) {
    println!("this will be virtual time for this update: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
    println!("also the relative speed of the game is now {}", time.effective_speed());
}

If you need to change the settings for any of the clocks, for example to pause() the game, you should use ResMut<Time<Virtual>>.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
#[derive(Event)]
struct PauseEvent(bool);

fn pause_system(mut time: ResMut<Time<Virtual>>, mut events: EventReader<PauseEvent>) {
    for ev in events.read() {
        if ev.0 {
            time.pause();
        } else {
            time.unpause();
        }
    }
}

Adding custom clocks

New custom clocks can be created by creating your own struct as a context and passing it to new_with(). These clocks can be inserted as resources as normal and then accessed by systems. You can use the advance_by() or advance_to() methods to move the clock forwards based on your own logic.

If you want to add methods for your time instance and they require access to both your context and the generic time part, it's probably simplest to add a custom trait for them and implement it for Time<Custom>.

Your context struct will need to implement the [Default] trait because [Time] structures support reflection. It also makes initialization trivial by being able to call app.init_resource::<Time<Custom>>().

You can also replace the "generic" Time clock resource if the "default" time for your game should not be the default virtual time provided. You can get a "generic" snapshot of your clock by calling as_generic() and then overwrite the [Time] resource with it. The default systems added by TimePlugin will overwrite the [Time] clock during First and FixedUpdate schedules.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
# use bevy_utils::Instant;
#
#[derive(Debug)]
struct Custom {
    last_external_time: Instant,
}

impl Default for Custom {
    fn default() -> Self {
        Self {
            last_external_time: Instant::now(),
        }
    }
}

trait CustomTime {
    fn update_from_external(&mut self, instant: Instant);
}

impl CustomTime for Time<Custom> {
    fn update_from_external(&mut self, instant: Instant) {
         let delta = instant - self.context().last_external_time;
         self.advance_by(delta);
         self.context_mut().last_external_time = instant;
    }
}

Associated Functions

For function details and documentation, click on the function link.

Time<Fixed>

Time

  • context:bevy_time::fixed::Fixed
  • wrap_period:bevy_utils::Duration
  • delta:bevy_utils::Duration
  • delta_secs:f32
  • delta_secs_f64:f64
  • elapsed:bevy_utils::Duration
  • elapsed_secs:f32
  • elapsed_secs_f64:f64
  • elapsed_wrapped:bevy_utils::Duration
  • elapsed_secs_wrapped:f32
  • elapsed_secs_wrapped_f64:f64

Description

A generic clock resource that tracks how much it has advanced since its previous update and since its creation.

Multiple instances of this resource are inserted automatically by TimePlugin:

  • Time<Real> tracks real wall-clock time elapsed.
  • Time<Virtual> tracks virtual game time that may be paused or scaled.
  • Time<Fixed> tracks fixed timesteps based on virtual time.
  • [Time] is a generic clock that corresponds to "current" or "default" time for systems. It contains Time<Virtual> except inside the FixedMain schedule when it contains Time<Fixed>.

The time elapsed since the previous time this clock was advanced is saved as delta() and the total amount of time the clock has advanced is saved as elapsed(). Both are represented as exact [Duration] values with fixed nanosecond precision. The clock does not support time moving backwards, but it can be updated with [Duration::ZERO] which will set delta() to zero.

These values are also available in seconds as f32 via delta_secs() and elapsed_secs(), and also in seconds as f64 via delta_secs_f64() and elapsed_secs_f64().

Since elapsed_secs() will grow constantly and is f32, it will exhibit gradual precision loss. For applications that require an f32 value but suffer from gradual precision loss there is elapsed_secs_wrapped() available. The same wrapped value is also available as [Duration] and f64 for consistency. The wrap period is by default 1 hour, and can be set by set_wrap_period().

Accessing clocks

By default, any systems requiring current delta() or elapsed() should use Res<Time> to access the default time configured for the program. By default, this refers to Time<Virtual> except during the FixedMain schedule when it refers to Time<Fixed>. This ensures your system can be used either in Update or FixedUpdate schedule depending on what is needed.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn ambivalent_system(time: Res<Time>) {
    println!("this how I see time: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

If your system needs to react based on real time (wall clock time), like for user interfaces, it should use Res<Time<Real>>. The delta() and elapsed() values will always correspond to real time and will not be affected by pause, time scaling or other tweaks.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn real_time_system(time: Res<Time<Real>>) {
    println!("this will always be real time: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

If your system specifically needs to access fixed timestep clock, even when placed in Update schedule, you should use Res<Time<Fixed>>. The delta() and elapsed() values will correspond to the latest fixed timestep that has been run.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn fixed_time_system(time: Res<Time<Fixed>>) {
    println!("this will always be the last executed fixed timestep: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

Finally, if your system specifically needs to know the current virtual game time, even if placed inside FixedUpdate, for example to know if the game is was_paused() or to use effective_speed(), you can use Res<Time<Virtual>>. However, if the system is placed in FixedUpdate, extra care must be used because your system might be run multiple times with the same delta() and elapsed() values as the virtual game time has not changed between the iterations.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn fixed_time_system(time: Res<Time<Virtual>>) {
    println!("this will be virtual time for this update: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
    println!("also the relative speed of the game is now {}", time.effective_speed());
}

If you need to change the settings for any of the clocks, for example to pause() the game, you should use ResMut<Time<Virtual>>.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
#[derive(Event)]
struct PauseEvent(bool);

fn pause_system(mut time: ResMut<Time<Virtual>>, mut events: EventReader<PauseEvent>) {
    for ev in events.read() {
        if ev.0 {
            time.pause();
        } else {
            time.unpause();
        }
    }
}

Adding custom clocks

New custom clocks can be created by creating your own struct as a context and passing it to new_with(). These clocks can be inserted as resources as normal and then accessed by systems. You can use the advance_by() or advance_to() methods to move the clock forwards based on your own logic.

If you want to add methods for your time instance and they require access to both your context and the generic time part, it's probably simplest to add a custom trait for them and implement it for Time<Custom>.

Your context struct will need to implement the [Default] trait because [Time] structures support reflection. It also makes initialization trivial by being able to call app.init_resource::<Time<Custom>>().

You can also replace the "generic" Time clock resource if the "default" time for your game should not be the default virtual time provided. You can get a "generic" snapshot of your clock by calling as_generic() and then overwrite the [Time] resource with it. The default systems added by TimePlugin will overwrite the [Time] clock during First and FixedUpdate schedules.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
# use bevy_utils::Instant;
#
#[derive(Debug)]
struct Custom {
    last_external_time: Instant,
}

impl Default for Custom {
    fn default() -> Self {
        Self {
            last_external_time: Instant::now(),
        }
    }
}

trait CustomTime {
    fn update_from_external(&mut self, instant: Instant);
}

impl CustomTime for Time<Custom> {
    fn update_from_external(&mut self, instant: Instant) {
         let delta = instant - self.context().last_external_time;
         self.advance_by(delta);
         self.context_mut().last_external_time = instant;
    }
}

Associated Functions

For function details and documentation, click on the function link.

Time<Real>

Time

  • context:bevy_time::real::Real
  • wrap_period:bevy_utils::Duration
  • delta:bevy_utils::Duration
  • delta_secs:f32
  • delta_secs_f64:f64
  • elapsed:bevy_utils::Duration
  • elapsed_secs:f32
  • elapsed_secs_f64:f64
  • elapsed_wrapped:bevy_utils::Duration
  • elapsed_secs_wrapped:f32
  • elapsed_secs_wrapped_f64:f64

Description

A generic clock resource that tracks how much it has advanced since its previous update and since its creation.

Multiple instances of this resource are inserted automatically by TimePlugin:

  • Time<Real> tracks real wall-clock time elapsed.
  • Time<Virtual> tracks virtual game time that may be paused or scaled.
  • Time<Fixed> tracks fixed timesteps based on virtual time.
  • [Time] is a generic clock that corresponds to "current" or "default" time for systems. It contains Time<Virtual> except inside the FixedMain schedule when it contains Time<Fixed>.

The time elapsed since the previous time this clock was advanced is saved as delta() and the total amount of time the clock has advanced is saved as elapsed(). Both are represented as exact [Duration] values with fixed nanosecond precision. The clock does not support time moving backwards, but it can be updated with [Duration::ZERO] which will set delta() to zero.

These values are also available in seconds as f32 via delta_secs() and elapsed_secs(), and also in seconds as f64 via delta_secs_f64() and elapsed_secs_f64().

Since elapsed_secs() will grow constantly and is f32, it will exhibit gradual precision loss. For applications that require an f32 value but suffer from gradual precision loss there is elapsed_secs_wrapped() available. The same wrapped value is also available as [Duration] and f64 for consistency. The wrap period is by default 1 hour, and can be set by set_wrap_period().

Accessing clocks

By default, any systems requiring current delta() or elapsed() should use Res<Time> to access the default time configured for the program. By default, this refers to Time<Virtual> except during the FixedMain schedule when it refers to Time<Fixed>. This ensures your system can be used either in Update or FixedUpdate schedule depending on what is needed.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn ambivalent_system(time: Res<Time>) {
    println!("this how I see time: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

If your system needs to react based on real time (wall clock time), like for user interfaces, it should use Res<Time<Real>>. The delta() and elapsed() values will always correspond to real time and will not be affected by pause, time scaling or other tweaks.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn real_time_system(time: Res<Time<Real>>) {
    println!("this will always be real time: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

If your system specifically needs to access fixed timestep clock, even when placed in Update schedule, you should use Res<Time<Fixed>>. The delta() and elapsed() values will correspond to the latest fixed timestep that has been run.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn fixed_time_system(time: Res<Time<Fixed>>) {
    println!("this will always be the last executed fixed timestep: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

Finally, if your system specifically needs to know the current virtual game time, even if placed inside FixedUpdate, for example to know if the game is was_paused() or to use effective_speed(), you can use Res<Time<Virtual>>. However, if the system is placed in FixedUpdate, extra care must be used because your system might be run multiple times with the same delta() and elapsed() values as the virtual game time has not changed between the iterations.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn fixed_time_system(time: Res<Time<Virtual>>) {
    println!("this will be virtual time for this update: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
    println!("also the relative speed of the game is now {}", time.effective_speed());
}

If you need to change the settings for any of the clocks, for example to pause() the game, you should use ResMut<Time<Virtual>>.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
#[derive(Event)]
struct PauseEvent(bool);

fn pause_system(mut time: ResMut<Time<Virtual>>, mut events: EventReader<PauseEvent>) {
    for ev in events.read() {
        if ev.0 {
            time.pause();
        } else {
            time.unpause();
        }
    }
}

Adding custom clocks

New custom clocks can be created by creating your own struct as a context and passing it to new_with(). These clocks can be inserted as resources as normal and then accessed by systems. You can use the advance_by() or advance_to() methods to move the clock forwards based on your own logic.

If you want to add methods for your time instance and they require access to both your context and the generic time part, it's probably simplest to add a custom trait for them and implement it for Time<Custom>.

Your context struct will need to implement the [Default] trait because [Time] structures support reflection. It also makes initialization trivial by being able to call app.init_resource::<Time<Custom>>().

You can also replace the "generic" Time clock resource if the "default" time for your game should not be the default virtual time provided. You can get a "generic" snapshot of your clock by calling as_generic() and then overwrite the [Time] resource with it. The default systems added by TimePlugin will overwrite the [Time] clock during First and FixedUpdate schedules.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
# use bevy_utils::Instant;
#
#[derive(Debug)]
struct Custom {
    last_external_time: Instant,
}

impl Default for Custom {
    fn default() -> Self {
        Self {
            last_external_time: Instant::now(),
        }
    }
}

trait CustomTime {
    fn update_from_external(&mut self, instant: Instant);
}

impl CustomTime for Time<Custom> {
    fn update_from_external(&mut self, instant: Instant) {
         let delta = instant - self.context().last_external_time;
         self.advance_by(delta);
         self.context_mut().last_external_time = instant;
    }
}

Associated Functions

For function details and documentation, click on the function link.

Time<Virtual>

Time

  • context:bevy_time::virt::Virtual
  • wrap_period:bevy_utils::Duration
  • delta:bevy_utils::Duration
  • delta_secs:f32
  • delta_secs_f64:f64
  • elapsed:bevy_utils::Duration
  • elapsed_secs:f32
  • elapsed_secs_f64:f64
  • elapsed_wrapped:bevy_utils::Duration
  • elapsed_secs_wrapped:f32
  • elapsed_secs_wrapped_f64:f64

Description

A generic clock resource that tracks how much it has advanced since its previous update and since its creation.

Multiple instances of this resource are inserted automatically by TimePlugin:

  • Time<Real> tracks real wall-clock time elapsed.
  • Time<Virtual> tracks virtual game time that may be paused or scaled.
  • Time<Fixed> tracks fixed timesteps based on virtual time.
  • [Time] is a generic clock that corresponds to "current" or "default" time for systems. It contains Time<Virtual> except inside the FixedMain schedule when it contains Time<Fixed>.

The time elapsed since the previous time this clock was advanced is saved as delta() and the total amount of time the clock has advanced is saved as elapsed(). Both are represented as exact [Duration] values with fixed nanosecond precision. The clock does not support time moving backwards, but it can be updated with [Duration::ZERO] which will set delta() to zero.

These values are also available in seconds as f32 via delta_secs() and elapsed_secs(), and also in seconds as f64 via delta_secs_f64() and elapsed_secs_f64().

Since elapsed_secs() will grow constantly and is f32, it will exhibit gradual precision loss. For applications that require an f32 value but suffer from gradual precision loss there is elapsed_secs_wrapped() available. The same wrapped value is also available as [Duration] and f64 for consistency. The wrap period is by default 1 hour, and can be set by set_wrap_period().

Accessing clocks

By default, any systems requiring current delta() or elapsed() should use Res<Time> to access the default time configured for the program. By default, this refers to Time<Virtual> except during the FixedMain schedule when it refers to Time<Fixed>. This ensures your system can be used either in Update or FixedUpdate schedule depending on what is needed.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn ambivalent_system(time: Res<Time>) {
    println!("this how I see time: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

If your system needs to react based on real time (wall clock time), like for user interfaces, it should use Res<Time<Real>>. The delta() and elapsed() values will always correspond to real time and will not be affected by pause, time scaling or other tweaks.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn real_time_system(time: Res<Time<Real>>) {
    println!("this will always be real time: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

If your system specifically needs to access fixed timestep clock, even when placed in Update schedule, you should use Res<Time<Fixed>>. The delta() and elapsed() values will correspond to the latest fixed timestep that has been run.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn fixed_time_system(time: Res<Time<Fixed>>) {
    println!("this will always be the last executed fixed timestep: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

Finally, if your system specifically needs to know the current virtual game time, even if placed inside FixedUpdate, for example to know if the game is was_paused() or to use effective_speed(), you can use Res<Time<Virtual>>. However, if the system is placed in FixedUpdate, extra care must be used because your system might be run multiple times with the same delta() and elapsed() values as the virtual game time has not changed between the iterations.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn fixed_time_system(time: Res<Time<Virtual>>) {
    println!("this will be virtual time for this update: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
    println!("also the relative speed of the game is now {}", time.effective_speed());
}

If you need to change the settings for any of the clocks, for example to pause() the game, you should use ResMut<Time<Virtual>>.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
#[derive(Event)]
struct PauseEvent(bool);

fn pause_system(mut time: ResMut<Time<Virtual>>, mut events: EventReader<PauseEvent>) {
    for ev in events.read() {
        if ev.0 {
            time.pause();
        } else {
            time.unpause();
        }
    }
}

Adding custom clocks

New custom clocks can be created by creating your own struct as a context and passing it to new_with(). These clocks can be inserted as resources as normal and then accessed by systems. You can use the advance_by() or advance_to() methods to move the clock forwards based on your own logic.

If you want to add methods for your time instance and they require access to both your context and the generic time part, it's probably simplest to add a custom trait for them and implement it for Time<Custom>.

Your context struct will need to implement the [Default] trait because [Time] structures support reflection. It also makes initialization trivial by being able to call app.init_resource::<Time<Custom>>().

You can also replace the "generic" Time clock resource if the "default" time for your game should not be the default virtual time provided. You can get a "generic" snapshot of your clock by calling as_generic() and then overwrite the [Time] resource with it. The default systems added by TimePlugin will overwrite the [Time] clock during First and FixedUpdate schedules.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
# use bevy_utils::Instant;
#
#[derive(Debug)]
struct Custom {
    last_external_time: Instant,
}

impl Default for Custom {
    fn default() -> Self {
        Self {
            last_external_time: Instant::now(),
        }
    }
}

trait CustomTime {
    fn update_from_external(&mut self, instant: Instant);
}

impl CustomTime for Time<Custom> {
    fn update_from_external(&mut self, instant: Instant) {
         let delta = instant - self.context().last_external_time;
         self.advance_by(delta);
         self.context_mut().last_external_time = instant;
    }
}

Associated Functions

For function details and documentation, click on the function link.

Range

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Range

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<[u8; 6]>

None

Some

  1. [u8; 6]

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<String>

None

Some

  1. String

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<SpatialScale>

None

Some

  1. bevy_audio::audio::SpatialScale

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<Color>

None

Some

  1. bevy_color::color::Color

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<Entity>

None

Some

  1. bevy_ecs::entity::Entity

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<ForceTouch>

None

Some

  1. bevy_input::touch::ForceTouch

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<CompassOctant>

None

Some

  1. bevy_math::compass::CompassOctant

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<Rect>

None

Some

  1. bevy_math::rects::rect::Rect

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<Indices>

None

Some

  1. bevy_mesh::index::Indices

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<ReflectReference>

None

Some

  1. ReflectReference

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<ScriptValue>

None

Some

  1. bevy_mod_scripting_core::bindings::script_value::ScriptValue

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<SubCameraView>

None

Some

  1. bevy_render::camera::camera::SubCameraView

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<Viewport>

None

Some

  1. bevy_render::camera::camera::Viewport

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<TextureAtlas>

None

Some

  1. bevy_sprite::texture_atlas::TextureAtlas

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<ReflectSchedule>

None

Some

  1. bevy_system_reflection::ReflectSchedule

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<ReflectSystem>

None

Some

  1. bevy_system_reflection::ReflectSystem

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<Instant>

None

Some

  1. bevy_utils::Instant

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<WindowTheme>

None

Some

  1. bevy_window::window::WindowTheme

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<bool>

None

Some

  1. bool

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<char>

None

Some

  1. char

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<NonZeroI16>

None

Some

  1. core::num::NonZeroI16

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<NonZeroU16>

None

Some

  1. core::num::NonZeroU16

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<NonZeroU32>

None

Some

  1. core::num::NonZeroU32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<f32>

None

Some

  1. f32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<f64>

None

Some

  1. f64

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<DVec2>

None

Some

  1. glam::DVec2

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<Vec2>

None

Some

  1. glam::Vec2

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<Vec3>

None

Some

  1. glam::Vec3

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<NodeIndex>

None

Some

  1. petgraph::graph::NodeIndex

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<u16>

None

Some

  1. u16

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<u32>

None

Some

  1. u32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<usize>

None

Some

  1. usize

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

SmallVec<TypeId(0x537ab1d71b3df3bb6cb5bbdcefa5ba81)>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

SmallVec<TypeId(0xbb89ab0d5b4c0e9af367d34b331091fe)>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

SmallVec<TypeId(0x816d5c242d5c7566479b765bde1a1f64)>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

SmallVec<TypeId(0xc02b4f0291ef0aad60339b7367f351ef)>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<(bevy_ecs::entity::Entity, bevy_picking::backend::HitData)>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Vec<Range>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

HashSet<GamepadButton>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<(u8, u8)>

None

Some

  1. (u8, u8)

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<(usize, usize)>

None

Some

  1. (usize, usize)

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<Cow>

None

Some

  1. alloc::borrow::Cow

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<Vec<String>>

None

Some

  1. alloc::vec::Vecalloc::string::String

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<Handle<Image>>

None

Some

  1. bevy_asset::handle::Handle<bevy_image::image::Image>

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<Handle<Mesh>>

None

Some

  1. bevy_asset::handle::Handle<bevy_mesh::mesh::Mesh>

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<(), InteropError>

Ok

  1. ()

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<String, InteropError>

Ok

  1. String

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<Entity, InteropError>

Ok

  1. bevy_ecs::entity::Entity

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<DynamicFunctionMut, InteropError>

Ok

  1. DynamicFunctionMut

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<ScriptComponentRegistration, ScriptResourceRegistration>

Ok

  1. bevy_mod_scripting_core::bindings::query::ScriptComponentRegistration

Err

  1. bevy_mod_scripting_core::bindings::query::ScriptResourceRegistration

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<ScriptComponentRegistration, InteropError>

Ok

  1. bevy_mod_scripting_core::bindings::query::ScriptComponentRegistration

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<ScriptQueryBuilder, InteropError>

Ok

  1. bevy_mod_scripting_core::bindings::query::ScriptQueryBuilder

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<ReflectReference, InteropError>

Ok

  1. ReflectReference

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<ScriptSystemBuilder, InteropError>

Ok

  1. bevy_mod_scripting_core::bindings::script_system::ScriptSystemBuilder

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<ScriptValue, InteropError>

Ok

  1. bevy_mod_scripting_core::bindings::script_value::ScriptValue

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<ReflectSystem, InteropError>

Ok

  1. bevy_system_reflection::ReflectSystem

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<bool, InteropError>

Ok

  1. bool

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

HashMap<AnimationTargetId, u64>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

HashMap<GamepadAxis, AxisSettings>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

HashMap<GamepadButton, ButtonAxisSettings>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

HashMap<GamepadButton, ButtonSettings>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

HashMap<GamepadInput, f32>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

HashMap<NodeIndex, ActiveAnimation>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

HashMap<NodeIndex, f32>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<Vec<Entity>, InteropError>

Ok

  1. alloc::vec::Vec<bevy_ecs::entity::Entity>

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<Vec<ScriptQueryResult>, InteropError>

Ok

  1. alloc::vec::Vec<bevy_mod_scripting_core::bindings::query::ScriptQueryResult>

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<Vec<FunctionInfo>, InteropError>

Ok

  1. alloc::vec::Vec<bevy_mod_scripting_core::docgen::info::FunctionInfo>

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<Vec<ReflectSystem>, InteropError>

Ok

  1. alloc::vec::Vec<bevy_system_reflection::ReflectSystem>

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<Option<String>, InteropError>

Ok

  1. core::option::Optionalloc::string::String

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<Option<Entity>, InteropError>

Ok

  1. core::option::Option<bevy_ecs::entity::Entity>

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<Option<ReflectReference>, InteropError>

Ok

  1. core::option::Option<bevy_mod_scripting_core::bindings::reference::ReflectReference>

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<Option<ScriptValue>, InteropError>

Ok

  1. core::option::Option<bevy_mod_scripting_core::bindings::script_value::ScriptValue>

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<Option<ReflectSchedule>, InteropError>

Ok

  1. core::option::Option<bevy_system_reflection::ReflectSchedule>

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<Option<ReflectSystem>, InteropError>

Ok

  1. core::option::Option<bevy_system_reflection::ReflectSystem>

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<Option<usize>, InteropError>

Ok

  1. core::option::Option

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

DiGraph

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

HashMap<String, ScriptValue>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

HashMap<AnimationEventTarget, Vec<TimedAnimationEvent>>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

HashMap<AssetId<AnimationGraph>, ThreadedAnimationGraph>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

HashMap<Entity, Vec<Cascade>>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<ScriptTypeRegistration, Result<ScriptComponentRegistration, ScriptResourceRegistration>>

Ok

  1. bevy_mod_scripting_core::bindings::query::ScriptTypeRegistration

Err

  1. core::result::Result<bevy_mod_scripting_core::bindings::query::ScriptComponentRegistration, bevy_mod_scripting_core::bindings::query::ScriptResourceRegistration>

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Option<Result<ScriptTypeRegistration, Result<ScriptComponentRegistration, ScriptResourceRegistration>>>

None

Some

  1. core::result::Result<bevy_mod_scripting_core::bindings::query::ScriptTypeRegistration, core::result::Result<bevy_mod_scripting_core::bindings::query::ScriptComponentRegistration, bevy_mod_scripting_core::bindings::query::ScriptResourceRegistration>>

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Result<Option<Result<ScriptTypeRegistration, Result<ScriptComponentRegistration, ScriptResourceRegistration>>>, InteropError>

Ok

  1. core::option::Option<core::result::Result<bevy_mod_scripting_core::bindings::query::ScriptTypeRegistration, core::result::Result<bevy_mod_scripting_core::bindings::query::ScriptComponentRegistration, bevy_mod_scripting_core::bindings::query::ScriptResourceRegistration>>>

Err

  1. bevy_mod_scripting_core::error::InteropError

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

Core Callbacks

On top of callbacks which are registered by your application, BMS provides a set of core callbacks which are always available.

The two core callbacks are:

  • on_script_loaded
  • on_script_unloaded

on_script_loaded

This will be called right after a script has been loaded or reloaded. This is a good place to initialize your script. You should avoid placing a lot of logic into the global body of your script, and instead put it into this callback. Otherwise errors in the initialization will fail the loading of the script.

This callback will not have access to the entity variable, as when the script is being loaded it's not attached to an entity yet.

print("you can also use this space, but it's not recommended")
function on_script_loaded()
    print("Hello world")
end

on_script_unloaded

This will be called right before a script is unloaded. This is a good place to clean up any resources that your script has allocated. Note this is not called when a script is reloaded, only when it is being removed from the system.

This callback will not have access to the entity variable, as when the script is being unloaded it might not be attached to an entity.

function on_script_unloaded()
    print("Goodbye world")
end

Developing BMS

This section is for developers who want to contribute to the BMS project. It covers various topics necessary for understanding the project and contributing to it.

Contributing

Please see the code of conduct as well as the contributing guidelines first.

Setup

this crate contains a work in progress xtask setup which in theory should allow you to setup everything you need for local development by running:

cargo xtask init

This command currently supports the following IDE's

If you'd like to add support for another IDE, please feel free to open a PR!

Adding New Languages to BMS

If you are interested in adding a new language to BMS, please read this section first. Adding a new language is a non-trivial task depending on the language you want to add. It also requires a lot of effort and time to maintain a new language, so unless the language you want to add is widely used and has a large community, it might not be worth the effort.

Evaluating Feasibility

In order for a language to work well with BMS it's necessary it supports the following features:

  • Interoperability with Rust. If you can't call it from Rust easilly and there is no existing crate that can do it for you, it's a no-go.
  • First class functions. Or at least the ability to call an arbitrary function with an arbitrary number of arguments from a script. Without this feature, you would need to separately generate code for the bevy bindings which is painful and goes against the grain of BMS.

First Classs Functions

They don't necessarily have to be first class from the script POV, but they need to be first class from the POV of the host language. This means that the host language needs to be able to call a function with an arbitrary number of arguments.

Examples

Let's say your language supports a Value type which can be returned to the script. And it has a Value::Function variant. The type on the Rust side would look something like this:

pub enum Value {
    Function(Arc<Fn(&[Value]) -> Value>),
    // other variants
}

This is fine, and can be integrated with BMS. Since an Fn function can be a closure capturing a DynamicScriptFunction. If there is no support for FnMut closures though, you might face issues in the implementation. Iterators in bevy_mod_scripting_functions for example use DynamicScriptFunctionMut which cannot work with Fn closures.

Now let's imagine instead another language with a similar enum, supports this type instead:

#![allow(unused)]
fn main() {
pub enum Value {
    Function(Arc<dyn Function>),
    // other variants
}

pub trait Function {
    fn call(&self, args: Vec<Value>) -> Value;

    fn num_params() -> usize;
}
}

This implies that to call this function, you need to be able to know the amount of arguments it expects at COMPILE time. This is not compatibile with dynamic functions, and would require a lot of code generation to make work with BMS. Languages with no support for dynamic functions are not compatible with BMS.

Interoperability with Rust

Not all languages can easilly be called from Rust. Lua has a wonderful crate which works out the ffi and safety issues for us. But not all languages have this luxury. If you can't call it from Rust easilly and there is no existing crate that can do it for you, integrating with BMS might not be the best idea.

This section needs work and is not fully accurate as is.

Necessary Features

In order for a language to be called "implemented" in BMS, it needs to support the following features:

  • Every script function which is registered on a type's namespace must:
    • Be callable on a ReflectReference representing object of that type in the script
    local my_reference = ...
    my_reference:my_Registered_function()
    
    • If it's static it must be callable from a global proxy object for that type, i.e.
    MyType.my_static_function()
    
  • ReflectReferences must support a set of basic features:
    • Access to fields via reflection i.e.:
    local my_reference = ...
    my_reference.my_field = 5
    print(my_reference.my_field)
    
    • Basic operators and standard operations are overloaded with the appropriate standard dynamic function registered:
      • Addition: dispatches to the add binary function on the type
      • Multiplication: dispatches to the mul binary function on the type
      • Division: dispatches to the div binary function on the type
      • Subtraction: dispatches to the sub binary function on the type
      • Modulo: dispatches to the rem binary function on the type
      • Negation: dispatches to the neg unary function on the type
      • Exponentiation: dispatches to the pow binary function on the type
      • Equality: dispatches to the eq binary function on the type
      • Less than: dispatches to the lt binary function on the type
      • Length: calls the len method on ReflectReference or on the table if the value is one.
      • Iteration: dispatches to the iter method on ReflectReference which returns an iterator function, this can be repeatedly called until it returns ScriptValue::Unit to signal the end of the iteration.
      • Print: calls the display_ref method on ReflectReference or on the table if the value is one.
  • Script handlers, loaders etc. must be implemented such that the ThreadWorldContainer is set for every interaction with script contexts, or anywhere else it might be needed.