Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Doc: resource manager #428

Merged
merged 2 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions docs/resource-manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ this.engine.resourceManager.cancelNotLoaded("test.gltf");

> Note: Currently, unloading unfinished resources will throw an exception.

### 4. Resource Release

### 4. Get loaded resource

Loaded resources will be cached in *ResourceManager*, to get the loaded assets, you should call the `load` method again.

### 5. Resource Release

In order to avoid reloading resources, when the resources are loaded, they will be cached in _ResourceManager_. The cache itself takes up memory and video memory. When developers no longer need the cached content, they need to manually release the cached content.

Expand Down Expand Up @@ -127,7 +132,6 @@ engine.resourceManager

HDR Loader use [AssetType.HDR](${api}core/AssetType#HDR) to load texture with .HDR format,The resulting product is also a cube texture.


### 4. Environment
Oasis supports offline baking through [Oasis Editor](https://oasis.alipay.com/editor) or [glTF Viewer](https://oasisengine.cn/gltf-viewer) to get IBL baked products `*.env` file.

Expand Down Expand Up @@ -202,4 +206,4 @@ export class FBXLoader extends Loader<FBXResource> {
1. Use the [@resourceLoader](${api}core/resourceLoader) decorator to mark it as _ResourceLoader_, and pass in the type enumeration and the parsed resource suffix name. The above example `FBX` is a type enumeration, `["fbx"]` is the suffix name of the resource being parsed.
1. Override the [load](${api}core/ResourceManager#load) method, the `load` method will pass in `loadItem` and `resourceManager`, `loadItem` contains the basic information of loading, `resourceManager` can help Load other reference resources.
1. Return the [AssetPromise](${api}core/AssetPromise) object, `resolve` the resolved resource result, for example, FBX returns a specific `FBXResource`.
1. If an error is reported, it will be `reject` error.
1. If an error is reported, it will be `reject` error.
4 changes: 3 additions & 1 deletion docs/resource-manager.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ this.engine.resourceManager.cancelNotLoaded("test.gltf");
> 注意:目前取消加载未完成资源会抛出异常。


### 4. 资源释放
### 4. 获取加载过的资产
目前加载过的资产会缓存在 *ResourceManager* 中,如需获取加载过的资产,只需要再次调用 `load` 方法即可。
### 5. 资源释放
为了避免重复加载资源,当资源被加载完成之后,会被缓存在 *ResourceManager* 内。缓存本身会占用内存和显存,当开发者不再需要缓存的内容时,需要手动去释放缓存的内容。

> 注意:资源之间是相互依赖的。
Expand Down