melonJS
    Preparing search index...

    Interface MeshSettings

    interface MeshSettings {
        alphaCutoff?: number;
        alphaMap?: string | HTMLImageElement | TextureAtlas;
        baseColorFactor?: number[] | Float32Array<ArrayBufferLike>;
        castGroundShadow?: boolean;
        cullBackFaces?: boolean;
        depthTest?: 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;
        shadowDirectionX?: number;
        shadowDirectionZ?: number;
        shadowGroundNormal?: number[] | Vector3d;
        shadowGroundPoint?: number[] | Vector3d;
        shadowGroundY?: number;
        shadowLight?: Light3d;
        shadowOffset?: number;
        shadowOpacity?: number;
        shadowScale?: number;
        shadowStretch?: 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).

    baseColorFactor?: number[] | Float32Array<ArrayBufferLike>

    the material's base colour factor [r, g, b] in 0..1, LINEAR, applied as the mesh tint. That is the form a glTF material states it in (spec 3.9.2) and the form the loader hands back, so a mesh built from a node passes the node's own field straight through. It is ENCODED rather than scaled: a linear factor pushed through tint.setColor by multiplying by 255 renders every untextured material 60 to 70 counts too dark in the midtones, which reads as a lighting fault and gets debugged as one. For an ordinary sRGB colour use Renderable#setTint. The type admits undefined deliberately: the loader declares the field optional, so baseColorFactor: node.baseColorFactor is the headline use and it has to compile for a consumer building under exactOptionalPropertyTypes.

    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

    depthTest?: boolean

    whether geometry in front of this mesh hides it. false draws it over whatever is already there, for a glow or an overlay that has no surface to be occluded ON. Separate from the depth WRITE the transparent pass turns off on its own. Transparent pass only, GPU backends only

    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.

    shadowDirectionX?: number

    x of the ground direction the shadow is cast along. Together with shadowDirectionZ, zero length means no offset and no stretch.

    shadowDirectionZ?: number

    z of the ground direction the shadow is cast along.

    shadowGroundNormal?: number[] | Vector3d

    the UP normal of the floor the shadow lands on, for a surface that is not level. Needs the floor to be named, by shadowGroundY or by shadowGroundPoint; this says which way it faces. Defaults to world up. The tilt is clamped at 75 degrees alongside shadowGroundY, and NOT clamped alongside shadowGroundPoint, which states the plane outright. On an InstancedMesh one plane serves the whole set, through the set's origin at shadowGroundY, so a scatter over curved ground is one set per facet.

    shadowGroundPoint?: number[] | Vector3d

    the point on the floor the blob lands on, for ground that is not flat. Supersedes shadowGroundY, which can only put the blob on the caster's own vertical column; anywhere "down" is not world down, such as on a sphere, that lands the blob beside its caster rather than under it. Names a floor the same way shadowGroundY does, so shadowOffset and the height fade work with it.

    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.

    shadowLight?: Light3d

    a Light3d to take the direction from instead of setting it by hand. Read every draw, so a moving sun carries the shadow with it. Nothing is inferred from the scene: no light here means no direction.

    shadowOffset?: number

    how far to slide the shadow along shadowDirectionX/shadowDirectionZ, in multiples of the blob's own radius, for the look of a light that is not directly overhead. A ratio rather than a world distance so one value serves casters of any size. Honoured only when the floor has been named, by shadowGroundY or by shadowGroundPoint, since the blob is a flat quad and sliding it off a plane the game has NOT named puts it somewhere there is no floor. On an InstancedMesh it is one throw for the whole set.

    shadowOpacity?: number

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

    shadowScale?: number

    multiplier for the ground shadow's footprint. Non-positive or non-finite values hide the shadow without hiding the mesh.

    shadowStretch?: number

    how much longer the blob is along shadowDirectionX/shadowDirectionZ, for the look of a low light. Clamped to 3, and the shadow fades as it stretches. On an InstancedMesh it is one stretch for the whole set.

    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.