dacha
    Preparing search index...

    Class Mesh

    Mesh component for rendering 2D textures with a custom shader.

    Handles the visual representation of an actor using a texture. The material field specifies a shader and its options for the mesh. Similar to Sprite component, it can render a single texture or a frame from a sprite sheet. When a material is not provided, the default shader is used.

    // Create a mesh with a custom material shader
    const mesh = new Mesh({
    src: 'assets/flame.png',
    width: 64,
    height: 64,
    slice: 4,
    flipX: false,
    flipY: false,
    sortingLayer: 'units',
    sortOffset: { x: 0, y: 0 },
    color: '#ffffff',
    blending: 'normal',
    opacity: 1,
    disabled: false,
    material: {
    name: 'HeatDistort',
    options: { strength: 0.2 }
    }
    });

    // Add to actor
    actor.setComponent(mesh);

    // Modify properties
    mesh.material = undefined; // Remove the heat-distort shader and apply the default one instead

    Hierarchy (View Summary)

    Index
    actor?: Actor
    blending: BlendingMode

    Blending mode for rendering

    color: string

    Color tint applied to the mesh

    currentFrame: number

    Current frame to render

    disabled: boolean

    Whether the mesh is disabled and should not render

    flipX: boolean

    Whether to flip the mesh horizontally

    flipY: boolean

    Whether to flip the mesh vertically

    height: number

    Height of the mesh in pixels

    material?: MaterialConfig

    Material describes a shader and its options applied to a texture (optional).

    opacity: number

    Opacity from 0 (transparent) to 1 (opaque)

    renderData?: RenderData

    Internal rendering data

    slice: number

    Amount of frames in the sprite sheet

    sortingLayer: string

    Sorting layer name for rendering order

    sortOffset: Point

    Center point for sorting calculations

    src: string

    Path to the texture image file

    width: number

    Width of the mesh in pixels

    componentName: string