export namespace level {
/**
* add a level into the game manager (usually called by the preloader)
* @public
* @param {string} format - level format ("tmx" for Tiled maps, "gltf" / "glb" for 3D scenes)
* @param {string} levelId - the level id (or name)
* @param {Function} [callback] - a function to be called once the level is loaded
* @returns {boolean} true if the level was loaded
*/
function add(format: string, levelId: string, callback?: Function): boolean;
/**
* load a level into the game manager, and return a promise that settles once
* it is actually in the world
* (will also create all level defined entities, etc..)
*
* `options.onLoaded` still fires, so the two forms mix freely. An unknown
* `levelId` throws SYNCHRONOUSLY rather than rejecting — that is a typo, not
* a load failure, and it should not need `await` to surface.
* @overload
* @param {string} levelId - level id
* @param {LevelLoadOptions & { async: true }} options - load options, with `async` set
* @returns {Promise} resolves `true` once the level is in the world
* @example
* await me.loader.preload(game.assets);
* await me.level.load("a4_level1", { async: true });
* // the world is populated here
* @category Level
*/
function load(levelId: string, options: LevelLoadOptions & {
async: true;
}): Promise;
/**
* load a level into the game manager
* (will also create all level defined entities, etc..)
*
* While the game loop is running the load is DEFERRED to a timer, so this
* returns before anything is in the world. Sequence follow-up work from
* `options.onLoaded`, from an `event.LEVEL_LOADED` listener, or by passing
* `async: true` and awaiting the promise that overload returns.
*
* Note that `await me.level.load(id)` without `async: true` does not await
* the load: the call returns a boolean, and `await true` resolves at once.
* @overload
* @param {string} levelId - level id
* @param {LevelLoadOptions & { async?: false }} [options] - additional optional parameters
* @returns {boolean} `true`
* @example
* // load a level
* me.level.load("a4_level1");
*
* // load into a specific container
* me.level.load("a4_level2", { container: levelContainer });
*
* // a glTF/GLB scene (preloaded with type "glb") under a Camera3d:
* // 50 pixels per glTF unit, authored intensities kept at a 1/1000 scale
* me.level.load("diorama", { scale: 50, lightIntensityScale: 0.001 });
* @category Level
*/
function load(levelId: string, options?: (LevelLoadOptions & {
async?: false;
}) | undefined): boolean;
/**
* return the current level id
* @public
* @returns {string}
*/
function getCurrentLevelId(): string;
/**
* return the current level definition.
* for a reference to the live instantiated level,
* rather use the container in which it was loaded (e.g. app.world)
* @public
* @returns {TMXTileMap|GLTFScene} the current level object (a TMXTileMap for Tiled maps, a GLTFScene for glTF/GLB scenes)
*/
function getCurrentLevel(): TMXTileMap | GLTFScene;
/**
* reload the current level, and return a promise that settles once the level is in the world.
*
* @overload
* @param {LevelLoadOptions & { async: true }} options - load options, with `async` set
* @returns {Promise} resolves `true` once the level is back in the world
* @example
* await me.level.reload({ async: true });
* @category Level
*/
function reload(options: LevelLoadOptions & {
async: true;
}): Promise;
/**
* reload the current level.
*
* While the game loop is running the load is deferred to a timer, so this
* returns before anything is in the world — see {@link level.load}.
* @overload
* @param {LevelLoadOptions & { async?: false }} [options] - additional optional parameters
* @returns {boolean} `true`
* @category Level
*/
function reload(options?: (LevelLoadOptions & {
async?: false;
}) | undefined): boolean;
/**
* load the next level, and return a promise that settles once the level is in the world.
*
* With no level to go to this reports `false` WITHOUT loading anything, and
* the promise form resolves `false` rather than rejecting: running out of
* levels is an ordinary outcome, not an error.
*
* @overload
* @param {LevelLoadOptions & { async: true }} options - load options, with `async` set
* @returns {Promise} resolves `true`, or `false` if there is no next level
* @example
* await me.level.next({ async: true });
* @category Level
*/
function next(options: LevelLoadOptions & {
async: true;
}): Promise;
/**
* load the next level.
*
* With no level to go to this reports `false` WITHOUT loading anything, and
* the promise form resolves `false` rather than rejecting: running out of
* levels is an ordinary outcome, not an error.
*
* While the game loop is running the load is deferred to a timer, so this
* returns before anything is in the world — see {@link level.load}.
* @overload
* @param {LevelLoadOptions & { async?: false }} [options] - additional optional parameters
* @returns {boolean} `true` if the next level was loaded, `false` if there is none
* @category Level
*/
function next(options?: (LevelLoadOptions & {
async?: false;
}) | undefined): boolean;
/**
* load the previous level, and return a promise that settles once the level is in the world.
*
* With no level to go to this reports `false` WITHOUT loading anything, and
* the promise form resolves `false` rather than rejecting: running out of
* levels is an ordinary outcome, not an error.
*
* @overload
* @param {LevelLoadOptions & { async: true }} options - load options, with `async` set
* @returns {Promise} resolves `true`, or `false` if there is no previous level
* @example
* await me.level.previous({ async: true });
* @category Level
*/
function previous(options: LevelLoadOptions & {
async: true;
}): Promise;
/**
* load the previous level.
*
* With no level to go to this reports `false` WITHOUT loading anything, and
* the promise form resolves `false` rather than rejecting: running out of
* levels is an ordinary outcome, not an error.
*
* While the game loop is running the load is deferred to a timer, so this
* returns before anything is in the world — see {@link level.load}.
* @overload
* @param {LevelLoadOptions & { async?: false }} [options] - additional optional parameters
* @returns {boolean} `true` if the previous level was loaded, `false` if there is none
* @category Level
*/
function previous(options?: (LevelLoadOptions & {
async?: false;
}) | undefined): boolean;
/**
* return the amount of level preloaded
* @public
* @returns {number} the amount of level preloaded
*/
function levelCount(): number;
}
/**
* Options accepted by every level-loading call.
*
* `async` is the switch that decides what the call HANDS BACK: leave it out and
* you get the boolean these calls have always returned, set it and you get a
* promise that settles once the level is actually in the world. Everything else
* behaves identically either way, `onLoaded` included.
*
* Awaiting a call WITHOUT `async: true` is not an error, but it is not a wait
* either: the call hands back a boolean, and `await true` resolves immediately.
* While the loop is running the load is deferred onto a timer, so it has NOT
* happened by the time such an `await` resumes. Pass the flag when you mean to
* await.
*/
export type LevelLoadOptions = {
/**
* - container in which to load the specified level
*/
container?: Container;
/**
* - callback for when the level is fully loaded, called in both forms
*/
onLoaded?: Function;
/**
* - return a promise that settles once the level is in the world, instead of a boolean
*/
async?: boolean;
/**
* - (TMX only) if true, flatten all objects into the given container
*/
flatten?: boolean;
/**
* - (TMX only) if true, set the viewport bounds to the map size
*/
setViewportBounds?: boolean;
/**
* - (glTF/GLB only) pixels per glTF unit applied to the whole scene
*/
scale?: number;
/**
* - (glTF/GLB only) convert the right-handed (Y-up) source to the engine's Y-down via a rotation rather than a mirror
*/
rightHanded?: boolean;
/**
* - (glTF/GLB only) add the scene's authored `KHR_lights_punctual` lights (plus a soft ambient fill) as {@link Light3d} world children
*/
lights?: boolean;
/**
* - (glTF/GLB only) multiply each light's authored physical intensity by this factor instead of normalizing it to 1
*/
lightIntensityScale?: number;
/**
* - (glTF/GLB only) give every mesh in the scene a ground shadow; omit to inherit the application's `castGroundShadow` setting (on by default)
*/
castGroundShadow?: boolean;
/**
* - (glTF/GLB only) world Y the ground shadows land on
*/
shadowGroundY?: number;
};
import TMXTileMap from "./tiled/TMXTileMap.js";
import GLTFScene from "./gltf/GLTFScene.js";
//# sourceMappingURL=level.d.ts.map