savoiardi/material

Material constructors and material property updates.

The module exposes option records for common Three.js material families and a shared set of mutating helpers for runtime updates.

Types

Options for creating a basic material.

pub type BasicOptions {
  BasicOptions(
    color: Int,
    transparent: Bool,
    opacity: Float,
    color_map: option.Option(texture.Texture),
    side: MaterialSide,
    alpha_test: Float,
    depth_write: Bool,
  )
}

Constructors

Options for creating a lambert material.

pub type LambertOptions {
  LambertOptions(
    color: Int,
    color_map: option.Option(texture.Texture),
    normal_map: option.Option(texture.Texture),
    ambient_occlusion_map: option.Option(texture.Texture),
    transparent: Bool,
    opacity: Float,
    alpha_test: Float,
  )
}

Constructors

Options for creating a basic line material.

pub type LineBasicOptions {
  LineBasicOptions(
    color: Int,
    transparent: Bool,
    opacity: Float,
    alpha_test: Float,
    depth_write: Bool,
    linewidth: Float,
  )
}

Constructors

  • LineBasicOptions(
      color: Int,
      transparent: Bool,
      opacity: Float,
      alpha_test: Float,
      depth_write: Bool,
      linewidth: Float,
    )

Options for creating a matcap material.

pub type MatcapOptions {
  MatcapOptions(
    color: Int,
    matcap: option.Option(texture.Texture),
    transparent: Bool,
    opacity: Float,
    flat_shading: Bool,
    side: MaterialSide,
  )
}

Constructors

A render material.

pub type Material

The face sides a material can render.

pub type MaterialSide {
  FrontSide
  BackSide
  DoubleSide
}

Constructors

  • FrontSide
  • BackSide
  • DoubleSide

Options for creating a normal material.

pub type NormalOptions {
  NormalOptions(
    transparent: Bool,
    opacity: Float,
    wireframe: Bool,
    flat_shading: Bool,
    side: MaterialSide,
  )
}

Constructors

  • NormalOptions(
      transparent: Bool,
      opacity: Float,
      wireframe: Bool,
      flat_shading: Bool,
      side: MaterialSide,
    )

Options for creating a phong material.

pub type PhongOptions {
  PhongOptions(
    color: Int,
    shininess: Float,
    color_map: option.Option(texture.Texture),
    normal_map: option.Option(texture.Texture),
    ambient_occlusion_map: option.Option(texture.Texture),
    transparent: Bool,
    opacity: Float,
    alpha_test: Float,
  )
}

Constructors

Options for creating a physical material.

pub type PhysicalOptions {
  PhysicalOptions(
    color: Int,
    metalness: Float,
    roughness: Float,
    transparent: Bool,
    opacity: Float,
    color_map: option.Option(texture.Texture),
    normal_map: option.Option(texture.Texture),
    ambient_occlusion_map: option.Option(texture.Texture),
    displacement_map: option.Option(texture.Texture),
    displacement_scale: Float,
    displacement_bias: Float,
    roughness_map: option.Option(texture.Texture),
    metalness_map: option.Option(texture.Texture),
    emissive: Int,
    emissive_intensity: Float,
    alpha_test: Float,
    clearcoat: Float,
    clearcoat_roughness: Float,
    transmission: Float,
    thickness: Float,
    ior: Float,
  )
}

Constructors

Options for creating a shadow material.

pub type ShadowOptions {
  ShadowOptions(color: Int, transparent: Bool, opacity: Float)
}

Constructors

  • ShadowOptions(color: Int, transparent: Bool, opacity: Float)

Options for creating a sprite material.

The sprite-specific properties match THREE.SpriteMaterial directly. The shared material controls (transparent, opacity, alpha_test, depth_test, and depth_write) come from the base THREE.Material API.

pub type SpriteOptions {
  SpriteOptions(
    color: Int,
    transparent: Bool,
    opacity: Float,
    map: option.Option(texture.Texture),
    alpha_map: option.Option(texture.Texture),
    alpha_test: Float,
    rotation: Float,
    size_attenuation: Bool,
    fog: Bool,
    depth_test: Bool,
    depth_write: Bool,
  )
}

