import { IRenderer2dComponent, Point2, RendererOptions } from '@gg-web-engine/core'; import { Application, ApplicationOptions } from 'pixi.js'; import { PixiSceneComponent } from './pixi-scene.component'; import { PixiCameraComponent } from './pixi-camera.component'; import { PixiGgWorld, PixiVisualTypeDocRepo2D } from '../types'; import { Observable } from 'rxjs'; export declare class PixiRendererComponent extends IRenderer2dComponent { readonly scene: PixiSceneComponent; camera: PixiCameraComponent; readonly canvas?: HTMLCanvasElement | undefined; readonly application: Application; private _initialized; /** Set by a `dispose()` that came before pixi's async `init` finished; init then destroys. */ private disposed; /** Emits once pixi's init has finished, also to late subscribers; completes empty on an earlier dispose. */ private readonly onInitialized$; protected world: PixiGgWorld | null; /** * `true` once pixi's asynchronous `Application.init` has finished: from then on `application`'s * `renderer`, `canvas` and event system exist. Never `true` for a renderer disposed before that. */ get initialized(): boolean; /** * Emits once and completes when pixi's asynchronous `Application.init` has finished - right away * for a subscriber that comes later. Completes without emitting when the renderer is disposed * before that. Wait for it before using `application.renderer` (its event system, a render * texture, a bitmap font installed against it). Drawing and resizing don't need it: a `render()` * or `resizeRenderer()` before init runs once init is done. * * @example * ```ts * const renderer = world.addRenderer(camera, canvas, { transparent: true }); * await firstValueFrom(renderer.renderer.initialized$); * renderer.renderer.application.renderer.events.cursorStyles.default = 'none'; * ``` */ get initialized$(): Observable; private debugView; /** Screen-fixed sprite showing the scene's background texture, when it has one. */ private backgroundSprite; /** The environment color currently overriding the renderer's clear color, `null` when none is. */ private appliedClearColor; /** The clear color and alpha the renderer was created with, captured when first overridden. */ private initialClear; private _physicsDebugViewActive; get physicsDebugViewActive(): boolean; set physicsDebugViewActive(value: boolean); constructor(scene: PixiSceneComponent, camera: PixiCameraComponent, canvas?: HTMLCanvasElement | undefined, options?: Partial); resizeRenderer(newSize: Point2): void; /** * Sets the native renderer's resolution, resizing its drawing buffer and keeping its size in CSS * pixels. Before pixi's async init has finished, the change is applied once it has. */ setResolution(resolution: number): void; /** The native renderer's texture system once the renderer is initialized, `null` before. */ get nativeTextureSystem(): unknown; addToWorld(world: PixiGgWorld): void; removeFromWorld(world: PixiGgWorld, dispose?: boolean): void; render(): void; /** * Shows the scene's `environment.background`: a color becomes the renderer's clear color, a * texture a sprite behind the world container scaled to cover the whole canvas. Without one the * renderer keeps the clear color it was created with. */ private applyBackground; /** * Overrides the renderer's clear color with `color`, or with `null` puts back the one the * renderer was created with. The alpha the renderer was created with is kept either way. */ private setClearColor; /** * A canvas the app passed in stays in the page (its layout is the app's), only a canvas pixi * created itself is removed. Either way pixi loses the WebGL context on destroy, so the canvas * can't host another renderer. */ private get nativeDestroyOptions(); /** * Destroys the pixi application and with it the WebGL context of its canvas, right away instead * of at garbage collection (a page gets only about 16 contexts). The canvas can't host another * renderer afterwards: core's `replaceCanvas` puts a blank copy in its place for the next one. */ dispose(): void; }