API / resource/blobasset
resource/blobasset
블롭 애셋. (바이너리)
Blob asset. (binary)
BlobAssetextends Asset
블롭 애셋. (바이너리)
Blob asset. (binary)
예제Example파일을 블롭으로 받기Fetch a file as a blob
import { BlobAsset } from "./build/vanilla.js";
const blobAsset = new BlobAsset();
await blobAsset.load("examples/assets/beep.wav");
const blob = blobAsset.getBlob();
console.log(blob.size, blob.type, blobAsset.isLoaded());비동기 애셋 로드.
Loads the asset asynchronously.
- assetPathstring
- 파일 경로. (이미 읽혔으면 아무것도 하지 않는다)File path. (does nothing if already loaded)
반환ReturnsPromise<void> 다 받으면 풀리는 프로미스. (실패 응답이면 console.error 로 알리고 거부된다)A promise resolved when fully fetched. (on a failed response it reports with console.error and rejects)
짝Counterpart: vanilla-engine BlobAsset.load
이미 가진 바이트로 읽기. (이미 읽혔어도 새 바이트로 바꾼다)
Loads from bytes already held. (Replaces with the new bytes even if already loaded)
- assetPathstring
- getAssetPath 에 쓸 이름.Name used for getAssetPath.
- bytesArrayBuffer | ArrayBufferView | Blob
- 파일의 바이트. (Blob 이면 그대로 쓰고, 아니면 Blob 으로 감싼다)Bytes of the file. (used as is if a Blob, otherwise wrapped in a Blob)
짝Counterpart: vanilla-engine BlobAsset.load_from_bytes
블롭 반환.
Returns the blob.
반환ReturnsBlob 받은 블롭. (읽기 전이면 null)The fetched blob. (null before loading)
짝Counterpart: vanilla-engine BlobAsset.get_blob