Blockbench Reference Docs
    Preparing search index...

    A texture combines the functionality of material, texture, and image, in one. Textures can be linked to files on the local hard drive, or hold the information in RAM.

    Index

    Constructors

    Properties

    canvas: HTMLCanvasElement

    The texture's associated canvas. Since 4.9, this is the main source of truth for textures in internal mode.

    ctx: CanvasRenderingContext2D

    The 2D context of the texture's associated canvas.

    currentFrame: number
    display_height: number
    error: number
    folder: string

    Relative path to the file's directory, used by some formats such as Java Block/Item

    frame_interpolate: boolean

    Interpolate between frames

    frame_order: string

    Custom frame order

    frame_order_type: "loop" | "custom" | "backwards" | "back_and_forth"
    frame_time: number

    Texture animation frame time

    frameCount: number
    height: number
    id: string

    Texture ID or key, used by some formats. By default this is a number that increases with every texture that is added

    Texture image element

    internal: boolean

    If true, the texture is loaded internally. If false, the texture is loaded directly from a file

    layers: TextureLayer[]
    layers_enabled: boolean
    load_callback?: (texture: Texture) => void

    Set a function that will run once the next time the texture is loaded

    menu: Menu
    mode: never

    Whether the latest version of the texture is currently loaded from and linked to a file on disk, or held in memory as bitmap data

    Use Texture.internal instead

    multi_selected: boolean

    Whether the texture is multi selected

    name: string
    namespace: string
    particle: boolean

    Whether the texture is used for the models particle system. Used by some formats such as Java Block/Item

    path?: string
    pbr_channel: "color" | "normal" | "height" | "mer"
    ratio: number
    relative_path?: string
    render_mode: string
    render_sides: string
    saved: boolean
    selected: boolean

    Whether the texture is directly selected

    selected_layer: TextureLayer
    selection: IntMatrix

    Texture selection in paint mode

    show_icon: boolean
    source: string

    HTML-style source of the texture's displayed data. Can be a path (desktop app only), or a base64 data URL

    sync_to_project: string

    The UUID of the project to sync the texture to

    uuid: string
    uv_height: number
    uv_width: number
    visible: boolean

    Whether the texture is visible. Used for layered textures mode

    width: number
    all: Texture[]
    selected?: Texture

    Accessors

    Methods

    • Adds texture to the textures list and initializes it

      Parameters

      • Optionalundo: boolean

        If true, an undo point is created

      • Optionaluv_size_from_resolution: boolean

      Returns Texture

    • Applies the texture to the selected elements

      Parameters

      • Optionalall: boolean | "blank"

        If true, the texture is applied to all faces of the elements. If 'blank', the texture is only applied to blank faces

      Returns this

    • Wrapper to do edits to the texture.

      Parameters

      • Optionalcallback: (instance: any) => void | HTMLCanvasElement
      • Optionaloptions: TextureEditOptions

        Editing options

      Returns void

    • Enables 'particle' on this texture if it is not enabled on any other texture

      Returns this

    • Parameters

      • file: { content?: string; name: string; path: string }

      Returns this

    • Get the material that the texture displays. When previewing PBR, this will return the shared PBR material

      Returns ShaderMaterial | MeshStandardMaterial

    • Returns {
          animation?: {
              frames?: number[];
              frametime: number;
              height?: number;
              interpolate?: boolean;
              width?: number;
          };
      }

    • Get the UV height of the texture if the format uses per texture UV size, otherwise get the project texture height

      Returns number

    • Get the UV width of the texture if the format uses per texture UV size, otherwise get the project texture width

      Returns number

    • Loads the texture from it's current source

      Parameters

      • Optionalcb: () => {}

        Callback function

      Returns this

    • Loads file content only.

      Does not read png.mcmeta, or attempt to overwrite an existing texture in the project with the same name.

      Used internally when loading .bbmodel files

      Parameters

      • path: string

      Returns this

    • Loads the default white error texture

      Parameters

      • Optionalerror_id: number

        Sets the error ID of the texture

      Returns this

    • Removes the texture

      Parameters

      • Optionalno_update: boolean

        If true, the texture is silently removed. The interface is not updated, no undo point is created

      Returns void

    • Opens a dialog to replace the texture with another file

      Parameters

      • force: boolean

        If true, no warning appears of the texture has unsaved changes

      Returns void

    • Turns the texture selection into a layer

      Parameters

      • Optionalundo: boolean

        Whether to create an undo entry

      • Optionalclone: boolean

        When true, the selection is copied into the new layer and also left on the original layer

      Returns void

    • When editing the same texture in different tabs (via Edit In Blockbench option), sync changes that were made to the texture to other projects

      Returns this

    • Update everything after a content edit to the texture or one of the layers. Updates the material, the layers, marks the texture as unsaved, syncs changes to other projects

      Returns void

    • Update the attached img element with the content from the texture's canvas

      Returns void

    • Redraws the texture content from the layers

      Parameters

      • Optionalupdate_data_url: boolean

        If true, the texture source gets updated as well. This is slower, but is necessary at the end of an edit. During an edit, to preview changes, this can be false

      Returns void