catalog
Import
Section titled “Import”import * as api from "@fungi.computer/art-library/catalog";Exports
Section titled “Exports”| Kind | Export | Description |
|---|---|---|
| class | CatalogError | A pack’s receipt is inconsistent with its files. |
| class | UnknownModelError | A model id that no catalog row has; suggestions are the nearest real models. |
| type alias | PackSource | Where the catalog reads a pack’s receipt and model bytes. |
| type alias | ModelKind | The catalog’s closed vocabulary of model categories. |
| type alias | ModelRow | A validated catalog row, including model dimensions and attribution. |
| constant | shippedPacks | Reads the packs shipped beside this module. |
| constant | packKinds | The kind of every model in a pack, or null for a pack whose receipt lists no
model rows (its files are parts or one-offs, and stay out of the catalog). Every
pack is named, so a new pack cannot ship without a decision here. |
| function | modelCatalog() | The library’s models, derived from each pack’s PROVENANCE.json and the files
on disk; nothing else lists them. A row exists for each item row of a receipt
(and each character), and packs without item rows are absent. A pack’s reused
rows name files another pack already lists, so they add none. |
| function | searchModels() | The rows that best match a query, best first. Query words match a row’s id words, then its tags and kind; a misspelling still matches its nearest id words. Rows that match nothing are left out. |
| function | requireModel() | The row with exactly this id. |
Node catalog discovery from @fungi.computer/art-library/catalog:
modelCatalog(), searchModels and requireModel.
This entrypoint reads the shipped provenance receipts and model bytes to derive
rows, including their dimensions and licences. Browser applications use the
generated models rows from @fungi.computer/art-library/models instead; do
not bundle this Node reader. Selecting a row does not load a mesh. Use the
/three entrypoint’s modelLoader() and a bundled asset URL for that step.
Example
Section titled “Example”import { modelCatalog, requireModel, searchModels,} from "@fungi.computer/art-library/catalog";
const rows = await modelCatalog();const candidates = searchModels(rows, "alpaca", { kind: "animal" });const mascot = requireModel(rows, "animated-animals/alpaca");console.log(candidates, mascot.originalLicense);CatalogErrorclass
Section titled “CatalogError”A pack’s receipt is inconsistent with its files.
Extends
Section titled “Extends”Error
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CatalogError(message?): CatalogError;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
message? |
string |
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”Error.constructor;Constructor
Section titled “Constructor”new CatalogError(message?, options?): CatalogError;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
message? |
string |
options? |
ErrorOptions |
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”Error.constructor;Properties
Section titled “Properties”readonly name: "CatalogError" = "CatalogError";Stable diagnostic name for a receipt/file inconsistency.
Overrides
Section titled “Overrides”Error.name;UnknownModelErrorclass
Section titled “UnknownModelError”A model id that no catalog row has; suggestions are the nearest real models.
Extends
Section titled “Extends”Error
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new UnknownModelError(id, suggestions): UnknownModelError;Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
id |
string |
Requested id absent from the catalog. |
suggestions |
readonly Readonly<{ id: string; pack: | "animated-animals" | "buildings" | "cell-keys" | "characters" | "farm-animals" | "food-a" | "furnishings-b" | "interiors" | "inventory" | "medieval-village" | "modular-ar3" | "modular-guns" | "plain-bat" | "rifle" | "storage-a" | "storage-b" | "street-a" | "survival-loot" | "town-props-b" | "upper-floor-a" | "vehicles"; kind: | "item" | "character" | "animal" | "building" | "furniture" | "street" | "vehicle" | "food"; name: string; tags: string[]; description: string; width: number; height: number; depth: number; sizeSource: "declared" | "typical"; sizeNote: string | null; file: string; author: string; originalLicense: string; fileLicense: string; }>[] |
Nearest existing catalog rows, ordered by search relevance. |
Returns
Section titled “Returns”Overrides
Section titled “Overrides”Error.constructor;Properties
Section titled “Properties”readonly name: "UnknownModelError" = "UnknownModelError";Stable diagnostic name for a missing model id.
Overrides
Section titled “Overrides”Error.name;readonly id: string;Requested id absent from the catalog.
suggestions
Section titled “suggestions”readonly suggestions: readonly Readonly<{ id: string; pack: | "animated-animals" | "buildings" | "cell-keys" | "characters" | "farm-animals" | "food-a" | "furnishings-b" | "interiors" | "inventory" | "medieval-village" | "modular-ar3" | "modular-guns" | "plain-bat" | "rifle" | "storage-a" | "storage-b" | "street-a" | "survival-loot" | "town-props-b" | "upper-floor-a" | "vehicles"; kind: | "item" | "character" | "animal" | "building" | "furniture" | "street" | "vehicle" | "food"; name: string; tags: string[]; description: string; width: number; height: number; depth: number; sizeSource: "declared" | "typical"; sizeNote: string | null; file: string; author: string; originalLicense: string; fileLicense: string;}>[];Nearest existing catalog rows, ordered by search relevance.
PackSourcetype alias
Section titled “PackSource”type PackSource = object;Where the catalog reads a pack’s receipt and model bytes.
Methods
Section titled “Methods”receipt()
Section titled “receipt()”receipt(pack): Promise<string>;Read a pack’s provenance receipt as JSON text.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
pack |
| "animated-animals" | "buildings" | "cell-keys" | "characters" | "farm-animals" | "food-a" | "furnishings-b" | "interiors" | "inventory" | "medieval-village" | "modular-ar3" | "modular-guns" | "plain-bat" | "rifle" | "storage-a" | "storage-b" | "street-a" | "survival-loot" | "town-props-b" | "upper-floor-a" | "vehicles" |
Returns
Section titled “Returns”Promise<string>
model()
Section titled “model()”model(pack, file): Promise<Uint8Array<ArrayBufferLike>>;Read one model file relative to its pack.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
pack |
| "animated-animals" | "buildings" | "cell-keys" | "characters" | "farm-animals" | "food-a" | "furnishings-b" | "interiors" | "inventory" | "medieval-village" | "modular-ar3" | "modular-guns" | "plain-bat" | "rifle" | "storage-a" | "storage-b" | "street-a" | "survival-loot" | "town-props-b" | "upper-floor-a" | "vehicles" |
file |
string |
Returns
Section titled “Returns”Promise<Uint8Array<ArrayBufferLike>>
ModelKindtype alias
Section titled “ModelKind”type ModelKind = | "item" | "character" | "animal" | "building" | "furniture" | "street" | "vehicle" | "food";The catalog’s closed vocabulary of model categories.
ModelRowtype alias
Section titled “ModelRow”type ModelRow = Readonly<{ id: string; pack: | "animated-animals" | "buildings" | "cell-keys" | "characters" | "farm-animals" | "food-a" | "furnishings-b" | "interiors" | "inventory" | "medieval-village" | "modular-ar3" | "modular-guns" | "plain-bat" | "rifle" | "storage-a" | "storage-b" | "street-a" | "survival-loot" | "town-props-b" | "upper-floor-a" | "vehicles"; kind: | "item" | "character" | "animal" | "building" | "furniture" | "street" | "vehicle" | "food"; name: string; tags: string[]; description: string; width: number; height: number; depth: number; sizeSource: "declared" | "typical"; sizeNote: string | null; file: string; author: string; originalLicense: string; fileLicense: string;}>;A validated catalog row, including model dimensions and attribution.
shippedPacksconstant
Section titled “shippedPacks”const shippedPacks: PackSource;Reads the packs shipped beside this module.
packKindsconstant
Section titled “packKinds”const packKinds: object;The kind of every model in a pack, or null for a pack whose receipt lists no
model rows (its files are parts or one-offs, and stay out of the catalog). Every
pack is named, so a new pack cannot ship without a decision here.
Type Declaration
Section titled “Type Declaration”modelCatalog()function
Section titled “modelCatalog()”function modelCatalog(source?): Promise< readonly Readonly<{ id: string; pack: | "animated-animals" | "buildings" | "cell-keys" | "characters" | "farm-animals" | "food-a" | "furnishings-b" | "interiors" | "inventory" | "medieval-village" | "modular-ar3" | "modular-guns" | "plain-bat" | "rifle" | "storage-a" | "storage-b" | "street-a" | "survival-loot" | "town-props-b" | "upper-floor-a" | "vehicles"; kind: | "item" | "character" | "animal" | "building" | "furniture" | "street" | "vehicle" | "food"; name: string; tags: string[]; description: string; width: number; height: number; depth: number; sizeSource: "declared" | "typical"; sizeNote: string | null; file: string; author: string; originalLicense: string; fileLicense: string; }>[]>;The library’s models, derived from each pack’s PROVENANCE.json and the files
on disk; nothing else lists them. A row exists for each item row of a receipt
(and each character), and packs without item rows are absent. A pack’s reused
rows name files another pack already lists, so they add none.
Size comes from the model’s bounding box, scaled to the real height or length
its receipt gives (heightMetres or lengthMetres, else a
typicalLengthMetres with its note). A receipt that gives none is an error, so
every row is in metres.
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
source |
PackSource |
shippedPacks |
Returns
Section titled “Returns”Promise<readonly Readonly<{ id: string; pack: |
"animated-animals" | "buildings" | "cell-keys" | "characters" |
"farm-animals" | "food-a" | "furnishings-b" | "interiors" |
"inventory" | "medieval-village" | "modular-ar3" | "modular-guns" |
"plain-bat" | "rifle" | "storage-a" | "storage-b" | "street-a" |
"survival-loot" | "town-props-b" | "upper-floor-a" | "vehicles";
kind: | "item" | "character" | "animal" | "building" |
"furniture" | "street" | "vehicle" | "food"; name: string;
tags: string[]; description: string; width: number; height:
number; depth: number; sizeSource: "declared" | "typical";
sizeNote: string | null; file: string; author: string;
originalLicense: string; fileLicense: string; }>[]>
Throws
Section titled “Throws”CatalogError when a receipt and its files disagree.
searchModels()function
Section titled “searchModels()”function searchModels( rows, query, options?,): readonly Readonly<{ id: string; pack: | "animated-animals" | "buildings" | "cell-keys" | "characters" | "farm-animals" | "food-a" | "furnishings-b" | "interiors" | "inventory" | "medieval-village" | "modular-ar3" | "modular-guns" | "plain-bat" | "rifle" | "storage-a" | "storage-b" | "street-a" | "survival-loot" | "town-props-b" | "upper-floor-a" | "vehicles"; kind: | "item" | "character" | "animal" | "building" | "furniture" | "street" | "vehicle" | "food"; name: string; tags: string[]; description: string; width: number; height: number; depth: number; sizeSource: "declared" | "typical"; sizeNote: string | null; file: string; author: string; originalLicense: string; fileLicense: string;}>[];The rows that best match a query, best first. Query words match a row’s id words, then its tags and kind; a misspelling still matches its nearest id words. Rows that match nothing are left out.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
rows |
readonly Readonly<{ id: string; pack: | "animated-animals" | "buildings" | "cell-keys" | "characters" | "farm-animals" | "food-a" | "furnishings-b" | "interiors" | "inventory" | "medieval-village" | "modular-ar3" | "modular-guns" | "plain-bat" | "rifle" | "storage-a" | "storage-b" | "street-a" | "survival-loot" | "town-props-b" | "upper-floor-a" | "vehicles"; kind: | "item" | "character" | "animal" | "building" | "furniture" | "street" | "vehicle" | "food"; name: string; tags: string[]; description: string; width: number; height: number; depth: number; sizeSource: "declared" | "typical"; sizeNote: string | null; file: string; author: string; originalLicense: string; fileLicense: string; }>[] |
query |
string |
options |
{ kind?: | "item" | "character" | "animal" | "building" | "furniture" | "street" | "vehicle" | "food"; limit?: number; } |
options.kind? |
| "item" | "character" | "animal" | "building" | "furniture" | "street" | "vehicle" | "food" |
options.limit? |
number |
Returns
Section titled “Returns”readonly Readonly<{ id: string; pack: | "animated-animals" |
"buildings" | "cell-keys" | "characters" | "farm-animals" |
"food-a" | "furnishings-b" | "interiors" | "inventory" |
"medieval-village" | "modular-ar3" | "modular-guns" | "plain-bat" |
"rifle" | "storage-a" | "storage-b" | "street-a" | "survival-loot"
| "town-props-b" | "upper-floor-a" | "vehicles"; kind: | "item" |
"character" | "animal" | "building" | "furniture" | "street" |
"vehicle" | "food"; name: string; tags: string[]; description:
string; width: number; height: number; depth: number;
sizeSource: "declared" | "typical"; sizeNote: string | null;
file: string; author: string; originalLicense: string;
fileLicense: string; }>[]
requireModel()function
Section titled “requireModel()”function requireModel(rows, id): ModelRow;The row with exactly this id.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
rows |
readonly Readonly<{ id: string; pack: | "animated-animals" | "buildings" | "cell-keys" | "characters" | "farm-animals" | "food-a" | "furnishings-b" | "interiors" | "inventory" | "medieval-village" | "modular-ar3" | "modular-guns" | "plain-bat" | "rifle" | "storage-a" | "storage-b" | "street-a" | "survival-loot" | "town-props-b" | "upper-floor-a" | "vehicles"; kind: | "item" | "character" | "animal" | "building" | "furniture" | "street" | "vehicle" | "food"; name: string; tags: string[]; description: string; width: number; height: number; depth: number; sizeSource: "declared" | "typical"; sizeNote: string | null; file: string; author: string; originalLicense: string; fileLicense: string; }>[] |
id |
string |
Returns
Section titled “Returns”Throws
Section titled “Throws”UnknownModelError listing the 3 nearest real models.