Skip to main content

Mat4

Struct Mat4 

Source
#[repr(C)]
pub struct Mat4 { pub x_axis: Vec4, pub y_axis: Vec4, pub z_axis: Vec4, pub w_axis: Vec4, }
Expand description

A 4x4 column major matrix.

If you are primarily dealing with 3D affine transformations considering using Affine3A which is faster than a 4x4 matrix for some affine operations.

Affine transformations including 3D translation, rotation and scale can be created using methods such as Self::from_translation(), Self::from_quat(), Self::from_scale() and Self::from_scale_rotation_translation().

The Self::transform_point3() and Self::transform_vector3() convenience methods are provided for performing affine transformations on 3D vectors and points. These multiply 3D inputs as 4D vectors with an implicit w value of 1 for points and 0 for vectors respectively. These methods assume that Self contains a valid affine transform.

SIMD vector types are used for storage on supported platforms.

This type is 16 byte aligned.

Fields§

§x_axis: Vec4§y_axis: Vec4§z_axis: Vec4§w_axis: Vec4

Implementations§

Source§

impl Mat4

Source

pub const ZERO: Mat4

A 4x4 matrix with all elements set to 0.0.

Source

pub const IDENTITY: Mat4

A 4x4 identity matrix, where all diagonal elements are 1, and all off-diagonal elements are 0.

Source

pub const NAN: Mat4

All NAN:s.

Source

pub const fn from_cols( x_axis: Vec4, y_axis: Vec4, z_axis: Vec4, w_axis: Vec4, ) -> Mat4

Creates a 4x4 matrix from four column vectors.

See also Self::from_rows when the data is in row major order.

Source

pub const fn from_rows(row0: Vec4, row1: Vec4, row2: Vec4, row3: Vec4) -> Mat4

Creates a 4x4 matrix from four row vectors.

Matrices are stored in column major order, so the given rows are permuted into the matrix layout. Use Self::from_cols instead when the data is already in column major order.

Source

pub const fn from_cols_array(m: &[f32; 16]) -> Mat4

Creates a 4x4 matrix from a [f32; 16] array stored in column major order.

If the data is in row major order use Self::from_rows_array instead.

Source

pub const fn to_cols_array(&self) -> [f32; 16]

Creates a [f32; 16] array storing data in column major order.

If you require the data in row major order use Self::to_rows_array instead.

Source

pub const fn from_cols_array_2d(m: &[[f32; 4]; 4]) -> Mat4

Creates a 4x4 matrix from a [[f32; 4]; 4] 4D array stored in column major order.

If the data is in row major order transpose the returned matrix.

Examples found in repository?
examples/3d/irradiance_volumes.rs (lines 59-64)
59static VOXEL_FROM_WORLD: Mat4 = Mat4::from_cols_array_2d(&[
60    [-42.317566, 0.0, 0.0, 0.0],
61    [0.0, 0.0, 44.601563, 0.0],
62    [0.0, 16.73776, 0.0, 0.0],
63    [0.0, 6.544792, 0.0, 1.0],
64]);
Source

pub const fn to_cols_array_2d(&self) -> [[f32; 4]; 4]

Creates a [[f32; 4]; 4] 4D array storing data in column major order.

If you require row major order transpose the matrix first.

Source

pub const fn from_rows_array(m: &[f32; 16]) -> Mat4

Creates a 4x4 matrix from a [f32; 16] array stored in row major order.

Matrices are stored in column major order, so the array is permuted into the matrix layout. Use Self::from_cols_array instead when the data is already in column major order.

Source

pub const fn to_rows_array(&self) -> [f32; 16]

Creates a [f32; 16] array storing data in row major order.

Matrices are stored in column major order, so the array is permuted out of the column major storage. Use Self::to_cols_array instead when you want data in column major order.

Source

pub const fn from_diagonal(diagonal: Vec4) -> Mat4

Creates a 4x4 matrix with its diagonal set to diagonal and all other entries set to 0.

Source

pub fn from_scale_rotation_translation( scale: Vec3, rotation: Quat, translation: Vec3, ) -> Mat4

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.

Source

pub fn from_rotation_translation(rotation: Quat, translation: Vec3) -> Mat4

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.

Source

pub fn to_scale_rotation_translation(&self) -> (Vec3, Quat, Vec3)

Extracts scale, rotation and translation from self. The input matrix is expected to be a 3D affine transformation matrix otherwise the output will be invalid.

§Panics

Will panic if self is not a valid affine transformation matrix, if the determinant of the 3x3 linear part (the rotation and scale part of the transform) is zero, when glam_assert is enabled.

Source

pub fn from_quat(rotation: Quat) -> Mat4

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.

Source

pub fn from_mat3(m: Mat3) -> Mat4

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().

Source

pub fn from_mat3_translation(mat3: Mat3, translation: Vec3) -> Mat4

Creates an affine transformation matrics from a 3x3 matrix (expressing scale, shear and rotation) and a translation vector.

Equivalent to Mat4::from_translation(translation) * Mat4::from_mat3(mat3)

Source

pub fn from_mat3a(m: Mat3A) -> Mat4

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().

Examples found in repository?
examples/3d/mirror.rs (line 355)
341fn calculate_mirror_camera_transform_and_projection(
342    main_camera_transform: &Transform,
343    main_camera_projection: &PerspectiveProjection,
344    mirror_transform: &Transform,
345) -> (Transform, PerspectiveProjection) {
346    // Calculate the reflection matrix (a.k.a. Householder matrix) that will
347    // reflect the scene across the mirror plane.
348    //
349    // Note that you must calculate this in *matrix* form and only *afterward*
350    // convert to a `Transform` instead of composing `Transform`s. This is
351    // because the reflection matrix has non-uniform scale, and composing
352    // transforms can't always handle composition of matrices with non-uniform
353    // scales.
354    let mirror_camera_transform = Transform::from_matrix(
355        Mat4::from_mat3a(reflection_matrix(Vec3::NEG_Z)) * main_camera_transform.to_matrix(),
356    );
357
358    // Compute the distance from the camera to the mirror plane. This will be
359    // used to calculate the distance to the near clip plane for the mirror
360    // world.
361    let distance_from_camera_to_mirror = InfinitePlane3d::new(mirror_transform.rotation * Vec3::Y)
362        .signed_distance(
363            Isometry3d::IDENTITY,
364            mirror_transform.translation - main_camera_transform.translation,
365        );
366
367    // Compute the normal of the mirror plane in view space.
368    let view_from_world = main_camera_transform.compute_affine().matrix3.inverse();
369    let mirror_projection_plane_normal =
370        (view_from_world * (mirror_transform.rotation * Vec3::NEG_Y)).normalize();
371
372    // Compute the final projection. It should match the main camera projection,
373    // except that `near` and `near_normal` should be set to the updated near
374    // plane and near normal plane as above.
375    let mirror_camera_projection = PerspectiveProjection {
376        near_clip_plane: mirror_projection_plane_normal.extend(distance_from_camera_to_mirror),
377        ..*main_camera_projection
378    };
379
380    (mirror_camera_transform, mirror_camera_projection)
381}
Source

pub fn from_translation(translation: Vec3) -> Mat4

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().

