@needle-tools/engine
Version:
Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.
44 lines (43 loc) • 1.55 kB
TypeScript
import { type Constructor, type IComponent } from "./engine_types.js";
declare type setter = (v: any) => void;
declare type getter = () => any;
/**
* Marks a field to trigger the `onValidate` callback when its value changes.
* Useful for reacting to property changes from the editor or at runtime.
*
* Your component must implement `onValidate(property?: string)` to receive notifications.
*
* @param set Optional custom setter called before the value is assigned
* @param get Optional custom getter called when the value is read
*
* @example Basic usage
* ```ts
* export class MyComponent extends Behaviour {
* @serializable()
* @validate()
* color: Color = new Color(1, 0, 0);
*
* onValidate(property?: string) {
* if (property === "color") {
* console.log("Color changed to:", this.color);
* }
* }
* }
* ```
* @example With custom setter
* ```ts
* @validate(function(value) {
* console.log("Setting speed to", value);
* })
* speed: number = 1;
* ```
*/
export declare const validate: (set?: setter, get?: getter) => (target: IComponent | any, propertyKey: string, descriptor?: undefined) => void;
/** Experimental attribute
* Use to hook into another type's methods and run before the other methods run (similar to Harmony prefixes).
* Return false to prevent the original method from running.
*/
export declare const prefix: <T>(type: Constructor<T>) => (target: IComponent | any, _propertyKey: string | {
name: string;
}, _PropertyDescriptor: PropertyDescriptor) => void;
export {};