UNPKG

hytopia

Version:

The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.

268 lines (121 loc) 3.93 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [server](./server.md) &gt; [ModelRegistry](./server.modelregistry.md) ## ModelRegistry class Manages model data for all known models of the game. When to use: querying model metadata (bounds, node names, animations, trimesh). Do NOT use for: runtime mesh editing; use dedicated tooling or physics colliders. **Signature:** ```typescript export default class ModelRegistry ``` ## Remarks The ModelRegistry is created internally as a global singleton accessible via `ModelRegistry.instance`<!-- -->. Model data is preloaded during server startup and cached in memory. Pattern: call `ModelRegistry.hasModel` before accessing metadata to avoid warnings. Anti-pattern: calling `ModelRegistry.getTrimesh` every tick; it may allocate arrays. The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `ModelRegistry` class. ## Example ```typescript import { ModelRegistry } from 'hytopia'; const modelRegistry = ModelRegistry.instance; const boundingBox = modelRegistry.getBoundingBox('models/player.gltf'); ``` \*\*Category:\*\* Models ## Properties <table><thead><tr><th> Property </th><th> Modifiers </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> [instance](./server.modelregistry.instance.md) </td><td> `static` `readonly` </td><td> [ModelRegistry](./server.modelregistry.md) </td><td> The global ModelRegistry instance as a singleton. \*\*Category:\*\* Models </td></tr> <tr><td> [optimize](./server.modelregistry.optimize.md) </td><td> </td><td> boolean </td><td> Whether to generate optimized models if needed. Defaults to `true` in development, `false` in production. \*\*Category:\*\* Models </td></tr> </tbody></table> ## Methods <table><thead><tr><th> Method </th><th> Modifiers </th><th> Description </th></tr></thead> <tbody><tr><td> [getAllModelUris()](./server.modelregistry.getallmodeluris.md) </td><td> </td><td> Retrieves an array of all available model URIs. </td></tr> <tr><td> [getAnimationNames(modelUri)](./server.modelregistry.getanimationnames.md) </td><td> </td><td> Retrieves an array of all known animation names for a model. </td></tr> <tr><td> [getBoundingBox(modelUri)](./server.modelregistry.getboundingbox.md) </td><td> </td><td> Retrieves the bounding box of a model. </td></tr> <tr><td> [getDepth(modelUri)](./server.modelregistry.getdepth.md) </td><td> </td><td> Retrieves the Z-axis depth of a model for a scale of 1. </td></tr> <tr><td> [getHeight(modelUri)](./server.modelregistry.getheight.md) </td><td> </td><td> Retrieves the Y-axis height of a model for a scale of 1. </td></tr> <tr><td> [getNodeNames(modelUri)](./server.modelregistry.getnodenames.md) </td><td> </td><td> Retrieves the names of all nodes in a model. </td></tr> <tr><td> [getTrimesh(modelUri, scale)](./server.modelregistry.gettrimesh.md) </td><td> </td><td> Retrieves the trimesh of a model. </td></tr> <tr><td> [getWidth(modelUri)](./server.modelregistry.getwidth.md) </td><td> </td><td> Retrieves the X-axis width of a model for a scale of 1. </td></tr> <tr><td> [hasModel(modelUri)](./server.modelregistry.hasmodel.md) </td><td> </td><td> Checks if a model is registered in the model registry. </td></tr> <tr><td> [modelHasNode(modelUri, nodeName)](./server.modelregistry.modelhasnode.md) </td><td> </td><td> Checks if a model has a node with the given name. </td></tr> </tbody></table>