Skip to main content

Asset

@physion/app / Exports / Asset

Class: Asset

Serves as the base class for most classes in Physion.

CoreObject itself extends EventEmitter to allow notifying the outside world on important events.

Hierarchy

Constructors

constructor

new Asset()

Constructs a new instance.

A unique id will be assigned to the newly created instance.

Inherited from

CoreObject.constructor

Properties

EVT_NAME_CHANGED

Static Readonly EVT_NAME_CHANGED: "nameChanged"

The name of the event that is emitted whenever the name of this object changes.

The argument suplied is the new name of the object.

Inherited from

CoreObject.EVT_NAME_CHANGED


EVT_PROPERTY_CHANGED

Static Readonly EVT_PROPERTY_CHANGED: "propertyChanged"

The name of the event that is emitted whenever a property of this object changes.

The arguments supplied are: (1) The name of the property that has changed and (2) the new value of that property.

Inherited from

CoreObject.EVT_PROPERTY_CHANGED


EVT_UPDATED

Static Readonly EVT_UPDATED: "updated"

Accessors

flags

get flags(): CoreObjectFlags

Returns

CoreObjectFlags

Inherited from

CoreObject.flags


id

get id(): string

Object's (unique) id

Note that the id of the object cannot be set (it is automatically assigned upon construction)

Returns

string

Inherited from

CoreObject.id


metaObject

get metaObject(): undefined | MetaObject

Returns the MetaObject that describes this class

Returns

undefined | MetaObject

Inherited from

CoreObject.metaObject


name

get name(): string

The object's name

The object's name is a free text value which defaults to an empty string.

Note that when the name of the object changes, the EVT_NAME_CHANGED signal will be emitted.

Returns

string

Overrides

CoreObject.name

set name(v): void

Parameters

NameType
vstring

Returns

void

Overrides

CoreObject.name

Methods

deserialize

deserialize(d): void

Parameters

NameType
dISerializedAsset

Returns

void


getExtras

getExtras(): any

Returns any extra data that this object needs to save during serialization.

In some cases an object might need to save some extra data without necessarily this extra data being part of its state (e.g. the AssetsLibrary of a Scene). In these cases subclasses can re-implement this method and return the data required.

The default implementation returns undefined meaning that no extra data needs to be saved during serialization.

Returns

any

Inherited from

CoreObject.getExtras


getState

getState(minified?): any

Returns this object's state

The object's state is an object containing key/value pairs corresponding to this object's properties. For example:

{
id: "Ssba4ch5ruok",
name: "Circle",
radius: 2,
// ...
}

To avoid including properties that are currently in their default value you can set minified = true when calling getState.

Note that read-only properties are not part of the object's state (with the exception of the id)

Parameters

NameTypeDefault valueDescription
minifiedbooleanfalseWhether to return a minified state or not

Returns

any

Inherited from

CoreObject.getState


getType

Abstract getType(): AssetType

Returns

AssetType


serialize

serialize(): ISerializedAsset

Returns

ISerializedAsset


setExtras

setExtras(_x): boolean

Sets any extra data that this object needs during de-serialization.

Returns true on success, otherwise returns false.

The default implementation does nothing and returns true.

Parameters

NameType
_xany

Returns

boolean

Inherited from

CoreObject.setExtras


setFlag

setFlag(flag, on?): void

Parameters

NameTypeDefault value
flagCoreObjectFlagsundefined
onbooleantrue

Returns

void

Inherited from

CoreObject.setFlag


setState

setState(state, updateId?): boolean

Sets the object's state

Parameters

NameTypeDefault valueDescription
stateanyundefinedThe state to be set
updateIdbooleantrueWhether to also update the id property

Returns

boolean

True on success otherwise false

Inherited from

CoreObject.setState


testFlag

testFlag(flag): boolean

Parameters

NameType
flagCoreObjectFlags

Returns

boolean

Inherited from

CoreObject.testFlag