import { BLEND_MODES } from '@gedit/render-engine'; import type { EmitterConfigV3 } from '@pixi/particle-emitter'; export interface MinAndMax { min: number; max: number; } export interface Pos { x: number; y: number; } export interface TimeValue { time: number; value: number | string; } export interface ListValue { list: TimeValue[]; isStepped?: boolean; } /** * @param minStart: number; * Minimum speed when initializing the particle, in world units/second. * @param maxStart: number; * Maximum speed when initializing the particle. in world units/second. * @param accel: {x: number; y: number} * Constant acceleration, in the coordinate space of the particle parent, in world units/second. * @param rotate?: boolean; * Rotate the particle with its direction of movement. * While initial movement direction reacts to rotation settings, this overrides any dynamic rotation. * Defaults to false. * @param maxSpeed?: number; * Maximum linear speed. 0 is unlimited. Defaults to 0. */ export interface MoveAccelerationConfig { accel: Pos; minStart: number; maxStart: number; rotate: boolean; maxSpeed: number; } export interface AlphaConfig { alpha: ListValue | number; } export interface AlphaStaticConfig { alpha: number; } export interface TextureConfig { textures?: string[]; } export interface AnimateTexture { texture: string; count: number; } export interface AnimatedConfig { framerate: number; loop: boolean; textures: AnimateTexture[]; } export interface AnimateTextureConfig { anim?: AnimatedConfig; anims?: AnimatedConfig[]; } export interface TextureTypeConfig extends TextureConfig, AnimateTextureConfig { type: | 'animatedRandom' | 'animatedSingle' | 'textureRandom' | 'textureOrdered'; } export interface BlendModeConfig { blendMode: BLEND_MODES; } export interface ColorConfig { color: ListValue | string; } // https://github.com/pixijs/particle-emitter/blob/master/src/behaviors/PathMovement.ts export interface MovePathConfig { path: string | ((x: number) => number); speed: ListValue; minMult?: number; } /** * @param minStart: number; * Minimum starting rotation of the particles, in degrees. 0 is facing right, 90 is upwards. * @param maxStart: number; * Maximum starting rotation of the particles, in degrees. 0 is facing right, 90 is upwards. * @param minSpeed: number; * Minimum rotation speed of the particles, in degrees/second. Positive is counter-clockwise. * @param maxSpeed: number; * Maximum rotation speed of the particles, in degrees/second. Positive is counter-clockwise. * @param accel: number; * Constant rotational acceleration of the particles, in degrees/second/second. */ export interface RotationConfig { minStart: number; maxStart: number; minSpeed: number; maxSpeed: number; accel: number; } // rotationStatic: MinAndMax export interface NoRotationConfig { rotation: number; } export interface ScaleConfig { scale: ListValue; minMult: number; } // scaleStatic: MinAndMax /** * @param pacing: number; * Description: Spacing between each particle spawned in a wave, in degrees. * @param start: number; * Description: Angle to start placing particles at, in degrees. 0 is facing right, 90 is facing upwards. * @param distance: number; * Description: Distance from the emitter to spawn particles, forming a ring/arc. */ export interface SpawnBurstConfig { spacing: number; start: number; distance: number; } export interface SpawnShapeConfig { type: 'rect' | 'polygonalChain' | 'torus'; data: | { x: number; y: number; width?: number; height?: number; // tours radius?: number; innerRadius?: number; rotation?: boolean; } // polygonalChain | Array>; } export interface SpawnPointConfig {} // TODO: https://github.com/pixijs/particle-emitter/blob/master/src/behaviors/SingleTexture.ts export interface MoveSpeedConfig { speed: ListValue; minMult?: number; } export interface SpawnRectAndTorusData { x: number; y: number; width?: number; height?: number; radius?: number; innerRadius?: number; // rotation?: boolean; affectRotation?: boolean; } export interface SpawnTypeConfig { // shape type?: 'rect' | 'polygonalChain' | 'torus' | 'spawnPoint' | 'spawnBurst'; data?: SpawnRectAndTorusData | Pos[] | Pos[][]; spacing?: number; start?: number; distance?: number; } export type BehaviorsConfig = | MinAndMax | MoveAccelerationConfig | AlphaConfig | AlphaStaticConfig | BlendModeConfig | MoveSpeedConfig | ColorConfig | MovePathConfig | RotationConfig | NoRotationConfig | ScaleConfig // 发射类型 | SpawnTypeConfig | SpawnShapeConfig | SpawnPointConfig | SpawnBurstConfig // 图片类型 | TextureTypeConfig | AnimatedConfig | TextureConfig; /* type BehaviorsType = | "moveAcceleration" | "alpha" | "alphaStatic" | "blendMode" | "spawnBurst" | "color" | "colorStatic" | "movePath" | "spawnPoint" | "textureRandom" | "rotation" | "rotationStatic" | "noRotation" | "scale" | "scaleStatic" | "spawnShape" | "moveSpeed"; */ export enum BehaviorsType { MOVE_ACCELERATION = 'moveAcceleration', ALPHA = 'alpha', ALPHA_STATIC = 'alphaStatic', BLEND_MODE = 'blendMode', COLOR = 'color', COLOR_STATIC = 'colorStatic', MOVE_PATH = 'movePath', TEXTURE_RANDOM = 'textureRandom', ROTATION = 'rotation', ROTATION_STATIC = 'rotationStatic', NO_ROTATION = 'noRotation', SCALE = 'scale', SCALE_STATIC = 'scaleStatic', MOVE_SPEED = 'moveSpeed', MOVE_SPEED_STATIC = 'moveSpeedStatic', SPAWN_TYPE = 'spawnType', TEXTURE_TYPE = 'textureType', SPAWN_POINT = 'spawnPoint', SPAWN_SHAPE = 'spawnShape', SPAWN_BURST = 'spawnBurst', } export interface BehaviorsSchema { type: BehaviorsType; label?: string; config: BehaviorsConfig; } export interface ParticlesSchema extends Omit { type?: string; example?: string; ease?: string; // behaviors 属性; behaviors: BehaviorsSchema[]; }