Examples found in repository?
tests/3d/test_invalid_skinned_mesh.rs (line 145)
92fn setup_meshes(
93    mut commands: Commands,
94    mut mesh_assets: ResMut<Assets<Mesh>>,
95    mut material_assets: ResMut<Assets<StandardMaterial>>,
96    mut inverse_bindposes_assets: ResMut<Assets<SkinnedMeshInverseBindposes>>,
97) {
98    // Create a mesh with two rectangles.
99    let unskinned_mesh = Mesh::new(
100        PrimitiveTopology::TriangleList,
101        RenderAssetUsages::default(),
102    )
103    .with_inserted_attribute(
104        Mesh::ATTRIBUTE_POSITION,
105        vec![
106            [-0.3, -0.3, 0.0],
107            [0.3, -0.3, 0.0],
108            [-0.3, 0.3, 0.0],
109            [0.3, 0.3, 0.0],
110            [-0.4, 0.8, 0.0],
111            [0.4, 0.8, 0.0],
112            [-0.4, 1.8, 0.0],
113            [0.4, 1.8, 0.0],
114        ],
115    )
116    .with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, vec![[0.0, 0.0, 1.0]; 8])
117    .with_inserted_indices(Indices::U16(vec![0, 1, 3, 0, 3, 2, 4, 5, 7, 4, 7, 6]));
118
119    // Copy the mesh and add skinning attributes that bind each rectangle to a joint.
120    let skinned_mesh = unskinned_mesh
121        .clone()
122        .with_inserted_attribute(
123            Mesh::ATTRIBUTE_JOINT_INDEX,
124            VertexAttributeValues::Uint16x4(vec![
125                [0, 0, 0, 0],
126                [0, 0, 0, 0],
127                [0, 0, 0, 0],
128                [0, 0, 0, 0],
129                [1, 0, 0, 0],
130                [1, 0, 0, 0],
131                [1, 0, 0, 0],
132                [1, 0, 0, 0],
133            ]),
134        )
135        .with_inserted_attribute(
136            Mesh::ATTRIBUTE_JOINT_WEIGHT,
137            vec![[1.00, 0.00, 0.0, 0.0]; 8],
138        );
139
140    let unskinned_mesh_handle = mesh_assets.add(unskinned_mesh);
141    let skinned_mesh_handle = mesh_assets.add(skinned_mesh);
142
143    let inverse_bindposes_handle = inverse_bindposes_assets.add(vec![
144        Mat4::IDENTITY,
145        Mat4::from_translation(Vec3::new(0.0, -1.3, 0.0)),
146    ]);
147
148    let mesh_material_handle = material_assets.add(StandardMaterial::default());
149
150    let background_material_handle = material_assets.add(StandardMaterial {
151        base_color: Color::srgb(0.05, 0.15, 0.05),
152        reflectance: 0.2,
153        ..default()
154    });
155
156    #[derive(PartialEq)]
157    enum Variation {
158        Normal,
159        MissingMeshAttributes,
160        MissingJointEntity,
161        MissingSkinnedMeshComponent,
162    }
163
164    for (index, variation) in [
165        Variation::Normal,
166        Variation::MissingMeshAttributes,
167        Variation::MissingJointEntity,
168        Variation::MissingSkinnedMeshComponent,
169    ]
170    .into_iter()
171    .enumerate()
172    {
173        // Skip variations that are currently broken. See https://github.com/bevyengine/bevy/issues/16929,
174        // https://github.com/bevyengine/bevy/pull/18074.
175        if (variation == Variation::MissingSkinnedMeshComponent)
176            || (variation == Variation::MissingMeshAttributes)
177        {
178            continue;
179        }
180
181        let transform = Transform::from_xyz(((index as f32) - 1.5) * 4.5, 0.0, 0.0);
182
183        let joint_0 = commands.spawn(transform).id();
184
185        let joint_1 = commands
186            .spawn((ChildOf(joint_0), AnimatedJoint, Transform::IDENTITY))
187            .id();
188
189        if variation == Variation::MissingJointEntity {
190            commands.entity(joint_1).despawn();
191        }
192
193        let mesh_handle = match variation {
194            Variation::MissingMeshAttributes => &unskinned_mesh_handle,
195            _ => &skinned_mesh_handle,
196        };
197
198        let mut entity_commands = commands.spawn((
199            Mesh3d(mesh_handle.clone()),
200            MeshMaterial3d(mesh_material_handle.clone()),
201            transform,
202        ));
203
204        if variation != Variation::MissingSkinnedMeshComponent {
205            entity_commands.insert(SkinnedMesh {
206                inverse_bindposes: inverse_bindposes_handle.clone(),
207                joints: vec![joint_0, joint_1],
208            });
209        }
210
211        // Add a square behind the mesh to distinguish it from the other meshes.
212        commands.spawn((
213            Transform::from_xyz(transform.translation.x, transform.translation.y, -0.8),
214            Mesh3d(mesh_assets.add(Plane3d::default().mesh().size(4.3, 4.3).normal(Dir3::Z))),
215            MeshMaterial3d(background_material_handle.clone()),
216        ));
217    }
218}
More examples
Hide additional examples
tests/3d/test_skinned_mesh_bounds.rs (line 188)
124fn spawn_custom_meshes(
125    mut commands: Commands,
126    mut mesh_assets: ResMut<Assets<Mesh>>,
127    mut material_assets: ResMut<Assets<StandardMaterial>>,
128    mut inverse_bindposes_assets: ResMut<Assets<SkinnedMeshInverseBindposes>>,
129) {
130    let mesh_handle = mesh_assets.add(
131        Mesh::new(
132            PrimitiveTopology::TriangleStrip,
133            // Test that skinned mesh bounds work even if the mesh is render
134            // world only.
135            RenderAssetUsages::RENDER_WORLD,
136        )
137        .with_inserted_attribute(
138            Mesh::ATTRIBUTE_POSITION,
139            vec![
140                [-0.5, 0.0, 0.0],
141                [0.5, 0.0, 0.0],
142                [-0.5, 0.5, 0.0],
143                [0.5, 0.5, 0.0],
144                [-0.5, 1.0, 0.0],
145                [0.5, 1.0, 0.0],
146                [-0.5, 1.5, 0.0],
147                [0.5, 1.5, 0.0],
148                [-0.5, 2.0, 0.0],
149                [0.5, 2.0, 0.0],
150            ],
151        )
152        .with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, vec![[0.0, 0.0, 1.0]; 10])
153        .with_inserted_attribute(
154            Mesh::ATTRIBUTE_JOINT_INDEX,
155            VertexAttributeValues::Uint16x4(vec![
156                [1, 0, 0, 0],
157                [1, 0, 0, 0],
158                [1, 2, 0, 0],
159                [1, 2, 0, 0],
160                [1, 2, 0, 0],
161                [1, 2, 0, 0],
162                [2, 1, 0, 0],
163                [2, 1, 0, 0],
164                [2, 0, 0, 0],
165                [2, 0, 0, 0],
166            ]),
167        )
168        .with_inserted_attribute(
169            Mesh::ATTRIBUTE_JOINT_WEIGHT,
170            vec![
171                [1.00, 0.00, 0.0, 0.0],
172                [1.00, 0.00, 0.0, 0.0],
173                [0.75, 0.25, 0.0, 0.0],
174                [0.75, 0.25, 0.0, 0.0],
175                [0.50, 0.50, 0.0, 0.0],
176                [0.50, 0.50, 0.0, 0.0],
177                [0.75, 0.25, 0.0, 0.0],
178                [0.75, 0.25, 0.0, 0.0],
179                [1.00, 0.00, 0.0, 0.0],
180                [1.00, 0.00, 0.0, 0.0],
181            ],
182        )
183        .with_generated_skinned_mesh_bounds()
184        .unwrap(),
185    );
186
187    let inverse_bindposes_handle = inverse_bindposes_assets.add(vec![
188        Mat4::from_translation(Vec3::new(0.0, 0.0, 0.0)),
189        Mat4::from_translation(Vec3::new(0.0, 0.0, 0.0)),
190        Mat4::from_translation(Vec3::new(0.0, -1.0, 0.0)),
191    ]);
192
193    struct MeshInstance {
194        animations: [CustomAnimationId; 2],
195    }
196
197    let mesh_instances = [
198        // Simple cases. First joint is still, second joint is all rotation/translation/scale variations.
199        MeshInstance { animations: [0, 1] },
200        MeshInstance { animations: [0, 2] },
201        MeshInstance { animations: [0, 3] },
202        MeshInstance { animations: [0, 4] },
203        MeshInstance { animations: [0, 5] },
204        MeshInstance { animations: [0, 6] },
205        MeshInstance { animations: [0, 7] },
206        MeshInstance { animations: [0, 8] },
207        // Skewed cases. First joint is non-uniform scaling, second joint is rotation/translation variations.
208        MeshInstance { animations: [9, 1] },
209        MeshInstance { animations: [9, 2] },
210        MeshInstance { animations: [9, 3] },
211        MeshInstance { animations: [9, 4] },
212        MeshInstance { animations: [9, 5] },
213    ];
214
215    for (i, mesh_instance) in mesh_instances.iter().enumerate() {
216        let x = ((i as f32) * 2.0) - ((mesh_instances.len() - 1) as f32);
217
218        let base_entity = commands
219            .spawn((Transform::from_xyz(x, 0.0, 0.0), Visibility::default()))
220            .id();
221
222        let joints = vec![
223            commands.spawn((Transform::IDENTITY,)).id(),
224            commands
225                .spawn((
226                    CustomAnimation(mesh_instance.animations[0]),
227                    Transform::IDENTITY,
228                ))
229                .id(),
230            commands
231                .spawn((
232                    CustomAnimation(mesh_instance.animations[1]),
233                    Transform::IDENTITY,
234                ))
235                .id(),
236        ];
237
238        commands.entity(joints[0]).insert(ChildOf(base_entity));
239
240        commands.entity(joints[1]).insert(ChildOf(joints[0]));
241        commands.entity(joints[2]).insert(ChildOf(joints[1]));
242
243        let mesh_entity = commands
244            .spawn((
245                Transform::IDENTITY,
246                Mesh3d(mesh_handle.clone()),
247                MeshMaterial3d(material_assets.add(StandardMaterial {
248                    base_color: Color::WHITE,
249                    cull_mode: None,
250                    ..default()
251                })),
252                SkinnedMesh {
253                    inverse_bindposes: inverse_bindposes_handle.clone(),
254                    joints: joints.clone(),
255                },
256                DynamicSkinnedMeshBounds,
257            ))
258            .id();
259
260        commands.entity(mesh_entity).insert(ChildOf(base_entity));
261    }
262}
examples/animation/custom_skinned_mesh.rs (line 53)
38fn setup(
39    mut commands: Commands,
40    asset_server: Res<AssetServer>,
41    mut meshes: ResMut<Assets<Mesh>>,
42    mut materials: ResMut<Assets<StandardMaterial>>,
43    mut skinned_mesh_inverse_bindposes_assets: ResMut<Assets<SkinnedMeshInverseBindposes>>,
44) {
45    // Create a camera
46    commands.spawn((
47        Camera3d::default(),
48        Transform::from_xyz(2.5, 2.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
49    ));
50
51    // Create inverse bindpose matrices for a skeleton consists of 2 joints
52    let inverse_bindposes = skinned_mesh_inverse_bindposes_assets.add(vec![
53        Mat4::from_translation(Vec3::new(-0.5, -1.0, 0.0)),
54        Mat4::from_translation(Vec3::new(-0.5, -1.0, 0.0)),
55    ]);
56
57    // Create a mesh
58    let mesh = Mesh::new(
59        PrimitiveTopology::TriangleList,
60        RenderAssetUsages::RENDER_WORLD,
61    )
62    // Set mesh vertex positions
63    .with_inserted_attribute(
64        Mesh::ATTRIBUTE_POSITION,
65        vec![
66            [0.0, 0.0, 0.0],
67            [1.0, 0.0, 0.0],
68            [0.0, 0.5, 0.0],
69            [1.0, 0.5, 0.0],
70            [0.0, 1.0, 0.0],
71            [1.0, 1.0, 0.0],
72            [0.0, 1.5, 0.0],
73            [1.0, 1.5, 0.0],
74            [0.0, 2.0, 0.0],
75            [1.0, 2.0, 0.0],
76        ],
77    )
78    // Add UV coordinates that map the left half of the texture since its a 1 x
79    // 2 rectangle.
80    .with_inserted_attribute(
81        Mesh::ATTRIBUTE_UV_0,
82        vec![
83            [0.0, 0.00],
84            [0.5, 0.00],
85            [0.0, 0.25],
86            [0.5, 0.25],
87            [0.0, 0.50],
88            [0.5, 0.50],
89            [0.0, 0.75],
90            [0.5, 0.75],
91            [0.0, 1.00],
92            [0.5, 1.00],
93        ],
94    )
95    // Set mesh vertex normals
96    .with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, vec![[0.0, 0.0, 1.0]; 10])
97    // Set mesh vertex joint indices for mesh skinning.
98    // Each vertex gets 4 indices used to address the `JointTransforms` array in the vertex shader
99    //  as well as `SkinnedMeshJoint` array in the `SkinnedMesh` component.
100    // This means that a maximum of 4 joints can affect a single vertex.
101    .with_inserted_attribute(
102        Mesh::ATTRIBUTE_JOINT_INDEX,
103        // Need to be explicit here as [u16; 4] could be either Uint16x4 or Unorm16x4.
104        VertexAttributeValues::Uint16x4(vec![
105            [0, 0, 0, 0],
106            [0, 0, 0, 0],
107            [0, 1, 0, 0],
108            [0, 1, 0, 0],
109            [0, 1, 0, 0],
110            [0, 1, 0, 0],
111            [0, 1, 0, 0],
112            [0, 1, 0, 0],
113            [0, 1, 0, 0],
114            [0, 1, 0, 0],
115        ]),
116    )
117    // Set mesh vertex joint weights for mesh skinning.
118    // Each vertex gets 4 joint weights corresponding to the 4 joint indices assigned to it.
119    // The sum of these weights should equal to 1.
120    .with_inserted_attribute(
121        Mesh::ATTRIBUTE_JOINT_WEIGHT,
122        vec![
123            [1.00, 0.00, 0.0, 0.0],
124            [1.00, 0.00, 0.0, 0.0],
125            [0.75, 0.25, 0.0, 0.0],
126            [0.75, 0.25, 0.0, 0.0],
127            [0.50, 0.50, 0.0, 0.0],
128            [0.50, 0.50, 0.0, 0.0],
129            [0.25, 0.75, 0.0, 0.0],
130            [0.25, 0.75, 0.0, 0.0],
131            [0.00, 1.00, 0.0, 0.0],
132            [0.00, 1.00, 0.0, 0.0],
133        ],
134    )
135    // Tell bevy to construct triangles from a list of vertex indices,
136    // where each 3 vertex indices form a triangle.
137    .with_inserted_indices(Indices::U16(vec![
138        0, 1, 3, 0, 3, 2, 2, 3, 5, 2, 5, 4, 4, 5, 7, 4, 7, 6, 6, 7, 9, 6, 9, 8,
139    ]))
140    // Create skinned mesh bounds. Together with the `DynamicSkinnedMeshBounds`
141    // component, this will ensure the mesh is correctly frustum culled.
142    .with_generated_skinned_mesh_bounds()
143    .unwrap();
144
145    let mesh = meshes.add(mesh);
146
147    // We're seeding the PRNG here to make this example deterministic for testing purposes.
148    // This isn't strictly required in practical use unless you need your app to be deterministic.
149    let mut rng = ChaCha8Rng::seed_from_u64(42);
150
151    for i in -5..5 {
152        // Create joint entities
153        let joint_0 = commands
154            .spawn(Transform::from_xyz(
155                i as f32 * 1.5,
156                0.0,
157                // Move quads back a small amount to avoid Z-fighting and not
158                // obscure the transform gizmos.
159                -(i as f32 * 0.01).abs(),
160            ))
161            .id();
162        let joint_1 = commands.spawn((AnimatedJoint(i), Transform::IDENTITY)).id();
163
164        // Set joint_1 as a child of joint_0.
165        commands.entity(joint_0).add_children(&[joint_1]);
166
167        // Each joint in this vector corresponds to each inverse bindpose matrix in `SkinnedMeshInverseBindposes`.
168        let joint_entities = vec![joint_0, joint_1];
169
170        // Create skinned mesh renderer. Note that its transform doesn't affect the position of the mesh.
171        commands.spawn((
172            Mesh3d(mesh.clone()),
173            MeshMaterial3d(materials.add(StandardMaterial {
174                base_color: Color::srgb(
175                    rng.random_range(0.0..1.0),
176                    rng.random_range(0.0..1.0),
177                    rng.random_range(0.0..1.0),
178                ),
179                base_color_texture: Some(asset_server.load("textures/uv_checker_bw.png")),
180                ..default()
181            })),
182            SkinnedMesh {
183                inverse_bindposes: inverse_bindposes.clone(),
184                joints: joint_entities,
185            },
186            DynamicSkinnedMeshBounds,
187        ));
188    }
189}
Source

