@babylonjs/lite-gl 1.18.0 → 1.20.0-preview
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/CHANGELOG.md +1350 -0
- package/LICENSE +201 -0
- package/README.md +31 -0
- package/index.d.ts +13 -0
- package/index.js +7 -0
- package/index.js.map +1 -1
- package/package.json +9 -3
- package/text/_gpu/text-effect.d.ts +1 -0
- package/text/_gpu/text-effect.js +70 -0
- package/text/_gpu/text-effect.js.map +1 -0
- package/text/_gpu/text-instances.d.ts +1 -0
- package/text/_gpu/text-instances.js +57 -0
- package/text/_gpu/text-instances.js.map +1 -0
- package/text/_gpu/text-textures.d.ts +1 -0
- package/text/_gpu/text-textures.js +82 -0
- package/text/_gpu/text-textures.js.map +1 -0
- package/text/_gpu/text-vao.d.ts +1 -0
- package/text/_gpu/text-vao.js +49 -0
- package/text/_gpu/text-vao.js.map +1 -0
- package/text/default-text-data.d.ts +28 -0
- package/text/default-text-data.js +103 -0
- package/text/default-text-data.js.map +1 -0
- package/text/font.d.ts +16 -0
- package/text/font.js +24 -0
- package/text/font.js.map +1 -0
- package/text/glyph-extraction.d.ts +19 -0
- package/text/glyph-extraction.js +115 -0
- package/text/glyph-extraction.js.map +1 -0
- package/text/glyph-storage.d.ts +68 -0
- package/text/glyph-storage.js +298 -0
- package/text/glyph-storage.js.map +1 -0
- package/text/layout.d.ts +18 -0
- package/text/layout.js +219 -0
- package/text/layout.js.map +1 -0
- package/text/set-font-weight-offset.d.ts +5 -0
- package/text/set-font-weight-offset.js +67 -0
- package/text/set-font-weight-offset.js.map +1 -0
- package/text/shaders/slug-shader.d.ts +1 -0
- package/text/shaders/slug-shader.js +181 -0
- package/text/shaders/slug-shader.js.map +1 -0
- package/text/shaders/text-shader-fragment.d.ts +1 -0
- package/text/shaders/text-shader-fragment.js +2 -0
- package/text/shaders/text-shader-fragment.js.map +1 -0
- package/text/shaders/weight-shader-fragment.d.ts +1 -0
- package/text/shaders/weight-shader-fragment.js +75 -0
- package/text/shaders/weight-shader-fragment.js.map +1 -0
- package/text/text-data.d.ts +109 -0
- package/text/text-data.js +723 -0
- package/text/text-data.js.map +1 -0
- package/text/text-renderer.d.ts +68 -0
- package/text/text-renderer.js +238 -0
- package/text/text-renderer.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -146,6 +146,37 @@ use.
|
|
|
146
146
|
`setColorMask`, `clearEngine`; `setScissor`, `disableScissor`.
|
|
147
147
|
- **Blend** — `setBlendMode` + `GLBlendMode` (`DISABLE` / `ADD` / `ALPHA` /
|
|
148
148
|
`PREMULTIPLIED`), matching Babylon's `setAlphaMode` parameters.
|
|
149
|
+
- **Text (Slug)** — analytic, resolution-independent glyph rendering, the WebGL2
|
|
150
|
+
counterpart of Lite's `TextRenderer`: `loadFont` / `createFontFromBuffer`,
|
|
151
|
+
`createDefaultTextData` / `updateDefaultTextData` / `disposeDefaultTextData`
|
|
152
|
+
(shape + extract + pack in one call), or `createGlyphStorage` + `createTextData`
|
|
153
|
+
/ `updateTextData` / `disposeTextData` to drive your own layout;
|
|
154
|
+
`createTextLayer` / `setTextLayerPosition`, `createTextRenderer`,
|
|
155
|
+
`registerTextRenderer` / `unregisterTextRenderer` / `renderText` /
|
|
156
|
+
`isTextRendererReady`, and the optional synthetic-weight setter
|
|
157
|
+
`setFontWeightOffset` (its shader is only bundled when you import it). Text uses `text-shaper` for shaping; it is a dependency, not bundled by
|
|
158
|
+
consumers that never import the text API. See [Text](#text-slug) below.
|
|
159
|
+
|
|
160
|
+
### Text (Slug)
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
import { createGLEngine, loadFont, createDefaultTextData, createTextLayer, createTextRenderer, registerTextRenderer } from "@babylonjs/lite-gl";
|
|
164
|
+
|
|
165
|
+
const engine = createGLEngine(canvas);
|
|
166
|
+
const font = await loadFont("/fonts/Inter-Regular.ttf");
|
|
167
|
+
const data = createDefaultTextData(font, 48, "Hello, WebGL2", [1, 1, 1, 1]);
|
|
168
|
+
const layer = createTextLayer(data, { positionPx: { x: 24, y: 80 } });
|
|
169
|
+
const renderer = createTextRenderer(engine, { layers: [layer], clearValue: { r: 0.1, g: 0.1, b: 0.12 } });
|
|
170
|
+
registerTextRenderer(renderer); // draws every frame; unregisterTextRenderer to stop
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Glyph outlines are stored as quadratic curves in a float texture with a spatial
|
|
174
|
+
band index in an `rg32uint` texture; the fragment shader resolves analytic
|
|
175
|
+
coverage per pixel, so text stays sharp at any scale or rotation. The text data
|
|
176
|
+
(and its glyph storage) is borrowed by layers and renderers — dispose it
|
|
177
|
+
yourself with `disposeDefaultTextData` / `disposeTextData`. One glyph storage
|
|
178
|
+
can be drawn by a single engine only. Text is blended as premultiplied
|
|
179
|
+
source-over, with no depth test.
|
|
149
180
|
|
|
150
181
|
### Already-decoded textures
|
|
151
182
|
|
package/index.d.ts
CHANGED
|
@@ -28,3 +28,16 @@ export { createSpriteRenderer, renderSprites, setSpriteRendererTexture, disposeS
|
|
|
28
28
|
export type { GLSprite, GLSpriteColor, GLSpriteRendererOptions, GLSpriteRenderer } from "./sprites.js";
|
|
29
29
|
export { createHtmlElementTexture, updateHtmlElementTexture, GLSamplingMode } from "./html-texture.js";
|
|
30
30
|
export type { GLHtmlElementTextureOptions } from "./html-texture.js";
|
|
31
|
+
export type { GLFont } from "./text/font.js";
|
|
32
|
+
export { loadFont, createFontFromBuffer } from "./text/font.js";
|
|
33
|
+
export { extractGlyphCurves, cubicToQuadratics } from "./text/glyph-extraction.js";
|
|
34
|
+
export type { GLTextLayoutOptions } from "./text/layout.js";
|
|
35
|
+
export type { GLGlyphStorage, GLCurveSetId, GLQuadCurve, GLGlyphBounds, GLGlyphCurves } from "./text/glyph-storage.js";
|
|
36
|
+
export { createGlyphStorage, updateGlyphStorage, disposeGlyphStorage } from "./text/glyph-storage.js";
|
|
37
|
+
export type { GLTextData, GLPlacedGlyph, GLGlyphRun, GLTextDataUpdate } from "./text/text-data.js";
|
|
38
|
+
export { createTextData, updateTextData, disposeTextData } from "./text/text-data.js";
|
|
39
|
+
export type { GLDefaultTextData } from "./text/default-text-data.js";
|
|
40
|
+
export { createDefaultTextData, updateDefaultTextData, disposeDefaultTextData } from "./text/default-text-data.js";
|
|
41
|
+
export type { GLTextLayer, GLTextLayerOptions, GLTextRenderer, GLTextRendererOptions } from "./text/text-renderer.js";
|
|
42
|
+
export { createTextLayer, setTextLayerPosition, createTextRenderer, renderText, isTextRendererReady, addTextRendererLayer, removeTextRendererLayer, registerTextRenderer, unregisterTextRenderer, disposeTextRenderer, } from "./text/text-renderer.js";
|
|
43
|
+
export { setFontWeightOffset } from "./text/set-font-weight-offset.js";
|
package/index.js
CHANGED
|
@@ -44,4 +44,11 @@ export { createSpriteRenderer, renderSprites, setSpriteRendererTexture, disposeS
|
|
|
44
44
|
// ─── HTML-element textures ───────────────────────────────────────────
|
|
45
45
|
// GLSamplingMode is a const + same-name type; one value re-export carries both.
|
|
46
46
|
export { createHtmlElementTexture, updateHtmlElementTexture, GLSamplingMode } from "./html-texture.js";
|
|
47
|
+
export { loadFont, createFontFromBuffer } from "./text/font.js";
|
|
48
|
+
export { extractGlyphCurves, cubicToQuadratics } from "./text/glyph-extraction.js";
|
|
49
|
+
export { createGlyphStorage, updateGlyphStorage, disposeGlyphStorage } from "./text/glyph-storage.js";
|
|
50
|
+
export { createTextData, updateTextData, disposeTextData } from "./text/text-data.js";
|
|
51
|
+
export { createDefaultTextData, updateDefaultTextData, disposeDefaultTextData } from "./text/default-text-data.js";
|
|
52
|
+
export { createTextLayer, setTextLayerPosition, createTextRenderer, renderText, isTextRendererReady, addTextRendererLayer, removeTextRendererLayer, registerTextRenderer, unregisterTextRenderer, disposeTextRenderer, } from "./text/text-renderer.js";
|
|
53
|
+
export { setFontWeightOffset } from "./text/set-font-weight-offset.js";
|
|
47
54
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,gFAAgF;AAChF,EAAE;AACF,iFAAiF;AACjF,4EAA4E;AAC5E,2EAA2E;AAC3E,yEAAyE;AACzE,+DAA+D;AAC/D,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAC9E,wCAAwC;AAExC,wEAAwE;AACxE,OAAO,EACH,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,kBAAkB,GACrB,MAAM,cAAc,CAAC;AAGtB,uEAAuE;AACvE,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEvG,wEAAwE;AACxE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEjE,wEAAwE;AACxE,OAAO,EACH,YAAY,EACZ,SAAS,EACT,aAAa,EACb,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,GACpB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AAoB,EAAE,YAAY,EAAE,WAAW,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAGhK,wEAAwE;AACxE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE1D,wEAAwE;AACxE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAGpH,wEAAwE;AACxE,gFAAgF;AAChF,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["// @babylonjs/lite-gl — Public API\n// Function-based, tree-shakeable WebGL2 micro-engine. Import only what you use.\n//\n// Convention (mirrors @babylonjs/lite): the public API is re-exported EXPLICITLY\n// by name — never `export *`. This keeps the public surface intentional and\n// reviewable, lets `export type` mark type-only re-exports (required under\n// `isolatedModules`), and keeps internal helpers (e.g. `bindTextureRaw`,\n// `bindTextureForUpload`) out of consumers' bundles + `.d.ts`.\n//\n// The package is `sideEffects: false` and no module has top-level side effects,\n// so a consumer that imports only the symbols it needs tree-shakes everything\n// else (sprites, html-texture, …) away.\n\n// ─── Engine / context ────────────────────────────────────────────────\nexport {\n createGLEngine,\n disposeGLEngine,\n resizeGLEngine,\n setGLEngineSize,\n wipeGLStateCache,\n getRenderWidth,\n getRenderHeight,\n getHardwareScalingLevel,\n setHardwareScalingLevel,\n getRenderingCanvas,\n onContextLost,\n offContextLost,\n onContextRestored,\n offContextRestored,\n} from \"./context.js\";\nexport type { GLEngineOptions, GLEngineCaps, GLEngineContext } from \"./context.js\";\n\n// ─── Alpha-to-coverage (optional) ───────────────────────────────────\nexport { getAlphaToCoverage, getCurrentSampleCount, setAlphaToCoverage } from \"./alpha-to-coverage.js\";\n\n// ─── Render loop ─────────────────────────────────────────────────────\nexport { runRenderLoop, stopRenderLoop } from \"./render-loop.js\";\n\n// ─── Effects ─────────────────────────────────────────────────────────\nexport {\n createEffect,\n useEffect,\n isEffectReady,\n getEffectCompilationError,\n executeWhenCompiled,\n disposeEffect,\n setEffectFloat,\n setEffectFloat2,\n setEffectFloat3,\n setEffectFloat4,\n setEffectColor3,\n setEffectColor4,\n setEffectVector2,\n setEffectDirectColor4,\n setEffectInt,\n setEffectTexture,\n setEffectMatrix,\n setEffectMatrix3x3,\n setEffectFloatArray,\n setEffectFloatArray4,\n setEffectIntArray,\n} from \"./effect.js\";\nexport type { GLEffectOptions, GLEffect } from \"./effect.js\";\nexport { waitForEffect } from \"./effect-ready.js\";\nexport type { GLEffectWaitOptions } from \"./effect-ready.js\";\n\n// ─── Effect renderer (fullscreen quad) ───────────────────────────────\nexport { createEffectWrapper, applyEffectWrapper, drawEffect, setViewport, disposeEffectWrapper } from \"./effect-renderer.js\";\nexport type { GLEffectWrapperOptions, GLEffectWrapper, GLViewport } from \"./effect-renderer.js\";\n\n// ─── Textures ────────────────────────────────────────────────────────\nexport {\n createRawTexture,\n createFloatTexture,\n generateTextureMipMaps,\n loadTexture2D,\n bindTexture,\n disposeTexture,\n updateRawTexture,\n updateTextureSamplingMode,\n updateTextureWrapMode,\n createTextureFromHandle,\n} from \"./texture.js\";\nexport type { GLTextureOptions, GLFloatTextureOptions, GLTexture } from \"./texture.js\";\nexport { createTextureFromSource } from \"./texture-source.js\";\nexport type { GLTextureSourceOptions } from \"./texture-source.js\";\nexport {\n createTexture3DFromPixels,\n bindTexture3D,\n setEffectTexture3D,\n generateTexture3DMipMaps,\n updateTexture3DSamplingMode,\n updateTexture3DWrapMode,\n disposeTexture3D,\n} from \"./texture-3d.js\";\nexport type { GLPixelsTexture3DOptions, GLTexture3D } from \"./texture-3d.js\";\n\n// ─── Dynamic textures ────────────────────────────────────────────────\nexport { createDynamicTexture, updateDynamicTexture, clearDynamicTextureSource } from \"./dynamic-texture.js\";\n\n// ─── Render targets ──────────────────────────────────────────────────\nexport {\n createRenderTarget,\n createFloatRenderTarget,\n bindRenderTarget,\n generateRenderTargetMipMaps,\n resizeRenderTarget,\n readRenderTargetPixels,\n disposeRenderTarget,\n} from \"./render-target.js\";\nexport type { GLRenderTarget, GLRenderTargetOptions, GLFloatRenderTargetOptions } from \"./render-target.js\";\n\n// ─── Meshes / buffers / instancing ───────────────────────────────────\nexport {\n createVertexBuffer,\n updateVertexBuffer,\n createIndexBuffer,\n disposeBuffer,\n bindIndexBuffer,\n bindAttributes,\n unbindInstanceAttributes,\n drawIndexed,\n createMeshVao,\n bindMeshVao,\n drawMesh,\n disposeMeshVao,\n} from \"./mesh.js\";\nexport type { GLVertexBuffer, GLIndexBuffer, GLAttributeDescriptor, GLMeshVertexBuffer, GLMeshVao } from \"./mesh.js\";\n\n// ─── Blend modes ─────────────────────────────────────────────────────\n// GLBlendMode / GLBlendEquation are const + same-name type; one value\n// re-export carries both.\nexport { GLBlendMode, GLBlendEquation, setBlendMode, setBlendState, disableBlend } from \"./blend.js\";\nexport type { GLBlendState } from \"./blend.js\";\n\n// ─── Depth / stencil / color-mask / clear ────────────────────────────\nexport { setDepthState, setCullState, setStencilState, setStencilOpSeparate, setColorMask, clearEngine, generateRenderTargetStencil } from \"./depth-stencil.js\";\nexport type { GLDepthState, GLStencilState, GLStencilOpState, GLClearOptions } from \"./depth-stencil.js\";\n\n// ─── Scissor ─────────────────────────────────────────────────────────\nexport { setScissor, disableScissor } from \"./scissor.js\";\n\n// ─── Sprites ─────────────────────────────────────────────────────────\nexport { createSpriteRenderer, renderSprites, setSpriteRendererTexture, disposeSpriteRenderer } from \"./sprites.js\";\nexport type { GLSprite, GLSpriteColor, GLSpriteRendererOptions, GLSpriteRenderer } from \"./sprites.js\";\n\n// ─── HTML-element textures ───────────────────────────────────────────\n// GLSamplingMode is a const + same-name type; one value re-export carries both.\nexport { createHtmlElementTexture, updateHtmlElementTexture, GLSamplingMode } from \"./html-texture.js\";\nexport type { GLHtmlElementTextureOptions } from \"./html-texture.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"m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AKvG,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAGnF,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEtG,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtF,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAEnH,OAAO,EACH,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC","sourcesContent":["// @babylonjs/lite-gl — Public API\n// Function-based, tree-shakeable WebGL2 micro-engine. Import only what you use.\n//\n// Convention (mirrors @babylonjs/lite): the public API is re-exported EXPLICITLY\n// by name — never `export *`. This keeps the public surface intentional and\n// reviewable, lets `export type` mark type-only re-exports (required under\n// `isolatedModules`), and keeps internal helpers (e.g. `bindTextureRaw`,\n// `bindTextureForUpload`) out of consumers' bundles + `.d.ts`.\n//\n// The package is `sideEffects: false` and no module has top-level side effects,\n// so a consumer that imports only the symbols it needs tree-shakes everything\n// else (sprites, html-texture, …) away.\n\n// ─── Engine / context ────────────────────────────────────────────────\nexport {\n createGLEngine,\n disposeGLEngine,\n resizeGLEngine,\n setGLEngineSize,\n wipeGLStateCache,\n getRenderWidth,\n getRenderHeight,\n getHardwareScalingLevel,\n setHardwareScalingLevel,\n getRenderingCanvas,\n onContextLost,\n offContextLost,\n onContextRestored,\n offContextRestored,\n} from \"./context.js\";\nexport type { GLEngineOptions, GLEngineCaps, GLEngineContext } from \"./context.js\";\n\n// ─── Alpha-to-coverage (optional) ───────────────────────────────────\nexport { getAlphaToCoverage, getCurrentSampleCount, setAlphaToCoverage } from \"./alpha-to-coverage.js\";\n\n// ─── Render loop ─────────────────────────────────────────────────────\nexport { runRenderLoop, stopRenderLoop } from \"./render-loop.js\";\n\n// ─── Effects ─────────────────────────────────────────────────────────\nexport {\n createEffect,\n useEffect,\n isEffectReady,\n getEffectCompilationError,\n executeWhenCompiled,\n disposeEffect,\n setEffectFloat,\n setEffectFloat2,\n setEffectFloat3,\n setEffectFloat4,\n setEffectColor3,\n setEffectColor4,\n setEffectVector2,\n setEffectDirectColor4,\n setEffectInt,\n setEffectTexture,\n setEffectMatrix,\n setEffectMatrix3x3,\n setEffectFloatArray,\n setEffectFloatArray4,\n setEffectIntArray,\n} from \"./effect.js\";\nexport type { GLEffectOptions, GLEffect } from \"./effect.js\";\nexport { waitForEffect } from \"./effect-ready.js\";\nexport type { GLEffectWaitOptions } from \"./effect-ready.js\";\n\n// ─── Effect renderer (fullscreen quad) ───────────────────────────────\nexport { createEffectWrapper, applyEffectWrapper, drawEffect, setViewport, disposeEffectWrapper } from \"./effect-renderer.js\";\nexport type { GLEffectWrapperOptions, GLEffectWrapper, GLViewport } from \"./effect-renderer.js\";\n\n// ─── Textures ────────────────────────────────────────────────────────\nexport {\n createRawTexture,\n createFloatTexture,\n generateTextureMipMaps,\n loadTexture2D,\n bindTexture,\n disposeTexture,\n updateRawTexture,\n updateTextureSamplingMode,\n updateTextureWrapMode,\n createTextureFromHandle,\n} from \"./texture.js\";\nexport type { GLTextureOptions, GLFloatTextureOptions, GLTexture } from \"./texture.js\";\nexport { createTextureFromSource } from \"./texture-source.js\";\nexport type { GLTextureSourceOptions } from \"./texture-source.js\";\nexport {\n createTexture3DFromPixels,\n bindTexture3D,\n setEffectTexture3D,\n generateTexture3DMipMaps,\n updateTexture3DSamplingMode,\n updateTexture3DWrapMode,\n disposeTexture3D,\n} from \"./texture-3d.js\";\nexport type { GLPixelsTexture3DOptions, GLTexture3D } from \"./texture-3d.js\";\n\n// ─── Dynamic textures ────────────────────────────────────────────────\nexport { createDynamicTexture, updateDynamicTexture, clearDynamicTextureSource } from \"./dynamic-texture.js\";\n\n// ─── Render targets ──────────────────────────────────────────────────\nexport {\n createRenderTarget,\n createFloatRenderTarget,\n bindRenderTarget,\n generateRenderTargetMipMaps,\n resizeRenderTarget,\n readRenderTargetPixels,\n disposeRenderTarget,\n} from \"./render-target.js\";\nexport type { GLRenderTarget, GLRenderTargetOptions, GLFloatRenderTargetOptions } from \"./render-target.js\";\n\n// ─── Meshes / buffers / instancing ───────────────────────────────────\nexport {\n createVertexBuffer,\n updateVertexBuffer,\n createIndexBuffer,\n disposeBuffer,\n bindIndexBuffer,\n bindAttributes,\n unbindInstanceAttributes,\n drawIndexed,\n createMeshVao,\n bindMeshVao,\n drawMesh,\n disposeMeshVao,\n} from \"./mesh.js\";\nexport type { GLVertexBuffer, GLIndexBuffer, GLAttributeDescriptor, GLMeshVertexBuffer, GLMeshVao } from \"./mesh.js\";\n\n// ─── Blend modes ─────────────────────────────────────────────────────\n// GLBlendMode / GLBlendEquation are const + same-name type; one value\n// re-export carries both.\nexport { GLBlendMode, GLBlendEquation, setBlendMode, setBlendState, disableBlend } from \"./blend.js\";\nexport type { GLBlendState } from \"./blend.js\";\n\n// ─── Depth / stencil / color-mask / clear ────────────────────────────\nexport { setDepthState, setCullState, setStencilState, setStencilOpSeparate, setColorMask, clearEngine, generateRenderTargetStencil } from \"./depth-stencil.js\";\nexport type { GLDepthState, GLStencilState, GLStencilOpState, GLClearOptions } from \"./depth-stencil.js\";\n\n// ─── Scissor ─────────────────────────────────────────────────────────\nexport { setScissor, disableScissor } from \"./scissor.js\";\n\n// ─── Sprites ─────────────────────────────────────────────────────────\nexport { createSpriteRenderer, renderSprites, setSpriteRendererTexture, disposeSpriteRenderer } from \"./sprites.js\";\nexport type { GLSprite, GLSpriteColor, GLSpriteRendererOptions, GLSpriteRenderer } from \"./sprites.js\";\n\n// ─── HTML-element textures ───────────────────────────────────────────\n// GLSamplingMode is a const + same-name type; one value re-export carries both.\nexport { createHtmlElementTexture, updateHtmlElementTexture, GLSamplingMode } from \"./html-texture.js\";\nexport type { GLHtmlElementTextureOptions } from \"./html-texture.js\";\n\n// ─── Text (analytic Slug coverage) ───────────────────────────────────\nexport type { GLFont } from \"./text/font.js\";\nexport { loadFont, createFontFromBuffer } from \"./text/font.js\";\nexport { extractGlyphCurves, cubicToQuadratics } from \"./text/glyph-extraction.js\";\nexport type { GLTextLayoutOptions } from \"./text/layout.js\";\nexport type { GLGlyphStorage, GLCurveSetId, GLQuadCurve, GLGlyphBounds, GLGlyphCurves } from \"./text/glyph-storage.js\";\nexport { createGlyphStorage, updateGlyphStorage, disposeGlyphStorage } from \"./text/glyph-storage.js\";\nexport type { GLTextData, GLPlacedGlyph, GLGlyphRun, GLTextDataUpdate } from \"./text/text-data.js\";\nexport { createTextData, updateTextData, disposeTextData } from \"./text/text-data.js\";\nexport type { GLDefaultTextData } from \"./text/default-text-data.js\";\nexport { createDefaultTextData, updateDefaultTextData, disposeDefaultTextData } from \"./text/default-text-data.js\";\nexport type { GLTextLayer, GLTextLayerOptions, GLTextRenderer, GLTextRendererOptions } from \"./text/text-renderer.js\";\nexport {\n createTextLayer,\n setTextLayerPosition,\n createTextRenderer,\n renderText,\n isTextRendererReady,\n addTextRendererLayer,\n removeTextRendererLayer,\n registerTextRenderer,\n unregisterTextRenderer,\n disposeTextRenderer,\n} from \"./text/text-renderer.js\";\nexport { setFontWeightOffset } from \"./text/set-font-weight-offset.js\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@babylonjs/lite-gl",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0-preview",
|
|
4
4
|
"description": "Function-based, tree-shakeable WebGL2 micro-engine for fullscreen effects, sprites and dynamic textures — the WebGL counterpart of @babylonjs/lite.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"babylon",
|
|
@@ -25,6 +25,9 @@
|
|
|
25
25
|
"module": "./index.js",
|
|
26
26
|
"types": "./index.d.ts",
|
|
27
27
|
"sideEffects": false,
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"text-shaper": "^0.1.28"
|
|
30
|
+
},
|
|
28
31
|
"exports": {
|
|
29
32
|
".": {
|
|
30
33
|
"import": "./index.js",
|
|
@@ -32,7 +35,10 @@
|
|
|
32
35
|
}
|
|
33
36
|
},
|
|
34
37
|
"babylonLiteRelease": {
|
|
35
|
-
"azureBuildId": "
|
|
36
|
-
"sourceVersion": "
|
|
38
|
+
"azureBuildId": "162715083",
|
|
39
|
+
"sourceVersion": "3628bac1f882a6afb9db850d75364415e80cb992"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"tag": "preview"
|
|
37
43
|
}
|
|
38
44
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createEffect, setEffectFloat4, setEffectMatrix, useEffect } from "../../effect.js";
|
|
2
|
+
import { composeSlugShader } from "../shaders/slug-shader.js";
|
|
3
|
+
let programs = null;
|
|
4
|
+
let baseShader = null;
|
|
5
|
+
/** @internal Optional feature-owned variant factory. */
|
|
6
|
+
export let _createTextVariant = null;
|
|
7
|
+
/** @internal */
|
|
8
|
+
export function _installTextVariantResolver(factory) {
|
|
9
|
+
_createTextVariant = factory;
|
|
10
|
+
}
|
|
11
|
+
/** @internal Acquires one effect reference for this renderer. */
|
|
12
|
+
export function createTextProgram(engine, shader) {
|
|
13
|
+
const source = shader ?? (baseShader ??= composeSlugShader(null));
|
|
14
|
+
const effect = createEffect(engine, {
|
|
15
|
+
name: "text-slug" + source._key,
|
|
16
|
+
vertexSource: source._vert,
|
|
17
|
+
fragmentSource: source._frag,
|
|
18
|
+
uniformNames: ["mvp", "viewport", "color"],
|
|
19
|
+
samplerNames: ["curveTex", "bandTex", "glyphMetadata", "styles"],
|
|
20
|
+
attributeNames: ["corner", "anchor", "glyphStyle"],
|
|
21
|
+
});
|
|
22
|
+
const cache = (programs ??= new WeakMap());
|
|
23
|
+
let program = cache.get(effect);
|
|
24
|
+
if (!program) {
|
|
25
|
+
program = { _effect: effect, _uploadedProgram: null, _mvpInputs: new Float64Array(6), _mvp: new Float32Array(16) };
|
|
26
|
+
cache.set(effect, program);
|
|
27
|
+
}
|
|
28
|
+
return program;
|
|
29
|
+
}
|
|
30
|
+
/** @internal Skip unchanged projection work and uploads; relink always invalidates the cache. */
|
|
31
|
+
export function uploadTextUniforms(engine, program, layer, width, height) {
|
|
32
|
+
const effect = program._effect;
|
|
33
|
+
useEffect(engine, effect);
|
|
34
|
+
const inputs = program._mvpInputs;
|
|
35
|
+
const px = layer.positionPx.x;
|
|
36
|
+
const py = layer.positionPx.y;
|
|
37
|
+
const rotation = layer.rotationRad;
|
|
38
|
+
const scale = layer.scale;
|
|
39
|
+
if (program._uploadedProgram !== effect.program ||
|
|
40
|
+
inputs[0] !== px ||
|
|
41
|
+
inputs[1] !== py ||
|
|
42
|
+
inputs[2] !== rotation ||
|
|
43
|
+
inputs[3] !== scale ||
|
|
44
|
+
inputs[4] !== width ||
|
|
45
|
+
inputs[5] !== height) {
|
|
46
|
+
const mvp = program._mvp;
|
|
47
|
+
const cx = (2 * scale) / width;
|
|
48
|
+
const cy = (2 * scale) / height;
|
|
49
|
+
const cr = Math.cos(rotation);
|
|
50
|
+
const sr = Math.sin(rotation);
|
|
51
|
+
mvp[0] = cx * cr;
|
|
52
|
+
mvp[1] = -cy * sr;
|
|
53
|
+
mvp[4] = cx * sr;
|
|
54
|
+
mvp[5] = cy * cr;
|
|
55
|
+
mvp[10] = mvp[15] = 1;
|
|
56
|
+
mvp[12] = (2 * px) / width - 1;
|
|
57
|
+
mvp[13] = 1 - (2 * py) / height;
|
|
58
|
+
setEffectMatrix(engine, effect, "mvp", mvp);
|
|
59
|
+
inputs[0] = px;
|
|
60
|
+
inputs[1] = py;
|
|
61
|
+
inputs[2] = rotation;
|
|
62
|
+
inputs[3] = scale;
|
|
63
|
+
inputs[4] = width;
|
|
64
|
+
inputs[5] = height;
|
|
65
|
+
program._uploadedProgram = effect.program;
|
|
66
|
+
}
|
|
67
|
+
setEffectFloat4(engine, effect, "viewport", width, height, 0, 0);
|
|
68
|
+
setEffectFloat4(engine, effect, "color", layer.coverageGamma > 0 ? 1 / layer.coverageGamma : 1, 1, 1, layer.opacity);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=text-effect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-effect.js","sourceRoot":"","sources":["../../../src/text/_gpu/text-effect.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAe9D,IAAI,QAAQ,GAA0C,IAAI,CAAC;AAC3D,IAAI,UAAU,GAA8B,IAAI,CAAC;AAEjD,wDAAwD;AACxD,MAAM,CAAC,IAAI,kBAAkB,GAAsD,IAAI,CAAC;AAExF,gBAAgB;AAChB,MAAM,UAAU,2BAA2B,CAAC,OAAiD;IACzF,kBAAkB,GAAG,OAAO,CAAC;AACjC,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,iBAAiB,CAAC,MAAuB,EAAE,MAA2B;IAClF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,KAAK,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;IAClE,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,EAAE;QAChC,IAAI,EAAE,WAAW,GAAG,MAAM,CAAC,IAAI;QAC/B,YAAY,EAAE,MAAM,CAAC,KAAK;QAC1B,cAAc,EAAE,MAAM,CAAC,KAAK;QAC5B,YAAY,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE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AAC,GAAG,QAAQ,CAAC;QACrB,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;QAClB,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;QAClB,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;QACnB,OAAO,CAAC,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC;IAC9C,CAAC;IACD,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACjE,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;AACzH,CAAC","sourcesContent":["import type { GLEngineContext } from \"../../context.js\";\nimport { createEffect, setEffectFloat4, setEffectMatrix, useEffect } from \"../../effect.js\";\nimport type { GLEffect } from \"../../effect.js\";\nimport type { GLTextLayer } from \"../text-renderer.js\";\nimport { composeSlugShader } from \"../shaders/slug-shader.js\";\nimport type { ComposedSlugShader } from \"../shaders/slug-shader.js\";\n\n/** @internal Uniform caches belong to the shared program, not an individual layer/renderer. */\nexport interface TextProgram {\n /** @internal */\n _effect: GLEffect;\n /** @internal */\n _uploadedProgram: WebGLProgram | null;\n /** @internal */\n _mvpInputs: Float64Array;\n /** @internal */\n _mvp: Float32Array;\n}\n\nlet programs: WeakMap<GLEffect, TextProgram> | null = null;\nlet baseShader: ComposedSlugShader | null = null;\n\n/** @internal Optional feature-owned variant factory. */\nexport let _createTextVariant: ((engine: GLEngineContext) => TextProgram) | null = null;\n\n/** @internal */\nexport function _installTextVariantResolver(factory: (engine: GLEngineContext) => TextProgram): void {\n _createTextVariant = factory;\n}\n\n/** @internal Acquires one effect reference for this renderer. */\nexport function createTextProgram(engine: GLEngineContext, shader?: ComposedSlugShader): TextProgram {\n const source = shader ?? (baseShader ??= composeSlugShader(null));\n const effect = createEffect(engine, {\n name: \"text-slug\" + source._key,\n vertexSource: source._vert,\n fragmentSource: source._frag,\n uniformNames: [\"mvp\", \"viewport\", \"color\"],\n samplerNames: [\"curveTex\", \"bandTex\", \"glyphMetadata\", \"styles\"],\n attributeNames: [\"corner\", \"anchor\", \"glyphStyle\"],\n });\n const cache = (programs ??= new WeakMap());\n let program = cache.get(effect);\n if (!program) {\n program = { _effect: effect, _uploadedProgram: null, _mvpInputs: new Float64Array(6), _mvp: new Float32Array(16) };\n cache.set(effect, program);\n }\n return program;\n}\n\n/** @internal Skip unchanged projection work and uploads; relink always invalidates the cache. */\nexport function uploadTextUniforms(engine: GLEngineContext, program: TextProgram, layer: GLTextLayer, width: number, height: number): void {\n const effect = program._effect;\n useEffect(engine, effect);\n const inputs = program._mvpInputs;\n const px = layer.positionPx.x;\n const py = layer.positionPx.y;\n const rotation = layer.rotationRad;\n const scale = layer.scale;\n if (\n program._uploadedProgram !== effect.program ||\n inputs[0] !== px ||\n inputs[1] !== py ||\n inputs[2] !== rotation ||\n inputs[3] !== scale ||\n inputs[4] !== width ||\n inputs[5] !== height\n ) {\n const mvp = program._mvp;\n const cx = (2 * scale) / width;\n const cy = (2 * scale) / height;\n const cr = Math.cos(rotation);\n const sr = Math.sin(rotation);\n mvp[0] = cx * cr;\n mvp[1] = -cy * sr;\n mvp[4] = cx * sr;\n mvp[5] = cy * cr;\n mvp[10] = mvp[15] = 1;\n mvp[12] = (2 * px) / width - 1;\n mvp[13] = 1 - (2 * py) / height;\n setEffectMatrix(engine, effect, \"mvp\", mvp);\n inputs[0] = px;\n inputs[1] = py;\n inputs[2] = rotation;\n inputs[3] = scale;\n inputs[4] = width;\n inputs[5] = height;\n program._uploadedProgram = effect.program;\n }\n setEffectFloat4(engine, effect, \"viewport\", width, height, 0, 0);\n setEffectFloat4(engine, effect, \"color\", layer.coverageGamma > 0 ? 1 / layer.coverageGamma : 1, 1, 1, layer.opacity);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createVertexBuffer, disposeBuffer, updateVertexBuffer } from "../../mesh.js";
|
|
2
|
+
import { TEXT_INSTANCE_BYTES, TEXT_INSTANCE_FLOATS, TEXT_STYLE_FLOATS } from "../text-data.js";
|
|
3
|
+
import { createTextTexture, packTable, TABLE_WIDTH, uploadTextTexture } from "./text-textures.js";
|
|
4
|
+
/** @internal One upload per data mutation, even when several layers share the data. */
|
|
5
|
+
export function ensureTextDataGpu(engine, data) {
|
|
6
|
+
let gpu = data._gpu;
|
|
7
|
+
if (gpu && gpu._engine !== engine) {
|
|
8
|
+
throw new Error("lite-gl: text data cannot be drawn on multiple engines. Create separate text data for each engine.");
|
|
9
|
+
}
|
|
10
|
+
if (!gpu) {
|
|
11
|
+
const pixels = packTable(data._styles, data._styleCount * TEXT_STYLE_FLOATS);
|
|
12
|
+
const buffer = createVertexBuffer(engine, data._instances, true);
|
|
13
|
+
try {
|
|
14
|
+
gpu = {
|
|
15
|
+
_engine: engine,
|
|
16
|
+
_instanceBuf: buffer,
|
|
17
|
+
_styleTex: createTextTexture(engine, pixels, TABLE_WIDTH, pixels.length / (TABLE_WIDTH * 4)),
|
|
18
|
+
_stylePixels: pixels,
|
|
19
|
+
_uploadedVersion: data._version,
|
|
20
|
+
_uploadedStyleVersion: data._styleVersion,
|
|
21
|
+
};
|
|
22
|
+
data._gpu = gpu;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
disposeBuffer(engine, buffer);
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else if (gpu._instanceBuf._data !== data._instances) {
|
|
30
|
+
// Retain the live CPU pool, including partial edits, for context restoration.
|
|
31
|
+
const buffer = createVertexBuffer(engine, data._instances, true);
|
|
32
|
+
disposeBuffer(engine, gpu._instanceBuf);
|
|
33
|
+
gpu._instanceBuf = buffer;
|
|
34
|
+
gpu._uploadedVersion = data._version;
|
|
35
|
+
}
|
|
36
|
+
else if (gpu._uploadedVersion !== data._version) {
|
|
37
|
+
if (data._dirtyEnd > data._dirtyStart) {
|
|
38
|
+
const start = data._dirtyStart * TEXT_INSTANCE_FLOATS;
|
|
39
|
+
const end = data._dirtyEnd * TEXT_INSTANCE_FLOATS;
|
|
40
|
+
const source = start === 0 && end === data._instances.length ? data._instances : data._instances.subarray(start, end);
|
|
41
|
+
updateVertexBuffer(engine, gpu._instanceBuf, source, data._dirtyStart * TEXT_INSTANCE_BYTES);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
updateVertexBuffer(engine, gpu._instanceBuf, data._instances);
|
|
45
|
+
}
|
|
46
|
+
gpu._uploadedVersion = data._version;
|
|
47
|
+
}
|
|
48
|
+
data._dirtyStart = data._dirtyEnd = 0;
|
|
49
|
+
if (gpu._uploadedStyleVersion !== data._styleVersion) {
|
|
50
|
+
const pixels = packTable(data._styles, data._styleCount * TEXT_STYLE_FLOATS, gpu._stylePixels);
|
|
51
|
+
uploadTextTexture(engine, gpu._styleTex, pixels, TABLE_WIDTH, pixels.length / (TABLE_WIDTH * 4));
|
|
52
|
+
gpu._stylePixels = pixels;
|
|
53
|
+
gpu._uploadedStyleVersion = data._styleVersion;
|
|
54
|
+
}
|
|
55
|
+
return gpu;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=text-instances.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-instances.js","sourceRoot":"","sources":["../../../src/text/_gpu/text-instances.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEtF,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC/F,OAAO,EAAE,iBAAiB,E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AiB,CAAC,MAAM,EAAE,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC;QACjG,GAAG,CAAC,YAAY,GAAG,MAAM,CAAC;QAC1B,GAAG,CAAC,qBAAqB,GAAG,IAAI,CAAC,aAAa,CAAC;IACnD,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["import type { GLEngineContext } from \"../../context.js\";\nimport { createVertexBuffer, disposeBuffer, updateVertexBuffer } from \"../../mesh.js\";\nimport type { GLTextData, TextDataGpu } from \"../text-data.js\";\nimport { TEXT_INSTANCE_BYTES, TEXT_INSTANCE_FLOATS, TEXT_STYLE_FLOATS } from \"../text-data.js\";\nimport { createTextTexture, packTable, TABLE_WIDTH, uploadTextTexture } from \"./text-textures.js\";\n\n/** @internal One upload per data mutation, even when several layers share the data. */\nexport function ensureTextDataGpu(engine: GLEngineContext, data: GLTextData): TextDataGpu {\n let gpu = data._gpu;\n if (gpu && gpu._engine !== engine) {\n throw new Error(\"lite-gl: text data cannot be drawn on multiple engines. Create separate text data for each engine.\");\n }\n if (!gpu) {\n const pixels = packTable(data._styles, data._styleCount * TEXT_STYLE_FLOATS);\n const buffer = createVertexBuffer(engine, data._instances, true);\n try {\n gpu = {\n _engine: engine,\n _instanceBuf: buffer,\n _styleTex: createTextTexture(engine, pixels, TABLE_WIDTH, pixels.length / (TABLE_WIDTH * 4)),\n _stylePixels: pixels,\n _uploadedVersion: data._version,\n _uploadedStyleVersion: data._styleVersion,\n };\n data._gpu = gpu;\n } catch (error) {\n disposeBuffer(engine, buffer);\n throw error;\n }\n } else if (gpu._instanceBuf._data !== data._instances) {\n // Retain the live CPU pool, including partial edits, for context restoration.\n const buffer = createVertexBuffer(engine, data._instances, true);\n disposeBuffer(engine, gpu._instanceBuf);\n gpu._instanceBuf = buffer;\n gpu._uploadedVersion = data._version;\n } else if (gpu._uploadedVersion !== data._version) {\n if (data._dirtyEnd > data._dirtyStart) {\n const start = data._dirtyStart * TEXT_INSTANCE_FLOATS;\n const end = data._dirtyEnd * TEXT_INSTANCE_FLOATS;\n const source = start === 0 && end === data._instances.length ? data._instances : data._instances.subarray(start, end);\n updateVertexBuffer(engine, gpu._instanceBuf, source, data._dirtyStart * TEXT_INSTANCE_BYTES);\n } else {\n updateVertexBuffer(engine, gpu._instanceBuf, data._instances);\n }\n gpu._uploadedVersion = data._version;\n }\n data._dirtyStart = data._dirtyEnd = 0;\n if (gpu._uploadedStyleVersion !== data._styleVersion) {\n const pixels = packTable(data._styles, data._styleCount * TEXT_STYLE_FLOATS, gpu._stylePixels);\n uploadTextTexture(engine, gpu._styleTex, pixels, TABLE_WIDTH, pixels.length / (TABLE_WIDTH * 4));\n gpu._stylePixels = pixels;\n gpu._uploadedStyleVersion = data._styleVersion;\n }\n return gpu;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { createRawTexture, disposeTexture, updateRawTexture } from "../../texture.js";
|
|
2
|
+
import { GLYPH_METADATA_FLOATS, TEX_WIDTH } from "../glyph-storage.js";
|
|
3
|
+
/** @internal Lookup textures replace the WebGPU metadata/style storage buffers. */
|
|
4
|
+
export const TABLE_WIDTH = 256;
|
|
5
|
+
/** @internal Pad a lookup table to complete rows, retaining its existing allocation. */
|
|
6
|
+
export function packTable(source, floatCount, previous) {
|
|
7
|
+
const length = Math.max(1, Math.ceil(floatCount / (TABLE_WIDTH * 4))) * TABLE_WIDTH * 4;
|
|
8
|
+
const pixels = previous && previous.length >= length ? previous : new Float32Array(length);
|
|
9
|
+
pixels.set(source.subarray(0, floatCount));
|
|
10
|
+
return pixels;
|
|
11
|
+
}
|
|
12
|
+
function checkSize(engine, width, height) {
|
|
13
|
+
if (width > engine.caps.maxTextureSize || height > engine.caps.maxTextureSize) {
|
|
14
|
+
throw new Error(`lite-gl: text texture ${width}x${height} exceeds MAX_TEXTURE_SIZE ${engine.caps.maxTextureSize}.`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** @internal Numeric tables use nearest-only RG uint or RGBA float texels. */
|
|
18
|
+
export function createTextTexture(engine, pixels, width, height) {
|
|
19
|
+
checkSize(engine, width, height);
|
|
20
|
+
const gl = engine.gl;
|
|
21
|
+
const integer = pixels instanceof Uint32Array;
|
|
22
|
+
return createRawTexture(engine, pixels, width, height, integer ? gl.RG_INTEGER : gl.RGBA, integer ? gl.UNSIGNED_INT : gl.FLOAT, {
|
|
23
|
+
internalFormat: integer ? gl.RG32UI : gl.RGBA32F,
|
|
24
|
+
minFilter: gl.NEAREST,
|
|
25
|
+
magFilter: gl.NEAREST,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** @internal Preserve the texture object and its context-restore upload source. */
|
|
29
|
+
export function uploadTextTexture(engine, texture, pixels, width, height) {
|
|
30
|
+
checkSize(engine, width, height);
|
|
31
|
+
updateRawTexture(engine, texture, pixels, { width, height });
|
|
32
|
+
}
|
|
33
|
+
/** @internal Atlas resources are shared by every block using the same curve set. */
|
|
34
|
+
export function ensureSharedAtlasGpu(engine, atlas) {
|
|
35
|
+
let gpu = atlas._gpu;
|
|
36
|
+
if (gpu) {
|
|
37
|
+
if (gpu._engine !== engine) {
|
|
38
|
+
throw new Error("lite-gl: a glyph storage cannot be drawn on multiple engines. Create a separate storage for each engine.");
|
|
39
|
+
}
|
|
40
|
+
if (gpu._uploadedVersion === atlas._version) {
|
|
41
|
+
return gpu;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const curveRows = Math.max(1, Math.ceil(atlas._curveTexelsUsed / TEX_WIDTH));
|
|
45
|
+
const bandRows = Math.max(1, Math.ceil(atlas._bandTexelsUsed / TEX_WIDTH));
|
|
46
|
+
checkSize(engine, TEX_WIDTH, Math.max(curveRows, bandRows));
|
|
47
|
+
const metaPixels = packTable(atlas._metaData, atlas._slotCount * GLYPH_METADATA_FLOATS, gpu?._metaPixels);
|
|
48
|
+
const metaRows = metaPixels.length / (TABLE_WIDTH * 4);
|
|
49
|
+
checkSize(engine, TABLE_WIDTH, metaRows);
|
|
50
|
+
if (!gpu) {
|
|
51
|
+
const textures = [];
|
|
52
|
+
try {
|
|
53
|
+
textures.push(createTextTexture(engine, atlas._curveTexData, TEX_WIDTH, curveRows));
|
|
54
|
+
textures.push(createTextTexture(engine, atlas._bandTexData, TEX_WIDTH, bandRows));
|
|
55
|
+
textures.push(createTextTexture(engine, metaPixels, TABLE_WIDTH, metaRows));
|
|
56
|
+
gpu = {
|
|
57
|
+
_engine: engine,
|
|
58
|
+
_curveTex: textures[0],
|
|
59
|
+
_bandTex: textures[1],
|
|
60
|
+
_metaTex: textures[2],
|
|
61
|
+
_metaPixels: metaPixels,
|
|
62
|
+
_uploadedVersion: atlas._version,
|
|
63
|
+
};
|
|
64
|
+
atlas._gpu = gpu;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
for (const texture of textures) {
|
|
68
|
+
disposeTexture(engine, texture);
|
|
69
|
+
}
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
uploadTextTexture(engine, gpu._curveTex, atlas._curveTexData, TEX_WIDTH, curveRows);
|
|
75
|
+
uploadTextTexture(engine, gpu._bandTex, atlas._bandTexData, TEX_WIDTH, bandRows);
|
|
76
|
+
uploadTextTexture(engine, gpu._metaTex, metaPixels, TABLE_WIDTH, metaRows);
|
|
77
|
+
gpu._metaPixels = metaPixels;
|
|
78
|
+
gpu._uploadedVersion = atlas._version;
|
|
79
|
+
}
|
|
80
|
+
return gpu;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=text-textures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-textures.js","sourceRoot":"","sources":["../../../src/text/_gpu/text-textures.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gB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nC,CAAC;YACF,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;gBAC7B,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACpC,CAAC;YACD,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;SAAM,CAAC;QACJ,iBAAiB,CAAC,MAAM,EAAE,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,aAAa,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;QACpF,iBAAiB,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,YAAY,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;QACjF,iBAAiB,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;QAC3E,GAAG,CAAC,WAAW,GAAG,UAAU,CAAC;QAC7B,GAAG,CAAC,gBAAgB,GAAG,KAAK,CAAC,QAAQ,CAAC;IAC1C,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["import type { GLEngineContext } from \"../../context.js\";\nimport { createRawTexture, disposeTexture, updateRawTexture } from \"../../texture.js\";\nimport type { GLTexture } from \"../../texture.js\";\nimport { GLYPH_METADATA_FLOATS, TEX_WIDTH } from \"../glyph-storage.js\";\nimport type { SharedAtlas, SharedAtlasGpu } from \"../glyph-storage.js\";\n\n/** @internal Lookup textures replace the WebGPU metadata/style storage buffers. */\nexport const TABLE_WIDTH = 256;\n\n/** @internal Pad a lookup table to complete rows, retaining its existing allocation. */\nexport function packTable(source: Float32Array, floatCount: number, previous?: Float32Array): Float32Array {\n const length = Math.max(1, Math.ceil(floatCount / (TABLE_WIDTH * 4))) * TABLE_WIDTH * 4;\n const pixels = previous && previous.length >= length ? previous : new Float32Array(length);\n pixels.set(source.subarray(0, floatCount));\n return pixels;\n}\n\nfunction checkSize(engine: GLEngineContext, width: number, height: number): void {\n if (width > engine.caps.maxTextureSize || height > engine.caps.maxTextureSize) {\n throw new Error(`lite-gl: text texture ${width}x${height} exceeds MAX_TEXTURE_SIZE ${engine.caps.maxTextureSize}.`);\n }\n}\n\n/** @internal Numeric tables use nearest-only RG uint or RGBA float texels. */\nexport function createTextTexture(engine: GLEngineContext, pixels: Float32Array | Uint32Array, width: number, height: number): GLTexture {\n checkSize(engine, width, height);\n const gl = engine.gl;\n const integer = pixels instanceof Uint32Array;\n return createRawTexture(engine, pixels, width, height, integer ? gl.RG_INTEGER : gl.RGBA, integer ? gl.UNSIGNED_INT : gl.FLOAT, {\n internalFormat: integer ? gl.RG32UI : gl.RGBA32F,\n minFilter: gl.NEAREST,\n magFilter: gl.NEAREST,\n });\n}\n\n/** @internal Preserve the texture object and its context-restore upload source. */\nexport function uploadTextTexture(engine: GLEngineContext, texture: GLTexture, pixels: Float32Array | Uint32Array, width: number, height: number): void {\n checkSize(engine, width, height);\n updateRawTexture(engine, texture, pixels, { width, height });\n}\n\n/** @internal Atlas resources are shared by every block using the same curve set. */\nexport function ensureSharedAtlasGpu(engine: GLEngineContext, atlas: SharedAtlas): SharedAtlasGpu {\n let gpu = atlas._gpu;\n if (gpu) {\n if (gpu._engine !== engine) {\n throw new Error(\"lite-gl: a glyph storage cannot be drawn on multiple engines. Create a separate storage for each engine.\");\n }\n if (gpu._uploadedVersion === atlas._version) {\n return gpu;\n }\n }\n const curveRows = Math.max(1, Math.ceil(atlas._curveTexelsUsed / TEX_WIDTH));\n const bandRows = Math.max(1, Math.ceil(atlas._bandTexelsUsed / TEX_WIDTH));\n checkSize(engine, TEX_WIDTH, Math.max(curveRows, bandRows));\n const metaPixels = packTable(atlas._metaData, atlas._slotCount * GLYPH_METADATA_FLOATS, gpu?._metaPixels);\n const metaRows = metaPixels.length / (TABLE_WIDTH * 4);\n checkSize(engine, TABLE_WIDTH, metaRows);\n\n if (!gpu) {\n const textures: GLTexture[] = [];\n try {\n textures.push(createTextTexture(engine, atlas._curveTexData, TEX_WIDTH, curveRows));\n textures.push(createTextTexture(engine, atlas._bandTexData, TEX_WIDTH, bandRows));\n textures.push(createTextTexture(engine, metaPixels, TABLE_WIDTH, metaRows));\n gpu = {\n _engine: engine,\n _curveTex: textures[0]!,\n _bandTex: textures[1]!,\n _metaTex: textures[2]!,\n _metaPixels: metaPixels,\n _uploadedVersion: atlas._version,\n };\n atlas._gpu = gpu;\n } catch (error) {\n for (const texture of textures) {\n disposeTexture(engine, texture);\n }\n throw error;\n }\n } else {\n uploadTextTexture(engine, gpu._curveTex, atlas._curveTexData, TEX_WIDTH, curveRows);\n uploadTextTexture(engine, gpu._bandTex, atlas._bandTexData, TEX_WIDTH, bandRows);\n uploadTextTexture(engine, gpu._metaTex, metaPixels, TABLE_WIDTH, metaRows);\n gpu._metaPixels = metaPixels;\n gpu._uploadedVersion = atlas._version;\n }\n return gpu;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|