# core/asset (vanilla.js 0.4.0)

> https://vanillapunch.com/docs/vanilla.js/0.4.0/api/core/asset/

애셋.

## Asset extends Object

애셋.

예제: 이미지 애셋을 읽고 상태 보기

```js
import { ImageAsset } from "./build/vanilla.js";

const imageAsset = new ImageAsset();
await imageAsset.load("examples/assets/spritesheet.png");
console.log(imageAsset.getAssetType(), imageAsset.getAssetPath(), imageAsset.isLoaded());
imageAsset.unload();
console.log(imageAsset.isLoaded(), imageAsset.getAssetPath());
```

- `constructor()` (constructor, since 0.0.8): 생성.
- `async load(assetPath)` (method, since 0.0.8): 비동기 애셋 로드.
  - `assetPath` string: 애셋 경로. (이미 로드되었으면 아무것도 하지 않는다)
  - returns Promise<void>: 경로를 정하면 풀리는 프로미스. (이 기반 함수는 읽지 않고 로드 상태도 바꾸지 않는다)
- `unload()` (method, since 0.0.8): 애셋 언로드.
  - 그 자리에서 끝나고 아무것도 돌려주지 않는다. (로드되어 있었든 아니든 같다, 덮어쓴 하위 클래스와 같다)
- `setAssetType(assetType)` (method, since 0.0.10): 애셋 타입 설정.
  - `assetType` string: 애셋 타입 이름. ("image", "audio", "json", "text", "font", "blob" 같은, 하위 클래스가 생성자에서 정한다)
- `getAssetType()` (method, since 0.0.10): 애셋 타입 반환.
  - returns string: 애셋 타입 이름. (정하지 않았으면 "none")
- `setAssetPath(assetPath)` (method, since 0.0.9): 로드 경로 설정.
  - `assetPath` string: 로드 경로.
- `getAssetPath()` (method, since 0.0.9): 로드 경로 반환.
  - returns string: 로드 경로. (로드 전이나 언로드 뒤에는 빈 글)
- `setLoaded(isLoaded)` (method, since 0.0.9): 로드 되었는지 여부 설정.
  - `isLoaded` boolean: 로드 되었으면 참.
- `isLoaded()` (method, since 0.0.8): 로드 되었는지 여부 반환.
  - returns boolean: 로드 되었으면 참.

## AssetType (enum)

애셋 타입.

- `none` = `none`: 애셋 종류 없음.
- `image` = `image`: 이미지 애셋.
- `audio` = `audio`: 오디오 애셋.
- `json` = `json`: JSON 애셋.
- `text` = `text`: 텍스트 애셋.
- `font` = `font`: 글꼴 애셋.
- `blob` = `blob`: 바이너리 덩어리 애셋.
- `bunch` = `bunch`: 묶음 애셋.
- `visual` = `visual`: 비주얼 애셋.
