melonJS
    Preparing search index...

    Interface MeshSettings

    interface MeshSettings {
        alphaCutoff?: number;
        alphaMap?: string | HTMLImageElement | TextureAtlas;
        castGroundShadow?: boolean;
        cullBackFaces?: boolean;
        emissive?: number[] | Float32Array<ArrayBufferLike>;
        fog?: boolean;
        height?: number;
        indices?:
            | number[]
            | Uint16Array<ArrayBufferLike>
            | Uint32Array<ArrayBufferLike>;
        lit?: boolean;
        material?: string;
        model?: string;
        normalize?: boolean;
        normalMap?: string | HTMLImageElement | TextureAtlas;
        normals?: number[] | Float32Array<ArrayBufferLike>;
        rightHanded?: boolean;
        scale?: number;
        shadowGroundY?: number;
        shadowOpacity?: number;
        shininess?: number;
        specular?: number[] | Float32Array<ArrayBufferLike>;
        texture?:
            | string
            | HTMLCanvasElement
            | HTMLImageElement
            | Texture2d
            | TextureAtlas;
        textureFilter?: string;
        textureRepeat?: string;
        transparent?: boolean;
        uvs?: number[]
        | Float32Array<ArrayBufferLike>;
        vertexColors?: number[] | Uint32Array<ArrayBufferLike> | Color[];
        vertices?: number[] | Float32Array<ArrayBufferLike>;
        width?: number;
    }
    Index
    alphaCutoff?: number

    alpha cutout threshold. Fragments whose final alpha is below this value are discarded (hard-edged cutout — foliage, fences, decals — with no blending or sorting). 0 disables the cutout. Set automatically by the glTF loader from a material's alphaMode: "MASK". GPU mesh path only (WebGL and WebGPU; the Canvas renderer ignores it).

    alphaMap?: string | HTMLImageElement | TextureAtlas

    per-texel opacity map, sampled in addition to the diffuse texture (MTL map_d).

    castGroundShadow?: boolean

    give this mesh a blob ground shadow, overriding the application's castGroundShadow setting in both directions. Omit to inherit. Needs a GPU backend and a Camera3d.

    cullBackFaces?: boolean

    enable backface culling

    emissive?: number[] | Float32Array<ArrayBufferLike>

    emissive (self-illumination) color [r, g, b] (0..1, may exceed 1 for HDR glow) added on top of the lit/unlit color so the surface glows regardless of scene lights (neon, lava, screens). Omit / all-zero for no emission. Set automatically by the glTF loader (emissiveFactor) and OBJ loader (MTL Ke). GPU mesh path only (WebGL and WebGPU; the Canvas renderer ignores it).

    fog?: boolean

    set false to exempt this mesh from the camera's distance fog (Camera3d#setFog); omit to fog whenever the camera does

    height?: number

    display height in pixels (normalized models only; ignored when normalize: false)

    indices?: number[] | Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>

    triangle vertex indices (alternative to model). A Uint32Array is preserved as-is for meshes past 65535 vertices — which is what the glTF parser emits for them — while a plain array is materialized as Uint16Array

    lit?: boolean

    shade this mesh with the scene's Light3d lights (the lit mesh pipeline) instead of rendering fullbright. Set automatically by the glTF importer when the scene carries a directional, point or spot light. With lit on and no lights present the batcher uploads a white ambient, so the result is indistinguishable from unlit.

    material?: string

    name of a preloaded MTL material (via loader.preload with type "mtl"). When provided, the diffuse texture (map_Kd), tint color (Kd), and opacity (d) are automatically applied. On a multi-material model each material's own map_Kd is bound for its own slice of the geometry (#1573) and each Kd is baked per-vertex, so one Mesh renders the whole model.

    model?: string

    name of a preloaded OBJ model (via loader.preload with type "obj"). Vertex normals come with it — authored vn when the file has them, generated from face geometry when it does not — so an OBJ model can be lit.

    normalize?: boolean

    fit the source geometry into a [-0.5, 0.5] unit cube before scaling, so width/height behave like a Sprite. Set false to keep the geometry's real-world coordinates — required when several meshes share one coordinate space (e.g. nodes of an imported glTF scene) so their relative scale and layout are preserved.

    normalMap?: string | HTMLImageElement | TextureAtlas

    tangent-space normal map (MTL map_bump/bump/norm), perturbing the lit path's shading normal per fragment. Needs lit to have any effect, and a Camera3d. See the Material Textures example.

    normals?: number[] | Float32Array<ArrayBufferLike>

    per-vertex normals for the lit path. An explicit value wins over the ones an OBJ or glTF source supplies; omit it and they are taken from the model, or generated from the geometry when the mesh is lit. Generated normals average per vertex where faces share vertices (smooth shading) and equal the face normal where they do not (flat shading) — the geometry decides, not a flag.

    rightHanded?: boolean

    treat the source as right-handed (Y-up, e.g. glTF) under the Camera3d world path. The default Y-up→Y-down bridge negates Y only (a reflection, which mirrors the scene left/right); true negates Y and Z (a rotation) so chirality is preserved and the result matches the authoring tool. See Mesh#rightHanded.

    scale?: number

    world-space scale (pixels per source unit) for the Camera3d path; defaults to width. Set this when width/height describe the renderable's world bounds (frustum culling) rather than the geometry scale — see Mesh#meshScale.

    shadowGroundY?: number

    world Y of the floor the shadow lands on. Omit and the blob sits at the object's own base at full strength; set it and the blob shrinks and fades as the object rises. Render space is Y-down, so the floor is a greater Y than the object above it.

    shadowOpacity?: number

    opacity of the shadow directly beneath the object, before any height fade.

    shininess?: number

    specular exponent for the lit path (MTL Ns). 0 for a fully diffuse surface.

    specular?: number[] | Float32Array<ArrayBufferLike>

    specular color [r, g, b] (0..1) for the lit path. Set by the OBJ loader from MTL Ks, and derived from glTF metallic/roughness.

    texture?:
        | string
        | HTMLCanvasElement
        | HTMLImageElement
        | Texture2d
        | TextureAtlas

    the texture to apply (image name, HTMLImageElement, or TextureAtlas). If omitted and settings.material is provided, the texture is resolved from the MTL material's map_Kd. Passing this pins ONE binding over the whole model, which on a multi-material model suppresses the per-material texture split — see Mesh#textureGroups.

    textureFilter?: string

    texture magnification filter ("nearest" for crisp pixel-art upscaling, "linear" for smooth) applied to the resolved texture. Omit to keep the renderer's global antiAlias default. On the mesh path, linear filtering also samples a generated mip chain with trilinear minification and 4× anisotropy (distant geometry stops shimmering) — "nearest" opts out, keeping crisp pixel-art models on hard level-0 sampling. GPU backends only (ignored by the Canvas renderer).

    textureRepeat?: string

    texture wrap mode ("repeat" / "repeat-x" / "repeat-y" / "no-repeat") this mesh samples its texture with (per-mesh — it does not modify the shared texture, so other meshes/sprites using the same image are unaffected). Use "repeat" when the geometry's UVs fall outside the [0, 1] range and rely on the texture tiling (e.g. glTF assets, whose default sampler wrap is REPEAT) — otherwise the texture clamps to its edge texels and looks flat. Ignored for the white-pixel fallback. Note: REPEAT on a non-power-of-two texture requires WebGL 2.

    transparent?: boolean

    draw in the transparent pass (blended, back-to-front, no depth write). Omit and a mesh goes transparent whenever its draw alpha is fractional; true for soft-alpha textures; false to stay opaque however faded

    uvs?: number[] | Float32Array<ArrayBufferLike>

    texture coordinates as u,v pairs (alternative to model)

    vertexColors?: number[] | Uint32Array<ArrayBufferLike> | Color[]

    per-vertex colour, one entry per vertex, multiplied into Mesh#tint. Either packed RGBA8 (Uint32Array, the form the batchers read — no conversion) or one Color per vertex. Omit for plain white. Lets a single mesh carry a gradient — fading a terrain toward the sky with distance, darkening a crease — which a per-object tint cannot express. An explicit value wins over the colours a multi-material OBJ bakes from its MTL.

    vertices?: number[] | Float32Array<ArrayBufferLike>

    vertex positions as x,y,z triplets (alternative to model)

    width?: number

    display width in pixels. With normalization on (the default) the model is scaled to fit this size; with normalize: false this is the uniform pixels-per-unit scale applied to the raw geometry. With normalize: false and an explicit scale, an omitted width/height is derived from the GEOMETRY's own extent, the way a Sprite takes its size from its frame — a mesh that reports no extent misleads frustum culling, pointer picking and the physics broadphase alike.