bloody-engine 1.0.2 → 1.0.4

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.
Files changed (66) hide show
  1. package/dist/node/index.js +0 -5
  2. package/dist/web/batch-renderer.test.d.ts +12 -0
  3. package/dist/web/batch-renderer.test.d.ts.map +1 -0
  4. package/dist/web/core/buffer.d.ts +58 -0
  5. package/dist/web/core/buffer.d.ts.map +1 -0
  6. package/dist/web/core/grahpic-device.d.ts +66 -0
  7. package/dist/web/core/grahpic-device.d.ts.map +1 -0
  8. package/dist/web/core/index.d.ts +8 -0
  9. package/dist/web/core/index.d.ts.map +1 -0
  10. package/dist/web/core/resource-loader-factory.d.ts +90 -0
  11. package/dist/web/core/resource-loader-factory.d.ts.map +1 -0
  12. package/dist/web/core/resource-loader.d.ts +71 -0
  13. package/dist/web/core/resource-loader.d.ts.map +1 -0
  14. package/dist/web/core/resource-pipeline.d.ts +139 -0
  15. package/dist/web/core/resource-pipeline.d.ts.map +1 -0
  16. package/dist/web/core/shader.d.ts +62 -0
  17. package/dist/web/core/shader.d.ts.map +1 -0
  18. package/dist/web/core/texture.d.ts +69 -0
  19. package/dist/web/core/texture.d.ts.map +1 -0
  20. package/dist/web/demo-node.d.ts +2 -0
  21. package/dist/web/demo-node.d.ts.map +1 -0
  22. package/dist/web/examples/batch-renderer-demo.d.ts +10 -0
  23. package/dist/web/examples/batch-renderer-demo.d.ts.map +1 -0
  24. package/dist/web/examples/projection-examples.d.ts +87 -0
  25. package/dist/web/examples/projection-examples.d.ts.map +1 -0
  26. package/dist/web/examples/resource-loader-demo.d.ts +14 -0
  27. package/dist/web/examples/resource-loader-demo.d.ts.map +1 -0
  28. package/dist/web/examples/shader-examples.d.ts +92 -0
  29. package/dist/web/examples/shader-examples.d.ts.map +1 -0
  30. package/dist/web/examples/sprite-batch-renderer-demo.d.ts +12 -0
  31. package/dist/web/examples/sprite-batch-renderer-demo.d.ts.map +1 -0
  32. package/dist/web/index-node-batch.d.ts +10 -0
  33. package/dist/web/index-node-batch.d.ts.map +1 -0
  34. package/dist/web/index.d.ts +7 -0
  35. package/dist/web/index.d.ts.map +1 -0
  36. package/dist/web/index.js +34 -37
  37. package/dist/web/index.umd.js +7 -7
  38. package/dist/web/platforms/browser/browser-context.d.ts +31 -0
  39. package/dist/web/platforms/browser/browser-context.d.ts.map +1 -0
  40. package/dist/web/platforms/browser/browser-resource-loader.d.ts +67 -0
  41. package/dist/web/platforms/browser/browser-resource-loader.d.ts.map +1 -0
  42. package/dist/web/platforms/node/node-context.d.ts +31 -0
  43. package/dist/web/platforms/node/node-context.d.ts.map +1 -0
  44. package/dist/web/platforms/node/node-resource-loader.d.ts +73 -0
  45. package/dist/web/platforms/node/node-resource-loader.d.ts.map +1 -0
  46. package/dist/web/platforms/node/sdl-window.d.ts +41 -0
  47. package/dist/web/platforms/node/sdl-window.d.ts.map +1 -0
  48. package/dist/web/projection.test.d.ts +5 -0
  49. package/dist/web/projection.test.d.ts.map +1 -0
  50. package/dist/web/public-api.d.ts +20 -0
  51. package/dist/web/public-api.d.ts.map +1 -0
  52. package/dist/web/rendering/batch-renderer.d.ts +273 -0
  53. package/dist/web/rendering/batch-renderer.d.ts.map +1 -0
  54. package/dist/web/rendering/camera.d.ts +153 -0
  55. package/dist/web/rendering/camera.d.ts.map +1 -0
  56. package/dist/web/rendering/projection.d.ts +108 -0
  57. package/dist/web/rendering/projection.d.ts.map +1 -0
  58. package/dist/web/rendering/rendering-context-factory.d.ts +24 -0
  59. package/dist/web/rendering/rendering-context-factory.d.ts.map +1 -0
  60. package/dist/web/rendering/rendering-context.d.ts +77 -0
  61. package/dist/web/rendering/rendering-context.d.ts.map +1 -0
  62. package/dist/web/rendering/vertex.d.ts +98 -0
  63. package/dist/web/rendering/vertex.d.ts.map +1 -0
  64. package/dist/web/scene/scene.d.ts +139 -0
  65. package/dist/web/scene/scene.d.ts.map +1 -0
  66. package/package.json +5 -4
