Class: Loader
アセット(画像、動画)の読み込み管理を行います。
loader 変数として negl からインポートして使用することができます。
取得方法
import { loader } from "negl";
// or
window.negl.loaderSince
1.0.0
Table of contents
Properties
Methods
Properties
isLoaded
• isLoaded: boolean = false
全てのアセットの読み込みが完了している場合 true, それ以外 false
Default Value
false
textureCache
• textureCache: Map<string, undefined | Texture>
URLとそれに紐づくアセットから生成したテクスチャのマッピングを保持します。もし、URLでアセットが取得できなかった場合はundefinedが格納されます。
Methods
getTexByElement
▸ getTexByElement(el): Promise<Texes>
HTMLに紐づくテクスチャを取得
const texes = await loader.getTexByElement(el);Parameters
| Name | Type | Description |
|---|---|---|
el | HTMLElement | HTML要素 |
Returns
Promise<Texes>
HTML要素に紐付く全てのテクスチャ
loadTex
▸ loadTex(url): Promise<undefined | Texture>
urlに設定されたアセット(画像、動画)の読み込み、テクスチャを返却します。
const tex = await loader.loadTex('/img/sample.jpg');Parameters
| Name | Type |
|---|---|
url | string |
Returns
Promise<undefined | Texture>