API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classAssetVariantSet

@codexo/exojs / assets / stable

Per-device selection between several files that stand for one logical asset. Without this layer a path is a path: one URL, one set of bytes, on every device. That is the wrong shape for two things a real project needs - a texture shipped once per compressed format family (no GPU supports them all) and once per display density - because the choice can only be made where the device is known, which is at load time. Selection happens before the source is canonicalized, so asset identity is keyed on the file that was actually chosen. Two devices picking different candidates therefore get different cache entries instead of one entry whose contents depend on who wrote it last. A source with no rule resolves to itself. Nothing is registered by default, so an application that never calls define pays one map lookup per load and nothing else.

1
props
5
methods
0
events
Import
import { AssetVariantSet } from '@codexo/exojs'

Per-device selection between several files that stand for one logical asset.

Without this layer a path is a path: one URL, one set of bytes, on every device. That is the wrong shape for two things a real project needs - a texture shipped once per compressed format family (no GPU supports them all) and once per display density - because the choice can only be made where the device is known, which is at load time.

Selection happens before the source is canonicalized, so asset identity is keyed on the file that was actually chosen. Two devices picking different candidates therefore get different cache entries instead of one entry whose contents depend on who wrote it last.

A source with no rule resolves to itself. Nothing is registered by default, so an application that never calls define pays one map lookup per load and nothing else.

Constructors1
new(): AssetVariantSet
Methods5
clear(): this
Forget every rule. The profile is left alone - it describes the device, not the content.
Declare the candidates for one logical source, replacing any previous rule for it. source is the name callers keep using; it never has to exist as a file. Order the candidates most-wanted first: it breaks ties, though a supported compressed format outranks declaration order (see resolve).
resolve(source: string): string
The source a load of source should actually fetch. Among the eligible candidates the one carrying the most preferred compressed format wins, then the highest density, then the earliest declared. Format outranks density deliberately: it is what decides VRAM and transfer cost, and a project that wants density to dominate simply declares only the candidates it wants chosen. Returns source unchanged when it has no rule, and when it has one whose candidates are all ineligible.
undefine(source: string): this
Drop the rule for source, so it resolves to itself again.
Properties1
Device capabilities selection is measured against. Written by the Application once the backend is initialized; assign it directly to override that - for a deterministic test, or to pin a format set a build already targets. Changing it does not re-resolve assets that are already resident: their identity was fixed by the profile in force when they were requested.
Source