Documentation / scene / PropertyAccessor
Type Alias: PropertyAccessor<T, U>
PropertyAccessor<
T,U> =object
Defined in: libs/scene/src/utility/serialization/types.ts:146
Descriptor for a serializable property of a class/type.
This binds together:
- Metadata:
type,name,default,readonly,persistent,options - Accessors:
get,set,add,delete,createfor manipulating the underlying object state - Predicates:
isValid,isNullable,isHiddento control UI and validation - Commands:
commandfor action-style properties (type: 'command') - Utilities:
getDefaultValueto 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:148
The storage/serialization data type.
name
name:
string
Defined in: libs/scene/src/utility/serialization/types.ts:150
Unique property name (stable identifier for tooling/serialization).
description?
optionaldescription?:string
Defined in: libs/scene/src/utility/serialization/types.ts:152
Description of this property
phase?
optionalphase?:number
Defined in: libs/scene/src/utility/serialization/types.ts:157
Optional evaluation phase/order hint (lower runs earlier). Useful for staged initialization or batched updates in editors.
readonly?
optionalreadonly?:boolean
Defined in: libs/scene/src/utility/serialization/types.ts:159
If true, the property is read-only in UI and programmatic setters may be disallowed.
default?
optionaldefault?:any
Defined in: libs/scene/src/utility/serialization/types.ts:161
Default value used if none is provided. Can be a primitive, array, or object.
options?
optionaloptions?:PropertyAccessorOptions
Defined in: libs/scene/src/utility/serialization/types.ts:168
Editor and validation options for this property.
get
get: <
K>(this,value) =>void
Defined in: libs/scene/src/utility/serialization/types.ts:177
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?
optionalset?: <K>(this,value,index?) =>void|Promise<void>
Defined in: libs/scene/src/utility/serialization/types.ts:191
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?
optionalcreate?: (this,ctor,index) =>Nullable<object>
Defined in: libs/scene/src/utility/serialization/types.ts:205
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?
optionaldelete?: (this,index) =>void|Promise<void>
Defined in: libs/scene/src/utility/serialization/types.ts:212
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?
optionaladd?: <K>(this,value,index?) =>void|Promise<void>
Defined in: libs/scene/src/utility/serialization/types.ts:222
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?
optionalisValid?: (this) =>boolean
Defined in: libs/scene/src/utility/serialization/types.ts:234
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?
optionalisPersistent?: (this) =>boolean
Defined in: libs/scene/src/utility/serialization/types.ts:240
Indicates whether this property is serializable. Default is serializable if not present.
Parameters
this
T
Returns
boolean
true if persistent, otherwise false.
isNullable?
optionalisNullable?: (this,index) =>boolean
Defined in: libs/scene/src/utility/serialization/types.ts:249
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?
optionalisHidden?: (this,index,obj?) =>boolean
Defined in: libs/scene/src/utility/serialization/types.ts:257
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?
optionalcommand?: (this,index) =>boolean
Defined in: libs/scene/src/utility/serialization/types.ts:266
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?
optionalgetDefaultValue?: (this) =>any
Defined in: libs/scene/src/utility/serialization/types.ts:272
Supplies a default value dynamically at runtime.
If provided, this takes precedence over the static default field.
Parameters
this
T
Returns
any