hytopia
Version:
The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.
142 lines (67 loc) • 2.23 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [server](./server.md) > [AssetsLibrary](./server.assetslibrary.md)
## AssetsLibrary class
Manages the assets library and synchronization of assets to the local assets directory in development.
When to use: pulling assets from the shared library during local development. Do NOT use for: production asset loading; the library is disabled in production.
**Signature:**
```typescript
export default class AssetsLibrary
```
## Remarks
The AssetsLibrary is created internally as a global singleton accessible via `AssetsLibrary.instance`<!-- -->.
Assets automatically sync to local assets in development mode the first time an asset in the library is requested by the client. You generally do not need to call `AssetsLibrary.syncAsset` unless you have a specific reason to.
## Example
```typescript
import { AssetsLibrary } from 'hytopia';
const assetsLibrary = AssetsLibrary.instance;
assetsLibrary.syncAsset('assets/models/player.gltf');
```
\*\*Category:\*\* Assets
## Properties
<table><thead><tr><th>
Property
</th><th>
Modifiers
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[assetsLibraryPath](./server.assetslibrary.assetslibrarypath.md)
</td><td>
`static`
`readonly`
</td><td>
string \| null
</td><td>
The path to the assets library package. Null if assets library is not available.
\*\*Category:\*\* Assets
</td></tr>
<tr><td>
[instance](./server.assetslibrary.instance.md)
</td><td>
`static`
`readonly`
</td><td>
[AssetsLibrary](./server.assetslibrary.md)
</td><td>
The global AssetsLibrary instance as a singleton.
\*\*Category:\*\* Assets
</td></tr>
</tbody></table>
## Methods
<table><thead><tr><th>
Method
</th><th>
Modifiers
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[syncAsset(assetPath)](./server.assetslibrary.syncasset.md)
</td><td>
</td><td>
Synchronizes an asset from the assets library to the local assets directory.
</td></tr>
</tbody></table>