pub fn from_axis_angle(axis: Vec3, angle: f32) -> Mat4

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.

Source

pub fn from_euler(order: EulerRot, a: f32, b: f32, c: f32) -> Mat4

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().

Source

pub fn to_euler(&self, order: EulerRot) -> (f32, f32, f32)

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.

Source

pub fn from_rotation_x(angle: f32) -> Mat4

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().

Source

pub fn from_rotation_y(angle: f32) -> Mat4

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().

Source

pub fn from_rotation_z(angle: f32) -> Mat4

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().

Source

pub fn from_scale(scale: Vec3) -> Mat4

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.

Source

pub const fn from_cols_slice(slice: &[f32]) -> Mat4

Creates a 4x4 matrix from the first 16 values in slice.

See also Self::from_rows_slice when the slice is in row major order.

§Panics

Panics if slice is less than 16 elements long.

Source

pub fn write_cols_to_slice(&self, slice: &mut [f32])

Writes the columns of self to the first 16 elements in slice.

§Panics

Panics if slice is less than 16 elements long.

Source

pub const fn from_rows_slice(slice: &[f32]) -> Mat4

Creates a 4x4 matrix from the first 16 values in slice, stored in row major order.

Matrices are stored in column major order, so the slice is permuted into the matrix layout. Use Self::from_cols_slice instead when the slice is already in column major order.

§Panics

Panics if slice is less than 16 elements long.

Source

pub fn col(&self, index: usize) -> Vec4

Returns the matrix column for the given index.

§Panics

Panics if index is greater than 3.

Source

