Skip to content

Assets beta ​

Class of @v12-engine/client

ts
export declare class Assets

The 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 ​

ts
constructor(
    folder?: string | undefined, base?: string, load?: Fetch);

Constructs a new instance of the Assets class

categories ​

ts
get categories(): AssetCategory[];

The categories of files the game's folder declares (its assets.json's categories), as a list

changed ​

ts
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 ​

ts
dispose(): void;

Lets go of the addresses made for the map's own files: what holds them is done

fetchFile ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
readonly folder?: string | undefined;

The game's own folder, under public, without slashes around it. Only the shared folders when left out

hasTexture ​

ts
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 ​

ts
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 ​

ts
imageUrl(path: string): string;

The file of a picture, by its path in images/: the game's own, or a shared one

kept ​

ts
kept?: KeptFiles;

The files kept between visits, when the game keeps them (GameView.files.keepFiles)

levelsOf ​

ts
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 ​

ts
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 ​

ts
get manifest(): Readonly<Required<AssetManifest>>;

What the game's folder holds, as its manifest says. Empty without one

modelUrl ​

ts
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 ​

ts
musicUrl(track: string): string;

The file of a music track

ownBase ​

ts
get ownBase(): string;

Where the game's own files are, under the app: /games/td/

packUrl ​

ts
packUrl(path: string): string | undefined;

The map's own file at a path, as an address in the page, if it has one

ready ​

ts
readonly ready: Promise<void>;

Settles once it is known what there is: the shared sounds and the game's own manifest

reloadSharedLevels ​

ts
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 ​

ts
setManifest(manifest: AssetManifest): void;

What the game's folder holds now: after the editor took a file in, say

setPack ​

ts
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 ​

ts
soundCount(name: string): number;

How many takes a sound has: 0 for one there is none of. Known once ready

soundNames ​

ts
soundNames(): string[];

Every sound there is, the game's and the shared ones, by name. Known once ready

soundUrl ​

ts
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 ​

ts
textureUrl(path: string): string;

The file of a texture, by its path in textures/: the game's own, or a shared one

videoUrl ​

ts
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