Skip to content

Documentation / scene / PropertyAccessor

Type Alias: PropertyAccessor<T, U> ​

PropertyAccessor<T, U> = object

Defined in: libs/scene/src/utility/serialization/types.ts:148

Descriptor for a serializable property of a class/type.

This binds together:

  • Metadata: type, name, default, readonly, persistent, options
  • Accessors: get, set, add, delete, create for manipulating the underlying object state
  • Predicates: isValid, isNullable, isHidden to control UI and validation
  • Commands: command for action-style properties (type: 'command')
  • Utilities: getDefaultValue to compute defaults dynamically

The accessors are invoked with this bound to the owning object instance.

Type Parameters ​

T ​

T = object

The instance type that owns the property.

U ​

U extends string = ""

Properties ​

type ​

type: PropertyType

Defined in: libs/scene/src/utility/serialization/types.ts:150

The storage/serialization data type.


name ​

name: string

Defined in: libs/scene/src/utility/serialization/types.ts:152

Unique property name (stable identifier for tooling/serialization).


description? ​

optional description?: string

Defined in: libs/scene/src/utility/serialization/types.ts:154

Description of this property


phase? ​

optional phase?: number

Defined in: libs/scene/src/utility/serialization/types.ts:159

Optional evaluation phase/order hint (lower runs earlier). Useful for staged initialization or batched updates in editors.


readonly? ​

optional readonly?: boolean

Defined in: libs/scene/src/utility/serialization/types.ts:161

If true, the property is read-only in UI and programmatic setters may be disallowed.


default? ​

optional default?: any

Defined in: libs/scene/src/utility/serialization/types.ts:163

Default value used if none is provided. Can be a primitive, array, or object.


options? ​

optional options?: PropertyAccessorOptions

Defined in: libs/scene/src/utility/serialization/types.ts:170

Editor and validation options for this property.


get ​

get: <K>(this, value) => void

Defined in: libs/scene/src/utility/serialization/types.ts:179

Reads the current value from this into the provided value container.

Implementations should fully populate the appropriate lane(s) (e.g., num, str, etc.) according to the property's PropertyType.

Type Parameters ​

K ​

K extends string

Parameters ​

this ​

T

value ​

U extends "" ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>

Output container to be filled by the getter.

Returns ​

void


set? ​

optional set?: <K>(this, value, index?) => void | Promise<void>

Defined in: libs/scene/src/utility/serialization/types.ts:193

Writes an incoming value to this.

For array-like properties, index can target a specific element. Implementations should read from the appropriate lane(s) of value according to PropertyType.

Type Parameters ​

K ​

K extends string

Parameters ​

this ​

T

value ​

U extends "" ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>

Input container carrying the new value.

index? ​

number

Optional element index for array-like properties.

Returns ​

void | Promise<void>

Optionally Promise<void> if asynchronous work is required.


create? ​

optional create?: (this, ctor, index) => Nullable<object>

Defined in: libs/scene/src/utility/serialization/types.ts:207

Creates a new embedded/contained object for object-like properties.

Typically used for embedded or object_array to instantiate an element.

Parameters ​

this ​

T

ctor ​

GenericConstructor

Constructor to instantiate.

index ​

number

Target index where the new object will be inserted.

Returns ​

Nullable<object>

The newly created object instance.


delete? ​

optional delete?: (this, index) => void | Promise<void>

Defined in: libs/scene/src/utility/serialization/types.ts:214

Deletes an element from an array-like property or clears a value.

Parameters ​

this ​

T

index ​

number

Target element index.

Returns ​

void | Promise<void>

Optionally Promise<void> if asynchronous work is required.


add? ​

optional add?: <K>(this, value, index?) => void | Promise<void>

Defined in: libs/scene/src/utility/serialization/types.ts:224

Adds a new element/value to an array-like property.

If index is omitted, implementations may append to the end.

Type Parameters ​

K ​

K extends string

Parameters ​

this ​

T

value ​

U extends "" ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>

The value to add (read appropriate lane(s) per PropertyType).

index? ​

number

Optional insertion index.

Returns ​

void | Promise<void>

Optionally Promise<void> if asynchronous work is required.


isValid? ​

optional isValid?: (this) => boolean

Defined in: libs/scene/src/utility/serialization/types.ts:236

Validates the current state of this with respect to this property.

Returning false may block serialization or UI confirmation.

Parameters ​

this ​

T

Returns ​

boolean

true if valid, otherwise false.


isPersistent? ​

optional isPersistent?: (this) => boolean

Defined in: libs/scene/src/utility/serialization/types.ts:242

Indicates whether this property is serializable. Default is serializable if not present.

Parameters ​

this ​

T

Returns ​

boolean

true if persistent, otherwise false.


isNullable? ​

optional isNullable?: (this, index) => boolean

Defined in: libs/scene/src/utility/serialization/types.ts:251

Indicates whether a specific element or slot may be null or undefined.

Applies to array-like or optional properties.

Parameters ​

this ​

T

index ​

number

Target element index.

Returns ​

boolean

true if nullable, otherwise false.


isHidden? ​

optional isHidden?: (this, index, obj?) => boolean

Defined in: libs/scene/src/utility/serialization/types.ts:259

Controls visibility of a specific element or the property in UI.

Parameters ​

this ​

T

index ​

number

Target element index.

obj? ​

unknown

Value at index

Returns ​

boolean

true if hidden, otherwise false.


command? ​

optional command?: (this, index) => boolean

Defined in: libs/scene/src/utility/serialization/types.ts:268

Executes a command-style property.

Only meaningful for type: 'command'. Return value may indicate success or toggle state.

Parameters ​

this ​

T

index ​

number

Optional command index for multi-command groups.

Returns ​

boolean

Command result, commonly a boolean for toggle-like actions.


getDefaultValue? ​

optional getDefaultValue?: (this) => any

Defined in: libs/scene/src/utility/serialization/types.ts:274

Supplies a default value dynamically at runtime.

If provided, this takes precedence over the static default field.

Parameters ​

this ​

T

Returns ​

any

Released under the MIT License.