Assets beta
Class of @v12-engine/client
export declare class AssetsThe game's files as the client reads them: the shared sounds and the game's own manifest, fetched and kept in the browser's cache
Members
constructor
constructor(
folder?: string | undefined, base?: string, load?: Fetch);Constructs a new instance of the Assets class
categories
get categories(): AssetCategory[];The categories of files the game's folder declares (its assets.json's categories), as a list
changed
changed(folder: 'models' | 'textures', path: string): void;Says a model's or texture's file changed on disk (the dev server's file events, hotFiles): the address of it is another from now on, so neither the browser's cache, the files kept between visits nor Babylon's texture cache hands back the file as it was. path is the file's path in its folder (models/ or textures/)
dispose
dispose(): void;Lets go of the addresses made for the map's own files: what holds them is done
fetchFile
fetchFile(url: string): Promise<Response>;A file of the game, as data: from what is kept between visits when the game keeps them, from the network otherwise. What models and sounds are loaded through
fileAt
fileAt(url: string): Promise<{
url: string;
done(): void;
}>;A file of the game at an address to load it from: itself, or a copy in the page of what is kept between visits. done lets go of the copy once it is loaded
fileUrl
fileUrl(path: string, own: boolean): string;The file of an asset by its path in a folder: the game's own folder, or the shared ones
folder
readonly folder?: string | undefined;The game's own folder, under public, without slashes around it. Only the shared folders when left out
hasTexture
hasTexture(path: string): boolean;Whether a texture is known to be there, by its path in textures/: the game's own (its manifest), or one a pack brings. The shared ones are not listed: unknown is not there
iconUrl
iconUrl(path: string): string;The file of a picture of a button, by its path in icons/: the game's own, or a shared one
imageUrl
imageUrl(path: string): string;The file of a picture, by its path in images/: the game's own, or a shared one
kept
kept?: KeptFiles;The files kept between visits, when the game keeps them (GameView.files.keepFiles)
levelsOf
levelsOf(src: string): readonly {
src: string;
ratio?: number;
}[] | undefined;A model's lighter levels (npm run lod), by their files and the part of the triangles each keeps where it is known: as the game's assets.json or the shared models/levels.json says. Nothing where neither says (a level may still be beside it); none for a model said to have none. Known once ready
log
log: Logger;Where it says what went wrong: the log of the game it is part of, once that has taken it (GameClient.log)
manifest
get manifest(): Readonly<Required<AssetManifest>>;What the game's folder holds, as its manifest says. Empty without one
modelUrl
modelUrl(src: string): string;The file of a model, by the path its ModelDef.src gives: a level of one (<model>.lod<n>.glb) where its model is. A map's own file is an address without an extension: modelExtension says what the loader reads it as
musicUrl
musicUrl(track: string): string;The file of a music track
ownBase
get ownBase(): string;Where the game's own files are, under the app: /games/td/
packUrl
packUrl(path: string): string | undefined;The map's own file at a path, as an address in the page, if it has one
ready
readonly ready: Promise<void>;Settles once it is known what there is: the shared sounds and the game's own manifest
reloadSharedLevels
reloadSharedLevels(): Promise<void>;Reads what the shared models/levels.json says again: after the editor made or took away the levels of a shared model (into the project's own public/models). Nothing where there is no such file
setManifest
setManifest(manifest: AssetManifest): void;What the game's folder holds now: after the editor took a file in, say
setPack
setPack(pack: MapPack | undefined): void;The files a map brings with it (MapPack), looked up before the game's and the shared ones. Those of the map before go. Nothing for none
soundCount
soundCount(name: string): number;How many takes a sound has: 0 for one there is none of. Known once ready
soundNames
soundNames(): string[];Every sound there is, the game's and the shared ones, by name. Known once ready
soundUrl
soundUrl(name: string, take?: number): string;The file of a take of a sound (1 and up), or of the one there is when it has one
textureUrl
textureUrl(path: string): string;The file of a texture, by its path in textures/: the game's own, or a shared one
videoUrl
videoUrl(path: string): string;The file of a video, by its path in videos/: the map's own, the game's, or a shared one