vanilladocs
vanillapunch.com
API / resource/blobasset

resource/blobasset

블롭 애셋. (바이너리)

Blob asset. (binary)

BlobAssetextends Asset

짝Counterpart: vanilla-engine BlobAsset

블롭 애셋. (바이너리)

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());
생성자constructorconstructor()#0.0.9 부터since 0.0.9소스source

생성.

Constructor.

짝Counterpart: vanilla-engine BlobAsset.new

메서드methodasync load(assetPath)#0.0.9 부터since 0.0.9소스source

비동기 애셋 로드.

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

메서드methodloadFromBytes(assetPath, bytes)#0.4.0 부터since 0.4.0소스source

이미 가진 바이트로 읽기. (이미 읽혔어도 새 바이트로 바꾼다)

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

메서드methodgetBlob()#0.0.9 부터since 0.0.9소스source

블롭 반환.

Returns the blob.

반환ReturnsBlob 받은 블롭. (읽기 전이면 null)The fetched blob. (null before loading)

짝Counterpart: vanilla-engine BlobAsset.get_blob