Skip to main content

Abstract Class: Resource<Props>

Defined in: modules/core/src/adapter/resources/resource.ts:97

Base class for GPU (WebGPU/WebGL) Resources

Extended by​

Type Parameters​

Props​

Props extends ResourceProps

Constructors​

Constructor​

new Resource<Props>(device, props, defaultProps): Resource<Props>

Defined in: modules/core/src/adapter/resources/resource.ts:154

Create a new Resource. Called from Subclass

Parameters​

device​

Device

props​

Props

defaultProps​

Required<Props>

Returns​

Resource<Props>

Properties​

destroyed​

destroyed: boolean = false

Defined in: modules/core/src/adapter/resources/resource.ts:131

Whether this resource has been destroyed


device​

abstract readonly device: Device

Defined in: modules/core/src/adapter/resources/resource.ts:124

The device that this resource is associated with


handle​

abstract readonly handle: unknown

Defined in: modules/core/src/adapter/resources/resource.ts:126

The handle for the underlying resource, e.g. WebGL object or WebGPU handle


id​

id: string

Defined in: modules/core/src/adapter/resources/resource.ts:118

props.id, for debugging.


props​

readonly props: Required<Props>

Defined in: modules/core/src/adapter/resources/resource.ts:120

The props that this resource was created with


userData​

readonly userData: Record<string, unknown> = {}

Defined in: modules/core/src/adapter/resources/resource.ts:122

User data object, reserved for the application


defaultProps​

static defaultProps: Required<ResourceProps>

Defined in: modules/core/src/adapter/resources/resource.ts:99

Default properties for resource

Accessors​

[toStringTag]​

Get Signature​

get abstract [toStringTag](): string

Defined in: modules/core/src/adapter/resources/resource.ts:106

Returns​

string


isHandleBorrowed​

Get Signature​

get isHandleBorrowed(): boolean

Defined in: modules/core/src/adapter/resources/resource.ts:147

Whether luma.gl may only reference the opaque externally owned resource handle.

Returns​

boolean


ownsHandle​

Get Signature​

get ownsHandle(): boolean

Defined in: modules/core/src/adapter/resources/resource.ts:140

Whether luma.gl created and owns the underlying resource handle.

Returns​

boolean

Methods​

attachResource()​

attachResource(resource): void

Defined in: modules/core/src/adapter/resources/resource.ts:200

Attaches a resource. Attached resources are auto destroyed when this resource is destroyed Called automatically when sub resources are auto created but can be called by application

Parameters​

resource​

Resource<ResourceProps>

Returns​

void


delete()​

delete(): this

Defined in: modules/core/src/adapter/resources/resource.ts:181

Returns​

this

Deprecated​

Use destroy()


destroy()​

destroy(): void

Defined in: modules/core/src/adapter/resources/resource.ts:173

destroy can be called on any resource to release it before it is garbage collected.

Returns​

void


destroyAttachedResource()​

destroyAttachedResource(resource): void

Defined in: modules/core/src/adapter/resources/resource.ts:214

Destroys a resource (only if owned), and removes from the owned (auto-destroy) list for this resource.

Parameters​

resource​

Resource<ResourceProps>

Returns​

void


destroyAttachedResources()​

destroyAttachedResources(): void

Defined in: modules/core/src/adapter/resources/resource.ts:221

Destroy all owned resources. Make sure the resources are no longer needed before calling.

Returns​

void


detachResource()​

detachResource(resource): void

Defined in: modules/core/src/adapter/resources/resource.ts:207

Detach an attached resource. The resource will no longer be auto-destroyed when this resource is destroyed.

Parameters​

resource​

Resource<ResourceProps>

Returns​

void


getProps()​

getProps(): object

Defined in: modules/core/src/adapter/resources/resource.ts:190

Combines a map of user props and default props, only including props from defaultProps

Returns​

object

returns a map of overridden default props


toJSON()​

toJSON(): string

Defined in: modules/core/src/adapter/resources/resource.ts:113

Compact serialization for assertion diffs and structured debug logs.

Returns​

string


toString()​

toString(): string

Defined in: modules/core/src/adapter/resources/resource.ts:108

Returns​

string