threepipe
Version:
A modern 3D viewer framework built on top of three.js, written in TypeScript, designed to make creating high-quality, modular, and extensible 3D experiences on the web simple and enjoyable.
46 lines • 1.56 kB
TypeScript
import { IViewerPlugin, ThreeViewer } from '../../../viewer';
import { EntityComponentPlugin } from '../EntityComponentPlugin';
import { Class } from 'ts-browser-helpers';
import { TypedType } from './typeSystem';
import { UiObjectConfig } from 'uiconfig.js';
export interface ComponentCtx {
viewer: ThreeViewer;
ecp: EntityComponentPlugin;
plugin: <T extends IViewerPlugin>(type: Class<T> | string) => T;
}
export interface StatePropConfig<T = any> {
key: string;
label?: string;
type?: TypedType;
default?: T;
uiConfig?: Partial<UiObjectConfig>;
}
export interface ComponentDefn {
ComponentType: string;
StateProperties?: (string | StatePropConfig)[];
}
export interface ComponentJSON {
type: string;
state: Record<string, any>;
}
/**
* Sample usage -
* ```typescript
* export const physicsBodyType = ['static', 'dynamic', 'kinematic'] as const
* export type PhysicsBodyType = typeof physicsBodyType[number]
* export class PhysicsComponent extends Object3DComponent {
* static ComponentType = 'PhysicsComponent'
* static StateProperties: ComponentDefn['StateProperties'] = ['mass', {
* key: 'type',
* type: literalStrings(physicsBodyType),
* }]
* // ...
* }
* ```
* @param type
*/
export declare function literalStrings<T extends string | number | boolean = string | number | boolean>(type: T[] | readonly T[]): {
readonly oneOf: (`"${T}"`)[];
readonly type: "Union";
};
//# sourceMappingURL=../../../src/plugins/extras/components/componentTypes.d.ts.map