textmode.js 0.4.0 → 0.6.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/textmode.esm.js +2868 -2164
- package/dist/textmode.esm.min.js +2863 -2159
- package/dist/textmode.umd.js +11 -8
- package/dist/textmode.umd.min.js +11 -8
- package/dist/types/Textmode.d.ts +13 -22
- package/dist/types/index.d.ts +8 -6
- package/dist/types/rendering/index.d.ts +3 -3
- package/dist/types/rendering/webgl/batching/DrawQueue.d.ts +89 -0
- package/dist/types/rendering/webgl/{VAOManager.d.ts → batching/GeometryAttributeCache.d.ts} +4 -4
- package/dist/types/rendering/webgl/batching/InstanceAttributeBinder.d.ts +87 -0
- package/dist/types/rendering/webgl/{InstanceBatch.d.ts → batching/InstanceBatch.d.ts} +25 -34
- package/dist/types/rendering/webgl/batching/InstanceBuffer.d.ts +78 -0
- package/dist/types/rendering/webgl/{InstanceData.d.ts → batching/InstanceData.d.ts} +11 -18
- package/dist/types/rendering/webgl/batching/InstanceWriter.d.ts +70 -0
- package/dist/types/rendering/webgl/{Framebuffer.d.ts → core/Framebuffer.d.ts} +37 -39
- package/dist/types/rendering/webgl/core/Renderer.d.ts +64 -0
- package/dist/types/rendering/webgl/{Shader.d.ts → core/Shader.d.ts} +2 -23
- package/dist/types/rendering/webgl/core/interfaces/IFramebuffer.d.ts +103 -0
- package/dist/types/rendering/webgl/core/interfaces/IRenderer.d.ts +210 -0
- package/dist/types/rendering/webgl/geometries/{Arc.d.ts → 2d/Arc.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/{BezierCurve.d.ts → 2d/BezierCurve.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/{Ellipse.d.ts → 2d/Ellipse.d.ts} +6 -5
- package/dist/types/rendering/webgl/geometries/{Line.d.ts → 2d/Line.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/{Rectangle.d.ts → 2d/Rectangle.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/{Triangle.d.ts → 2d/Triangle.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/BaseGeometry.d.ts +30 -26
- package/dist/types/rendering/webgl/geometries/immediate/ImmediateQuad.d.ts +33 -0
- package/dist/types/rendering/webgl/geometries/index.d.ts +6 -6
- package/dist/types/rendering/webgl/geometries/utils/GeometryDescriptors.d.ts +31 -0
- package/dist/types/rendering/webgl/geometries/utils/GeometryGenerator.d.ts +16 -0
- package/dist/types/rendering/webgl/index.d.ts +15 -14
- package/dist/types/rendering/webgl/materials/Material.d.ts +26 -0
- package/dist/types/rendering/webgl/materials/MaterialManager.d.ts +63 -0
- package/dist/types/rendering/webgl/materials/index.d.ts +2 -0
- package/dist/types/rendering/webgl/pipeline/MaterialBatchPipeline.d.ts +63 -0
- package/dist/types/rendering/webgl/pipeline/index.d.ts +7 -0
- package/dist/types/rendering/webgl/state/RenderState.d.ts +143 -0
- package/dist/types/rendering/webgl/types/DrawCommand.d.ts +5 -3
- package/dist/types/rendering/webgl/types/GeometryTypes.d.ts +10 -10
- package/dist/types/rendering/webgl/types/RenderTypes.d.ts +1 -1
- package/dist/types/rendering/webgl/utils/GLUtils.d.ts +45 -0
- package/dist/types/rendering/webgl/utils/hash.d.ts +118 -0
- package/dist/types/textmode/AnimationController.d.ts +11 -21
- package/dist/types/textmode/Canvas.d.ts +10 -2
- package/dist/types/textmode/Grid.d.ts +2 -0
- package/dist/types/textmode/TextmodeColor.d.ts +57 -0
- package/dist/types/textmode/Textmodifier.d.ts +40 -212
- package/dist/types/textmode/interfaces/ITextmodifier.d.ts +272 -0
- package/dist/types/textmode/interfaces/index.d.ts +1 -0
- package/dist/types/textmode/loadables/TextmodeImage.d.ts +21 -0
- package/dist/types/textmode/loadables/TextmodeSource.d.ts +130 -0
- package/dist/types/textmode/loadables/TextmodeVideo.d.ts +237 -0
- package/dist/types/textmode/{font → loadables/font}/CharacterColorMapper.d.ts +1 -1
- package/dist/types/textmode/{font → loadables/font}/CharacterExtractor.d.ts +0 -10
- package/dist/types/textmode/{font → loadables/font}/TextmodeFont.d.ts +6 -3
- package/dist/types/textmode/{font → loadables/font}/TextureAtlas.d.ts +4 -11
- package/dist/types/textmode/{font → loadables/font}/typr/types.d.ts +0 -6
- package/dist/types/textmode/loadables/index.d.ts +5 -0
- package/dist/types/textmode/loading/LoadingPhaseTracker.d.ts +20 -0
- package/dist/types/textmode/loading/LoadingScreenManager.d.ts +170 -0
- package/dist/types/textmode/loading/LoadingScreenState.d.ts +22 -0
- package/dist/types/textmode/loading/LoadingScreenTheme.d.ts +26 -0
- package/dist/types/textmode/loading/LoadingScreenTransition.d.ts +17 -0
- package/dist/types/textmode/loading/index.d.ts +6 -0
- package/dist/types/textmode/loading/templates/SpinnerTemplate.d.ts +2 -0
- package/dist/types/textmode/loading/templates/index.d.ts +1 -0
- package/dist/types/textmode/loading/types.d.ts +251 -0
- package/dist/types/textmode/managers/KeyboardManager.d.ts +2 -3
- package/dist/types/textmode/managers/MouseManager.d.ts +1 -1
- package/dist/types/textmode/{plugins → managers}/PluginManager.d.ts +12 -15
- package/dist/types/textmode/managers/TouchManager.d.ts +0 -2
- package/dist/types/textmode/mixins/AnimationMixin.d.ts +2 -122
- package/dist/types/textmode/mixins/FontMixin.d.ts +2 -77
- package/dist/types/textmode/mixins/KeyboardMixin.d.ts +3 -85
- package/dist/types/textmode/mixins/MouseMixin.d.ts +3 -130
- package/dist/types/textmode/mixins/RenderingMixin.d.ts +2 -749
- package/dist/types/textmode/mixins/TextmodifierMixin.d.ts +2 -44
- package/dist/types/textmode/mixins/TouchMixin.d.ts +2 -187
- package/dist/types/textmode/mixins/index.d.ts +8 -8
- package/dist/types/textmode/mixins/interfaces/IAnimationMixin.d.ts +167 -0
- package/dist/types/textmode/mixins/interfaces/IFontMixin.d.ts +46 -0
- package/dist/types/textmode/mixins/interfaces/IKeyboardMixin.d.ts +235 -0
- package/dist/types/textmode/mixins/interfaces/IMouseMixin.d.ts +457 -0
- package/dist/types/textmode/mixins/interfaces/IRenderingMixin.d.ts +1085 -0
- package/dist/types/textmode/mixins/interfaces/ITouchMixin.d.ts +186 -0
- package/dist/types/textmode/types.d.ts +49 -0
- package/dist/types/textmode/utils/cssColor.d.ts +8 -0
- package/dist/types/utils/array.d.ts +34 -0
- package/dist/types/utils/math.d.ts +69 -0
- package/package.json +1 -1
- package/dist/types/rendering/webgl/DrawQueue.d.ts +0 -30
- package/dist/types/rendering/webgl/RenderPipeline.d.ts +0 -30
- package/dist/types/rendering/webgl/RenderState.d.ts +0 -73
- package/dist/types/rendering/webgl/Renderer.d.ts +0 -158
- package/dist/types/rendering/webgl/ShaderManager.d.ts +0 -66
- package/dist/types/rendering/webgl/geometries/NoiseGrid.d.ts +0 -1
- package/dist/types/textmode/TextmodeImage.d.ts +0 -161
- package/dist/types/textmode/mixins/ShaderMixin.d.ts +0 -1
- /package/dist/types/rendering/webgl/{StateCache.d.ts → utils/ViewportCache.d.ts} +0 -0
- /package/dist/types/textmode/{font → loadables/font}/MetricsCalculator.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/index.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/types.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/typr/Typr.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/utils/FontTableReader.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/utils/index.d.ts +0 -0
|
@@ -2,7 +2,7 @@ import { GLFramebuffer } from './Framebuffer';
|
|
|
2
2
|
/**
|
|
3
3
|
* Supported uniform value types
|
|
4
4
|
*/
|
|
5
|
-
type UniformValue = number | boolean | number[] | number[][] | Float32Array | Int32Array | GLFramebuffer | WebGLTexture;
|
|
5
|
+
export type UniformValue = number | boolean | number[] | number[][] | Float32Array | Int32Array | GLFramebuffer | WebGLTexture;
|
|
6
6
|
/**
|
|
7
7
|
* WebGL implementation of the shader abstraction.
|
|
8
8
|
* Provides GPU shader program management with automatic uniform handling and minification support.
|
|
@@ -32,31 +32,11 @@ export declare class GLShader {
|
|
|
32
32
|
* Reset texture unit counter and other state
|
|
33
33
|
*/
|
|
34
34
|
private _resetState;
|
|
35
|
-
$setUniforms(uniforms: Record<string,
|
|
36
|
-
/**
|
|
37
|
-
* Check if a uniform exists in this shader
|
|
38
|
-
*/
|
|
39
|
-
$hasUniform(name: string): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Get debug information about a uniform
|
|
42
|
-
*/
|
|
43
|
-
$getUniformInfo(name: string): {
|
|
44
|
-
type: number;
|
|
45
|
-
size: number;
|
|
46
|
-
} | null;
|
|
47
|
-
/**
|
|
48
|
-
* List all available uniforms for debugging
|
|
49
|
-
*/
|
|
50
|
-
$listUniforms(): Array<{
|
|
51
|
-
name: string;
|
|
52
|
-
type: number;
|
|
53
|
-
size: number;
|
|
54
|
-
}>;
|
|
35
|
+
$setUniforms(uniforms: Record<string, any>): void;
|
|
55
36
|
/**
|
|
56
37
|
* Set a single uniform value with automatic texture unit management and proper type detection
|
|
57
38
|
*/
|
|
58
39
|
$setUniform(name: string, value: UniformValue): void;
|
|
59
|
-
private _getNextTextureUnit;
|
|
60
40
|
/**
|
|
61
41
|
* Get the WebGL program
|
|
62
42
|
*/
|
|
@@ -67,4 +47,3 @@ export declare class GLShader {
|
|
|
67
47
|
*/
|
|
68
48
|
$dispose(): void;
|
|
69
49
|
}
|
|
70
|
-
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for managing offscreen rendering targets (framebuffers).
|
|
3
|
+
*
|
|
4
|
+
* Framebuffers are used to render content offscreen, enabling effects like:
|
|
5
|
+
* - Post-processing filters
|
|
6
|
+
* - Multi-pass rendering
|
|
7
|
+
* - Render-to-texture operations
|
|
8
|
+
* - Double buffering
|
|
9
|
+
*
|
|
10
|
+
* Framebuffers in this system support Multiple Render Targets (MRT), allowing
|
|
11
|
+
* multiple textures to be written simultaneously in a single render pass.
|
|
12
|
+
*/
|
|
13
|
+
export interface IFramebuffer {
|
|
14
|
+
/**
|
|
15
|
+
* Get the current framebuffer width in pixels/cells.
|
|
16
|
+
*/
|
|
17
|
+
readonly width: number;
|
|
18
|
+
/**
|
|
19
|
+
* Get the current framebuffer height in pixels/cells.
|
|
20
|
+
*/
|
|
21
|
+
readonly height: number;
|
|
22
|
+
/**
|
|
23
|
+
* Get all textures associated with this framebuffer.
|
|
24
|
+
*
|
|
25
|
+
* Useful for binding textures for reading in shaders.
|
|
26
|
+
*
|
|
27
|
+
* Textmode framebuffers allocate 4 attachments by default:
|
|
28
|
+
* - 0: Character data encoded in red and green channels
|
|
29
|
+
* - 1: Character colors
|
|
30
|
+
* - 2: Cell background colors
|
|
31
|
+
* - 3: Inversion, horizontal/flip flags, and rotation encoded in red, green, blue, alpha channels
|
|
32
|
+
*/
|
|
33
|
+
readonly textures: WebGLTexture[];
|
|
34
|
+
/**
|
|
35
|
+
* Update the framebuffer texture with canvas or video content.
|
|
36
|
+
* Note: Only updates the first attachment in multi-attachment mode.
|
|
37
|
+
*
|
|
38
|
+
* @param source - The HTML canvas or video element to copy from
|
|
39
|
+
* @ignore
|
|
40
|
+
*/
|
|
41
|
+
$update(source: HTMLCanvasElement | HTMLVideoElement): void;
|
|
42
|
+
/**
|
|
43
|
+
* Resize the framebuffer to new dimensions.
|
|
44
|
+
* This recreates the internal textures with the new size and invalidates any cached pixel data.
|
|
45
|
+
*
|
|
46
|
+
* @param width - New width in pixels/cells
|
|
47
|
+
* @param height - New height in pixels/cells
|
|
48
|
+
*/
|
|
49
|
+
resize(width: number, height: number): void;
|
|
50
|
+
/**
|
|
51
|
+
* Read pixels from a specific color attachment into an RGBA Uint8Array.
|
|
52
|
+
*
|
|
53
|
+
* The returned pixel data:
|
|
54
|
+
* - Is in RGBA format (4 bytes per pixel)
|
|
55
|
+
* - Has top-left origin (first pixel is top-left corner)
|
|
56
|
+
* - Is cached until the next render pass to this framebuffer
|
|
57
|
+
*
|
|
58
|
+
* @param attachmentIndex - The index of the color attachment to read (0-based)<br/>
|
|
59
|
+
* 0. Character data and transform info<br/>
|
|
60
|
+
* 1. Character colors<br/>
|
|
61
|
+
* 2. Cell background colors<br/>
|
|
62
|
+
* @returns A Uint8Array containing the pixel data in RGBA format
|
|
63
|
+
*/
|
|
64
|
+
readPixels(attachmentIndex: number): Uint8Array;
|
|
65
|
+
/**
|
|
66
|
+
* Begin drawing to this framebuffer.
|
|
67
|
+
*
|
|
68
|
+
* This method:
|
|
69
|
+
* - Flushes any pending draw calls to maintain proper render order
|
|
70
|
+
* - Saves the current framebuffer and viewport state
|
|
71
|
+
* - Binds this framebuffer as the render target
|
|
72
|
+
* - Clears all color attachments to transparent black
|
|
73
|
+
* - Sets the viewport to match the framebuffer dimensions
|
|
74
|
+
*
|
|
75
|
+
* All subsequent drawing operations will target this framebuffer until {@link end} is called.
|
|
76
|
+
*/
|
|
77
|
+
begin(): void;
|
|
78
|
+
/**
|
|
79
|
+
* End rendering to this framebuffer and restore previous state.
|
|
80
|
+
*
|
|
81
|
+
* This method:
|
|
82
|
+
* - Flushes any pending draw calls into this framebuffer
|
|
83
|
+
* - Restores the previously bound framebuffer
|
|
84
|
+
* - Restores the previous viewport settings
|
|
85
|
+
*
|
|
86
|
+
* After calling this method, rendering operations will target the previously active framebuffer.
|
|
87
|
+
*/
|
|
88
|
+
end(): void;
|
|
89
|
+
/**
|
|
90
|
+
* Dispose of WebGL resources used by this framebuffer.
|
|
91
|
+
*
|
|
92
|
+
* This releases:
|
|
93
|
+
* - The WebGL framebuffer object
|
|
94
|
+
* - All associated texture objects
|
|
95
|
+
* - Any cached pixel data
|
|
96
|
+
*
|
|
97
|
+
* This method is idempotent and safe to call multiple times.
|
|
98
|
+
* After disposal, the framebuffer should not be used for rendering.
|
|
99
|
+
*
|
|
100
|
+
* @ignore
|
|
101
|
+
*/
|
|
102
|
+
$dispose(): void;
|
|
103
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import type { GLFramebuffer, FramebufferOptions } from "../Framebuffer";
|
|
2
|
+
import type { GLShader } from "../Shader";
|
|
3
|
+
import type { RenderState } from "../../state/RenderState";
|
|
4
|
+
/**
|
|
5
|
+
* Interface for the core WebGL renderer that manages the WebGL context and provides high-level rendering operations.
|
|
6
|
+
*
|
|
7
|
+
* This interface defines the contract for all rendering operations including:
|
|
8
|
+
* - Shader management and creation
|
|
9
|
+
* - Framebuffer operations
|
|
10
|
+
* - Primitive rendering (rectangles, lines, ellipses, triangles, arcs, bezier curves)
|
|
11
|
+
* - Image and texture rendering
|
|
12
|
+
* - State management
|
|
13
|
+
* - Viewport and clearing operations
|
|
14
|
+
*/
|
|
15
|
+
export interface IRenderer {
|
|
16
|
+
/**
|
|
17
|
+
* Get the WebGL rendering context.
|
|
18
|
+
* Provides direct access to the underlying WebGL2 context for advanced operations.
|
|
19
|
+
*/
|
|
20
|
+
readonly context: WebGLRenderingContext;
|
|
21
|
+
/**
|
|
22
|
+
* Get the current render state.
|
|
23
|
+
* The render state tracks the current rendering configuration including blend modes,
|
|
24
|
+
* colors, and other state that affects how primitives are drawn.
|
|
25
|
+
*/
|
|
26
|
+
readonly state: RenderState;
|
|
27
|
+
/**
|
|
28
|
+
* Set the current shader for subsequent rendering operations.
|
|
29
|
+
* This binds the shader program and makes it active for all following draw calls
|
|
30
|
+
* until a different shader is set.
|
|
31
|
+
*
|
|
32
|
+
* @param shader - The shader to activate
|
|
33
|
+
*/
|
|
34
|
+
$shader(shader: GLShader): void;
|
|
35
|
+
/**
|
|
36
|
+
* Create a new shader from vertex and fragment source code.
|
|
37
|
+
* The shader is compiled, linked, and cached by the shader manager.
|
|
38
|
+
*
|
|
39
|
+
* @param vertexSource - GLSL source code for the vertex shader
|
|
40
|
+
* @param fragmentSource - GLSL source code for the fragment shader
|
|
41
|
+
* @returns A compiled and linked shader program
|
|
42
|
+
*/
|
|
43
|
+
$createShader(vertexSource: string, fragmentSource: string): GLShader;
|
|
44
|
+
/**
|
|
45
|
+
* Set a custom user shader for subsequent rendering operations.
|
|
46
|
+
* This shader will be used for primitive rendering instead of the default shader.
|
|
47
|
+
* Pass null to reset to the default shader.
|
|
48
|
+
*
|
|
49
|
+
* @param shader - The custom shader to use, or null to reset to default
|
|
50
|
+
*/
|
|
51
|
+
$setUserShader(shader: GLShader | null): void;
|
|
52
|
+
/**
|
|
53
|
+
* Set a uniform value for the current user shader.
|
|
54
|
+
* The uniform must exist in the shader for this to have any effect.
|
|
55
|
+
*
|
|
56
|
+
* @param name - The name of the uniform variable in the shader
|
|
57
|
+
* @param value - The value to set (type must match the uniform type in the shader)
|
|
58
|
+
*/
|
|
59
|
+
$setUniform(name: string, value: any): void;
|
|
60
|
+
/**
|
|
61
|
+
* Set multiple uniform values for the current user shader.
|
|
62
|
+
* This is a convenience method for setting multiple uniforms at once.
|
|
63
|
+
*
|
|
64
|
+
* @param uniforms - A record mapping uniform names to their values
|
|
65
|
+
*/
|
|
66
|
+
$setUserUniforms(uniforms: Record<string, any>): void;
|
|
67
|
+
/**
|
|
68
|
+
* Create a filter shader using the standard instanced vertex shader.
|
|
69
|
+
* Filter shaders are commonly used for post-processing effects and only require
|
|
70
|
+
* a custom fragment shader since they use a standard quad-rendering vertex shader.
|
|
71
|
+
*
|
|
72
|
+
* @param fragmentSource - GLSL source code for the fragment shader
|
|
73
|
+
* @returns A shader configured for filter operations
|
|
74
|
+
*/
|
|
75
|
+
$createFilterShader(fragmentSource: string): GLShader;
|
|
76
|
+
/**
|
|
77
|
+
* Draw a quad covering the pixel rectangle (x, y, width, height) on the canvas.
|
|
78
|
+
* The quad is converted to NDC (Normalized Device Coordinates) and rendered with the
|
|
79
|
+
* current shader using only the a_position attribute.
|
|
80
|
+
* Origin: top-left (canvas space).
|
|
81
|
+
*
|
|
82
|
+
* @param x - X coordinate of the top-left corner in pixels
|
|
83
|
+
* @param y - Y coordinate of the top-left corner in pixels
|
|
84
|
+
* @param width - Width of the quad in pixels
|
|
85
|
+
* @param height - Height of the quad in pixels
|
|
86
|
+
*/
|
|
87
|
+
$quad(x: number, y: number, width: number, height: number): void;
|
|
88
|
+
/**
|
|
89
|
+
* Draw a rectangle.
|
|
90
|
+
* The rectangle is rendered using the current shader and render state.
|
|
91
|
+
*
|
|
92
|
+
* @param x - X coordinate of the top-left corner
|
|
93
|
+
* @param y - Y coordinate of the top-left corner
|
|
94
|
+
* @param width - Width of the rectangle
|
|
95
|
+
* @param height - Height of the rectangle
|
|
96
|
+
*/
|
|
97
|
+
$rect(x: number, y: number, width: number, height: number): void;
|
|
98
|
+
/**
|
|
99
|
+
* Draw a line from one point to another.
|
|
100
|
+
* The line is rendered with the current stroke settings from the render state.
|
|
101
|
+
*
|
|
102
|
+
* @param x1 - X coordinate of the line start point
|
|
103
|
+
* @param y1 - Y coordinate of the line start point
|
|
104
|
+
* @param x2 - X coordinate of the line end point
|
|
105
|
+
* @param y2 - Y coordinate of the line end point
|
|
106
|
+
*/
|
|
107
|
+
$line(x1: number, y1: number, x2: number, y2: number): void;
|
|
108
|
+
/**
|
|
109
|
+
* Draw an ellipse.
|
|
110
|
+
* The ellipse is centered at (x, y) with the specified width and height.
|
|
111
|
+
*
|
|
112
|
+
* @param x - X coordinate of the center
|
|
113
|
+
* @param y - Y coordinate of the center
|
|
114
|
+
* @param width - Width of the ellipse
|
|
115
|
+
* @param height - Height of the ellipse
|
|
116
|
+
*/
|
|
117
|
+
$ellipse(x: number, y: number, width: number, height: number): void;
|
|
118
|
+
/**
|
|
119
|
+
* Draw a triangle.
|
|
120
|
+
* The triangle is defined by three vertices and rendered with the current render state.
|
|
121
|
+
*
|
|
122
|
+
* @param x1 - First vertex X coordinate
|
|
123
|
+
* @param y1 - First vertex Y coordinate
|
|
124
|
+
* @param x2 - Second vertex X coordinate
|
|
125
|
+
* @param y2 - Second vertex Y coordinate
|
|
126
|
+
* @param x3 - Third vertex X coordinate
|
|
127
|
+
* @param y3 - Third vertex Y coordinate
|
|
128
|
+
*/
|
|
129
|
+
$triangle(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): void;
|
|
130
|
+
/**
|
|
131
|
+
* Draw a cubic Bezier curve.
|
|
132
|
+
* The curve is defined by a start point, two control points, and an end point.
|
|
133
|
+
*
|
|
134
|
+
* @param x1 - Start point X coordinate
|
|
135
|
+
* @param y1 - Start point Y coordinate
|
|
136
|
+
* @param cp1x - First control point X coordinate
|
|
137
|
+
* @param cp1y - First control point Y coordinate
|
|
138
|
+
* @param cp2x - Second control point X coordinate
|
|
139
|
+
* @param cp2y - Second control point Y coordinate
|
|
140
|
+
* @param x2 - End point X coordinate
|
|
141
|
+
* @param y2 - End point Y coordinate
|
|
142
|
+
*/
|
|
143
|
+
$bezierCurve(x1: number, y1: number, cp1x: number, cp1y: number, cp2x: number, cp2y: number, x2: number, y2: number): void;
|
|
144
|
+
/**
|
|
145
|
+
* Draw an arc (a portion of an ellipse).
|
|
146
|
+
* The arc is part of an ellipse centered at (x, y) with the specified dimensions,
|
|
147
|
+
* drawn from the start angle to the stop angle.
|
|
148
|
+
*
|
|
149
|
+
* @param x - X coordinate of the center
|
|
150
|
+
* @param y - Y coordinate of the center
|
|
151
|
+
* @param width - Width of the ellipse
|
|
152
|
+
* @param height - Height of the ellipse
|
|
153
|
+
* @param start - Start angle in radians
|
|
154
|
+
* @param stop - Stop angle in radians
|
|
155
|
+
*/
|
|
156
|
+
$arc(x: number, y: number, width: number, height: number, start: number, stop: number): void;
|
|
157
|
+
/**
|
|
158
|
+
* Create a new framebuffer for off-screen rendering.
|
|
159
|
+
* Framebuffers can be used for render-to-texture operations, post-processing,
|
|
160
|
+
* and other advanced rendering techniques.
|
|
161
|
+
*
|
|
162
|
+
* @param width - Width of the framebuffer in pixels
|
|
163
|
+
* @param height - Height of the framebuffer in pixels
|
|
164
|
+
* @param attachmentCount - Number of color attachments (default: 1, supports MRT)
|
|
165
|
+
* @param options - Additional framebuffer configuration options
|
|
166
|
+
* @returns A new framebuffer instance
|
|
167
|
+
*/
|
|
168
|
+
$createFramebuffer(width: number, height: number, attachmentCount?: number, options?: FramebufferOptions): GLFramebuffer;
|
|
169
|
+
/**
|
|
170
|
+
* Fill the current framebuffer with a solid color.
|
|
171
|
+
* This sets the canvas background color in the render state and clears the framebuffer.
|
|
172
|
+
* If only one value is provided, it's used for all RGB components.
|
|
173
|
+
*
|
|
174
|
+
* @param r - Red component (0-255)
|
|
175
|
+
* @param g - Green component (0-255), defaults to r if not provided
|
|
176
|
+
* @param b - Blue component (0-255), defaults to r if not provided
|
|
177
|
+
* @param a - Alpha component (0-255), defaults to 255 if not provided
|
|
178
|
+
*/
|
|
179
|
+
$background(r: number, g?: number, b?: number, a?: number): void;
|
|
180
|
+
/**
|
|
181
|
+
* Clear the current framebuffer to a specified color.
|
|
182
|
+
* Color components should be in the range [0, 1].
|
|
183
|
+
*
|
|
184
|
+
* @param r - Red component (0-1), defaults to 0
|
|
185
|
+
* @param g - Green component (0-1), defaults to 0
|
|
186
|
+
* @param b - Blue component (0-1), defaults to 0
|
|
187
|
+
* @param a - Alpha component (0-1), defaults to 0
|
|
188
|
+
*/
|
|
189
|
+
$clear(r?: number, g?: number, b?: number, a?: number): void;
|
|
190
|
+
/**
|
|
191
|
+
* Reset the viewport to match the canvas dimensions.
|
|
192
|
+
* This ensures the viewport is synchronized with the canvas size, which is
|
|
193
|
+
* important after canvas resize operations.
|
|
194
|
+
*/
|
|
195
|
+
$resetViewport(): void;
|
|
196
|
+
/**
|
|
197
|
+
* Flush all batched instances for instanced rendering.
|
|
198
|
+
* This must be called at the end of each frame to actually render all batched geometry.
|
|
199
|
+
* The method processes the entire draw queue and renders all primitives that were
|
|
200
|
+
* queued during the frame.
|
|
201
|
+
*/
|
|
202
|
+
$flushInstances(): void;
|
|
203
|
+
/**
|
|
204
|
+
* Dispose of all WebGL resources managed by this renderer.
|
|
205
|
+
* This releases buffers, shaders, geometries, and other GPU resources.
|
|
206
|
+
* This method is idempotent and safe to call multiple times.
|
|
207
|
+
* After disposal, the renderer should not be used.
|
|
208
|
+
*/
|
|
209
|
+
$dispose(): void;
|
|
210
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Instanced arc (pie segment) geometry implementation
|
|
3
3
|
*/
|
|
4
|
-
import type { InstanceBatch } from '
|
|
5
|
-
import { type ArcParams } from '
|
|
6
|
-
import { BaseGeometry } from '
|
|
4
|
+
import type { InstanceBatch } from '../../batching/InstanceBatch';
|
|
5
|
+
import { type ArcParams } from '../../types/GeometryTypes';
|
|
6
|
+
import { BaseGeometry } from '../BaseGeometry';
|
|
7
|
+
import type { IRenderState } from '../../state/RenderState';
|
|
7
8
|
/**
|
|
8
9
|
* Instanced arc geometry renderer.
|
|
9
10
|
* Batches arc draw calls using a unit triangle fan scaled to width/height.
|
|
@@ -12,5 +13,5 @@ import { BaseGeometry } from './BaseGeometry';
|
|
|
12
13
|
export declare class Arc extends BaseGeometry {
|
|
13
14
|
constructor(gl: WebGL2RenderingContext, batch: InstanceBatch);
|
|
14
15
|
/** Add an arc instance (filled pie segment) */
|
|
15
|
-
$addInstance(params: ArcParams, renderState:
|
|
16
|
+
$addInstance(params: ArcParams, renderState: IRenderState): number;
|
|
16
17
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Instanced bezier curve geometry implementation
|
|
3
3
|
*/
|
|
4
|
-
import type { InstanceBatch } from '
|
|
5
|
-
import { type BezierCurveParams } from '
|
|
6
|
-
import { BaseGeometry } from '
|
|
4
|
+
import type { InstanceBatch } from '../../batching/InstanceBatch';
|
|
5
|
+
import { type BezierCurveParams } from '../../types/GeometryTypes';
|
|
6
|
+
import { BaseGeometry } from '../BaseGeometry';
|
|
7
|
+
import type { IRenderState } from '../../state/RenderState';
|
|
7
8
|
/**
|
|
8
9
|
* TRUE INSTANCED bezier curve geometry renderer.
|
|
9
10
|
*
|
|
@@ -18,5 +19,5 @@ export declare class BezierCurve extends BaseGeometry {
|
|
|
18
19
|
/**
|
|
19
20
|
* Add a bezier curve instance to the batch - TRUE INSTANCED APPROACH
|
|
20
21
|
*/
|
|
21
|
-
$addInstance(params: BezierCurveParams, renderState:
|
|
22
|
+
$addInstance(params: BezierCurveParams, renderState: IRenderState): number;
|
|
22
23
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Instanced ellipse geometry implementation
|
|
3
3
|
*/
|
|
4
|
-
import type { InstanceBatch } from '
|
|
5
|
-
import { type EllipseParams } from '
|
|
6
|
-
import { BaseGeometry } from '
|
|
4
|
+
import type { InstanceBatch } from '../../batching/InstanceBatch';
|
|
5
|
+
import { type EllipseParams } from '../../types/GeometryTypes';
|
|
6
|
+
import { BaseGeometry } from '../BaseGeometry';
|
|
7
|
+
import type { IRenderState } from '../../state/RenderState';
|
|
7
8
|
/**
|
|
8
9
|
* Instanced ellipse geometry renderer.
|
|
9
10
|
* Batches all ellipse draw calls for efficient GPU rendering.
|
|
@@ -12,9 +13,9 @@ export declare class Ellipse extends BaseGeometry {
|
|
|
12
13
|
constructor(gl: WebGL2RenderingContext, batch: InstanceBatch);
|
|
13
14
|
/**
|
|
14
15
|
* Add an ellipse instance to the batch
|
|
15
|
-
* @param params Ellipse parameters
|
|
16
|
+
* @param params Ellipse parameters
|
|
16
17
|
* @param renderState Current render state
|
|
17
18
|
* @returns Index of the added instance
|
|
18
19
|
*/
|
|
19
|
-
$addInstance(params: EllipseParams, renderState:
|
|
20
|
+
$addInstance(params: EllipseParams, renderState: IRenderState): number;
|
|
20
21
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Instanced line geometry implementation
|
|
3
3
|
*/
|
|
4
|
-
import type { InstanceBatch } from '
|
|
5
|
-
import { type LineParams } from '
|
|
6
|
-
import { BaseGeometry } from '
|
|
4
|
+
import type { InstanceBatch } from '../../batching/InstanceBatch';
|
|
5
|
+
import { type LineParams } from '../../types/GeometryTypes';
|
|
6
|
+
import { BaseGeometry } from '../BaseGeometry';
|
|
7
|
+
import type { IRenderState } from '../../state/RenderState';
|
|
7
8
|
/**
|
|
8
9
|
* Instanced line geometry renderer.
|
|
9
10
|
* Batches all line draw calls for efficient GPU rendering.
|
|
@@ -16,5 +17,5 @@ export declare class Line extends BaseGeometry {
|
|
|
16
17
|
* @param renderState Current render state
|
|
17
18
|
* @returns Index of the added instance
|
|
18
19
|
*/
|
|
19
|
-
$addInstance(params: LineParams, renderState:
|
|
20
|
+
$addInstance(params: LineParams, renderState: IRenderState): number;
|
|
20
21
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Instanced rectangle geometry implementation
|
|
3
3
|
*/
|
|
4
|
-
import type { InstanceBatch } from '
|
|
5
|
-
import { type RectangleParams } from '
|
|
6
|
-
import { BaseGeometry } from '
|
|
4
|
+
import type { InstanceBatch } from '../../batching/InstanceBatch';
|
|
5
|
+
import { type RectangleParams } from '../../types/GeometryTypes';
|
|
6
|
+
import { BaseGeometry } from '../BaseGeometry';
|
|
7
|
+
import type { IRenderState } from '../../state/RenderState';
|
|
7
8
|
/**
|
|
8
9
|
* Instanced rectangle geometry renderer.
|
|
9
10
|
* Batches all rectangle draw calls for efficient GPU rendering.
|
|
@@ -16,5 +17,5 @@ export declare class Rectangle extends BaseGeometry {
|
|
|
16
17
|
* @param renderState Current render state
|
|
17
18
|
* @returns Index of the added instance
|
|
18
19
|
*/
|
|
19
|
-
$addInstance(params: RectangleParams, renderState:
|
|
20
|
+
$addInstance(params: RectangleParams, renderState: IRenderState): number;
|
|
20
21
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Instanced triangle geometry implementation
|
|
3
3
|
*/
|
|
4
|
-
import type { InstanceBatch } from '
|
|
5
|
-
import { type TriangleParams } from '
|
|
6
|
-
import { BaseGeometry } from '
|
|
4
|
+
import type { InstanceBatch } from '../../batching/InstanceBatch';
|
|
5
|
+
import { type TriangleParams } from '../../types/GeometryTypes';
|
|
6
|
+
import { BaseGeometry } from '../BaseGeometry';
|
|
7
|
+
import type { IRenderState } from '../../state/RenderState';
|
|
7
8
|
/**
|
|
8
9
|
* Instanced triangle geometry renderer.
|
|
9
10
|
* Batches all triangle draw calls for efficient GPU rendering.
|
|
@@ -16,5 +17,5 @@ export declare class Triangle extends BaseGeometry {
|
|
|
16
17
|
* @param renderState Current render state
|
|
17
18
|
* @returns Index of the added instance
|
|
18
19
|
*/
|
|
19
|
-
$addInstance(params: TriangleParams, renderState:
|
|
20
|
+
$addInstance(params: TriangleParams, renderState: IRenderState): number;
|
|
20
21
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import type { InstanceBatch } from '../InstanceBatch';
|
|
5
|
-
import type { InstanceData } from '../InstanceData';
|
|
1
|
+
import type { InstanceBatch } from '../batching/InstanceBatch';
|
|
2
|
+
import type { InstanceData } from '../batching/InstanceData';
|
|
6
3
|
import type { IGeometry, GeometryType, UnitGeometryData } from '../types/GeometryTypes';
|
|
7
|
-
import type { IRenderState } from '../RenderState';
|
|
4
|
+
import type { IRenderState } from '../state/RenderState';
|
|
8
5
|
/**
|
|
9
6
|
* Abstract base class for all instanced geometries.
|
|
10
7
|
* Provides common functionality for instance data creation and batch management.
|
|
@@ -24,26 +21,33 @@ export declare abstract class BaseGeometry implements IGeometry {
|
|
|
24
21
|
$hasInstances(): boolean;
|
|
25
22
|
$dispose(): void;
|
|
26
23
|
abstract $addInstance(params: any, renderState: any): number;
|
|
24
|
+
protected _addInstance(instanceData: InstanceData, _rotationCenterX: number, _rotationCenterY: number): number;
|
|
27
25
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*
|
|
26
|
+
* Write instance data directly to batch buffer (zero-allocation helper).
|
|
27
|
+
* Handles all common instance data setup to eliminate code duplication.
|
|
28
|
+
*
|
|
29
|
+
* @param x - X position
|
|
30
|
+
* @param y - Y position
|
|
31
|
+
* @param width - Width
|
|
32
|
+
* @param height - Height
|
|
33
|
+
* @param centerX - Rotation center X (in pixels)
|
|
34
|
+
* @param centerY - Rotation center Y (in pixels)
|
|
35
|
+
* @param renderState - Current render state
|
|
36
|
+
* @param geometryData - Optional geometry-specific data (arc angles, bezier points, depth)
|
|
37
|
+
* @returns Index of the written instance
|
|
35
38
|
*/
|
|
36
|
-
protected
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
protected _writeInstance(x: number, y: number, width: number, height: number, renderState: IRenderState, geometryData?: {
|
|
40
|
+
arcStart?: number;
|
|
41
|
+
arcStop?: number;
|
|
42
|
+
cp1x?: number;
|
|
43
|
+
cp1y?: number;
|
|
44
|
+
cp2x?: number;
|
|
45
|
+
cp2y?: number;
|
|
46
|
+
bezStartX?: number;
|
|
47
|
+
bezStartY?: number;
|
|
48
|
+
bezEndX?: number;
|
|
49
|
+
bezEndY?: number;
|
|
50
|
+
depth?: number;
|
|
51
|
+
baseZ?: number;
|
|
52
|
+
}): number;
|
|
49
53
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Immediate-mode quad renderer for full-screen passes and framebuffer presentation.
|
|
3
|
+
*
|
|
4
|
+
* This is NOT an instanced geometry - it's a simple, stateless utility for drawing
|
|
5
|
+
* a single textured quad immediately. Used primarily for presenting final framebuffer
|
|
6
|
+
* results to the screen or for filter passes.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Simple immediate-mode quad renderer.
|
|
10
|
+
* No instancing, no batching, just a single quad drawn with vertex positions in NDC.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ImmediateQuad {
|
|
13
|
+
private _gl;
|
|
14
|
+
private _vbo;
|
|
15
|
+
private _vertexData;
|
|
16
|
+
constructor(gl: WebGL2RenderingContext);
|
|
17
|
+
/**
|
|
18
|
+
* Draw a quad immediately with the given pixel coordinates.
|
|
19
|
+
* Converts pixel coordinates to NDC and renders a textured quad.
|
|
20
|
+
*
|
|
21
|
+
* The current shader must be bound before calling this method.
|
|
22
|
+
*
|
|
23
|
+
* @param x X position in pixels
|
|
24
|
+
* @param y Y position in pixels
|
|
25
|
+
* @param width Width in pixels
|
|
26
|
+
* @param height Height in pixels
|
|
27
|
+
*/
|
|
28
|
+
$draw(x: number, y: number, width: number, height: number): void;
|
|
29
|
+
/**
|
|
30
|
+
* Dispose of WebGL resources.
|
|
31
|
+
*/
|
|
32
|
+
$dispose(): void;
|
|
33
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { Rectangle } from './Rectangle';
|
|
2
|
-
export { Line } from './Line';
|
|
3
|
-
export { Ellipse } from './Ellipse';
|
|
4
|
-
export { Arc } from './Arc';
|
|
5
|
-
export { Triangle } from './Triangle';
|
|
6
|
-
export { BezierCurve } from './BezierCurve';
|
|
1
|
+
export { Rectangle } from './2d/Rectangle';
|
|
2
|
+
export { Line } from './2d/Line';
|
|
3
|
+
export { Ellipse } from './2d/Ellipse';
|
|
4
|
+
export { Arc } from './2d/Arc';
|
|
5
|
+
export { Triangle } from './2d/Triangle';
|
|
6
|
+
export { BezierCurve } from './2d/BezierCurve';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared geometry attribute descriptors to eliminate redundant definitions.
|
|
3
|
+
* All geometries of the same dimensionality (2D/3D) share identical stride and attribute layouts.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Unit quad vertex data used by both instanced and immediate quad rendering.
|
|
7
|
+
* Format: [x, y, u, v] for each vertex (position + texCoord interleaved)
|
|
8
|
+
* Layout: Two triangles forming a unit square centered at origin from (-0.5,-0.5) to (0.5,0.5)
|
|
9
|
+
*/
|
|
10
|
+
export declare const UNIT_QUAD: Float32Array<ArrayBuffer>;
|
|
11
|
+
/**
|
|
12
|
+
* Standard 2D geometry attribute descriptor.
|
|
13
|
+
* Used by: Rectangle, Line, Ellipse, Triangle, Arc, BezierCurve
|
|
14
|
+
*
|
|
15
|
+
* Layout: [position.xy, texCoord.uv]
|
|
16
|
+
* Stride: 16 bytes (4 floats)
|
|
17
|
+
*/
|
|
18
|
+
export declare const GEOMETRY_2D_DESCRIPTOR: {
|
|
19
|
+
readonly _stride: 16;
|
|
20
|
+
readonly _primitiveType: 4;
|
|
21
|
+
readonly _attributes: {
|
|
22
|
+
readonly _position: {
|
|
23
|
+
readonly size: 2;
|
|
24
|
+
readonly offset: 0;
|
|
25
|
+
};
|
|
26
|
+
readonly _texCoord: {
|
|
27
|
+
readonly size: 2;
|
|
28
|
+
readonly offset: 8;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Geometry generation utilities for 2D shapes.
|
|
3
|
+
* 2D geometries use 4 floats per vertex: position.xy + texCoord.uv
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Generate 2D circle/ellipse vertices.
|
|
7
|
+
*/
|
|
8
|
+
export declare function generateCircleVertices(segments?: number): Float32Array;
|
|
9
|
+
/**
|
|
10
|
+
* Generate unit arc vertices for 2D arc rendering.
|
|
11
|
+
*/
|
|
12
|
+
export declare function generateArcVertices(segments: number): Float32Array;
|
|
13
|
+
/**
|
|
14
|
+
* Generate bezier curve geometry (multi-segment for GPU evaluation).
|
|
15
|
+
*/
|
|
16
|
+
export declare function generateBezierVertices(segments?: number): Float32Array;
|