pub fn col_mut(&mut self, index: usize) -> &mut Vec4

Returns a mutable reference to the matrix column for the given index.

§Panics

Panics if index is greater than 3.

Examples found in repository?
examples/camera/custom_projection.rs (line 25)
23    fn get_clip_from_view(&self) -> Mat4 {
24        let mut mat = self.perspective.get_clip_from_view();
25        mat.col_mut(2)[0] = self.horizontal_obliqueness;
26        mat.col_mut(2)[1] = self.vertical_obliqueness;
27        mat
28    }
29
30    fn get_clip_from_view_for_sub(&self, sub_view: &bevy::camera::SubCameraView) -> Mat4 {
31        let mut mat = self.perspective.get_clip_from_view_for_sub(sub_view);
32        mat.col_mut(2)[0] = self.horizontal_obliqueness;
33        mat.col_mut(2)[1] = self.vertical_obliqueness;
34        mat
35    }
Source

pub fn row(&self, index: usize) -> Vec4

Returns the matrix row for the given index.

See also Self::set_row when you need to change the row.

§Panics

Panics if index is greater than 3.

Source

pub fn set_row(&mut self, index: usize, row: Vec4)

Sets the matrix row for the given index.

Matrices are stored in column major order, so the row is spread across all 4 columns and writing it touches every column. Use Self::col_mut instead when you can work with columns. See also Self::row.

§Panics

Panics if index is greater than 3.

Source

pub fn is_finite(&self) -> bool

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Source

pub fn is_nan(&self) -> bool

Returns true if any elements are NaN.

Source

pub fn transpose(&self) -> Mat4

Returns the transpose of self.

Source

pub fn diagonal(&self) -> Vec4

Returns the diagonal of self.

Source

pub fn determinant(&self) -> f32

Returns the determinant of self.

Source

pub fn inverse(&self) -> Mat4

Returns the inverse of self.

If the matrix is not invertible the returned matrix will be invalid. The returned matrix will also be invalid if the inverse is not finite, which can happen when self contains very large or very small values. Use Self::try_inverse or Self::inverse_or_zero to detect these cases.

§Panics

Will panic if the resulting inverted matrix is not finite when glam_assert is enabled.

Examples found in repository?
examples/3d/irradiance_volumes.rs (line 557)
528fn create_cubes(
529    image_assets: Res<Assets<Image>>,
530    mut commands: Commands,
531    irradiance_volumes: Query<(&IrradianceVolume, &GlobalTransform)>,
532    voxel_cube_parents: Query<Entity, With<VoxelCubeParent>>,
533    voxel_cubes: Query<Entity, With<VoxelCube>>,
534    example_assets: Res<ExampleAssets>,
535    mut voxel_visualization_material_assets: ResMut<Assets<VoxelVisualizationMaterial>>,
536) {
537    // If voxel cubes have already been spawned, don't do anything.
538    if !voxel_cubes.is_empty() {
539        return;
540    }
541
542    let Some(voxel_cube_parent) = voxel_cube_parents.iter().next() else {
543        return;
544    };
545
546    for (irradiance_volume, global_transform) in irradiance_volumes.iter() {
547        let Some(image) = image_assets.get(&irradiance_volume.voxels) else {
548            continue;
549        };
550
551        let resolution = image.texture_descriptor.size;
552
553        let voxel_cube_material = voxel_visualization_material_assets.add(ExtendedMaterial {
554            base: StandardMaterial::from(Color::from(RED)),
555            extension: VoxelVisualizationExtension {
556                irradiance_volume_info: VoxelVisualizationIrradianceVolumeInfo {
557                    world_from_voxel: VOXEL_FROM_WORLD.inverse(),
558                    voxel_from_world: VOXEL_FROM_WORLD,
559                    resolution: uvec3(
560                        resolution.width,
561                        resolution.height,
562                        resolution.depth_or_array_layers,
563                    ),
564                    intensity: IRRADIANCE_VOLUME_INTENSITY,
565                },
566            },
567        });
568
569        let scale = vec3(
570            1.0 / resolution.width as f32,
571            1.0 / resolution.height as f32,
572            1.0 / resolution.depth_or_array_layers as f32,
573        );
574
575        // Spawn a cube for each voxel.
576        for z in 0..resolution.depth_or_array_layers {
577            for y in 0..resolution.height {
578                for x in 0..resolution.width {
579                    let uvw = (uvec3(x, y, z).as_vec3() + 0.5) * scale - 0.5;
580                    let pos = global_transform.transform_point(uvw);
581                    let voxel_cube = commands
582                        .spawn((
583                            Mesh3d(example_assets.voxel_cube.clone()),
584                            MeshMaterial3d(voxel_cube_material.clone()),
585                            Transform::from_scale(Vec3::splat(VOXEL_CUBE_SCALE))
586                                .with_translation(pos),
587                        ))
588                        .insert(VoxelCube)
589                        .insert(NotShadowCaster)
590                        .id();
591
592                    commands.entity(voxel_cube_parent).add_child(voxel_cube);
593                }
594            }
595        }
596    }
597}
Source

pub fn try_inverse(&self) -> Option<Mat4>

Returns the inverse of self or None if the matrix is not invertible, or if the inverse is not finite.

Source

pub fn inverse_or_zero(&self) -> Mat4

Returns the inverse of self or Mat4::ZERO if the matrix is not invertible, or if the inverse is not finite.

Source

pub fn look_to_lh(eye: Vec3, dir: Vec3, up: Vec3) -> Mat4

👎Deprecated since 0.33.1:

use the glam::camera::lh::view::look_to_mat4 function instead

Creates a left-handed view matrix using a camera position, a facing direction and an up direction

For a view coordinate system with +X=right, +Y=up and +Z=forward.

§Panics

Will panic if dir or up are not normalized, or if dir and up are parallel, when glam_assert is enabled.

Source

pub fn look_to_rh(eye: Vec3, dir: Vec3, up: Vec3) -> Mat4

👎Deprecated since 0.33.1:

use the glam::camera::rh::view::look_to_mat4 function instead

Creates a right-handed view matrix using a camera position, a facing direction, and an up direction.

For a view coordinate system with +X=right, +Y=up and +Z=back.

§Panics

Will panic if dir or up are not normalized, or if dir and up are parallel, when glam_assert is enabled.

Source

pub fn look_at_lh(eye: Vec3, center: Vec3, up: Vec3) -> Mat4

👎Deprecated since 0.33.1:

use the glam::camera::lh::view::look_at_mat4 function instead

Creates a left-handed view matrix using a camera position, a focal points and an up direction.

For a view coordinate system with +X=right, +Y=up and +Z=forward.

§Panics

Will panic if up is not normalized, if center is equal to eye, or if the view direction is parallel to up, when glam_assert is enabled.

Source

pub fn look_at_rh(eye: Vec3, center: Vec3, up: Vec3) -> Mat4

👎Deprecated since 0.33.1:

use the glam::camera::rh::view::look_at_mat4 function instead

Creates a right-handed view matrix using a camera position, a focal point, and an up direction.

For a view coordinate system with +X=right, +Y=up and +Z=back.

§Panics

Will panic if up is not normalized, if center is equal to eye, or if the view direction is parallel to up, when glam_assert is enabled.

Source

pub fn frustum_rh_gl( left: f32, right: f32, bottom: f32, top: f32, z_near: f32, z_far: f32, ) -> Mat4

👎Deprecated since 0.33.1:

use the glam::camera::rh::proj::opengl::frustum function instead

Creates a right-handed perspective projection matrix with [-1,1] depth range.

This is the same as the OpenGL glFrustum function.

See https://registry.khronos.org/OpenGL-Refpages/gl2.1/xhtml/glFrustum.xml

Source

pub fn frustum_lh( left: f32, right: f32, bottom: f32, top: f32, z_near: f32, z_far: f32, ) -> Mat4

👎Deprecated since 0.33.1:

use the glam::camera::lh::proj::directx::frustum function instead

Creates a left-handed perspective projection matrix with [0,1] depth range.

§Panics

Will panic if left equals right, bottom equals top, z_near equals z_far, or z_near or z_far are not positive when glam_assert is enabled.

Source

pub fn frustum_rh( left: f32, right: f32, bottom: f32, top: f32, z_near: f32, z_far: f32, ) -> Mat4

👎Deprecated since 0.33.1:

use the glam::camera::rh::proj::directx::frustum function instead

Creates a right-handed perspective projection matrix with [0,1] depth range.

§Panics

Will panic if left equals right, bottom equals top, z_near equals z_far, or z_near or z_far are not positive when glam_assert is enabled.

Source

pub fn perspective_rh_gl( fov_y_radians: f32, aspect_ratio: f32, z_near: f32, z_far: f32, ) -> Mat4

