Skip to content
On this page

kagurajs - v0.2.7 / Exports / Asset

Class: Asset

Kagura asset class.

Remarks

It is KaguraJS asset class. It does manage game asset. import:

ts
import { Asset } from "kagurajs"

Example

ts
// On Vite
import { Asset } from "kagurajs"
import cat from "./assets/cat.png"

const catAsset = new Asset().fromURL(cat) // Load asset via Vite import.

Example

ts
// Not use esm
const { Asset } = kagura

const catAsset = new Asset().fromURL("/assets/cat.png") // Load asset via raw URL.

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Asset()

Defined in

src/assets/asset.ts:32

Properties

#blobData

Private #blobData: Blob

Defined in

src/assets/asset.ts:30


#blobURL

Private #blobURL: URL

Defined in

src/assets/asset.ts:31

Accessors

blob

get blob(): Blob

Returns

Blob

Defined in

src/assets/asset.ts:80


url

get url(): URL

Returns asset's URL.

Returns

URL

A asset's URL

Defined in

src/assets/asset.ts:76

Methods

fromBlob

fromBlob(blob): Asset

Load asset from Blob.

Parameters

NameTypeDescription
blobBlobLoad blob Object

Returns

Asset

Defined in

src/assets/asset.ts:43


fromResponse

fromResponse(response): Promise<Asset>

Parameters

NameType
responseResponse

Returns

Promise<Asset>

Defined in

src/assets/asset.ts:66


fromURL

fromURL(url): Promise<Asset>

Load asset from URL.

Parameters

NameType
urlstring | URL

Returns

Promise<Asset>

Example

ts
const assets = new Asset().fromURL(url)

Defined in

src/assets/asset.ts:57


getDataUrl

getDataUrl(): Promise<string>

Returns

Promise<string>

Defined in

src/assets/asset.ts:84


getPixiTexure

getPixiTexure(): Promise<Texture<Resource>>

Returns

Promise<Texture<Resource>>

Defined in

src/assets/asset.ts:88