Constructors

Options for creating a standard material.

pub type StandardOptions {
  StandardOptions(
    color: Int,
    metalness: Float,
    roughness: Float,
    transparent: Bool,
    opacity: Float,
    color_map: option.Option(texture.Texture),
    normal_map: option.Option(texture.Texture),
    ambient_occlusion_map: option.Option(texture.Texture),
    displacement_map: option.Option(texture.Texture),
    displacement_scale: Float,
    displacement_bias: Float,
    roughness_map: option.Option(texture.Texture),
    metalness_map: option.Option(texture.Texture),
    emissive: Int,
    emissive_intensity: Float,
    alpha_test: Float,
  )
}

Constructors

Options for creating a toon material.

pub type ToonOptions {
  ToonOptions(
    color: Int,
    color_map: option.Option(texture.Texture),
    normal_map: option.Option(texture.Texture),
    ambient_occlusion_map: option.Option(texture.Texture),
    transparent: Bool,
    opacity: Float,
    alpha_test: Float,
  )
}

Constructors

Values

pub fn basic(options: BasicOptions) -> Material

Creates a basic material.

pub fn basic_options() -> BasicOptions

Returns default options for a basic material.

pub fn clear_alpha_map(material: Material) -> Material

Clears the alpha map of a material.

pub fn clear_color_map(material: Material) -> Material

Clears the base color map of a material.

pub fn clear_map(material: Material) -> Material

Clears the material map.

pub fn dispose(material: Material) -> Nil

Disposes a material.

pub fn lambert(options: LambertOptions) -> Material

Creates a lambert material.

pub fn lambert_options() -> LambertOptions

Returns default options for a lambert material.

pub fn line_basic(options: LineBasicOptions) -> Material

Creates a line basic material.

pub fn line_basic_options() -> LineBasicOptions

Returns default options for a line basic material.

pub fn matcap(options: MatcapOptions) -> Material

Creates a matcap material.

pub fn matcap_options() -> MatcapOptions

Returns default options for a matcap material.

pub fn normal(options: NormalOptions) -> Material

Creates a normal material.

pub fn normal_options() -> NormalOptions

Returns default options for a normal material.

pub fn phong(options: PhongOptions) -> Material

Creates a phong material.

pub fn phong_options() -> PhongOptions

Returns default options for a phong material.

pub fn physical(options: PhysicalOptions) -> Material

Creates a physical material.

pub fn physical_options() -> PhysicalOptions

Returns default options for a physical material.

pub fn set_alpha_map(
  material: Material,
  alpha_map: texture.Texture,
) -> Material

Sets the alpha map of a material.

pub fn set_alpha_test(
  material: Material,
  alpha_test: Float,
) -> Material

Sets the alpha test threshold of a material.

pub fn set_ambient_occlusion_map(
  material: Material,
  ambient_occlusion_map: texture.Texture,
) -> Material

Sets the ambient occlusion map of a material.

pub fn set_ambient_occlusion_map_intensity(
  material: Material,
  ambient_occlusion_map_intensity: Float,
) -> Material

Sets the ambient occlusion map intensity.

pub fn set_clearcoat(
  material: Material,
  clearcoat: Float,
) -> Material

Sets the clearcoat amount of a material.

pub fn set_clearcoat_roughness(
  material: Material,
  clearcoat_roughness: Float,
) -> Material

Sets the clearcoat roughness of a material.

pub fn set_color(material: Material, color: Int) -> Material

Sets the base color of a material.

pub fn set_color_map(
  material: Material,
  color_map: texture.Texture,
) -> Material

Sets the base color map of a material.

pub fn set_depth_test(
  material: Material,
  depth_test: Bool,
) -> Material

Enables or disables depth testing.

pub fn set_depth_write(
  material: Material,
  depth_write: Bool,
) -> Material

Enables or disables depth writing.

pub fn set_displacement_bias(
  material: Material,
  displacement_bias: Float,
) -> Material

Sets the displacement bias of a material.

