@serializable and other decorators
Complete reference for TypeScript decorators in Needle Engine. Learn how to use @serializable for editor properties, @syncField for multiplayer networking, @validate for change callbacks, and @prefix
Examples
Serializable
import { Behaviour, serializable, EventList } from "@needle-tools/engine";
import { Object3D } from "three";
export class SomeComponentType extends Behaviour {}
export class ButtonObject extends Behaviour {
// you can omit the type if it's a primitive
// e.g. Number, String or Bool
@serializable()
myNumber: number = 42;
// otherwise add the concrete type that you want to serialize to
@serializable(EventList)
onClick?: EventList;
@serializable(SomeComponentType)
myComponent?: SomeComponentType;
// Note that for arrays you still add the concrete type (not the array)
@serializable(Object3D)
myObjects?: Object3D[];
}SyncField
Validate
Prefix
Last updated