UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

304 lines (303 loc) 18.6 kB
import { Plane } from '@jscad/modeling/src/maths/plane'; import { AnimationAction, AnimationMixer, Box3, Camera, CatmullRomCurve3, Color, Matrix4, Quaternion, Vector2, Vector3, Vector4, Intersection, Material, Object3D, Ray, Sphere, Texture, Euler } from 'three'; import { ParamInitValuesTypeMap } from '../../../../params/types/ParamInitValuesTypeMap'; import { ParamType } from '../../../../poly/ParamType'; import { BaseConnectionPoint } from './_Base'; import { BaseParamType } from '../../../../params/_Base'; import { BaseNodeType } from '../../../_Base'; export declare enum JsConnectionPointType { ANIMATION_MIXER = "AnimationMixer", ANIMATION_ACTION = "AnimationAction", BOOLEAN = "boolean", BOOLEAN_ARRAY = "boolean[]", BOX3 = "Box3", CAMERA = "Camera", CATMULL_ROM_CURVE3 = "CatmullRomCurve3", COLOR = "Color", COLOR_ARRAY = "Color[]", EULER = "Euler", EULER_ARRAY = "Euler[]", FLOAT = "float", FLOAT_ARRAY = "float[]", INT = "int", INT_ARRAY = "int[]", INTERSECTION = "Intersection", INTERSECTION_ARRAY = "Intersection[]", MATERIAL = "Material", MATRIX4 = "Matrix4", MATRIX4_ARRAY = "Matrix4[]", NODE = "Node", OBJECT_3D = "Object3D", OBJECT_3D_ARRAY = "Object3D[]", PARAM = "Param", PLANE = "Plane", QUATERNION = "Quaternion", QUATERNION_ARRAY = "Quaternion[]", RAY = "Ray", SPHERE = "Sphere", STRING = "string", STRING_ARRAY = "string[]", TEXTURE = "Texture", TEXTURE_ARRAY = "Texture[]", TRIGGER = "trigger", VECTOR2 = "Vector2", VECTOR2_ARRAY = "Vector2[]", VECTOR3 = "Vector3", VECTOR3_ARRAY = "Vector3[]", VECTOR4 = "Vector4", VECTOR4_ARRAY = "Vector4[]" } export type PrimitiveArrayElement = boolean | number | string; export type VectorArrayElement = Color | Euler | Matrix4 | Quaternion | Vector2 | Vector3 | Vector4; export declare const JS_CONNECTION_TYPES_FOR_CONSTANT: JsConnectionPointType[]; export declare function isJsConnectionPointNumber(type: JsConnectionPointType): boolean; export declare function isJsConnectionPointPrimitive(type: JsConnectionPointType): boolean; export declare function isJsConnectionPointVector(type: JsConnectionPointType): boolean; export declare function isJsConnectionPointArray(type: JsConnectionPointType): boolean; export declare const JS_CONNECTION_POINT_TYPES: Array<JsConnectionPointType>; type JsConnectionPointTypeToArrayTypeMapGeneric = { [key in JsConnectionPointType]: JsConnectionPointType; }; export interface JsIConnectionPointTypeToArrayTypeMap extends JsConnectionPointTypeToArrayTypeMapGeneric { [JsConnectionPointType.ANIMATION_MIXER]: JsConnectionPointType.ANIMATION_MIXER; [JsConnectionPointType.ANIMATION_ACTION]: JsConnectionPointType.ANIMATION_ACTION; [JsConnectionPointType.BOOLEAN]: JsConnectionPointType.BOOLEAN_ARRAY; [JsConnectionPointType.BOOLEAN_ARRAY]: JsConnectionPointType.BOOLEAN_ARRAY; [JsConnectionPointType.BOX3]: JsConnectionPointType.BOX3; [JsConnectionPointType.CAMERA]: JsConnectionPointType.CAMERA; [JsConnectionPointType.CATMULL_ROM_CURVE3]: JsConnectionPointType.CATMULL_ROM_CURVE3; [JsConnectionPointType.COLOR]: JsConnectionPointType.COLOR_ARRAY; [JsConnectionPointType.COLOR_ARRAY]: JsConnectionPointType.COLOR_ARRAY; [JsConnectionPointType.EULER]: JsConnectionPointType.EULER_ARRAY; [JsConnectionPointType.EULER_ARRAY]: JsConnectionPointType.EULER_ARRAY; [JsConnectionPointType.FLOAT]: JsConnectionPointType.FLOAT_ARRAY; [JsConnectionPointType.FLOAT_ARRAY]: JsConnectionPointType.FLOAT_ARRAY; [JsConnectionPointType.INT]: JsConnectionPointType.INT_ARRAY; [JsConnectionPointType.INT_ARRAY]: JsConnectionPointType.INT_ARRAY; [JsConnectionPointType.INTERSECTION]: JsConnectionPointType.INTERSECTION_ARRAY; [JsConnectionPointType.INTERSECTION_ARRAY]: JsConnectionPointType.INTERSECTION_ARRAY; [JsConnectionPointType.MATERIAL]: JsConnectionPointType.MATERIAL; [JsConnectionPointType.MATRIX4]: JsConnectionPointType.MATRIX4_ARRAY; [JsConnectionPointType.MATRIX4_ARRAY]: JsConnectionPointType.MATRIX4_ARRAY; [JsConnectionPointType.NODE]: JsConnectionPointType.NODE; [JsConnectionPointType.OBJECT_3D]: JsConnectionPointType.OBJECT_3D_ARRAY; [JsConnectionPointType.OBJECT_3D_ARRAY]: JsConnectionPointType.OBJECT_3D_ARRAY; [JsConnectionPointType.PARAM]: JsConnectionPointType.PARAM; [JsConnectionPointType.PLANE]: JsConnectionPointType.PLANE; [JsConnectionPointType.QUATERNION]: JsConnectionPointType.QUATERNION_ARRAY; [JsConnectionPointType.QUATERNION_ARRAY]: JsConnectionPointType.QUATERNION_ARRAY; [JsConnectionPointType.RAY]: JsConnectionPointType.RAY; [JsConnectionPointType.SPHERE]: JsConnectionPointType.SPHERE; [JsConnectionPointType.STRING]: JsConnectionPointType.STRING_ARRAY; [JsConnectionPointType.STRING_ARRAY]: JsConnectionPointType.STRING_ARRAY; [JsConnectionPointType.TEXTURE]: JsConnectionPointType.TEXTURE_ARRAY; [JsConnectionPointType.TEXTURE_ARRAY]: JsConnectionPointType.TEXTURE_ARRAY; [JsConnectionPointType.TRIGGER]: JsConnectionPointType.TRIGGER; [JsConnectionPointType.VECTOR2]: JsConnectionPointType.VECTOR2_ARRAY; [JsConnectionPointType.VECTOR2_ARRAY]: JsConnectionPointType.VECTOR2_ARRAY; [JsConnectionPointType.VECTOR3]: JsConnectionPointType.VECTOR3_ARRAY; [JsConnectionPointType.VECTOR3_ARRAY]: JsConnectionPointType.VECTOR3_ARRAY; [JsConnectionPointType.VECTOR4]: JsConnectionPointType.VECTOR4_ARRAY; [JsConnectionPointType.VECTOR4_ARRAY]: JsConnectionPointType.VECTOR4_ARRAY; } export declare const JsConnectionPointTypeToArrayTypeMap: JsIConnectionPointTypeToArrayTypeMap; type JsConnectionPointTypeFromArrayTypeMapGeneric = { [key in JsConnectionPointType]: JsConnectionPointType; }; export interface JsIConnectionPointTypeFromArrayTypeMap extends JsConnectionPointTypeFromArrayTypeMapGeneric { [JsConnectionPointType.ANIMATION_MIXER]: JsConnectionPointType.ANIMATION_MIXER; [JsConnectionPointType.ANIMATION_ACTION]: JsConnectionPointType.ANIMATION_ACTION; [JsConnectionPointType.BOOLEAN]: JsConnectionPointType.BOOLEAN; [JsConnectionPointType.BOOLEAN_ARRAY]: JsConnectionPointType.BOOLEAN; [JsConnectionPointType.BOX3]: JsConnectionPointType.BOX3; [JsConnectionPointType.CAMERA]: JsConnectionPointType.CAMERA; [JsConnectionPointType.CATMULL_ROM_CURVE3]: JsConnectionPointType.CATMULL_ROM_CURVE3; [JsConnectionPointType.COLOR]: JsConnectionPointType.COLOR; [JsConnectionPointType.COLOR_ARRAY]: JsConnectionPointType.COLOR; [JsConnectionPointType.EULER]: JsConnectionPointType.EULER; [JsConnectionPointType.EULER_ARRAY]: JsConnectionPointType.EULER; [JsConnectionPointType.FLOAT]: JsConnectionPointType.FLOAT; [JsConnectionPointType.FLOAT_ARRAY]: JsConnectionPointType.FLOAT; [JsConnectionPointType.INT]: JsConnectionPointType.INT; [JsConnectionPointType.INT_ARRAY]: JsConnectionPointType.INT; [JsConnectionPointType.INTERSECTION]: JsConnectionPointType.INTERSECTION; [JsConnectionPointType.INTERSECTION_ARRAY]: JsConnectionPointType.INTERSECTION; [JsConnectionPointType.MATERIAL]: JsConnectionPointType.MATERIAL; [JsConnectionPointType.MATRIX4]: JsConnectionPointType.MATRIX4; [JsConnectionPointType.MATRIX4_ARRAY]: JsConnectionPointType.MATRIX4; [JsConnectionPointType.NODE]: JsConnectionPointType.NODE; [JsConnectionPointType.OBJECT_3D]: JsConnectionPointType.OBJECT_3D; [JsConnectionPointType.OBJECT_3D_ARRAY]: JsConnectionPointType.OBJECT_3D; [JsConnectionPointType.PARAM]: JsConnectionPointType.PARAM; [JsConnectionPointType.PLANE]: JsConnectionPointType.PLANE; [JsConnectionPointType.QUATERNION]: JsConnectionPointType.QUATERNION; [JsConnectionPointType.QUATERNION_ARRAY]: JsConnectionPointType.QUATERNION; [JsConnectionPointType.RAY]: JsConnectionPointType.RAY; [JsConnectionPointType.SPHERE]: JsConnectionPointType.SPHERE; [JsConnectionPointType.STRING]: JsConnectionPointType.STRING; [JsConnectionPointType.STRING_ARRAY]: JsConnectionPointType.STRING; [JsConnectionPointType.TEXTURE]: JsConnectionPointType.TEXTURE; [JsConnectionPointType.TEXTURE_ARRAY]: JsConnectionPointType.TEXTURE; [JsConnectionPointType.TRIGGER]: JsConnectionPointType.TRIGGER; [JsConnectionPointType.VECTOR2]: JsConnectionPointType.VECTOR2; [JsConnectionPointType.VECTOR2_ARRAY]: JsConnectionPointType.VECTOR2; [JsConnectionPointType.VECTOR3]: JsConnectionPointType.VECTOR3; [JsConnectionPointType.VECTOR3_ARRAY]: JsConnectionPointType.VECTOR3; [JsConnectionPointType.VECTOR4]: JsConnectionPointType.VECTOR4; [JsConnectionPointType.VECTOR4_ARRAY]: JsConnectionPointType.VECTOR4; } export declare const JsConnectionPointTypeFromArrayTypeMap: JsIConnectionPointTypeFromArrayTypeMap; export type ArrayableConnectionPointType = JsConnectionPointType.BOOLEAN | JsConnectionPointType.COLOR | JsConnectionPointType.FLOAT | JsConnectionPointType.INT | JsConnectionPointType.INTERSECTION | JsConnectionPointType.MATRIX4 | JsConnectionPointType.QUATERNION | JsConnectionPointType.STRING | JsConnectionPointType.TEXTURE | JsConnectionPointType.VECTOR2 | JsConnectionPointType.VECTOR3 | JsConnectionPointType.VECTOR4; export declare const ARRAYABLE_CONNECTION_TYPES: Set<ArrayableConnectionPointType>; export type JsConnectionPointTypeArray = JsConnectionPointType.BOOLEAN_ARRAY | JsConnectionPointType.COLOR_ARRAY | JsConnectionPointType.FLOAT_ARRAY | JsConnectionPointType.INT_ARRAY | JsConnectionPointType.INTERSECTION_ARRAY | JsConnectionPointType.MATRIX4_ARRAY | JsConnectionPointType.OBJECT_3D_ARRAY | JsConnectionPointType.QUATERNION_ARRAY | JsConnectionPointType.STRING_ARRAY | JsConnectionPointType.TEXTURE_ARRAY | JsConnectionPointType.VECTOR2_ARRAY | JsConnectionPointType.VECTOR3_ARRAY | JsConnectionPointType.VECTOR4_ARRAY; export declare const ARRAY_JS_CONNECTION_TYPES: Array<JsConnectionPointTypeArray>; export declare const ARRAY_JS_CONNECTION_TYPES_SET: Set<JsConnectionPointTypeArray>; export type ParamConvertibleJsType = JsConnectionPointType.BOOLEAN | JsConnectionPointType.COLOR | JsConnectionPointType.FLOAT | JsConnectionPointType.INT | JsConnectionPointType.STRING | JsConnectionPointType.VECTOR2 | JsConnectionPointType.VECTOR3 | JsConnectionPointType.VECTOR4; export declare const PARAM_CONVERTIBLE_JS_CONNECTION_POINT_TYPES: Array<ParamConvertibleJsType>; export type PointAttributeJsType = JsConnectionPointType.COLOR | JsConnectionPointType.FLOAT | JsConnectionPointType.INT | JsConnectionPointType.VECTOR2 | JsConnectionPointType.VECTOR3 | JsConnectionPointType.VECTOR4; export declare const POINT_ATTRIBUTE_JS_CONNECTION_POINT_TYPES: Array<PointAttributeJsType>; export type JsDataType = PrimitiveArrayElement | Array<PrimitiveArrayElement> | VectorArrayElement | Array<VectorArrayElement> | AnimationMixer | AnimationAction | Box3 | Camera | CatmullRomCurve3 | Euler | Euler[] | Intersection | Array<Intersection> | Material | Object3D | Array<Object3D> | Ray | Sphere | Texture | Array<Texture> | BaseNodeType | BaseParamType | null; type JSConnectionPointTypeToDataTypeMapGeneric = { [key in JsConnectionPointType]: JsDataType; }; export interface JsIConnectionPointTypeToDataTypeMap extends JSConnectionPointTypeToDataTypeMapGeneric { [JsConnectionPointType.ANIMATION_MIXER]: AnimationMixer; [JsConnectionPointType.ANIMATION_ACTION]: AnimationAction; [JsConnectionPointType.BOOLEAN]: boolean; [JsConnectionPointType.BOOLEAN_ARRAY]: boolean[]; [JsConnectionPointType.BOX3]: Box3; [JsConnectionPointType.CAMERA]: Camera; [JsConnectionPointType.CATMULL_ROM_CURVE3]: CatmullRomCurve3; [JsConnectionPointType.COLOR]: Color; [JsConnectionPointType.COLOR_ARRAY]: Color[]; [JsConnectionPointType.EULER]: Euler; [JsConnectionPointType.EULER_ARRAY]: Euler[]; [JsConnectionPointType.FLOAT]: number; [JsConnectionPointType.FLOAT_ARRAY]: number[]; [JsConnectionPointType.INT]: number; [JsConnectionPointType.INT_ARRAY]: number[]; [JsConnectionPointType.INTERSECTION]: Intersection; [JsConnectionPointType.INTERSECTION_ARRAY]: Intersection[]; [JsConnectionPointType.MATERIAL]: Material; [JsConnectionPointType.MATRIX4]: Matrix4; [JsConnectionPointType.MATRIX4_ARRAY]: Matrix4[]; [JsConnectionPointType.NODE]: BaseNodeType; [JsConnectionPointType.OBJECT_3D]: Object3D; [JsConnectionPointType.OBJECT_3D_ARRAY]: Object3D[]; [JsConnectionPointType.PARAM]: BaseParamType; [JsConnectionPointType.PLANE]: Plane; [JsConnectionPointType.QUATERNION]: Quaternion; [JsConnectionPointType.QUATERNION_ARRAY]: Quaternion[]; [JsConnectionPointType.RAY]: Ray; [JsConnectionPointType.SPHERE]: Sphere; [JsConnectionPointType.STRING]: string; [JsConnectionPointType.STRING_ARRAY]: string[]; [JsConnectionPointType.TEXTURE]: Texture; [JsConnectionPointType.TEXTURE_ARRAY]: Texture[]; [JsConnectionPointType.TRIGGER]: null; [JsConnectionPointType.VECTOR2]: Vector2; [JsConnectionPointType.VECTOR2_ARRAY]: Vector2[]; [JsConnectionPointType.VECTOR3]: Vector3; [JsConnectionPointType.VECTOR3_ARRAY]: Vector3[]; [JsConnectionPointType.VECTOR4]: Vector4; [JsConnectionPointType.VECTOR4_ARRAY]: Vector4[]; } type JSConnectionPointTypeToParamTypeMapGeneric = { [key in JsConnectionPointType]: ParamType | undefined; }; export interface JsIConnectionPointTypeToParamTypeMap extends JSConnectionPointTypeToParamTypeMapGeneric { [JsConnectionPointType.ANIMATION_MIXER]: ParamType.BUTTON; [JsConnectionPointType.ANIMATION_ACTION]: ParamType.BUTTON; [JsConnectionPointType.BOOLEAN]: ParamType.BOOLEAN; [JsConnectionPointType.BOOLEAN_ARRAY]: ParamType.BUTTON; [JsConnectionPointType.BOX3]: ParamType.BUTTON; [JsConnectionPointType.CAMERA]: ParamType.BUTTON; [JsConnectionPointType.CATMULL_ROM_CURVE3]: ParamType.BUTTON; [JsConnectionPointType.COLOR]: ParamType.COLOR; [JsConnectionPointType.COLOR_ARRAY]: ParamType.BUTTON; [JsConnectionPointType.EULER]: ParamType.BUTTON; [JsConnectionPointType.EULER_ARRAY]: ParamType.BUTTON; [JsConnectionPointType.FLOAT]: ParamType.FLOAT; [JsConnectionPointType.FLOAT_ARRAY]: ParamType.BUTTON; [JsConnectionPointType.INT]: ParamType.INTEGER; [JsConnectionPointType.INT_ARRAY]: ParamType.BUTTON; [JsConnectionPointType.INTERSECTION]: ParamType.BUTTON; [JsConnectionPointType.INTERSECTION_ARRAY]: ParamType.BUTTON; [JsConnectionPointType.MATERIAL]: ParamType.BUTTON; [JsConnectionPointType.MATRIX4]: ParamType.BUTTON; [JsConnectionPointType.MATRIX4_ARRAY]: ParamType.BUTTON; [JsConnectionPointType.NODE]: ParamType.NODE_PATH; [JsConnectionPointType.OBJECT_3D]: ParamType.BUTTON; [JsConnectionPointType.OBJECT_3D_ARRAY]: ParamType.BUTTON; [JsConnectionPointType.PARAM]: ParamType.PARAM_PATH; [JsConnectionPointType.PLANE]: ParamType.BUTTON; [JsConnectionPointType.QUATERNION]: ParamType.BUTTON; [JsConnectionPointType.QUATERNION_ARRAY]: ParamType.BUTTON; [JsConnectionPointType.RAY]: ParamType.BUTTON; [JsConnectionPointType.SPHERE]: ParamType.BUTTON; [JsConnectionPointType.STRING]: ParamType.STRING; [JsConnectionPointType.STRING_ARRAY]: ParamType.BUTTON; [JsConnectionPointType.TEXTURE]: ParamType.BUTTON; [JsConnectionPointType.TEXTURE_ARRAY]: ParamType.BUTTON; [JsConnectionPointType.TRIGGER]: ParamType.BUTTON; [JsConnectionPointType.VECTOR2]: ParamType.VECTOR2; [JsConnectionPointType.VECTOR2_ARRAY]: ParamType.BUTTON; [JsConnectionPointType.VECTOR3]: ParamType.VECTOR3; [JsConnectionPointType.VECTOR3_ARRAY]: ParamType.BUTTON; [JsConnectionPointType.VECTOR4]: ParamType.VECTOR4; [JsConnectionPointType.VECTOR4_ARRAY]: ParamType.BUTTON; } export declare const JsConnectionPointTypeToParamTypeMap: JsIConnectionPointTypeToParamTypeMap; type JsParamTypeToConnectionPointTypeMapGeneric = { [key in ParamType]: JsConnectionPointType | undefined; }; export interface IJsParamTypeToConnectionPointTypeMap extends JsParamTypeToConnectionPointTypeMapGeneric { [ParamType.BOOLEAN]: JsConnectionPointType.BOOLEAN; [ParamType.COLOR]: JsConnectionPointType.COLOR; [ParamType.FLOAT]: JsConnectionPointType.FLOAT; [ParamType.INTEGER]: JsConnectionPointType.INT; [ParamType.FOLDER]: undefined; [ParamType.VECTOR2]: JsConnectionPointType.VECTOR2; [ParamType.VECTOR3]: JsConnectionPointType.VECTOR3; [ParamType.VECTOR4]: JsConnectionPointType.VECTOR4; [ParamType.BUTTON]: undefined; [ParamType.NODE_PATH]: JsConnectionPointType.NODE; [ParamType.PARAM_PATH]: JsConnectionPointType.PARAM; [ParamType.RAMP]: undefined; [ParamType.STRING]: JsConnectionPointType.STRING; } export declare const JsParamTypeToConnectionPointTypeMap: IJsParamTypeToConnectionPointTypeMap; export type ConnectionPointInitValueMapGeneric = { [key in JsConnectionPointType]: ParamInitValuesTypeMap[JsIConnectionPointTypeToParamTypeMap[key]]; }; export declare const JsConnectionPointInitValueMap: ConnectionPointInitValueMapGeneric; export type ConnectionPointComponentsCountMapGeneric = { [key in JsConnectionPointType]: number; }; export declare const JsConnectionPointComponentsCountMap: ConnectionPointComponentsCountMapGeneric; export interface JsConnectionPointData<T extends JsConnectionPointType> { name: string; type: T; isArray?: boolean; } interface JsConnectionPointOptions<T extends JsConnectionPointType> { inNodeDefinition?: boolean; init_value?: ConnectionPointInitValueMapGeneric[T]; } export declare const JS_CONNECTION_POINT_IN_NODE_DEF: JsConnectionPointOptions<JsConnectionPointType>; export declare class JsConnectionPoint<T extends JsConnectionPointType> extends BaseConnectionPoint { protected _type: T; protected _options?: JsConnectionPointOptions<T> | undefined; protected _json: JsConnectionPointData<T> | undefined; protected _init_value?: ConnectionPointInitValueMapGeneric[T]; protected _isArray: boolean; constructor(_name: string, _type: T, _options?: JsConnectionPointOptions<T> | undefined); type(): T; are_types_matched(src_type: string, dest_type: string): boolean; get param_type(): JsIConnectionPointTypeToParamTypeMap[T]; get init_value(): ConnectionPointInitValueMapGeneric[T] | undefined; toJSON(): JsConnectionPointData<T>; protected _createJSON(): JsConnectionPointData<T>; } export type BaseJsConnectionPoint = JsConnectionPoint<JsConnectionPointType>; export {};