Skip to content

API Variable Assets

github-actions[bot] edited this page Nov 29, 2026 · 6 revisions

Variable: Assets

const Assets: object;

Defined in: src/engine/scene/Assets.ts:116

Type Declaration

platform

Get Signature

get platform(): ImportPlatform;

The platform per-platform import overrides resolve for (ADR 0115): "android" under Tauri mobile on Android, "desktop" under Tauri elsewhere, else "web" (ADR 0351 §1); settable (null = detect).

Returns

ImportPlatform

Set Signature

set platform(value): void;
Parameters
value

ImportPlatform | null

Returns

void

addSource()

addSource(source): void;

Parameters

source

AssetSource

Returns

void

bytes()

bytes(path): Promise<Uint8Array<ArrayBufferLike>>;

A file's bytes, fetched from its URL (Assets.url); read from disk for the dedicated server's file: URLs.

Parameters

path

string

Returns

Promise<Uint8Array<ArrayBufferLike>>

clearSources()

clearSources(): void;

Returns

void

fromGlob()

fromGlob(modules): AssetSource;

Wrap the result of a Vite glob import made from the game's asset folder: import.meta.glob("./**/*.{png,mp3,json}", { eager: true, import: "default" }). Keys are paths relative to that folder; values are URLs or parsed JSON. Text files (ADR 0254) must hold their contents, so glob those with query: "?raw".

Parameters

modules

Record<string, unknown>

Returns

AssetSource

fromObject()

fromObject(map): AssetSource;

A source backed by a plain object, handy for tests: { "scenes/a.json": {...} }.

Parameters

map

Record<string, unknown>

Returns

AssetSource

get()

get(path): unknown;

The raw asset value (see AssetSource.get), for comparing what a file held; read values through json, text or url. Throws if no source has the asset.

Parameters

path

string

Returns

unknown

has()

has(path): boolean;

Parameters

path

string

Returns

boolean

importSettings()

importSettings(path): ImportSettings;

An asset's import settings (ADR 0040), read from its sidecar <path>.meta.json; the defaults when it has none. A slice reference (images/a.png#walk_0) reads its image's. Problems in the sidecar are reported once each as warnings, and the defaults used for those values. Per-platform overrides are resolved for Assets.platform (ADR 0115).

Parameters

path

string

Returns

ImportSettings

json()

json<T>(path): T;

A JSON file's parsed contents (scenes, prefabs, project settings). Throws for other files.

Type Parameters

T

T = unknown

Parameters

path

string

Returns

T

removeSource()

removeSource(source): void;

Parameters

source

AssetSource

Returns

void

text()

text(path): string;

A text file's contents (.xml, .css, .wgsl, .glsl, .md, .txt, JavaScript). Throws for other files: one that loads as a URL (a .cube LUT, an .obj) is read with Assets.bytes.

Parameters

path

string

Returns

string

url()

url(path): string;

The URL serving a file's bytes (images, audio, models, fonts, LUTs). Throws for JSON and text files, which load as their contents.

Parameters

path

string

Returns

string

Clone this wiki locally