👎Deprecated since 0.33.1:

use the glam::camera::rh::proj::opengl::perspective function instead

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

Source

pub fn perspective_lh( fov_y_radians: f32, aspect_ratio: f32, z_near: f32, z_far: f32, ) -> Mat4

👎Deprecated since 0.33.1:

use the glam::camera::lh::proj::directx::perspective function instead

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 fov_y_radians is not in the range (0, π), if aspect_ratio is zero, or if z_near or z_far are less than or equal to zero, or if z_near is equal to z_far, when glam_assert is enabled.

Source

pub fn perspective_rh( fov_y_radians: f32, aspect_ratio: f32, z_near: f32, z_far: f32, ) -> Mat4

👎Deprecated since 0.33.1:

use the glam::camera::rh::proj::directx::perspective function instead

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 fov_y_radians is not in the range (0, π), if aspect_ratio is zero, or if z_near or z_far are less than or equal to zero, or if z_near is equal to z_far, when glam_assert is enabled.

Source

pub fn perspective_infinite_lh( fov_y_radians: f32, aspect_ratio: f32, z_near: f32, ) -> Mat4

👎Deprecated since 0.33.1:

use the glam::camera::lh::proj::directx::perspective_infinite function instead

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 fov_y_radians is not in the range (0, π), if aspect_ratio is zero, or if z_near is less than or equal to zero when glam_assert is enabled.

Source

pub fn perspective_infinite_reverse_lh( fov_y_radians: f32, aspect_ratio: f32, z_near: f32, ) -> Mat4

👎Deprecated since 0.33.1:

use the glam::camera::lh::proj::directx::perspective_infinite_reverse function instead

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 fov_y_radians is not in the range (0, π), if aspect_ratio is zero, or if z_near is less than or equal to zero when glam_assert is enabled.

Source

pub fn perspective_infinite_rh( fov_y_radians: f32, aspect_ratio: f32, z_near: f32, ) -> Mat4

👎Deprecated since 0.33.1:

use the glam::camera::rh::proj::directx::perspective_infinite function instead

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 fov_y_radians is not in the range (0, π), if aspect_ratio is zero, or if z_near is less than or equal to zero when glam_assert is enabled.

Source

pub fn perspective_infinite_reverse_rh( fov_y_radians: f32, aspect_ratio: f32, z_near: f32, ) -> Mat4

👎Deprecated since 0.33.1:

use the glam::camera::rh::proj::directx::perspective_infinite_reverse function instead

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 fov_y_radians is not in the range (0, π), if aspect_ratio is zero, or if z_near is less than or equal to zero when glam_assert is enabled.

Source

pub fn orthographic_rh_gl( left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32, ) -> Mat4

👎Deprecated since 0.33.1:

use the glam::camera::rh::proj::opengl::orthographic function instead

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.

Source

pub fn orthographic_lh( left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32, ) -> Mat4

👎Deprecated since 0.33.1:

use the glam::camera::lh::proj::directx::orthographic function instead

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.

Source

pub fn orthographic_rh( left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32, ) -> Mat4

👎Deprecated since 0.33.1:

use the glam::camera::rh::proj::directx::orthographic function instead

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.

Source

pub fn project_point3(&self, rhs: Vec3) -> Vec3

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.

Source

pub fn transform_point3(&self, rhs: Vec3) -> Vec3

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.

Source

pub fn transform_vector3(&self, rhs: Vec3) -> Vec3

Transforms the given 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.

Source

pub fn project_point3a(&self, rhs: Vec3A) -> Vec3A

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.

Source

pub fn transform_point3a(&self, rhs: Vec3A) -> Vec3A

Transforms the given Vec3A as 3D point.

This is the equivalent of multiplying the Vec3A as a 4D vector where w is 1.0.

This method assumes that self contains a valid affine transform. If self contains a perspective transform, or if you are unsure, the Self::project_point3a() 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.

Source

pub fn transform_vector3a(&self, rhs: Vec3A) -> Vec3A

Transforms the given Vec3A as 3D vector.

This is the equivalent of multiplying the Vec3A 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.

Source

pub fn mul_vec4(&self, rhs: Vec4) -> Vec4

Transforms a 4D vector.

Source

pub fn mul_transpose_vec4(&self, rhs: Vec4) -> Vec4

Transforms a 4D vector by the transpose of self.

Source

pub fn mul_mat4(&self, rhs: &Mat4) -> Mat4

Multiplies two 4x4 matrices.

Source

pub fn add_mat4(&self, rhs: &Mat4) -> Mat4

Adds two 4x4 matrices.

Source

pub fn sub_mat4(&self, rhs: &Mat4) -> Mat4

Subtracts two 4x4 matrices.

Source

pub fn mul_scalar(&self, rhs: f32) -> Mat4

Multiplies a 4x4 matrix by a scalar.

Source

pub fn mul_diagonal_scale(&self, scale: Vec4) -> Mat4

Multiply self by a scaling vector scale. This is faster than creating a whole diagonal scaling matrix and then multiplying that. This operation is commutative.

Source

pub fn div_scalar(&self, rhs: f32) -> Mat4

Divides a 4x4 matrix by a scalar.

Source

pub fn recip(&self) -> Mat4

Returns a matrix containing the reciprocal 1.0/n of each element of self.

Source

pub fn abs_diff_eq(&self, rhs: Mat4, max_abs_diff: f32) -> bool

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.

Source

pub fn abs(&self) -> Mat4

Takes the absolute value of each element in self

Source

pub fn as_dmat4(&self) -> DMat4