@@ -0,0 +1,31 @@
1
+ import { RenderingContext, RenderingContextOptions } from '../../rendering/rendering-context';
2
+ /**
3
+ * Browser-based WebGL rendering context implementation
4
+ * Manages rendering to an HTML canvas element
5
+ */
6
+ export declare class BrowserRenderingContext implements RenderingContext {
7
+ glContext: WebGLRenderingContext;
8
+ width: number;
9
+ height: number;
10
+ isBrowser: boolean;
11
+ private canvas;
12
+ constructor(options: RenderingContextOptions);
13
+ resize(width: number, height: number): void;
14
+ getViewport(): {
15
+ width: number;
16
+ height: number;
17
+ };
18
+ clear(color?: {
19
+ r: number;
20
+ g: number;
21
+ b: number;
22
+ a: number;
23
+ }): void;
24
+ present(): void;
25
+ dispose(): void;
26
+ /**
27
+ * Get the underlying canvas element (browser-specific)
28
+ */
29
+ getCanvas(): HTMLCanvasElement;
30
+ }
31
+ //# sourceMappingURL=browser-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-context.d.ts","sourceRoot":"","sources":["../../../../src/platforms/browser/browser-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,mCAAmC,CAAC;AAE3C;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,gBAAgB;IAC9D,SAAS,EAAE,qBAAqB,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAQ;IAE1B,OAAO,CAAC,MAAM,CAAoB;gBAEtB,OAAO,EAAE,uBAAuB;IA0B5C,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAQ3C,WAAW,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAIhD,KAAK,CAAC,KAAK,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IASnE,OAAO,IAAI,IAAI;IAIf,OAAO,IAAI,IAAI;IAOf;;OAEG;IACH,SAAS,IAAI,iBAAiB;CAG/B"}
@@ -0,0 +1,67 @@
1
+ import { IResourceLoader, ResourceLoadOptions, ResourceLoadResult } from '../../core/resource-loader';
2
+ /**
3
+ * Resource loader implementation for browser environments
4
+ * Uses the Fetch API to load resources from URLs
5
+ */
6
+ export declare class BrowserResourceLoader implements IResourceLoader {
7
+ /**
8
+ * Base URL for resolving relative paths
9
+ */
10
+ private baseUrl;
11
+ /**
12
+ * Default request timeout in milliseconds
13
+ */
14
+ private defaultTimeout;
15
+ /**
16
+ * Create a new browser resource loader
17
+ * @param baseUrl Optional base URL for resolving relative paths (defaults to current origin)
18
+ * @param timeout Default timeout for requests in milliseconds (default: 10000)
19
+ */
20
+ constructor(baseUrl?: string, timeout?: number);
21
+ /**
22
+ * Get the current origin (protocol + host + port)
23
+ */
24
+ private getCurrentOrigin;
25
+ /**
26
+ * Resolve a relative path against the base URL
27
+ * @param path Relative or absolute path
28
+ * @returns Resolved absolute URL
29
+ */
30
+ private resolvePath;
31
+ /**
32
+ * Load a single resource from a URL
33
+ * @param path URL or relative path to the resource
34
+ * @param options Optional loading configuration
35
+ * @returns Promise resolving to the resource content
36
+ */
37
+ load(path: string, options?: ResourceLoadOptions): Promise<string>;
38
+ /**
39
+ * Load multiple resources in parallel
40
+ * @param paths Array of URLs or paths
41
+ * @param options Optional loading configuration
42
+ * @returns Promise resolving to array of load results
43
+ */
44
+ loadMultiple(paths: string[], options?: ResourceLoadOptions): Promise<ResourceLoadResult[]>;
45
+ /**
46
+ * Check if the path is valid for loading in the browser
47
+ * @param path URL or path to check
48
+ * @returns true if the path can be loaded
49
+ */
50
+ canLoad(path: string): boolean;
51
+ /**
52
+ * Set a new base URL for resolving relative paths
53
+ * @param baseUrl New base URL
54
+ */
55
+ setBaseUrl(baseUrl: string): void;
56
+ /**
57
+ * Get the current base URL
58
+ * @returns Current base URL
59
+ */
60
+ getBaseUrl(): string;
61
+ /**
62
+ * Set the default request timeout
63
+ * @param timeout Timeout in milliseconds
64
+ */
65
+ setTimeout(timeout: number): void;
66
+ }
67
+ //# sourceMappingURL=browser-resource-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-resource-loader.d.ts","sourceRoot":"","sources":["../../../../src/platforms/browser/browser-resource-loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AAEpC;;;GAGG;AACH,qBAAa,qBAAsB,YAAW,eAAe;IAC3D;;OAEG;IACH,OAAO,CAAC,OAAO,CAAS;IAExB;;OAEG;IACH,OAAO,CAAC,cAAc,CAAS;IAE/B;;;;OAIG;gBACS,OAAO,GAAE,MAAW,EAAE,OAAO,GAAE,MAAc;IAKzD;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAMxB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAyBnB;;;;;OAKG;IACG,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IA8CxE;;;;;OAKG;IACG,YAAY,CAChB,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAsBhC;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAe9B;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIjC;;;OAGG;IACH,UAAU,IAAI,MAAM;IAIpB;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAGlC"}
@@ -0,0 +1,31 @@
1
+ import { RenderingContext, RenderingContextOptions } from '../../rendering/rendering-context';
2
+ /**
3
+ * Node.js-based WebGL rendering context implementation
4
+ * Uses headless-gl (node-gl) for server-side rendering
5
+ */
6
+ export declare class NodeRenderingContext implements RenderingContext {
7
+ glContext: WebGLRenderingContext;
8
+ width: number;
9
+ height: number;
10
+ isBrowser: boolean;
11
+ constructor(options: RenderingContextOptions);
12
+ resize(width: number, height: number): void;
13
+ getViewport(): {
14
+ width: number;
15
+ height: number;
16
+ };
17
+ clear(color?: {
18
+ r: number;
19
+ g: number;
20
+ b: number;
21
+ a: number;
22
+ }): void;
23
+ present(): void;
24
+ dispose(): void;
25
+ /**
26
+ * Read the current framebuffer contents as RGBA pixel data
27
+ * Used for capturing frames for display or saving
28
+ */
29
+ readPixels(): Uint8Array;
30
+ }
31
+ //# sourceMappingURL=node-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-context.d.ts","sourceRoot":"","sources":["../../../../src/platforms/node/node-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,mCAAmC,CAAC;AAE3C;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,gBAAgB;IAC3D,SAAS,EAAE,qBAAqB,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAS;gBAEf,OAAO,EAAE,uBAAuB;IAiB5C,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAU3C,WAAW,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAIhD,KAAK,CAAC,KAAK,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IASnE,OAAO,IAAI,IAAI;IAKf,OAAO,IAAI,IAAI;IAOf;;;OAGG;IACH,UAAU,IAAI,UAAU;CAazB"}
@@ -0,0 +1,73 @@
1
+ import { Stats } from 'fs';
2
+ import { IResourceLoader, ResourceLoadOptions, ResourceLoadResult } from '../../core/resource-loader';
3
+ /**
4
+ * Resource loader implementation for Node.js environments
5
+ * Uses fs.promises to load resources from the file system
6
+ */
7
+ export declare class NodeResourceLoader implements IResourceLoader {
8
+ /**
9
+ * Base directory for resolving relative paths
10
+ */
11
+ private baseDir;
12
+ /**
13
+ * Create a new Node.js resource loader
14
+ * @param baseDir Optional base directory for resolving relative paths (defaults to current working directory)
15
+ */
16
+ constructor(baseDir?: string);
17
+ /**
18
+ * Resolve a relative path against the base directory
19
+ * @param filePath Relative or absolute file path
20
+ * @returns Resolved absolute file path
21
+ */
22
+ private resolvePath;
23
+ /**
24
+ * Load a single resource from a file
25
+ * @param filePath File path (relative or absolute)
26
+ * @param options Optional loading configuration
27
+ * @returns Promise resolving to the file content
28
+ */
29
+ load(filePath: string, options?: ResourceLoadOptions): Promise<string>;
30
+ /**
31
+ * Load multiple resources in parallel
32
+ * @param filePaths Array of file paths
33
+ * @param options Optional loading configuration
34
+ * @returns Promise resolving to array of load results
35
+ */
36
+ loadMultiple(filePaths: string[], options?: ResourceLoadOptions): Promise<ResourceLoadResult[]>;
37
+ /**
38
+ * Check if the path is valid for loading in Node.js
39
+ * @param filePath File path to check
40
+ * @returns true if the path can be loaded
41
+ */
42
+ canLoad(filePath: string): boolean;
43
+ /**
44
+ * Check if a file exists without loading it
45
+ * @param filePath File path to check
46
+ * @returns Promise resolving to true if file exists
47
+ */
48
+ exists(filePath: string): Promise<boolean>;
49
+ /**
50
+ * Get file statistics (size, modification time, etc.)
51
+ * @param filePath File path to check
52
+ * @returns Promise resolving to file stats
53
+ */
54
+ getStats(filePath: string): Promise<Stats>;
55
+ /**
56
+ * Set a new base directory for resolving relative paths
57
+ * @param baseDir New base directory
58
+ */
59
+ setBaseDir(baseDir: string): void;
60
+ /**
61
+ * Get the current base directory
62
+ * @returns Current base directory
63
+ */
64
+ getBaseDir(): string;
65
+ /**
66
+ * List all files in a directory
67
+ * @param dirPath Directory path to list
68
+ * @param recursive Whether to recursively list subdirectories (default: false)
69
+ * @returns Promise resolving to array of file paths
70
+ */
71
+ listDirectory(dirPath: string, recursive?: boolean): Promise<string[]>;
72
+ }
73
+ //# sourceMappingURL=node-resource-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-resource-loader.d.ts","sourceRoot":"","sources":["../../../../src/platforms/node/node-resource-loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AAEpC;;;GAGG;AACH,qBAAa,kBAAmB,YAAW,eAAe;IACxD;;OAEG;IACH,OAAO,CAAC,OAAO,CAAS;IAExB;;;OAGG;gBACS,OAAO,GAAE,MAAsB;IAI3C;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAUnB;;;;;OAKG;IACG,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAuC5E;;;;;OAKG;IACG,YAAY,CAChB,SAAS,EAAE,MAAM,EAAE,EACnB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAsBhC;;;;OAIG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAYlC;;;;OAIG;IACG,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAUhD;;;;OAIG;IACG,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAKhD;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIjC;;;OAGG;IACH,UAAU,IAAI,MAAM;IAIpB;;;;;OAKG;IACG,aAAa,CACjB,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,OAAe,GACzB,OAAO,CAAC,MAAM,EAAE,CAAC;CAkBrB"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * SDL Window wrapper for displaying rendered content
3
+ * Handles window creation, event polling, and surface updates
4
+ */
5
+ export declare class SDLWindow {
6
+ private window;
7
+ private width;
8
+ private height;
9
+ private title;
10
+ private closed;
11
+ constructor(width: number, height: number, title?: string);
12
+ /**
13
+ * Get window dimensions
14
+ */
15
+ getDimensions(): {
16
+ width: number;
17
+ height: number;
18
+ };
19
+ /**
20
+ * Display pixel data in the window
21
+ * @param pixels Uint8Array of RGBA pixel data
22
+ */
23
+ updatePixels(pixels: Uint8Array): void;
24
+ /**
25
+ * Register an event handler
26
+ */
27
+ on(eventName: string, handler: Function): void;
28
+ /**
29
+ * Check if window is still open
30
+ */
31
+ isOpen(): boolean;
32
+ /**
33
+ * Cleanup and close window
34
+ */
35
+ cleanup(): void;
36
+ /**
37
+ * Destroy the window (alias for cleanup)
38
+ */
39
+ destroy(): void;
40
+ }
41
+ //# sourceMappingURL=sdl-window.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdl-window.d.ts","sourceRoot":"","sources":["../../../../src/platforms/node/sdl-window.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAkB;gBAEpB,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,MAAwB;IA6B1E;;OAEG;IACH,aAAa,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAIlD;;;OAGG;IACH,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAkBtC;;OAEG;IACH,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI;IAkB9C;;OAEG;IACH,MAAM,IAAI,OAAO;IAIjB;;OAEG;IACH,OAAO,IAAI,IAAI;IAcf;;OAEG;IACH,OAAO,IAAI,IAAI;CAGhB"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Tests for 2.5D Isometric Projection Mathematics
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=projection.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection.test.d.ts","sourceRoot":"","sources":["../../src/projection.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,20 @@
1
+ export { GraphicsDevice } from './core/grahpic-device';
2
+ export type { RenderingContext, RenderingContextOptions, } from './rendering/rendering-context';
3
+ export { BrowserRenderingContext } from './platforms/browser/browser-context';
4
+ export { NodeRenderingContext } from './platforms/node/node-context';
5
+ export { RenderingContextFactory } from './rendering/rendering-context-factory';
6
+ export { Shader } from './core/shader';
7
+ export { Texture } from './core/texture';
8
+ export { VertexBuffer, IndexBuffer } from './core/buffer';
9
+ export { BatchRenderer, SpriteBatchRenderer } from './rendering/batch-renderer';
10
+ export type { QuadInstance, SpriteQuadInstance } from './rendering/batch-renderer';
11
+ export { Camera, Matrix4 } from './rendering/camera';
12
+ export type { IResourceLoader, ResourceLoadResult, ResourceLoadOptions, BatchLoadResult, } from './core/resource-loader';
13
+ export { BrowserResourceLoader, } from './platforms/browser/browser-resource-loader';
14
+ export { NodeResourceLoader } from './platforms/node/node-resource-loader';
15
+ export { ResourceLoaderFactory, Environment, createResourceLoader, } from './core/resource-loader-factory';
16
+ export type { ResourceLoaderFactoryOptions } from './core/resource-loader-factory';
17
+ export { ResourcePipeline, createResourcePipeline, } from './core/resource-pipeline';
18
+ export type { ShaderSource, NamedShaderSource, ResourcePipelineOptions, } from './core/resource-pipeline';
19
+ export { runBrowserResourceLoaderDemo } from './examples/resource-loader-demo';
20
+ //# sourceMappingURL=public-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../src/public-api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,YAAY,EACV,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAGhF,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG1D,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAChF,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGnF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGrD,YAAY,EACV,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,qBAAqB,GACtB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AACxC,YAAY,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EACL,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC"}
@@ -0,0 +1,273 @@
1
+ import { Shader } from '../core/shader';
2
+ import { Texture } from '../core/texture';
3
+ import { Camera } from './camera';
4
+ /**
5
+ * V1 Quad instance data (for backward compatibility)
6
+ */
7
+ export interface QuadInstance {
8
+ /** X position */
9
+ x: number;
10
+ /** Y position */
11
+ y: number;
12
+ /** Width */
13
+ width: number;
14
+ /** Height */
15
+ height: number;
16
+ /** Rotation in radians */
17
+ rotation: number;
18
+ /** Color as [r, g, b] (0-1 range) */
19
+ color: [number, number, number];
20
+ }
21
+ /**
22
+ * V2 Sprite Quad instance data with full 2.5D support
23
+ */
24
+ export interface SpriteQuadInstance {
25
+ /** Position in 2.5D space */
26
+ x: number;
27
+ y: number;
28
+ z: number;
29
+ /** Width and height */
30
+ width: number;
31
+ height: number;
32
+ /** Rotation in radians */
33
+ rotation: number;
34
+ /** Color tint (0-1 range, default white) */
35
+ color?: {
36
+ r: number;
37
+ g: number;
38
+ b: number;
39
+ a: number;
40
+ };
41
+ /** Texture coordinates (UV region in texture atlas) */
42
+ uvRect?: {
43
+ uMin: number;
44
+ vMin: number;
45
+ uMax: number;
46
+ vMax: number;
47
+ };
48
+ /** Texture index for atlas selection */
49
+ texIndex?: number;
50
+ /** Grid position for GPU-based transformation (optional) */
51
+ gridX?: number;
52
+ gridY?: number;
53
+ }
54
+ /**
55
+ * V1 Batch Renderer for backward compatibility
56
+ * Renders 2D colored quads with position and texture coordinates
57
+ *
58
+ * Features:
59
+ * - Dynamic vertex buffer for per-frame updates
60
+ * - Batch rendering of multiple quads in single draw call
61
+ * - Simple 2D positioning and coloring
62
+ */
63
+ export declare class BatchRenderer {
64
+ private gl;
65
+ private shader;
66
+ private vertexBuffer;
67
+ private maxQuads;
68
+ private vertexData;
69
+ private quads;
70
+ private isDirty;
71
+ private verticesPerQuad;
72
+ private floatsPerVertex;
73
+ private texture;
74
+ /**
75
+ * Create a new batch renderer (V1)
76
+ * @param gl WebGL rendering context
77
+ * @param shader Shader program to use
78
+ * @param maxQuads Maximum number of quads to batch (default 1000)
79
+ */
80
+ constructor(gl: WebGLRenderingContext, shader: Shader, maxQuads?: number);
81
+ /**
82
+ * Set the texture for batch rendering
83
+ * @param texture The texture to use when rendering
84
+ */
85
+ setTexture(texture: Texture | null): void;
86
+ /**
87
+ * Add a quad to the batch
88
+ * @param quad Quad instance to add
89
+ */
90
+ addQuad(quad: QuadInstance): void;
91
+ /**
92
+ * Clear all quads from the batch
93
+ */
94
+ clear(): void;
95
+ /**
96
+ * Get number of quads currently in batch
97
+ */
98
+ getQuadCount(): number;
99
+ /**
100
+ * Update the batch - rebuilds vertex buffer if quads changed
101
+ */
102
+ update(): void;
103
+ /**
104
+ * Render the batch
105
+ * @param camera Optional camera for view transform (defaults to identity matrix)
106
+ */
107
+ render(camera?: Camera): void;
108
+ /**
109
+ * Generate vertices for a quad with rotation applied
110
+ * Returns 6 vertices (2 triangles)
111
+ * @private
112
+ */
113
+ private generateQuadVertices;
114
+ /**
115
+ * Dispose resources
116
+ */
117
+ dispose(): void;
118
+ }
119
+ /**
120
+ * V2 Batch Renderer for 2.5D sprites
121
+ * Supports position (x, y, z), texture coordinates (u, v),
122
+ * color tint (r, g, b, a), and texture index for texture atlases
123
+ */
124
+ export declare class SpriteBatchRenderer {
125
+ private gl;
126
+ private shader;
127
+ private vertexBuffer;
128
+ private maxQuads;
129
+ private vertexData;
130
+ private quads;
131
+ private isDirty;
132
+ private verticesPerQuad;
133
+ private floatsPerVertex;
134
+ private texture;
135
+ private depthTestEnabled;
136
+ /**
137
+ * Create a new sprite batch renderer (V2)
138
+ * @param gl WebGL rendering context
139
+ * @param shader Shader program to use (should be SHADERS_V2)
140
+ * @param maxQuads Maximum number of quads to batch (default 1000)
141
+ */
142
+ constructor(gl: WebGLRenderingContext, shader: Shader, maxQuads?: number);
143
+ /**
144
+ * Set the texture for batch rendering
145
+ * @param texture The texture to use when rendering
146
+ */
147
+ setTexture(texture: Texture | null): void;
148
+ /**
149
+ * Add a sprite quad to the batch
150
+ * @param quad Sprite quad instance to add
151
+ */
152
+ addQuad(quad: SpriteQuadInstance): void;
153
+ /**
154
+ * Clear all quads from the batch
155
+ */
156
+ clear(): void;
157
+ /**
158
+ * Get number of quads currently in batch
159
+ */
160
+ getQuadCount(): number;
161
+ /**
162
+ * Update the batch - rebuilds vertex buffer if quads changed
163
+ */
164
+ update(): void;
165
+ /**
166
+ * Set whether depth testing is enabled
167
+ * When enabled, sprites with lower Z values appear behind sprites with higher Z values
168
+ * @param enabled Whether to enable depth testing (default true)
169
+ */
170
+ setDepthTestEnabled(enabled: boolean): void;
171
+ /**
172
+ * Render the batch
173
+ * @param camera Optional camera for view transform (defaults to identity matrix)
174
+ */
175
+ render(camera?: Camera): void;
176
+ /**
177
+ * Generate vertices for a quad with rotation applied
178
+ * Returns 6 vertices (2 triangles)
179
+ * @private
180
+ */
181
+ private generateQuadVertices;
182
+ /**
183
+ * Dispose resources
184
+ */
185
+ dispose(): void;
186
+ }
187
+ /**
188
+ * GPU-Based Sprite Batch Renderer (V3)
189
+ *
190
+ * This version moves the 2.5D transformation from CPU to GPU.
191
+ * The vertex shader handles isometric projection, rotation, and camera transform.
192
+ *
193
+ * Key differences from SpriteBatchRenderer (V2):
194
+ * - Stores grid position (gridX, gridY) instead of screen position (x, y)
195
+ * - Passes local offset to shader for GPU-based rotation
196
+ * - Shader handles isometric projection and camera transform
197
+ * - Reduced CPU overhead for transformation calculations
198
+ *
199
+ * Vertex Layout (12 floats per vertex):
200
+ * [0-1] GridPosition: gridX, gridY
201
+ * [2] ZPosition: z
202
+ * [3-4] LocalOffset: localX, localY (quad corner offset)
203
+ * [5-6] TexCoord: u, v
204
+ * [7-10] Color: r, g, b, a
205
+ * [11] TexIndex: texture index
206
+ */
207
+ export declare class GPUBasedSpriteBatchRenderer {
208
+ private gl;
209
+ private shader;
210
+ private vertexBuffer;
211
+ private maxQuads;
212
+ private vertexData;
213
+ private quads;
214
+ private isDirty;
215
+ private verticesPerQuad;
216
+ private floatsPerVertex;
217
+ private texture;
218
+ private depthTestEnabled;
219
+ private tileSize;
220
+ private zScale;
221
+ private resolution;
222
+ /**
223
+ * Create a new GPU-based sprite batch renderer (V3)
224
+ * @param gl WebGL rendering context
225
+ * @param shader Shader program to use (should be SHADERS_V3)
226
+ * @param maxQuads Maximum number of quads to batch (default 1000)
227
+ * @param tileSize Tile size for isometric projection (default {width: 64, height: 32})
228
+ * @param zScale Scale factor for Z height (default 1.0)
229
+ */
230
+ constructor(gl: WebGLRenderingContext, shader: Shader, maxQuads?: number, tileSize?: {
231
+ width: number;
232
+ height: number;
233
+ }, zScale?: number);
234
+ /**
235
+ * Set the texture for batch rendering
236
+ * @param texture The texture to use when rendering
237
+ */
238
+ setTexture(texture: Texture | null): void;
239
+ /**
240
+ * Add a sprite quad to the batch
241
+ * If gridX and gridY are provided, uses GPU transformation.
242
+ * Otherwise, converts x, y to grid coordinates.
243
+ * @param quad Sprite quad instance to add
244
+ */
245
+ addQuad(quad: SpriteQuadInstance): void;
246
+ /**
247
+ * Clear all quads from the batch
248
+ */
249
+ clear(): void;
250
+ /**
251
+ * Get number of quads currently in batch
252
+ */
253
+ getQuadCount(): number;
254
+ /**
255
+ * Update the batch - rebuilds vertex buffer if quads changed
256
+ */
257
+ update(): void;
258
+ /**
259
+ * Set whether depth testing is enabled
260
+ * @param enabled Whether to enable depth testing (default true)
261
+ */
262
+ setDepthTestEnabled(enabled: boolean): void;
263
+ /**
264
+ * Render the batch with GPU-based transformation
265
+ * @param camera Camera for view transform
266
+ */
267
+ render(camera: Camera): void;
268
+ /**
269
+ * Clean up GPU resources
270
+ */
271
+ dispose(): void;
272
+ }
273
+ //# sourceMappingURL=batch-renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batch-renderer.d.ts","sourceRoot":"","sources":["../../../src/rendering/batch-renderer.ts"],"names":[],"mappings":"AAAA;;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