Trait bevy_hanabi::ToWgslString

source ·
pub trait ToWgslString {
    // Required method
    fn to_wgsl_string(&self) -> String;
}
Expand description

Extension trait to convert an object to WGSL code.

This is mainly used for floating-point constants. This is required because WGSL doesn’t support a floating point constant without a decimal separator (e.g. 0. instead of 0), which would be what a regular string formatting function like format!() would produce, but which is interpreted as an integral type by WGSL instead.

§Example

let x = 2.0_f32;
assert_eq!("let x = 2.;", format!("let x = {};", x.to_wgsl_string()));

§Remark

This trait is soft-deprecated. It serves the same purpose as EvalContext::eval(), however it lacks any context for the evaluation of an expression producing WGSL code, so its use is limited. It’s still useful for constant (literal) expressions, which do not require any context to evaluate.

Required Methods§

source

fn to_wgsl_string(&self) -> String

Convert an object to a string representing its WGSL code.

Implementations on Foreign Types§

source§

impl ToWgslString for bool

source§

impl ToWgslString for f32

source§

impl ToWgslString for f64

source§

impl ToWgslString for i32

source§

impl ToWgslString for u32

source§

impl ToWgslString for BVec2

source§

impl ToWgslString for BVec3

source§

impl ToWgslString for BVec4

source§

impl ToWgslString for Vec4

source§

impl ToWgslString for Vec2

source§

impl ToWgslString for Vec3

source§

impl ToWgslString for IVec2

source§

impl ToWgslString for IVec3

source§

impl ToWgslString for IVec4

source§

impl ToWgslString for UVec2

source§

impl ToWgslString for UVec3

source§

impl ToWgslString for UVec4

Implementors§