Available on crate feature f64 only.
Examples found in repository?
examples/camera/pan_orbit_camera_custom_input_plugin.rs (line 219)
185    pub fn receive_messages(
186        mut events: MessageReader<Self>,
187        mut controllers: Query<(&mut PanOrbitCamera, &GlobalTransform)>,
188        mut camera_map: ResMut<CameraPointerMap>,
189        pointer_map: Res<PointerMap>,
190        pointer_interactions: Query<&PointerInteraction>,
191        pointer_locations: Query<&PointerLocation>,
192        cameras: Query<(&Camera, &Projection)>,
193        windows: Query<&Window>,
194    ) {
195        for event in events.read() {
196            let Ok((mut controller, cam_transform)) = controllers.get_mut(event.camera()) else {
197                continue;
198            };
199
200            match event {
201                PanOrbitCameraInputMessage::Start { kind, pointer, .. } => {
202                    if controller.is_actively_controlled() {
203                        continue;
204                    }
205                    let anchor = pointer_map
206                        .get_entity(*pointer)
207                        .and_then(|entity| pointer_interactions.get(entity).ok())
208                        .and_then(|interaction| interaction.get_nearest_hit())
209                        // Since `bevy` 0.17.3:
210                        //
211                        // If the current hit is on a window, we cannot use the `hit.position` as an anchor
212                        // as the `hit.position` is in viewport coordinates.
213                        .filter(|(entity, _hit)| !windows.contains(*entity))
214                        .and_then(|(_, hit)| hit.position)
215                        .map(|world_space_hit| {
216                            // Convert the world space hit to view (camera) space
217                            cam_transform
218                                .to_matrix()
219                                .as_dmat4()
220                                .inverse()
221                                .transform_point3(world_space_hit.into())
222                        })
223                        .filter(|p| {
224                            #[cfg(debug_assertions)]
225                            if !p.is_finite() {
226                                bevy::log::warn!(
227                                    "Non-finite input fed to camera controller: {p:?}"
228                                );
229                            }
230                            p.is_finite()
231                        })
232                        .or_else(|| {
233                            let camera = cameras.get(event.camera()).ok();
234                            let pointer_location = pointer_map
235                                .get_entity(*pointer)
236                                .and_then(|entity| pointer_locations.get(entity).ok())
237                                .and_then(|l| l.location());
238                            if let Some(((camera, proj), pointer_location)) =
239                                camera.zip(pointer_location)
240                            {
241                                screen_to_view_space(
242                                    camera,
243                                    proj,
244                                    &controller,
245                                    pointer_location.position,
246                                )
247                            } else {
248                                None
249                            }
250                        })
251                        .filter(|p| p.is_finite());
252
253                    match kind {
254                        MotionKind::OrbitZoom => controller.start_orbit(anchor),
255                        MotionKind::PanZoom => controller.start_pan(anchor),
256                        MotionKind::Zoom => controller.start_zoom(anchor),
257                    }
258                    camera_map.insert(*pointer, event.camera());
259                }
260                PanOrbitCameraInputMessage::End { .. } => {
261                    controller.end_move();
262                    if let Some(pointer) = camera_map
263                        .iter()
264                        .find(|(.., camera)| **camera == event.camera())
265                        .map(|(&pointer, ..)| pointer)
266                    {
267                        camera_map.remove(&pointer);
268                    }
269                }
270            }
271        }
272    }
273
274    /// While a camera motion is active, this system will take care of sending new pointer motion to
275    /// the camera controller. The camera controller assumes that pan and orbit movements are tied
276    /// to screen space pointer motion.
277    ///
278    /// This is because some of the pixel-perfect features of the controller require that data be
279    /// passed in as screen space deltas, to compute perfect first-order control. This is also
280    /// because the plugin uses pointer information to know which camera is being controlled.
281    ///
282    /// If you want to control the camera with different inputs, you will need to replace this
283    /// system with one that tracks other input methods, and sends the required zoom and screenspace
284    /// movement information.
285    pub fn send_pointer_inputs(
286        camera_map: Res<CameraPointerMap>,
287        mut camera_controllers: Query<&mut PanOrbitCamera>,
288        mut mouse_wheel: MessageReader<MouseWheel>,
289        mut moves: MessageReader<PointerInput>,
290    ) {
291        let moves_list: Vec<_> = moves.read().collect();
292        for (pointer, camera) in camera_map.iter() {
293            let Ok(mut camera_controller) = camera_controllers.get_mut(*camera) else {
294                continue;
295            };
296
297            let screenspace_input = moves_list
298                .iter()
299                .filter(|m| m.pointer_id.eq(pointer))
300                .filter_map(|m| match m.action {
301                    PointerAction::Move { delta } => Some(delta),
302                    _ => None,
303                })
304                .sum();
305
306            let zoom_amount = match pointer {
307                // TODO: add pinch zoom support
308                PointerId::Mouse => mouse_wheel
309                    .read()
310                    .map(|mw| {
311                        let scroll_multiplier = match mw.unit {
312                            MouseScrollUnit::Line => 150.0,
313                            MouseScrollUnit::Pixel => 1.0,
314                        };
315                        mw.y * scroll_multiplier
316                    })
317                    .sum::<f32>(),
318                _ => 0.0,
319            };
320
321            camera_controller.send_screenspace_input(screenspace_input);
322            camera_controller.send_zoom_input(zoom_amount);
323        }
324        // This must be cleared manually because reading these inputs is conditional - we are not
325        // guaranteed to be flushing the events every frame.
326        mouse_wheel.clear();
327    }
328}
329
330fn screen_to_view_space(
331    camera: &Camera,
332    proj: &Projection,
333    controller: &PanOrbitCamera,
334    target_position: Vec2,
335) -> Option<DVec3> {
336    let mut viewport_position = if let Some(rect) = camera.logical_viewport_rect() {
337        target_position.as_dvec2() - rect.min.as_dvec2()
338    } else {
339        target_position.as_dvec2()
340    };
341    let target_size = camera.logical_viewport_size()?.as_dvec2();
342    // Flip the Y co-ordinate origin from the top to the bottom.
343    viewport_position.y = target_size.y - viewport_position.y;
344    let ndc = viewport_position * 2. / target_size - DVec2::ONE;
345    let ndc_to_view = proj.get_clip_from_view().as_dmat4().inverse();
346    let view_near_plane = ndc_to_view.project_point3(ndc.extend(1.));
347    match &proj {
348        Projection::Perspective(_) | Projection::Custom(_) => {
349            // Using EPSILON because an NDC with Z = 0 returns NaNs.
350            let view_far_plane = ndc_to_view.project_point3(ndc.extend(f64::EPSILON));
351            let direction = (view_far_plane - view_near_plane).normalize();
352            Some((direction / direction.z) * controller.last_anchor_depth())
353        }
354        Projection::Orthographic(_) => Some(DVec3::new(
355            view_near_plane.x,
356            view_near_plane.y,
357            controller.last_anchor_depth(),
358        )),
359    }
360}

Trait Implementations§

Source§

impl AbsDiffEq for Mat4

Source§

type Epsilon = <f32 as AbsDiffEq>::Epsilon

Used for specifying relative comparisons.
Source§

fn default_epsilon() -> <Mat4 as AbsDiffEq>::Epsilon

The default tolerance to use when testing values that are close together. Read more
Source§

fn abs_diff_eq( &self, other: &Mat4, epsilon: <Mat4 as AbsDiffEq>::Epsilon, ) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
Source§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of AbsDiffEq::abs_diff_eq.
Source§

impl Add for Mat4

Source§

type Output = Mat4

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Mat4) -> Mat4

Performs the + operation. Read more
Source§

impl Add<&Mat4> for Mat4

Source§

type Output = Mat4

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Mat4) -> Mat4

Performs the + operation. Read more
Source§

impl Add<&Mat4> for &Mat4

Source§

type Output = Mat4

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Mat4) -> Mat4

Performs the + operation. Read more
Source§

impl Add<Mat4> for &Mat4

Source§

type Output = Mat4

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Mat4) -> Mat4

Performs the + operation. Read more
Source§

impl AddAssign for Mat4

Source§

fn add_assign(&mut self, rhs: Mat4)

Performs the += operation. Read more
Source§

impl AddAssign<&Mat4> for Mat4

Source§

fn add_assign(&mut self, rhs: &Mat4)

Performs the += operation. Read more
Source§

impl AsMut<[f32; 16]> for Mat4

Source§

fn as_mut(&mut self) -> &mut [f32; 16]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsMutMatrixParts<f32, 4, 4> for Mat4

Source§

fn as_mut_parts(&mut self) -> &mut [[f32; 4]; 4]

Source§

impl AsRef<[f32; 16]> for Mat4

Source§

fn as_ref(&self) -> &[f32; 16]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRefMatrixParts<f32, 4, 4> for Mat4

Source§

fn as_ref_parts(&self) -> &[[f32; 4]; 4]

Source§

impl Clone for Mat4

Source§

fn clone(&self) -> Mat4

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Mat4

Source§

impl CreateFrom for Mat4
where Mat4: ShaderType<ExtraMetadata = MatrixMetadata> + FromMatrixParts<f32, 4, 4>, f32: MatrixScalar + CreateFrom,

Source§

fn create_from<B>(reader: &mut Reader<B>) -> Mat4
where B: BufferRef,

Source§

impl Debug for Mat4

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Mat4

Source§

fn default() -> Mat4

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Mat4

Deserialize expects a sequence of 16 values.

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Mat4, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Mat4

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Div<&f32> for Mat4

Source§

type Output = Mat4

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &f32) -> Mat4

Performs the / operation. Read more
Source§

impl Div<&f32> for &Mat4

Source§

type Output = Mat4

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &f32) -> Mat4

Performs the / operation. Read more
Source§

impl Div<f32> for Mat4

Source§

type Output = Mat4

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f32) -> Mat4

Performs the / operation. Read more
Source§

impl Div<f32> for &Mat4

Source§

type Output = Mat4

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f32) -> Mat4

Performs the / operation. Read more
Source§

impl DivAssign<&f32> for Mat4

Source§

fn div_assign(&mut self, rhs: &f32)

Performs the /= operation. Read more
Source§

impl DivAssign<f32> for Mat4

Source§

fn div_assign(&mut self, rhs: f32)

Performs the /= operation. Read more
Source§

impl From<Affine3> for Mat4

Source§

fn from(m: Affine3) -> Mat4

Converts to this type from the input type.
Source§

impl From<Affine3A> for Mat4

Source§

fn from(m: Affine3A) -> Mat4

Converts to this type from the input type.
Source§

impl From<Mat4> for GlobalTransform

Source§

fn from(world_from_local: Mat4) -> GlobalTransform

Converts to this type from the input type.
Source§

impl FromArg for Mat4

Source§

type This<'from_arg> = Mat4

The type to convert into. Read more
Source§

fn from_arg(arg: Arg<'_>) -> Result<<Mat4 as FromArg>::This<'_>, ArgError>

Creates an item from an argument. Read more
Source§

impl FromMatrixParts<f32, 4, 4> for Mat4

Source§

fn from_parts(parts: [[f32; 4]; 4]) -> Mat4

Source§

impl FromReflect for Mat4

Source§

fn from_reflect(reflect: &(dyn PartialReflect + 'static)) -> Option<Mat4>

Constructs a concrete instance of Self from a reflected value.
Source§

fn take_from_reflect( reflect: Box<dyn PartialReflect>, ) -> Result<Self, Box<dyn PartialReflect>>

Attempts to downcast the given value to Self using, constructing the value using from_reflect if that fails. Read more
Source§

impl GetOwnership for Mat4

Source§

fn ownership() -> Ownership

Returns the ownership of Self.
Source§

impl GetTypeRegistration for Mat4

Source§

fn get_type_registration() -> TypeRegistration

Returns the default TypeRegistration for this type.
Source§

fn register_type_dependencies(registry: &mut TypeRegistry)

Registers other types needed by this type. Read more
Source§

impl IntoReturn for Mat4

Source§

fn into_return<'into_return>(self) -> Return<'into_return>
where Mat4: 'into_return,

Converts Self into a Return value.
Source§

impl Mul for Mat4

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Mat4) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<&Affine3> for Mat4

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Affine3) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<&Affine3> for &Mat4

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Affine3) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<&Affine3A> for Mat4

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Affine3A) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<&Affine3A> for &Mat4

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Affine3A) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<&Mat4> for Affine3

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Mat4) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<&Mat4> for &Affine3

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Mat4) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<&Mat4> for Affine3A

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Mat4) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<&Mat4> for &Affine3A

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Mat4) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<&Mat4> for Mat4

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Mat4) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<&Mat4> for &Mat4

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Mat4) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<&Vec4> for Mat4

