@codexo/exojs 0.6.4 → 0.6.5

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 (43) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/dist/esm/core/Application.d.ts +0 -1
  3. package/dist/esm/core/Application.js +0 -1
  4. package/dist/esm/core/Application.js.map +1 -1
  5. package/dist/esm/core/SceneManager.js +11 -12
  6. package/dist/esm/core/SceneManager.js.map +1 -1
  7. package/dist/esm/index.js +0 -5
  8. package/dist/esm/index.js.map +1 -1
  9. package/dist/esm/math/geometry.d.ts +12 -8
  10. package/dist/esm/math/geometry.js +119 -72
  11. package/dist/esm/math/geometry.js.map +1 -1
  12. package/dist/esm/rendering/index.d.ts +0 -5
  13. package/dist/esm/rendering/primitives/Graphics.d.ts +3 -2
  14. package/dist/esm/rendering/primitives/Graphics.js +33 -25
  15. package/dist/esm/rendering/primitives/Graphics.js.map +1 -1
  16. package/dist/esm/rendering/webgl2/WebGl2Backend.js +1 -4
  17. package/dist/esm/rendering/webgl2/WebGl2Backend.js.map +1 -1
  18. package/dist/esm/rendering/webgpu/WebGpuBackend.js +0 -3
  19. package/dist/esm/rendering/webgpu/WebGpuBackend.js.map +1 -1
  20. package/dist/esm/rendering/webgpu/WebGpuMaskCompositor.js +1 -2
  21. package/dist/esm/rendering/webgpu/WebGpuMaskCompositor.js.map +1 -1
  22. package/dist/exo.esm.js +586 -1274
  23. package/dist/exo.esm.js.map +1 -1
  24. package/package.json +1 -1
  25. package/dist/esm/rendering/primitives/CircleGeometry.d.ts +0 -4
  26. package/dist/esm/rendering/primitives/CircleGeometry.js +0 -21
  27. package/dist/esm/rendering/primitives/CircleGeometry.js.map +0 -1
  28. package/dist/esm/rendering/primitives/DrawableShape.d.ts +0 -11
  29. package/dist/esm/rendering/primitives/DrawableShape.js +0 -21
  30. package/dist/esm/rendering/primitives/DrawableShape.js.map +0 -1
  31. package/dist/esm/rendering/primitives/Geometry.d.ts +0 -13
  32. package/dist/esm/rendering/primitives/Geometry.js +0 -16
  33. package/dist/esm/rendering/primitives/Geometry.js.map +0 -1
  34. package/dist/esm/rendering/webgl2/WebGl2PrimitiveRenderer.d.ts +0 -26
  35. package/dist/esm/rendering/webgl2/WebGl2PrimitiveRenderer.js +0 -222
  36. package/dist/esm/rendering/webgl2/WebGl2PrimitiveRenderer.js.map +0 -1
  37. package/dist/esm/rendering/webgl2/glsl/primitive.frag.js +0 -4
  38. package/dist/esm/rendering/webgl2/glsl/primitive.frag.js.map +0 -1
  39. package/dist/esm/rendering/webgl2/glsl/primitive.vert.js +0 -4
  40. package/dist/esm/rendering/webgl2/glsl/primitive.vert.js.map +0 -1
  41. package/dist/esm/rendering/webgpu/WebGpuPrimitiveRenderer.d.ts +0 -38
  42. package/dist/esm/rendering/webgpu/WebGpuPrimitiveRenderer.js +0 -488
  43. package/dist/esm/rendering/webgpu/WebGpuPrimitiveRenderer.js.map +0 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@codexo/exojs",
3
3
  "description": "A TypeScript-first browser 2D runtime for games and interactive apps.",
