import { DisplayObject2dOpts, IDisplayObject2dComponentFactory, ParallaxLayer2dOpts, Shape2DDescriptor, Text2dStyle, ParticleSystem2dRenderOptions, TextureOptions } from '@gg-web-engine/core'; import { PixiDisplayObjectComponent } from './components/pixi-display-object.component'; import { Texture } from 'pixi.js'; import type { PixiSceneComponent } from './components/pixi-scene.component'; import { PixiParallaxLayerComponent } from './components/pixi-parallax-layer.component'; import { PixiVisualTypeDocRepo2D } from './types'; import { PixiTextComponent } from './components/pixi-text.component'; import { PixiCameraComponent } from './components/pixi-camera.component'; import { PixiAnimatedSpriteComponent } from './components/pixi-animated-sprite.component'; import { PixiParticleSystemComponent, PixiParticleSystemExtraOpts } from './components/pixi-particle-system.component'; /** A single named clip's location within a uniform-grid atlas - see `PixiGridAtlasOptions`. */ export type PixiGridAtlasClip = { /** Row index (0-based) within the grid this clip's frames live on. */ row: number; /** Number of consecutive frames (columns), starting at column 0, this clip uses. */ frameCount: number; /** Playback speed, in frames per second. Default 10. */ fps?: number; }; /** * Describes a texture atlas laid out as a uniform grid of equally-sized frames (the common case for * a hand-authored pixel-art character sheet) - one row per animation clip, `frameCount` consecutive * columns per clip starting at column 0. See `PixiFactory.createAnimatedSprite`. */ export type PixiGridAtlasOptions = { /** Width, in pixels, of a single frame cell. */ frameWidth: number; /** Height, in pixels, of a single frame cell. */ frameHeight: number; /** Named clips, keyed the same way `CharacterAnimation2dClipMap`/`CharacterAnimation2dState` expect * (e.g. `idle`/`walk`/`run`/`jump`) - any name is accepted, `IAnimatedDisplayObject2dComponent.animationNames` * just reflects whatever keys are given here. */ clips: Record; }; export type PixiDisplayObject3dOpts = DisplayObject2dOpts; export declare class PixiFactory extends IDisplayObject2dComponentFactory { private readonly scene?; /** * @param scene - The scene this factory belongs to; `prepare` uploads to its renderers. Without * one, `prepare` does nothing. */ constructor(scene?: PixiSceneComponent | undefined); createPrimitive(descriptor: Shape2DDescriptor, material?: PixiDisplayObject3dOpts): PixiDisplayObjectComponent; /** Fills an untextured shape's path with `material.color` and outlines it with `material.stroke`. */ private paint; /** A sprite showing `texture`, centered on its position, tinted with `material.color` if set. */ private texturedSprite; private createNativePrimitive; /** * Builds an animated sprite from a texture laid out as a uniform grid atlas (see * `PixiGridAtlasOptions`) - the entry point for a character sprite with named clips (idle/walk/ * run/jump, ...). Slices each clip's own row into `frameCount` individual frame textures sharing * `baseTexture`'s source (no copying/re-encoding, just distinct `frame` rectangles). */ createAnimatedSprite(baseTexture: Texture, options: PixiGridAtlasOptions): PixiAnimatedSpriteComponent; createParallaxLayer(options: ParallaxLayer2dOpts): PixiParallaxLayerComponent; createParticleSystem(options: ParticleSystem2dRenderOptions & Partial): PixiParticleSystemComponent; loadTexture(url: string, options?: TextureOptions): Promise; /** * Decodes an already-fetched image file into a texture of its own: unlike `loadTexture`, nothing * goes through pixi's global `Assets` cache, so the texture belongs to whoever asked for it and * is freed with `disposeTexture`. */ textureFromData(data: Blob, options?: TextureOptions): Promise; private decodeSvg; /** Frees a texture made by `textureFromData`, together with its image. */ disposeTexture(texture: Texture): void; /** * Uploads a texture to the GPU on every renderer drawing the scene, instead of on the first * frame it is visible in. A renderer that is not initialized yet is skipped. */ prepare(texture: Texture): Promise; createTextureFromCanvas(canvas: HTMLCanvasElement, options?: TextureOptions): Texture; createCamera(): PixiCameraComponent; createText(text: string, style?: Text2dStyle): PixiTextComponent; private applyTextureOptions; }