Source§

type Output = Vec4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Vec4) -> Vec4

Performs the * operation. Read more
Source§

impl Mul<&Vec4> for &Mat4

Source§

type Output = Vec4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Vec4) -> Vec4

Performs the * operation. Read more
Source§

impl Mul<&f32> for Mat4

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &f32) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<&f32> for &Mat4

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &f32) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<Affine3> for Mat4

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Affine3) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<Affine3> for &Mat4

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Affine3) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<Affine3A> for Mat4

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Affine3A) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<Affine3A> for &Mat4

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Affine3A) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<Mat4> for Affine3

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Mat4) -> <Affine3 as Mul<Mat4>>::Output

Performs the * operation. Read more
Source§

impl Mul<Mat4> for &Affine3

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Mat4) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<Mat4> for Affine3A

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Mat4) -> <Affine3A as Mul<Mat4>>::Output

Performs the * operation. Read more
Source§

impl Mul<Mat4> for &Affine3A

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Mat4) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<Mat4> for &Mat4

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Mat4) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<Vec4> for Mat4

Source§

type Output = Vec4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec4) -> <Mat4 as Mul<Vec4>>::Output

Performs the * operation. Read more
Source§

impl Mul<Vec4> for &Mat4

Source§

type Output = Vec4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec4) -> Vec4

Performs the * operation. Read more
Source§

impl Mul<f32> for Mat4

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f32) -> Mat4

Performs the * operation. Read more
Source§

impl Mul<f32> for &Mat4

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f32) -> Mat4

Performs the * operation. Read more
Source§

impl MulAssign for Mat4

Source§

fn mul_assign(&mut self, rhs: Mat4)

Performs the *= operation. Read more
Source§

impl MulAssign<&Affine3> for Mat4

Source§

fn mul_assign(&mut self, rhs: &Affine3)

Performs the *= operation. Read more
Source§

impl MulAssign<&Affine3A> for Mat4

Source§

fn mul_assign(&mut self, rhs: &Affine3A)

Performs the *= operation. Read more
Source§

impl MulAssign<&Mat4> for Mat4

Source§

fn mul_assign(&mut self, rhs: &Mat4)

Performs the *= operation. Read more
Source§

impl MulAssign<&f32> for Mat4

Source§

fn mul_assign(&mut self, rhs: &f32)

Performs the *= operation. Read more
Source§

impl MulAssign<Affine3> for Mat4

Source§

fn mul_assign(&mut self, rhs: Affine3)

Performs the *= operation. Read more
Source§

impl MulAssign<Affine3A> for Mat4

Source§

fn mul_assign(&mut self, rhs: Affine3A)

Performs the *= operation. Read more
Source§

impl MulAssign<f32> for Mat4

Source§

fn mul_assign(&mut self, rhs: f32)

Performs the *= operation. Read more
Source§

impl Neg for Mat4

Source§

type Output = Mat4

The resulting type after applying the - operator.
Source§

fn neg(self) -> <Mat4 as Neg>::Output

Performs the unary - operation. Read more
Source§

impl Neg for &Mat4

Source§

type Output = Mat4

The resulting type after applying the - operator.
Source§

fn neg(self) -> Mat4

Performs the unary - operation. Read more
Source§

impl PartialEq for Mat4

Source§

fn eq(&self, rhs: &Mat4) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialReflect for Mat4

Source§

fn get_represented_type_info(&self) -> Option<&'static TypeInfo>

Returns the TypeInfo of the type represented by this value. Read more
Source§