4
- "version": "0.6.4",
4
+ "version": "0.6.5",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist/esm/",
@@ -1,4 +0,0 @@
1
- import { Geometry } from './Geometry';
2
- export declare class CircleGeometry extends Geometry {
3
- constructor(centerX: number, centerY: number, radius: number);
4
- }
@@ -1,21 +0,0 @@
1
- import { Geometry } from './Geometry.js';
2
-
3
- class CircleGeometry extends Geometry {
4
- constructor(centerX, centerY, radius) {
5
- const length = Math.floor(15 * Math.sqrt(radius + radius)), segment = (Math.PI * 2) / length, vertices = [], indices = [], points = [];
6
- let index = vertices.length / 6;
7
- indices.push(index);
8
- for (let i = 0; i < length + 1; i++) {
9
- const segmentX = centerX + (Math.sin(segment * i) * radius), segmentY = centerY + (Math.cos(segment * i) * radius);
10
- points.push(segmentX, segmentY);
11
- vertices.push(centerX, centerY);
12
- vertices.push(segmentX, segmentY);
13
- indices.push(index++, index++);
14
- }
15
- indices.push(index - 1);
16
- super({ vertices, indices, points });
17
- }
18
- }
19
-
20
- export { CircleGeometry };
21
- //# sourceMappingURL=CircleGeometry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CircleGeometry.js","sources":["../../../../../src/rendering/primitives/CircleGeometry.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEM,MAAO,cAAe,SAAQ,QAAQ,CAAA;AAExC,IAAA,WAAA,CAAmB,OAAe,EAAE,OAAe,EAAE,MAAc,EAAA;AAC/D,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,EACtD,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,IAAI,MAAM,EAChC,QAAQ,GAAG,EAAE,EACb,OAAO,GAAG,EAAE,EACZ,MAAM,GAAG,EAAE;AAEf,QAAA,IAAI,KAAK,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC;AAE/B,QAAA,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;AAEnB,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AACjC,YAAA,MAAM,QAAQ,GAAG,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,EACvD,QAAQ,GAAG,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC;AAEzD,YAAA,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC;AAE/B,YAAA,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC;AAC/B,YAAA,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC;YAEjC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC;QAClC;AAEA,QAAA,OAAO,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QAEvB,KAAK,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IACxC;AACH;;;;"}
@@ -1,11 +0,0 @@
1
- import { RenderingPrimitives } from '@/rendering/types';
2
- import type { Geometry } from '@/rendering/primitives/Geometry';
3
- import type { Color } from '@/core/Color';
4
- import { Drawable } from '@/rendering/Drawable';
5
- export declare class DrawableShape extends Drawable {
6
- readonly geometry: Geometry;
7
- readonly drawMode: RenderingPrimitives;
8
- readonly color: Color;
9
- constructor(geometry: Geometry, color: Color, drawMode?: RenderingPrimitives);
10
- destroy(): void;
11
- }
@@ -1,21 +0,0 @@
1
- import { RenderingPrimitives } from '../types.js';
2
- import { Drawable } from '../Drawable.js';
3
-
4
- class DrawableShape extends Drawable {
5
- geometry;
6
- drawMode;
7
- color;
8
- constructor(geometry, color, drawMode = RenderingPrimitives.Triangles) {
9
- super();
10
- this.geometry = geometry;
11
- this.color = color.clone();
12
- this.drawMode = drawMode;
13
- }
14
- destroy() {
15
- super.destroy();
16
- this.color.destroy();
17
- }
18
- }
19
-
20
- export { DrawableShape };
21
- //# sourceMappingURL=DrawableShape.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DrawableShape.js","sources":["../../../../../src/rendering/primitives/DrawableShape.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAKM,MAAO,aAAc,SAAQ,QAAQ,CAAA;AAEvB,IAAA,QAAQ;AACR,IAAA,QAAQ;AACR,IAAA,KAAK;AAErB,IAAA,WAAA,CAAmB,QAAkB,EAAE,KAAY,EAAE,QAAA,GAAgC,mBAAmB,CAAC,SAAS,EAAA;AAC9G,QAAA,KAAK,EAAE;AAEP,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ;AACxB,QAAA,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE;AAC1B,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ;IAC5B;IAEgB,OAAO,GAAA;QACnB,KAAK,CAAC,OAAO,EAAE;AAEf,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IACxB;AACH;;;;"}
@@ -1,13 +0,0 @@
1
- interface GeometryOptions {
2
- vertices?: Array<number>;
3
- indices?: Array<number>;
4
- points?: Array<number>;
5
- }
6
- export declare class Geometry {
7
- readonly vertices: Float32Array;
8
- readonly indices: Uint16Array;
9
- readonly points: Array<number>;
10
- constructor({ vertices, indices, points, }?: GeometryOptions);
11
- destroy(): void;
12
- }
13
- export {};
@@ -1,16 +0,0 @@
1
- class Geometry {
2
- vertices;
3
- indices;
4
- points;
5
- constructor({ vertices = [], indices = [], points = [], } = {}) {
6
- this.vertices = new Float32Array(vertices);
7
- this.indices = new Uint16Array(indices);
8
- this.points = points;
9
- }
10
- destroy() {
11
- // todo - check if destroy is needed
12
- }
13
- }
14
-
15
- export { Geometry };
16
- //# sourceMappingURL=Geometry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Geometry.js","sources":["../../../../../src/rendering/primitives/Geometry.ts"],"sourcesContent":[null],"names":[],"mappings":"MAMa,QAAQ,CAAA;AAED,IAAA,QAAQ;AACR,IAAA,OAAO;AACP,IAAA,MAAM;AAEtB,IAAA,WAAA,CAAmB,EACf,QAAQ,GAAG,EAAE,EACb,OAAO,GAAG,EAAE,EACZ,MAAM,GAAG,EAAE,MACM,EAAE,EAAA;QACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC;QAC1C,IAAI,CAAC,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC;AACvC,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;IACxB;IAEO,OAAO,GAAA;;IAEd;AACH;;;;"}
@@ -1,26 +0,0 @@
1
- import { AbstractWebGl2Renderer } from './AbstractWebGl2Renderer';
2
- import type { DrawableShape } from '../primitives/DrawableShape';
3
- import type { WebGl2Backend } from './WebGl2Backend';
4
- export declare class WebGl2PrimitiveRenderer extends AbstractWebGl2Renderer<DrawableShape> {
5
- private _vertexCapacity;
6
- private _indexCapacity;
7
- private _vertexData;
8
- private _indexData;
9
- private _float32View;
10
- private _uint32View;
11
- private _shader;
12
- private _connection;
13
- private _currentBlendMode;
14
- private _currentView;
15
- private _viewId;
16
- constructor(batchSize: number);
17
- render(shape: DrawableShape): void;
18
- flush(): void;
19
- destroy(): void;
20
- protected onConnect(backend: WebGl2Backend): void;
21
- protected onDisconnect(): void;
22
- private _ensureVertexCapacity;
23
- private _ensureIndexCapacity;
24
- private _createBufferRuntime;
25
- private _createVaoRuntime;
26
- }
@@ -1,222 +0,0 @@
1
- import { AbstractWebGl2Renderer } from './AbstractWebGl2Renderer.js';
2
- import { Shader } from '../shader/Shader.js';
3
- import { createWebGl2ShaderProgram } from './WebGl2ShaderProgram.js';
4
- import { WebGl2VertexArrayObject } from './WebGl2VertexArrayObject.js';
5
- import { BufferTypes, BufferUsage } from '../types.js';
6
- import { WebGl2RenderBuffer } from './WebGl2RenderBuffer.js';
7
- import vertexSource from './glsl/primitive.vert.js';
8
- import fragmentSource from './glsl/primitive.frag.js';
9
-
10
- const minBatchVertexSize = 4;
11
- const vertexStrideBytes = 12;
12
- const vertexStrideWords = vertexStrideBytes / 4;
13
- class WebGl2PrimitiveRenderer extends AbstractWebGl2Renderer {
14
- _vertexCapacity;
15
- _indexCapacity;
16
- _vertexData;
17
- _indexData;
18
- _float32View;
19
- _uint32View;
20
- _shader = new Shader(vertexSource, fragmentSource);
21
- _connection = null;
22
- _currentBlendMode = null;
23
- _currentView = null;
24
- _viewId = -1;
25
- constructor(batchSize) {
26
- super();
27
- this._vertexCapacity = Math.max(minBatchVertexSize, batchSize);
28
- this._indexCapacity = Math.max(6, this._vertexCapacity * 3);
29
- this._vertexData = new ArrayBuffer(this._vertexCapacity * vertexStrideBytes);
30
- this._indexData = new Uint16Array(this._indexCapacity);
31
- this._float32View = new Float32Array(this._vertexData);
32
- this._uint32View = new Uint32Array(this._vertexData);
33
- }
34
- render(shape) {
35
- const connection = this._connection;
36
- if (!connection) {
37
- throw new Error('Renderer not connected');
38
- }
39
- const backend = this.getBackend();
40
- const { geometry, drawMode, color, blendMode } = shape;
41
- const vertices = geometry.vertices;
42
- const sourceIndices = geometry.indices;
43
- const vertexCount = vertices.length / 2;
44
- const indexCount = sourceIndices.length > 0 ? sourceIndices.length : vertexCount;
45
- if (vertexCount === 0 || indexCount === 0) {
46
- return;
47
- }
48
- this._ensureVertexCapacity(vertexCount);
49
- this._ensureIndexCapacity(indexCount);
50
- if (blendMode !== this._currentBlendMode) {
51
- this._currentBlendMode = blendMode;
52
- backend.setBlendMode(blendMode);
53
- }
54
- const view = backend.view;
55
- if (this._currentView !== view || this._viewId !== view.updateId) {
56
- this._currentView = view;
57
- this._viewId = view.updateId;
58
- this._shader.getUniform('u_projection').setValue(view.getTransform().toArray(false));
59
- }
60
- this._shader.getUniform('u_translation').setValue(shape.getGlobalTransform().toArray(false));
61
- const packedColor = color.toRgba();
62
- for (let i = 0; i < vertexCount; i++) {
63
- const sourceIndex = i * 2;
64
- const targetIndex = i * vertexStrideWords;
65
- this._float32View[targetIndex] = vertices[sourceIndex];
66
- this._float32View[targetIndex + 1] = vertices[sourceIndex + 1];
67
- this._uint32View[targetIndex + 2] = packedColor;
68
- }
69
- if (sourceIndices.length > 0) {
70
- this._indexData.set(sourceIndices, 0);
71
- }
72
- else {
73
- for (let i = 0; i < vertexCount; i++) {
74
- this._indexData[i] = i;
75
- }
76
- }
77
- this._shader.sync();
78
- backend.bindVertexArrayObject(connection.vao);
79
- connection.vertexBuffer.upload(this._float32View.subarray(0, vertexCount * vertexStrideWords));
80
- connection.indexBuffer.upload(this._indexData.subarray(0, indexCount));
81
- connection.vao.draw(indexCount, 0, drawMode);
82
- backend.stats.batches++;
83
- backend.stats.drawCalls++;
84
- }
85
- flush() {
86
- // Primitive rendering is immediate per shape in this bridge stage.
87
- }
88
- destroy() {
89
- this.disconnect();
90
- this._shader.destroy();
91
- this._currentBlendMode = null;
92
- this._currentView = null;
93
- }
94
- onConnect(backend) {
95
- const gl = backend.context;
96
- const vaoHandle = gl.createVertexArray();
97
- this._shader.connect(createWebGl2ShaderProgram(gl));
98
- if (vaoHandle === null) {
99
- throw new Error('Could not create vertex array object.');
100
- }
101
- const buffers = new Map();
102
- const indexBuffer = new WebGl2RenderBuffer(BufferTypes.ElementArrayBuffer, this._indexData, BufferUsage.DynamicDraw)
103
- .connect(this._createBufferRuntime(gl, buffers));
104
- const vertexBuffer = new WebGl2RenderBuffer(BufferTypes.ArrayBuffer, this._vertexData, BufferUsage.DynamicDraw)
105
- .connect(this._createBufferRuntime(gl, buffers));
106
- // Force shader finalize so the attribute table is populated. The
107
- // async-compile path defers attribute extraction from initialize()
108
- // to first sync(); without this nudge, getAttribute() below would
109
- // throw "Attribute 'a_position' is not available".
110
- this._shader.sync();
111
- const vao = new WebGl2VertexArrayObject()
112
- .addIndex(indexBuffer)
113
- .addAttribute(vertexBuffer, this._shader.getAttribute('a_position'), gl.FLOAT, false, vertexStrideBytes, 0)
114
- .addAttribute(vertexBuffer, this._shader.getAttribute('a_color'), gl.UNSIGNED_BYTE, true, vertexStrideBytes, 8)
115
- .connect(this._createVaoRuntime(gl, vaoHandle));
116
- this._connection = { gl, buffers, vaoHandle, vao, indexBuffer, vertexBuffer };
117
- }
118
- onDisconnect() {
119
- const connection = this._connection;
120
- if (!connection) {
121
- return;
122
- }
123
- this._shader.disconnect();
124
- connection.indexBuffer.destroy();
125
- connection.vertexBuffer.destroy();
126
- connection.vao.destroy();
127
- this._connection = null;
128
- this._currentBlendMode = null;
129
- this._currentView = null;
130
- this._viewId = -1;
131
- }
132
- _ensureVertexCapacity(vertexCount) {
133
- if (vertexCount <= this._vertexCapacity) {
134
- return;
135
- }
136
- while (this._vertexCapacity < vertexCount) {
137
- this._vertexCapacity *= 2;
138
- }
139
- this._vertexData = new ArrayBuffer(this._vertexCapacity * vertexStrideBytes);
140
- this._float32View = new Float32Array(this._vertexData);
141
- this._uint32View = new Uint32Array(this._vertexData);
142
- }
143
- _ensureIndexCapacity(indexCount) {
144
- if (indexCount <= this._indexCapacity) {
145
- return;
146
- }
147
- while (this._indexCapacity < indexCount) {
148
- this._indexCapacity *= 2;
149
- }
150
- this._indexData = new Uint16Array(this._indexCapacity);
151
- }
152
- _createBufferRuntime(gl, buffers) {
153
- const handle = gl.createBuffer();
154
- if (handle === null) {
155
- throw new Error('Could not create render buffer.');
156
- }
157
- return {
158
- bind: (buffer) => {
159
- gl.bindBuffer(buffer.type, handle);
160
- },
161
- upload: (buffer, offset) => {
162
- const state = buffers.get(buffer);
163
- const data = buffer.data;
164
- gl.bindBuffer(buffer.type, handle);
165
- if (state && state.dataByteLength >= data.byteLength) {
166
- gl.bufferSubData(buffer.type, offset, data);
167
- state.dataByteLength = data.byteLength;
168
- }
169
- else {
170
- gl.bufferData(buffer.type, data, buffer.usage);
171
- buffers.set(buffer, { handle, dataByteLength: data.byteLength });
172
- }
173
- },
174
- destroy: (buffer) => {
175
- gl.deleteBuffer(handle);
176
- buffers.delete(buffer);
177
- buffer.disconnect();
178
- },
179
- };
180
- }
181
- _createVaoRuntime(gl, vaoHandle) {
182
- let appliedVersion = -1;
183
- return {
184
- bind: (vao) => {
185
- gl.bindVertexArray(vaoHandle);
186
- if (appliedVersion !== vao.version) {
187
- let lastBuffer = null;
188
- for (const attribute of vao.attributes) {
189
- if (lastBuffer !== attribute.buffer) {
190
- attribute.buffer.bind();
191
- lastBuffer = attribute.buffer;
192
- }
193
- gl.vertexAttribPointer(attribute.location, attribute.size, attribute.type, attribute.normalized, attribute.stride, attribute.start);
194
- gl.enableVertexAttribArray(attribute.location);
195
- }
196
- if (vao.indexBuffer) {
197
- vao.indexBuffer.bind();
198
- }
199
- appliedVersion = vao.version;
200
- }
201
- },
202
- unbind: () => {
203
- gl.bindVertexArray(null);
204
- },
205
- draw: (vao, size, start, type) => {
206
- if (vao.indexBuffer) {
207
- gl.drawElements(type, size, gl.UNSIGNED_SHORT, start);
208
- }
209
- else {
210
- gl.drawArrays(type, start, size);
211
- }
212
- },
213
- destroy: (vao) => {
214
- gl.deleteVertexArray(vaoHandle);
215
- vao.disconnect();
216
- },
217
- };
218
- }
219
- }
220
-
221
- export { WebGl2PrimitiveRenderer };
222
- //# sourceMappingURL=WebGl2PrimitiveRenderer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebGl2PrimitiveRenderer.js","sources":["../../../../../src/rendering/webgl2/WebGl2PrimitiveRenderer.ts"],"sourcesContent":[null],"names":["Buffer"],"mappings":";;;;;;;;;AAaA,MAAM,kBAAkB,GAAG,CAAC;AAC5B,MAAM,iBAAiB,GAAG,EAAE;AAC5B,MAAM,iBAAiB,GAAG,iBAAiB,GAAG,CAAC;AAgBzC,MAAO,uBAAwB,SAAQ,sBAAqC,CAAA;AACtE,IAAA,eAAe;AACf,IAAA,cAAc;AACd,IAAA,WAAW;AACX,IAAA,UAAU;AACV,IAAA,YAAY;AACZ,IAAA,WAAW;IACX,OAAO,GAAW,IAAI,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC;IAC1D,WAAW,GAAuC,IAAI;IACtD,iBAAiB,GAAkB,IAAI;IACvC,YAAY,GAAgB,IAAI;IAChC,OAAO,GAAG,EAAE;AAEpB,IAAA,WAAA,CAAmB,SAAiB,EAAA;AAChC,QAAA,KAAK,EAAE;QAEP,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC,kBAAkB,EAAE,SAAS,CAAC;AAC9D,QAAA,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;AAC3D,QAAA,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,eAAe,GAAG,iBAAiB,CAAC;QAC5E,IAAI,CAAC,U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S,CAAC,MAAM,CAAC,IAAI,EAAE;AACvB,4BAAA,UAAU,GAAG,SAAS,CAAC,MAAM;wBACjC;wBAEA,EAAE,CAAC,mBAAmB,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC;AACnI,wBAAA,EAAE,CAAC,uBAAuB,CAAC,SAAS,CAAC,QAAQ,CAAC;oBAClD;AAEA,oBAAA,IAAI,GAAG,CAAC,WAAW,EAAE;AACjB,wBAAA,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE;oBAC1B;AAEA,oBAAA,cAAc,GAAG,GAAG,CAAC,OAAO;gBAChC;YACJ,CAAC;YACD,MAAM,EAAE,MAAW;AACf,gBAAA,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC;YAC5B,CAAC;YACD,IAAI,EAAE,CAAC,GAA4B,EAAE,IAAY,EAAE,KAAa,EAAE,IAAY,KAAU;AACpF,gBAAA,IAAI,GAAG,CAAC,WAAW,EAAE;AACjB,oBAAA,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,cAAc,EAAE,KAAK,CAAC;gBACzD;qBAAO;oBACH,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC;gBACpC;YACJ,CAAC;AACD,YAAA,OAAO,EAAE,CAAC,GAA4B,KAAU;AAC5C,gBAAA,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC;gBAC/B,GAAG,CAAC,UAAU,EAAE;YACpB,CAAC;SACJ;IACL;AACH;;;;"}
@@ -1,4 +0,0 @@
1
- var fragmentSource = "#version 300 es\nprecision lowp float;\n\nlayout(location = 0) out vec4 fragColor;\n\nin vec4 v_color;\n\nvoid main(void) {\n fragColor = v_color;\n}\n";
2
-
3
- export { fragmentSource as default };
4
- //# sourceMappingURL=primitive.frag.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"primitive.frag.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,4 +0,0 @@
1
- var vertexSource = "#version 300 es\nprecision lowp float;\n\nlayout(location = 0) in vec2 a_position;\nlayout(location = 1) in vec4 a_color;\n\nuniform mat3 u_projection;\nuniform mat3 u_translation;\n\nout vec4 v_color;\n\nvoid main(void) {\n gl_Position = vec4((u_projection * u_translation * vec3(a_position, 1.0)).xy, 0.0, 1.0);\n v_color = vec4(a_color.rgb * a_color.a, a_color.a);\n}\n";
2
-
3
- export { vertexSource as default };
4
- //# sourceMappingURL=primitive.vert.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"primitive.vert.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,38 +0,0 @@
1
- import { AbstractWebGpuRenderer } from '@/rendering/webgpu/AbstractWebGpuRenderer';
2
- import type { DrawableShape } from '@/rendering/primitives/DrawableShape';
3
- import type { WebGpuBackend } from '@/rendering/webgpu/WebGpuBackend';
4
- export declare class WebGpuPrimitiveRenderer extends AbstractWebGpuRenderer<DrawableShape> {
5
- private readonly _combinedTransform;
6
- private readonly _drawCalls;
7
- private _drawCallCount;
8
- private readonly _pipelines;
9
- private _device;
10
- private _shaderModule;
11
- private _pipelineLayout;
12
- private _vertexBuffer;
13
- private _indexBuffer;
14
- private _vertexBufferCapacity;
15
- private _indexBufferCapacity;
16
- private _vertexData;
17
- private _float32View;
18
- private _uint32View;
19
- private _packedIndexData;
20
- private _generatedIndexData;
21
- private _sequentialIndexData;
22
- render(shape: DrawableShape): void;
23
- flush(): void;
24
- destroy(): void;
25
- protected onConnect(backend: WebGpuBackend): void;
26
- protected onDisconnect(): void;
27
- private _writeShapeVertices;
28
- private _ensureVertexCapacity;
29
- private _ensureIndexCapacity;
30
- private _getPipeline;
31
- private _getTopology;
32
- private _resolveDrawCall;
33
- private _resolveLineLoopDrawCall;
34
- private _resolveTriangleFanDrawCall;
35
- private _getSequentialIndices;
36
- private _ensureGeneratedIndexCapacity;
37
- private _destroyBuffers;
38
- }