/**
* Sets the options for the loader.
* @param {Object} options - The options to set.
* @param {string} [options.crossOrigin] - The crossOrigin attribute to configure the CORS requests for Image and Video data element.
* @param {boolean} [options.nocache] - Enable or disable the nocache mechanism.
* @param {boolean} [options.withCredentials] - Indicates whether or not cross-site Access-Control requests should be made using credentials.
* @example
* // Set the crossOrigin attribute to "anonymous"
* me.loader.setOptions({ crossOrigin: "anonymous" });
*
* // Enable the nocache mechanism
* me.loader.setOptions({ nocache: true });
*
* // Enable withCredentials
* me.loader.setOptions({ withCredentials: true });
* @category Assets
*/
export function setOptions(options: {
crossOrigin?: string | undefined;
nocache?: boolean | undefined;
withCredentials?: boolean | undefined;
}): void;
/**
* change the default baseURL for the given asset type.
* (this will prepend the asset URL and must finish with a '/')
* @public
* @param {string} type - "*", "audio", "video", "binary", "image", "json", "js", "tmx", "tsx", "fontface", "aseprite", "shader", "obj", "mtl", "gltf", "glb"
* @param {string} [url="./"] - default base URL
* @example
* // change the base URL relative address for audio assets
* me.loader.setBaseURL("audio", "data/audio/");
* // change the base URL absolute address for all object types
* me.loader.setBaseURL("*", "http://myurl.com/")
* @category Assets
*/
export function setBaseURL(type: string, url?: string): void;
/**
* an asset definition to be used with the loader
* @typedef {object} Asset
* @property {string} name - name of the asset
* @property {string} type - the type of the asset ("audio"|"binary"|"image"|"json"|"js"|"tmx"|"tsx"|"fontface"|"video"|"aseprite"|"shader"|"obj"|"mtl"|"gltf"|"glb"). JSON-serialised Tiled maps and tilesets (`.tmj` / `.tsj`) load under `"tmx"` / `"tsx"` — those are file extensions, not asset types.
* @property {string|string[]} [src] - path and/or file name of the resource (for audio assets only the path is required).
* For image assets, an array of sources can be provided as a fallback chain (e.g. compressed texture formats by priority, with a PNG fallback).
* The loader will try each source in order and use the first one that loads successfully.
* @property {string|{glsl?: string, wgsl?: string}} [data] - inline content if not provided through a src url: TMX data for "tmx" assets, GLSL source (the ShaderEffect fragment-body convention) for "shader" assets. A shader may instead carry a `{glsl, wgsl}` pair, so one asset serves both backends; either half may be omitted
* @property {boolean} [stream=false] - Set to true to not to wait for large audio or video file to be downloaded before playing.
* @property {boolean} [autoplay=false] - Set to true to automatically start playing audio or video when loaded or added to a scene (using autoplay might require user iteraction to enable it)
* @property {boolean} [loop=false] - Set to true to automatically loop the audio or video when playing
* @see {@link preload}
* @see {@link load}
* @example
* // PNG tileset
* {name: "tileset-platformer", type: "image", src: "data/map/tileset.png"}
* // PNG packed texture
* {name: "texture", type:"image", src: "data/gfx/texture.png"}
* // PNG base64 encoded image
* {name: "texture", type:"image", src: "data:image/png;base64,iVBORw0KAAAQAAAAEACA..."}
* // compressed texture with fallback chain (tries each source in order until one succeeds)
* {name: "terrain", type:"image", src: ["data/gfx/terrain.astc.ktx", "data/gfx/terrain.dds", "data/gfx/terrain.png"]}
* // TSX file
* {name: "meta_tiles", type: "tsx", src: "data/map/meta_tiles.tsx"}
* // TMX level (XML & JSON)
* {name: "map1", type: "tmx", src: "data/map/map1.json"}
* {name: "map2", type: "tmx", src: "data/map/map2.tmx"}
* {name: "map3", type: "tmx", format: "json", data: {"height":15,"layers":[...],"tilewidth":32,"version":1,"width":20}}
* {name: "map4", type: "tmx", format: "xml", data: {xml representation of tmx}}
* // audio resources
* {name: "bgmusic", type: "audio", src: "data/audio/"}
* {name: "cling", type: "audio", src: "data/audio/"}
* // base64 encoded audio resources
* {name: "band", type: "audio", src: "data:audio/wav;base64,..."}
* // binary file
* {name: "ymTrack", type: "binary", src: "data/audio/main.ym"}
* // JSON file (used for texturePacker)
* {name: "texture", type: "json", src: "data/gfx/texture.json"}
* // JavaScript file
* {name: "plugin", type: "js", src: "data/js/plugin.js"}
* // Font Face
* { name: "'kenpixel'", type: "fontface", src: "data/font/kenvector_future.woff2" }
* // video resources
* {name: "intro", type: "video", src: "data/video/"}
* // 3D assets: Wavefront OBJ model + MTL material library
* {name: "ship", type: "obj", src: "data/models/ship.obj"}
* {name: "ship", type: "mtl", src: "data/models/ship.mtl"}
* // glTF / GLB scene (auto-registers with the level director)
* {name: "diorama", type: "glb", src: "data/scenes/diorama.glb"}
* // shader assets: an effect body, or a complete dual-backend program
* {name: "flash", type: "shader", src: "shaders/flash.frag"}
* {name: "toon", type: "shader", src: {vertex: "shaders/toon.vert", fragment: "shaders/toon.frag", wgsl: "shaders/toon.wgsl"}}
*/
/**
* specify a parser/preload function for the given asset type
* @param {string} type - asset type
* @param {function} parserFn - parser function
* @see {@link Asset.type}
* @example
* // specify a custom function for "abc" format
* function customAbcParser(data, onload, onerror) {
* // preload and do something with the data
* let parsedData = doSomething(data);
* // when done, call the onload callback with the parsed data
* onload(parsedData);
* // in case of error, call the onerror callback
* onerror();
* // return the amount of asset parsed
* return 1
* }
* // set the parser for the custom format
* loader.setParser("abc", customAbcParser);
* @category Assets
*/
export function setParser(type: string, parserFn: Function): void;
/**
* set all the specified game assets to be preloaded.
* @param {Asset[]} assets - list of assets to load
* @param {Function} [onloadcb=loader.onload] - function to be called when all resources are loaded
* @param {boolean} [switchToLoadState=true] - automatically switch to the loading screen
* @returns {Promise} resolves once every asset has loaded (rejects on a
* load failure). The `onloadcb` callback is still invoked on success, so both
* the callback and `await` forms work — use whichever you prefer.
* @example
* game.assets = [
* // PNG tileset
* {name: "tileset-platformer", type: "image", src: "data/map/tileset.png"},
* // PNG packed texture
* {name: "texture", type:"image", src: "data/gfx/texture.png"}
* // PNG base64 encoded image
* {name: "texture", type:"image", src: "data:image/png;base64,iVBORw0KAAAQAAAAEACA..."},
* // compressed texture with fallback chain (tries each source in order until one succeeds)
* {name: "terrain", type:"image", src: ["data/gfx/terrain.astc.ktx", "data/gfx/terrain.dds", "data/gfx/terrain.png"]},
* // TSX file
* {name: "meta_tiles", type: "tsx", src: "data/map/meta_tiles.tsx"},
* // TMX level (XML & JSON)
* {name: "map1", type: "tmx", src: "data/map/map1.json"},
* {name: "map2", type: "tmx", src: "data/map/map2.tmx"},
* {name: "map3", type: "tmx", format: "json", data: {"height":15,"layers":[...],"tilewidth":32,"version":1,"width":20}},
* {name: "map4", type: "tmx", format: "xml", data: {xml representation of tmx}},
* // audio resources
* {name: "bgmusic", type: "audio", src: "data/audio/"},
* {name: "cling", type: "audio", src: "data/audio/"},
* // base64 encoded audio resources
* {name: "band", type: "audio", src: "data:audio/wav;base64,..."},
* // binary file
* {name: "ymTrack", type: "binary", src: "data/audio/main.ym"},
* // JSON file (used for texturePacker)
* {name: "texture", type: "json", src: "data/gfx/texture.json"},
* // JavaScript file
* {name: "plugin", type: "js", src: "data/js/plugin.js"},
* // Font Face
* {name: "'kenpixel'", type: "fontface", src: "data/font/kenvector_future.woff2"},
* // video resources
* {name: "intro", type: "video", src: "data/video/"},
* // base64 encoded video asset
* me.loader.load({name: "avatar", type:"video", src: "data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZ..."};
* ];
* ...
* // set all resources to be loaded (callback form)
* me.loader.preload(game.assets, () => this.loaded());
* // ...or await it (the callback still fires too)
* await me.loader.preload(game.assets);
* @category Assets
*/
export function preload(assets: Asset[], onloadcb?: Function, switchToLoadState?: boolean): Promise;
/**
* retry loading assets after a loading failure
* @param {string} src - src of asset to reload
* @example
* event.on(
* event.LOADER_ERROR,
* (res) => {
* // custom function
* showErrorNotification({
* text: `Error during loading content: ${res.name}`,
* done: loader.reload(res.src);
* })
* }
* );
**/
export function reload(src: string): void;
/**
* Load a single asset (to be used if you need to load additional asset(s) during the game)
* @param {Asset} asset
* @param {Function} [onload] - function to be called when the asset is loaded
* @param {Function} [onerror] - function to be called in case of error
* @returns {number|Promise} with `onload`/`onerror` provided, the amount
* of corresponding resource to be preloaded (the legacy callback form). With
* **both omitted**, a Promise that resolves once the asset has loaded, so you
* can `await loader.load(asset)` for a one-off dynamic load.
* @example
* // load an image asset (callback form)
* me.loader.load({name: "avatar", type:"image", src: "data/avatar.png"}, () => this.onload(), () => this.onerror());
* // ...or await a single dynamic asset (no callbacks)
* await me.loader.load({name: "avatar", type: "image", src: "data/avatar.png"});
* // load a compressed texture with fallback chain
* me.loader.load({name: "terrain", type:"image", src: ["data/gfx/terrain.astc.ktx", "data/gfx/terrain.dds", "data/gfx/terrain.png"]}, () => this.onload());
* // load a base64 image asset
* me.loader.load({name: "avatar", type:"image", src: "data:image/png;base64,iVBORw0KAAAQAAAAEACA..."};
* // load a base64 video asset
* me.loader.load({
* name: "avatar",
* type:"video",
* src: "data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZ.."
* };
* // start loading music
* me.loader.load({
* name : "bgmusic",
* type : "audio",
* src : "data/audio/"
* }, function () {
* me.audio.play("bgmusic");
* });
* @category Assets
*/
export function load(asset: Asset, onload?: Function, onerror?: Function): number | Promise;
/**
* unload the specified asset to free memory
* @param {Asset} asset
* @returns {boolean} true if unloaded
* @example me.loader.unload({name: "avatar", type:"image"});
* @category Assets
*/
export function unload(asset: Asset): boolean;
/**
* unload all resources to free memory
* @example me.loader.unloadAll();
* @category Assets
*/
export function unloadAll(): void;
/**
* return the specified TMX/TSX object
* @param {string} elt - name of the tmx/tsx element ("map1");
* @returns {object} requested element or null if not found
* @category Assets
*/
export function getTMX(elt: string): object;
/**
* return the specified Binary object
* @param {string} elt - name of the binary object ("ymTrack");
* @returns {object} requested element or null if not found
* @category Assets
*/
export function getBinary(elt: string): object;
/**
* return the specified Image Object
* @param {string} image - name of the Image element ("tileset-platformer");
* @returns {HTMLImageElement|CompressedImage|null} requested element or null if not found
* @category Assets
*/
export function getImage(image: string): HTMLImageElement | CompressedImage | null;
/**
* return the specified JSON Object
* @param {string} elt - name of the json file
* @returns {JSON}
* @category Assets
*/
export function getJSON(elt: string): JSON;
/**
* return the specified OBJ model data
* @param {string} elt - name of the OBJ file (as specified in the preload list)
* @returns {object} parsed OBJ data with `vertices` (Float32Array), `uvs` (Float32Array), `indices` (Uint16Array), and `vertexCount` (number), or null if not found
* @category Assets
* @example
* // 1. preload the OBJ model and its texture
* me.loader.preload([
* { name: "cube", type: "obj", src: "models/cube.obj" },
* { name: "cube", type: "image", src: "models/cube_texture.png" },
* ], () => {
* // 2. create a Mesh using the preloaded model name
* const mesh = new me.Mesh(400, 300, {
* model: "cube", // references the preloaded OBJ
* texture: "cube", // references the preloaded image
* width: 200,
* height: 200,
* });
* me.game.world.addChild(mesh);
*
* // 3. or access the raw parsed data directly
* const data = me.loader.getOBJ("cube");
* // data.vertices — Float32Array of x,y,z positions
* // data.uvs — Float32Array of u,v texture coordinates
* // data.indices — Uint16Array of triangle vertex indices
* // data.vertexCount — number of unique vertices
* // data.groups — usemtl material groups ({materialName, start, count} index ranges)
* });
*/
export function getOBJ(elt: string): object;
/**
* One mesh primitive out of a parsed glTF/GLB scene.
*
* Spelled out rather than left as `object` so the geometry can be read from
* TypeScript — feeding `vertices`/`uvs`/`normals`/`indices` straight into a
* {@link Mesh} or {@link InstancedMesh} is the whole point of exposing it.
* @typedef {object} GLTFNode
* @property {number[]} world - accumulated world transform, 16 floats, column-major
* @property {Float32Array} vertices - positions, x,y,z triplets
* @property {Float32Array} normals - per-vertex normals
* @property {Float32Array} uvs - texture coordinates, u,v pairs
* @property {Uint16Array|Uint32Array} indices - triangle vertex indices
* @property {number} vertexCount - number of vertices
* @property {HTMLImageElement|null} image - decoded baseColor texture, or `null`
* @property {number[]} [baseColorFactor] - material baseColor factor, `[r, g, b, a]`
* @property {Uint32Array} [colors] - per-vertex colour, packed RGBA8
* @property {string} [textureRepeat] - wrap mode derived from the glTF sampler
* @property {string} [textureFilter] - magnification filter derived from the glTF sampler
* @property {number} [alphaCutoff] - cutout threshold from `alphaMode: "MASK"`
* @property {number[]} [emissive] - emissive factor, `[r, g, b]`
* @property {boolean} [unlit] - the material carried `KHR_materials_unlit`
* @property {boolean} [doubleSided] - the material is double-sided
* @property {string} [name] - the source node's name
*/
/**
* a parsed glTF/GLB scene descriptor, as returned by {@link loader.getGLTF}
* @typedef {object} GLTFData
* @property {GLTFNode[]} nodes - one entry per mesh primitive
* @property {Array<{world: number[], type?: string, perspective?: {yfov?: number, aspectRatio?: number, znear?: number, zfar?: number}, orthographic?: object}>} cameras - glTF cameras, each with its `world` transform + the glTF camera parameters (`perspective` for perspective cameras, `orthographic` otherwise)
* @property {object[]} lights - parsed `KHR_lights_punctual` lights (`type`, `color`, `intensity`, `range`, `innerConeAngle`/`outerConeAngle` for spots, world-space `direction`/`position`, `name`)
* @property {{min: number[], max: number[]}} bounds - world-space scene bounds in glTF units
* @property {object[]} graph - the full node graph (every node's TRS/matrix + children), for custom traversal
* @property {object[]} animations - parsed node animations (consumed by `GLTFModel` playback)
*/
/**
* return the parsed glTF/GLB scene descriptor for the given asset name.
*
* The descriptor is `{ nodes, cameras, lights, bounds, graph, animations }`:
* - `nodes` — one entry per mesh primitive, each carrying its accumulated
* `world` transform (16 floats, column-major), `vertices`, `normals`,
* `uvs`, `indices`, `vertexCount`, a decoded baseColor `image` (or `null`),
* and a `doubleSided` flag.
* - `cameras` — glTF cameras, each with its `world` transform + perspective
* parameters.
* - `lights` — parsed `KHR_lights_punctual` lights (`type`, `color`,
* `intensity`, `range`, spot cone angles, world-space
* `direction`/`position`, `name`); empty without the extension. The
* level director instantiates directional, point and spot lights
* automatically (see {@link level.load} options).
* - `bounds` — world-space `{ min, max }` (glTF units), handy for framing.
*
* Most code never needs this: a preloaded glTF/GLB auto-registers with the
* {@link level} director, so the whole scene loads into a container in one
* call via `me.level.load(name)` — exactly like a Tiled map. Reach for
* `getGLTF` only when you want to inspect the raw descriptor (e.g. to frame
* a `Camera3d` from the embedded camera).
* @param {string} elt - name of the glTF/GLB file (as specified in the preload list)
* @returns {GLTFData|null} the parsed scene descriptor, or `null` if not found
* @category Assets
* @example
* me.loader.preload(
* [{ name: "diorama", type: "glb", src: "scenes/diorama.glb" }],
* () => {
* // load the whole scene into the world (view under a Camera3d)
* me.level.load("diorama", { scale: 32 });
*
* // ...or inspect the raw descriptor for custom framing
* const scene = me.loader.getGLTF("diorama");
* const { min, max } = scene.bounds;
* },
* );
*/
export function getGLTF(elt: string): GLTFData | null;
/**
* Return the precompiled `ShaderEffect` for the given "shader" asset —
* compiled once during preloading, ready to assign to a renderable or
* camera `shader` property.
*
* **This returns a SHARED instance**: the *same* `ShaderEffect` object on
* every call, owned by the loader (its `shared` flag is `true`). That means:
* - it is safe to assign to any number of renderables — none of their
* cleanup paths will auto-destroy it, only {@link loader.unload} /
* {@link loader.unloadAll} free it (and its GL program);
* - all of them share ONE set of uniform values — `setUniform` on it
* affects every renderable using the shader.
*
* When a renderable needs its **own** uniform values, make a private,
* caller-owned copy with `ShaderEffect.clone()` — the clone's `shared` flag
* is reset to `false`, so it is auto-destroyed with the renderable it is
* assigned to, like any hand-constructed effect.
*
* A shader asset declared as a **complete program** — a
* `{vertex, fragment}` GLSL pair and/or a full `wgsl` module (see the
* example) — compiles into a raw {@link GLShader} instead, carrying one
* realization per GPU backend (`isWebGL` / `isWebGPU`): the type the
* hosted paths take directly (a `Mesh` custom shader,
* `renderer.customShader`, a custom batcher). Same shared-instance
* semantics, and `GLShader.clone()` likewise yields a caller-owned copy.
*
* Degradation is never fatal: a fragment-body asset without a body in the
* active renderer's language (or on Canvas) is an inert `ShaderEffect`
* stub, and a complete-program asset without a realization for the active
* backend is an inert `GLShader` — assigning either just keeps the
* built-in rendering. Note that shader assets require an initialized
* Application (`await app.init()`) — an inherent precondition of the
* preload flow, since the loading screen itself needs the renderer.
* @param {string} elt - name of the shader asset (as specified in the preload list)
* @returns {ShaderEffect|GLShader|null} the shared, precompiled shader, or `null` if not found
* @category Assets
* @example
* me.loader.preload([
* // from a file (or data: URI)
* { name: "waterRipple", type: "shader", src: "shaders/waterRipple.frag" },
* // or inline GLSL via the `data` field
* { name: "flash", type: "shader", data: `
* uniform float uIntensity;
* vec4 apply(vec4 color, vec2 uv) { return mix(color, vec4(1.0), uIntensity); }
* ` },
* // or a complete program — a {vertex, fragment} GLSL pair and/or a
* // full WGSL module → one GLShader carrying both realizations; the
* // active renderer hosts the one it speaks
* { name: "toonMesh", type: "shader", src: {
* vertex: "shaders/toon.vert",
* fragment: "shaders/toon.frag",
* wgsl: "shaders/toon.wgsl",
* } },
* ], () => {
* // one shared program — same uniform state for every user
* mySprite.addPostEffect(me.loader.getShader("waterRipple"));
* // private copy with its own uniforms (caller-owned, shared = false)
* boss.addPostEffect(me.loader.getShader("flash").clone());
* // a complete program hosts on a mesh, replacing the built-in shading
* myMesh.addPostEffect(me.loader.getShader("toonMesh"));
* });
*/
export function getShader(elt: string): ShaderEffect | GLShader | null;
/**
* return the specified MTL material data
* @param {string} elt - name of the MTL file (as specified in the preload list)
* @returns {object} map of material names to properties (`Kd`, `d`, `map_Kd`), or null if not found
* @category Assets
* @example
* // 1. preload OBJ + MTL + texture
* me.loader.preload([
* { name: "fox", type: "obj", src: "models/fox.obj" },
* { name: "fox", type: "mtl", src: "models/fox.mtl" },
* { name: "colormap", type: "image", src: "models/colormap.png" },
* ], () => {
* // 2. create a Mesh with material — texture, tint, opacity auto-applied
* const mesh = new me.Mesh(400, 300, {
* model: "fox",
* material: "fox",
* texture: "colormap",
* width: 200,
* height: 200,
* });
*
* // 3. or access the raw material data directly
* const materials = me.loader.getMTL("fox");
* // materials["colormap"].Kd — [r, g, b] diffuse color (0-1 range)
* // materials["colormap"].d — opacity (0-1)
* // materials["colormap"].Ke — [r, g, b] emissive color (glow, applied as Mesh.emissive)
* // materials["colormap"].map_Kd — resolved texture URL
* });
*/
export function getMTL(elt: string): object;
/**
* return the specified Video Object
* @param {string} elt - name of the video file
* @returns {HTMLVideoElement}
* @category Assets
*/
export function getVideo(elt: string): HTMLVideoElement;
/**
* return the specified FontFace Object
* @param {string} elt - name of the font file
* @returns {FontFace}
* @category Assets
*/
export function getFont(elt: string): FontFace;
/**
* a small class to manage loading of stuff and manage resources
* @namespace loader
*/
export let nocache: string;
/**
* @type {Object.}
*/
export const baseURL: {
[x: string]: string;
};
/**
* crossOrigin attribute to configure the CORS requests for Image and Video data element.
* By default (that is, when the attribute is not specified), CORS is not used at all.
* The "anonymous" keyword means that there will be no exchange of user credentials via cookies,
* client-side SSL certificates or HTTP authentication as described in the Terminology section of the CORS specification.
* @type {string}
* @default undefined
* @see {@link setOptions}
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes}
* @deprecated since 20.4.0, read-only — set it with
* {@link setOptions}. This is a module binding, so assigning to it throws a
* `TypeError`; the example below never worked.
* @example
* // allow for cross-origin texture loading
* me.loader.setOptions({ crossOrigin: "anonymous" });
*
* // set all resources to be loaded
* me.loader.preload(game.resources, () => this.loaded());
*/
export let crossOrigin: string;
/**
* indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies,
* authorization headers or TLS client certificates. Setting withCredentials has no effect on same-site requests.
* @public
* @type {boolean}
* @see {@link setOptions}
* @default false
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials}
* @deprecated since 20.4.0, read-only — set it with
* {@link setOptions}. This is a module binding, so assigning to it throws a
* `TypeError`; the example below never worked.
* @example
* // enable withCredentials, for assets behind a session cookie or login
* me.loader.setOptions({ withCredentials: true });
*
* // set all resources to be loaded
* me.loader.preload(game.resources, () => this.loaded());
*/
export let withCredentials: boolean;
/**
* an asset definition to be used with the loader
*/
export type Asset = {
/**
* - name of the asset
*/
name: string;
/**
* - the type of the asset ("audio"|"binary"|"image"|"json"|"js"|"tmx"|"tsx"|"fontface"|"video"|"aseprite"|"shader"|"obj"|"mtl"|"gltf"|"glb"). JSON-serialised Tiled maps and tilesets (`.tmj` / `.tsj`) load under `"tmx"` / `"tsx"` — those are file extensions, not asset types.
*/
type: string;
/**
* - path and/or file name of the resource (for audio assets only the path is required).
* For image assets, an array of sources can be provided as a fallback chain (e.g. compressed texture formats by priority, with a PNG fallback).
* The loader will try each source in order and use the first one that loads successfully.
*/
src?: string | string[];
/**
* - inline content if not provided through a src url: TMX data for "tmx" assets, GLSL source (the ShaderEffect fragment-body convention) for "shader" assets. A shader may instead carry a `{glsl, wgsl}` pair, so one asset serves both backends; either half may be omitted
*/
data?: string | {
glsl?: string;
wgsl?: string;
};
/**
* - Set to true to not to wait for large audio or video file to be downloaded before playing.
*/
stream?: boolean;
/**
* - Set to true to automatically start playing audio or video when loaded or added to a scene (using autoplay might require user iteraction to enable it)
*/
autoplay?: boolean;
/**
* - Set to true to automatically loop the audio or video when playing
*/
loop?: boolean;
};
/**
* One mesh primitive out of a parsed glTF/GLB scene.
*
* Spelled out rather than left as `object` so the geometry can be read from
* TypeScript — feeding `vertices`/`uvs`/`normals`/`indices` straight into a
* {@link Mesh} or {@link InstancedMesh} is the whole point of exposing it.
*/
export type GLTFNode = {
/**
* - accumulated world transform, 16 floats, column-major
*/
world: number[];
/**
* - positions, x,y,z triplets
*/
vertices: Float32Array;
/**
* - per-vertex normals
*/
normals: Float32Array;
/**
* - texture coordinates, u,v pairs
*/
uvs: Float32Array;
/**
* - triangle vertex indices
*/
indices: Uint16Array | Uint32Array;
/**
* - number of vertices
*/
vertexCount: number;
/**
* - decoded baseColor texture, or `null`
*/
image: HTMLImageElement | null;
/**
* - material baseColor factor, `[r, g, b, a]`
*/
baseColorFactor?: number[];
/**
* - per-vertex colour, packed RGBA8
*/
colors?: Uint32Array;
/**
* - wrap mode derived from the glTF sampler
*/
textureRepeat?: string;
/**
* - magnification filter derived from the glTF sampler
*/
textureFilter?: string;
/**
* - cutout threshold from `alphaMode: "MASK"`
*/
alphaCutoff?: number;
/**
* - emissive factor, `[r, g, b]`
*/
emissive?: number[];
/**
* - the material carried `KHR_materials_unlit`
*/
unlit?: boolean;
/**
* - the material is double-sided
*/
doubleSided?: boolean;
/**
* - the source node's name
*/
name?: string;
};
/**
* a parsed glTF/GLB scene descriptor, as returned by {@link loader.getGLTF}
*/
export type GLTFData = {
/**
* - one entry per mesh primitive
*/
nodes: GLTFNode[];
/**
* - glTF cameras, each with its `world` transform + the glTF camera parameters (`perspective` for perspective cameras, `orthographic` otherwise)
*/
cameras: Array<{
world: number[];
type?: string;
perspective?: {
yfov?: number;
aspectRatio?: number;
znear?: number;
zfar?: number;
};
orthographic?: object;
}>;
/**
* - parsed `KHR_lights_punctual` lights (`type`, `color`, `intensity`, `range`, `innerConeAngle`/`outerConeAngle` for spots, world-space `direction`/`position`, `name`)
*/
lights: object[];
/**
* - world-space scene bounds in glTF units
*/
bounds: {
min: number[];
max: number[];
};
/**
* - the full node graph (every node's TRS/matrix + children), for custom traversal
*/
graph: object[];
/**
* - parsed node animations (consumed by `GLTFModel` playback)
*/
animations: object[];
};
//# sourceMappingURL=loader.d.ts.map