fn try_apply( &mut self, value: &(dyn PartialReflect + 'static), ) -> Result<(), ApplyError>

Tries to apply a reflected value to this value. Read more
Source§

fn reflect_kind(&self) -> ReflectKind

Returns a zero-sized enumeration of “kinds” of type. Read more
Source§

fn reflect_ref(&self) -> ReflectRef<'_>

Returns an immutable enumeration of “kinds” of type. Read more
Source§

fn reflect_mut(&mut self) -> ReflectMut<'_>

Returns a mutable enumeration of “kinds” of type. Read more
Source§

fn reflect_owned(self: Box<Mat4>) -> ReflectOwned

Returns an owned enumeration of “kinds” of type. Read more
Source§

fn try_into_reflect( self: Box<Mat4>, ) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>

Attempts to cast this type to a boxed, fully-reflected value.
Source§

fn try_as_reflect(&self) -> Option<&(dyn Reflect + 'static)>

Attempts to cast this type to a fully-reflected value.
Source§

fn try_as_reflect_mut(&mut self) -> Option<&mut (dyn Reflect + 'static)>

Attempts to cast this type to a mutable, fully-reflected value.
Source§

fn into_partial_reflect(self: Box<Mat4>) -> Box<dyn PartialReflect>

Casts this type to a boxed, reflected value. Read more
Source§

fn as_partial_reflect(&self) -> &(dyn PartialReflect + 'static)

Casts this type to a reflected value. Read more
Source§

fn as_partial_reflect_mut(&mut self) -> &mut (dyn PartialReflect + 'static)

Casts this type to a mutable, reflected value. Read more
Source§

fn reflect_partial_eq( &self, value: &(dyn PartialReflect + 'static), ) -> Option<bool>

Returns a “partial equality” comparison result. Read more
Source§

fn reflect_partial_cmp( &self, value: &(dyn PartialReflect + 'static), ) -> Option<Ordering>

Returns a “partial comparison” result. Read more
Source§

fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Debug formatter for the value. Read more
Source§

fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>

Attempts to clone Self using reflection. Read more
Source§

fn apply(&mut self, value: &(dyn PartialReflect + 'static))

Applies a reflected value to this value. Read more
Source§

fn to_dynamic(&self) -> Result<Box<dyn PartialReflect>, ReflectCloneError>

Converts this reflected value into its dynamic representation based on its kind. Read more
Source§

fn reflect_clone_and_take<T>(&self) -> Result<T, ReflectCloneError>
where T: 'static, Self: Sized + TypePath,

For a type implementing PartialReflect, combines reflect_clone and take in a useful fashion, automatically constructing an appropriate ReflectCloneError if the downcast fails.
Source§

fn reflect_hash(&self) -> Option<u64>

Returns a hash of the value (which includes the type). Read more
Source§

fn is_dynamic(&self) -> bool

Indicates whether or not this type is a dynamic type. Read more
Source§

impl Pod for Mat4

Source§

impl Product for Mat4

Source§

fn product<I>(iter: I) -> Mat4
where I: Iterator<Item = Mat4>,

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl<'a> Product<&'a Mat4> for Mat4

Source§

fn product<I>(iter: I) -> Mat4
where I: Iterator<Item = &'a Mat4>,

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl ReadFrom for Mat4
where Mat4: ShaderType<ExtraMetadata = MatrixMetadata> + AsMutMatrixParts<f32, 4, 4>, f32: MatrixScalar + ReadFrom,

Source§

fn read_from<B>(&mut self, reader: &mut Reader<B>)
where B: BufferRef,

Source§

impl Reflect for Mat4

Source§

fn into_any(self: Box<Mat4>) -> Box<dyn Any>

Returns the value as a Box<dyn Any>. Read more
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Returns the value as a &dyn Any. Read more
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Returns the value as a &mut dyn Any. Read more
Source§

fn into_reflect(self: Box<Mat4>) -> Box<dyn Reflect>

Casts this type to a boxed, fully-reflected value.
Source§

fn as_reflect(&self) -> &(dyn Reflect + 'static)

Casts this type to a fully-reflected value.
Source§

fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)

Casts this type to a mutable, fully-reflected value.
Source§

fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>

Performs a type-checked assignment of a reflected value to this value. Read more
Source§

impl RelativeEq for Mat4

Source§

fn default_max_relative() -> <Mat4 as AbsDiffEq>::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
Source§

fn relative_eq( &self, other: &Mat4, epsilon: <Mat4 as AbsDiffEq>::Epsilon, max_relative: <Mat4 as AbsDiffEq>::Epsilon, ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
Source§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

The inverse of RelativeEq::relative_eq.
Source§

impl Serialize for Mat4

Serialize as a sequence of 16 values.

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl ShaderSize for Mat4
where f32: ShaderSize,

Source§

const SHADER_SIZE: NonZero<u64> = _

Represents WGSL Size (equivalent to ShaderType::min_size)
Source§

impl ShaderType for Mat4
where f32: ShaderSize,

Source§

fn min_size() -> NonZero<u64>

Represents the minimum size of Self (equivalent to GPUBufferBindingLayout.minBindingSize) Read more
Source§

fn size(&self) -> NonZero<u64>

Returns the size of Self at runtime Read more
Source§

fn assert_uniform_compat()

Source§

impl Struct for Mat4

Source§

fn field(&self, name: &str) -> Option<&(dyn PartialReflect + 'static)>

Gets a reference to the value of the field named name as a &dyn PartialReflect.
Source§

fn field_mut( &mut self, name: &str, ) -> Option<&mut (dyn PartialReflect + 'static)>

Gets a mutable reference to the value of the field named name as a &mut dyn PartialReflect.
Source§

fn field_at(&self, index: usize) -> Option<&(dyn PartialReflect + 'static)>

Gets a reference to the value of the field with index index as a &dyn PartialReflect.
Source§

fn field_at_mut( &mut self, index: usize, ) -> Option<&mut (dyn PartialReflect + 'static)>

Gets a mutable reference to the value of the field with index index as a &mut dyn PartialReflect.
Source§

fn name_at(&self, index: usize) -> Option<&str>

Gets the name of the field with index index.
Source§

fn index_of_name(&self, name: &str) -> Option<usize>

Gets the index of the field with the given name.
Source§

fn field_len(&self) -> usize

Returns the number of fields in the struct.
Source§

fn iter_fields(&self) -> FieldIter<'_> ⓘ

Returns an iterator over the values of the reflectable fields for this struct.
Source§

fn to_dynamic_struct(&self) -> Result<DynamicStruct, ReflectCloneError>

Creates a new DynamicStruct from this struct. Read more
Source§

fn get_represented_struct_info(&self) -> Option<&'static StructInfo>

Will return None if TypeInfo is not available.
Source§

impl Sub for Mat4

Source§

type Output = Mat4

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Mat4) -> Mat4

Performs the - operation. Read more
Source§

impl Sub<&Mat4> for Mat4

Source§

type Output = Mat4

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Mat4) -> Mat4

Performs the - operation. Read more
Source§

impl Sub<&Mat4> for &Mat4

Source§

type Output = Mat4

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Mat4) -> Mat4

Performs the - operation. Read more
Source§

impl Sub<Mat4> for &Mat4

Source§

type Output = Mat4

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Mat4) -> Mat4

Performs the - operation. Read more
Source§

impl SubAssign for Mat4

Source§

fn sub_assign(&mut self, rhs: Mat4)

Performs the -= operation. Read more
Source§

impl SubAssign<&Mat4> for Mat4

Source§

fn sub_assign(&mut self, rhs: &Mat4)

Performs the -= operation. Read more
Source§

impl Sum for Mat4

Source§

fn sum<I>(iter: I) -> Mat4
where I: Iterator<Item = Mat4>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<'a> Sum<&'a Mat4> for Mat4

Source§

fn sum<I>(iter: I) -> Mat4
where I: Iterator<Item = &'a Mat4>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl TransformPoint for Mat4

Source§

fn transform_point(&self, point: impl Into<Vec3>) -> Vec3

Transform a point.
Source§

impl TypePath for Mat4

Source§

fn type_path() -> &'static str

Returns the fully qualified path of the underlying type. Read more
Source§

fn short_type_path() -> &'static str

Returns a short, pretty-print enabled path to the type. Read more
Source§

fn type_ident() -> Option<&'static str>

Returns the name of the type, or None if it is anonymous. Read more
Source§

fn crate_name() -> Option<&'static str>

Returns the name of the crate the type is in, or None if it is anonymous. Read more
Source§

fn module_path() -> Option<&'static str>

Returns the path to the module the type is in, or None if it is anonymous. Read more
Source§

impl Typed for Mat4

Source§

fn type_info() -> &'static TypeInfo

Returns the compile-time info for the underlying type.
Source§

impl UlpsEq for Mat4

Source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
Source§

fn ulps_eq( &self, other: &Mat4, epsilon: <Mat4 as AbsDiffEq>::Epsilon, max_ulps: u32, ) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
Source§

fn ulps_ne(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of UlpsEq::ulps_eq.
Source§

impl WriteInto for Mat4
where Mat4: ShaderType<ExtraMetadata = MatrixMetadata> + AsRefMatrixParts<f32, 4, 4>, f32: MatrixScalar + WriteInto,

Source§

fn write_into<B>(&self, writer: &mut Writer<B>)
where B: BufferMut,

Source§

impl Zeroable for Mat4

Source§

fn zeroed() -> Self

Auto Trait Implementations§

§

impl Freeze for Mat4

§

impl RefUnwindSafe for Mat4

§

impl Send for Mat4

§

impl Sync for Mat4

§

impl Unpin for Mat4

§

impl UnsafeUnpin for Mat4

§

impl UnwindSafe for Mat4

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnyBitPattern for T
where T: Pod,

Source§

impl<T, U> AsBindGroupShaderType<U> for T
where U: ShaderType, &'a T: for<'a> Into<U>,

Source§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Brush for T
where T: Clone + PartialEq + Default + Debug,

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> DynamicTypePath for T
where T: TypePath,

Source§

impl<T> DynamicTyped for T
where T: Typed,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> FromTemplate for T
where T: Clone + Default + Unpin,

Source§

type Template = T

The Template for this type.
Source§

impl<T> FromWorld for T
where T: Default,

Source§

fn from_world(_world: &mut World) -> T

Creates Self using default().

Source§

impl<S> GetField for S
where S: Struct,

Source§

fn get_field<T>(&self, name: &str) -> Option<&T>
where T: Reflect,

Gets a reference to the value of the field named name, downcast to T.
Source§

fn get_field_mut<T>(&mut self, name: &str) -> Option<&mut T>
where T: Reflect,

Gets a mutable reference to the value of the field named name, downcast to T.
Source§

impl<T> GetPath for T
where T: Reflect + ?Sized,

Source§

fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>

Returns a reference to the value specified by path. Read more
Source§

fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>

Returns a mutable reference to the value specified by path. Read more
Source§

fn path<'p, T>( &self, path: impl ReflectPath<'p>, ) -> Result<&T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed reference to the value specified by path. Read more
Source§

fn path_mut<'p, T>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed mutable reference to the value specified by path. Read more
Source§

impl<T> GpuArrayBufferable for T

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> HitDataExtra for T
where T: Send + Sync + Debug + Any + 'static,

Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T> InitializeFromFunction<T> for T

Source§

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Interleave for T
where T: Pod,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<T> NoUninit for T
where T: Pod,

Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<G> PatchFromTemplate for G
where G: FromTemplate,

Source§

type Template = <G as FromTemplate>::Template

The Template that will be patched.
Source§

fn patch<F>(func: F) -> TemplatePatch<F, <G as PatchFromTemplate>::Template>
where F: FnOnce(&mut <G as PatchFromTemplate>::Template, &mut ResolveContext<'_>),

Takes a “patch function” func, and turns it into a TemplatePatch.
Source§

impl<T> PatchTemplate for T
where T: Template,

Source§

fn patch_template<F>(func: F) -> TemplatePatch<F, T>
where F: FnOnce(&mut T, &mut ResolveContext<'_>),

Takes a “patch function” func that patches this Template, and turns it into a TemplatePatch.
Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Reflectable for T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T> Settings for T
where T: 'static + Send + Sync,

Source§

impl<Ret> SpawnIfAsync<(), Ret> for Ret

Source§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
Source§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

Source§

fn super_from(input: T) -> O

Convert from a type to another type.
Source§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

Source§

fn super_into(self) -> O

Convert from a type to another type.
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> Template for T
where T: Clone + Unpin,

Source§

type Output = T

The type of value produced by this Template.
Source§

fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>

Uses this template and the given entity context to produce a Template::Output.
Source§

fn clone_template(&self) -> T

Clones this template. See Clone.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> TypeData for T
where T: 'static + Send + Sync + Clone,

Source§

fn clone_type_data(&self) -> Box<dyn TypeData>

Creates a type-erased clone of self.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more