Skip to main content

WebAsset

@physion/app / Exports / WebAsset

Class: WebAsset

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 WebAsset(url?): WebAsset

Parameters

NameTypeDefault value
urlstring""

Returns

WebAsset

Overrides

Asset.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 CoreObject.name of the object.

Inherited from

Asset.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

Asset.EVT_PROPERTY_CHANGED


EVT_UPDATED

Static Readonly EVT_UPDATED: "updated"

Inherited from

Asset.EVT_UPDATED

Accessors

flags

get flags(): CoreObjectFlags

Returns

CoreObjectFlags

Inherited from

Asset.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

Asset.id


metaObject

get metaObject(): undefined | MetaObject

Returns the MetaObject that describes this class

Returns

undefined | MetaObject

Inherited from

Asset.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 CoreObject.EVT_NAME_CHANGED signal will be emitted.

Returns

string

Inherited from

Asset.name

set name(v): void

Parameters

NameType
vstring

Returns

void

Inherited from

Asset.name


url

get url(): string

Returns

string

set url(v): void

Parameters

NameType
vstring

Returns

void

Methods

deserialize

deserialize(d): void

Parameters

NameType
dany

Returns

void

Overrides

Asset.deserialize


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

Asset.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

Asset.getState


getType

getType(): AssetType

Returns

AssetType

Inherited from

Asset.getType


serialize

serialize(): Object

Returns

Object

NameType
idstring
namestring
typeAssetType
urlstring

Overrides

Asset.serialize


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

Asset.setExtras


setFlag

setFlag(flag, on?): void

Parameters

NameTypeDefault value
flagCoreObjectFlagsundefined
onbooleantrue

Returns

void

Inherited from

Asset.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

Asset.setState


testFlag

testFlag(flag): boolean

Parameters

NameType
flagCoreObjectFlags

Returns

boolean

Inherited from

Asset.testFlag