savoiardi/texture
Texture loading and texture configuration.
The public API covers both regular textures and cube textures together with the most common color-space, mapping, wrapping, and filtering controls.
Types
Output color spaces supported by the texture API.
pub type ColorSpace {
SRGB
LinearSRGB
}
Constructors
-
SRGB -
LinearSRGB
A cube texture.
pub type CubeTexture
Magnification filters.
pub type MagnificationFilter {
Nearest
Linear
}
Constructors
-
Nearest -
Linear
Texture coordinate mappings supported by the texture API.
pub type Mapping {
UV
CubeReflection
CubeRefraction
EquirectangularReflection
EquirectangularRefraction
}
Constructors
-
UV -
CubeReflection -
CubeRefraction -
EquirectangularReflection -
EquirectangularRefraction
Minification filters.
pub type MinificationFilter {
NearestMinification
NearestMipmapNearest
NearestMipmapLinear
LinearMinification
LinearMipmapNearest
LinearMipmapLinear
}
Constructors
-
NearestMinification -
NearestMipmapNearest -
NearestMipmapLinear -
LinearMinification -
LinearMipmapNearest -
LinearMipmapLinear
Values
pub fn color_space_to_string(space: ColorSpace) -> String
Converts a color space to the underlying Three.js constant.
pub fn load(
loader: loader.TextureLoader,
url: String,
on_result: fn(Result(Texture, loader.LoadError)) -> Nil,
) -> Nil
Loads a texture and reports the result through a callback.
pub fn load_async(
loader: loader.TextureLoader,
url: String,
) -> promise.Promise(Result(Texture, loader.LoadError))
Loads a texture asynchronously.
pub fn load_cube(
loader: loader.CubeTextureLoader,
urls: List(String),
on_result: fn(Result(CubeTexture, loader.LoadError)) -> Nil,
) -> Nil
Loads a cube texture from six URLs and reports the result through a callback.
pub fn load_cube_async(
loader: loader.CubeTextureLoader,
urls: List(String),
) -> promise.Promise(Result(CubeTexture, loader.LoadError))
Loads a cube texture from six URLs asynchronously.
pub fn load_equirectangular(
loader: loader.TextureLoader,
url: String,
on_result: fn(Result(Texture, loader.LoadError)) -> Nil,
) -> Nil
Loads an equirectangular texture and reports the result through a callback.
pub fn load_equirectangular_async(
loader: loader.TextureLoader,
url: String,
) -> promise.Promise(Result(Texture, loader.LoadError))
Loads an equirectangular texture asynchronously.
pub fn set_anisotropy(
texture: Texture,
anisotropy: Int,
) -> Texture
Sets the anisotropy level of a texture.
pub fn set_center(
texture: Texture,
center: vec2.Vec2(Float),
) -> Texture
Sets the UV center of a texture.
pub fn set_color_space(
texture: Texture,
color_space: ColorSpace,
) -> Texture
Sets the color space of a texture.
pub fn set_cube_mapping(
cube_texture: CubeTexture,
mapping: Mapping,
) -> CubeTexture
Sets the mapping mode of a cube texture.
pub fn set_flip_y(texture: Texture, flip_y: Bool) -> Texture
Enables or disables vertical flipping when uploading a texture.
pub fn set_generate_mipmaps(
texture: Texture,
generate_mipmaps: Bool,
) -> Texture
Enables or disables mipmap generation.
pub fn set_mag_filter(
texture: Texture,
filter: MagnificationFilter,
) -> Texture
Sets the magnification filter of a texture.
pub fn set_mapping(texture: Texture, mapping: Mapping) -> Texture
Sets the mapping mode of a texture.
pub fn set_min_filter(
texture: Texture,
filter: MinificationFilter,
) -> Texture
Sets the minification filter of a texture.
pub fn set_needs_update(
texture: Texture,
needs_update: Bool,
) -> Texture
Marks a texture as needing an update.
pub fn set_offset(
texture: Texture,
offset: vec2.Vec2(Float),
) -> Texture
Sets the offset vector of a texture.
pub fn set_repeat(
texture: Texture,
repeat: vec2.Vec2(Float),
) -> Texture
Sets the repeat vector of a texture.
pub fn set_rotation(texture: Texture, rotation: Float) -> Texture
Sets the UV rotation of a texture.
pub fn set_wrap(
texture: Texture,
wrap_s: Wrapping,
wrap_t: Wrapping,
) -> Texture
Sets both wrapping modes of a texture.
pub fn set_wrap_s(
texture: Texture,
wrapping: Wrapping,
) -> Texture
Sets the horizontal wrapping mode of a texture.