pub fn set_displacement_map(
  material: Material,
  displacement_map: texture.Texture,
) -> Material

Sets the displacement map of a material.

pub fn set_displacement_scale(
  material: Material,
  displacement_scale: Float,
) -> Material

Sets the displacement scale of a material.

pub fn set_emissive(
  material: Material,
  emissive: Int,
) -> Material

Sets the emissive color of a material.

pub fn set_emissive_intensity(
  material: Material,
  emissive_intensity: Float,
) -> Material

Sets the emissive intensity of a material.

pub fn set_emissive_map(
  material: Material,
  emissive_map: texture.Texture,
) -> Material

Sets the emissive map of a material.

pub fn set_env_map(
  material: Material,
  env_map: texture.Texture,
) -> Material

Sets the environment map of a material.

pub fn set_flat_shading(
  material: Material,
  flat_shading: Bool,
) -> Material

Enables or disables flat shading.

pub fn set_fog(material: Material, fog: Bool) -> Material

Enables or disables scene fog for a material.

pub fn set_ior(material: Material, ior: Float) -> Material

Sets the index of refraction of a material.

pub fn set_line_width(
  material: Material,
  linewidth: Float,
) -> Material

Sets the line width of a material.

pub fn set_map(
  material: Material,
  map: texture.Texture,
) -> Material

Sets the material map.

pub fn set_matcap(
  material: Material,
  matcap: texture.Texture,
) -> Material

Sets the matcap texture of a material.

pub fn set_metalness(
  material: Material,
  metalness: Float,
) -> Material

Sets the metalness of a material.

pub fn set_metalness_map(
  material: Material,
  metalness_map: texture.Texture,
) -> Material

Sets the metalness map of a material.

pub fn set_needs_update(
  material: Material,
  needs_update: Bool,
) -> Material

Marks a material as needing an update.

pub fn set_normal_map(
  material: Material,
  normal_map: texture.Texture,
) -> Material

Sets the normal map of a material.

pub fn set_normal_scale(
  material: Material,
  normal_scale: vec2.Vec2(Float),
) -> Material

Sets the normal scale of a material.

pub fn set_opacity(
  material: Material,
  opacity: Float,
) -> Material

Sets the opacity of a material.

pub fn set_rotation(
  material: Material,
  rotation: Float,
) -> Material

Sets the sprite rotation in radians.

pub fn set_roughness(
  material: Material,
  roughness: Float,
) -> Material

Sets the roughness of a material.

pub fn set_roughness_map(
  material: Material,
  roughness_map: texture.Texture,
) -> Material

Sets the roughness map of a material.

pub fn set_side(
  material: Material,
  side: MaterialSide,
) -> Material

Sets which sides of geometry a material should render.

pub fn set_size_attenuation(
  material: Material,
  size_attenuation: Bool,
) -> Material

Enables or disables world-space size attenuation for sprites.

pub fn set_thickness(
  material: Material,
  thickness: Float,
) -> Material

Sets the thickness of a material.

pub fn set_transmission(
  material: Material,
  transmission: Float,
) -> Material

Sets the transmission amount of a material.

pub fn set_transparent(
  material: Material,
  transparent: Bool,
) -> Material

Sets whether a material is transparent.

pub fn set_vertex_colors(
  material: Material,
  vertex_colors: Bool,
) -> Material

Enables or disables vertex colors.

pub fn set_wireframe(
  material: Material,
  wireframe: Bool,
) -> Material

Enables or disables wireframe rendering.

pub fn shadow(options: ShadowOptions) -> Material

Creates a shadow material.

pub fn shadow_options() -> ShadowOptions

Returns default options for a shadow material.

pub fn sprite(options: SpriteOptions) -> Material

Creates a sprite material.

pub fn sprite_options() -> SpriteOptions

Returns default options for a sprite material.

pub fn standard(options: StandardOptions) -> Material

Creates a standard material.

pub fn standard_options() -> StandardOptions

Returns default options for a standard material.

pub fn toon(options: ToonOptions) -> Material

Creates a toon material.

pub fn toon_options() -> ToonOptions

Returns default options for a toon material.

Search Document