Class ModelConfig#
A model config (anira_model_config) built from the same *.model.json a native host
loads: await ModelConfig.fromUrl(anira, url) parses the file and fetches, relative to its
URL, the model file of every entry whose engine the module compiled in (or a custom engine’s),
attaching it as bytes. See Basic Usage.
- class ModelConfig(abi, config)#
A model config (anira_model_config), the web twin of
anira::ModelConfig, built from the same JSON file a native host loads. The file is parsed withanira_model_config_from_jsonand every model entry whose engine runs here gets its file fetched relative to the config’s URL and attached as bytes, so one*.model.json(the bundledextras/modelsones among them) serves native and web unchanged. Where the web differs:fromUrlandfromJsonfetch the model files (a browser has no file system to load them from), and the config is destroyed withdestroy()once the handlers built from it are prepared (a config is copied where it is used) or no longer needed.- Arguments:
abi (AniraBindings)
config (number)
- static async fromUrl(anira, url, options={})#
Fetch a
*.model.jsonand its model files; relative paths resolve againsturl.- Arguments:
anira (WithAbi)
url (string | URL)
options (Omit<ModelConfigLoadOptions, “baseUrl”>)
- Returns:
Promise<ModelConfig>
- static async fromJson(anira, json, options={})#
Parse a model config’s JSON text and fetch its model files (see
fromUrl).- Arguments:
anira (WithAbi)
json (string)
options (ModelConfigLoadOptions)
- Returns:
Promise<ModelConfig>
- static adopt(anira, ptr)#
Wrap a config pointer this object then owns (destroys).
- Arguments:
anira (WithAbi)
ptr (number)
- Returns:
ModelConfig
- setModelBytes(index, bytes)#
Replace model entry
index’s source withbytes, copied into the config (anira_model_config_set_model_bytes withANIRA_BYTES_COPY; the copy is the one ownership the web takes); chains, asanira::ModelConfig::set_model_bytes.- Arguments:
index (number)
bytes (Uint8Array)
- Returns:
this
- toJson()#
The config in v3 spelling (anira_model_config_to_json).
- Returns:
string
- native()#
The
anira_model_config*the raw entries take.- Returns:
number
- destroy()#