@combos-fun/plugin-renderer-3d-text 0.1.4-beta.1 → 0.1.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.
- package/README.md +34 -0
- package/agent-skill.md +35 -0
- package/dist/plugin-renderer-3d-text.cjs.js +206 -19
- package/dist/plugin-renderer-3d-text.cjs.js.map +1 -1
- package/dist/plugin-renderer-3d-text.cjs.prod.js +1 -1
- package/dist/plugin-renderer-3d-text.d.ts +74 -4
- package/dist/plugin-renderer-3d-text.esm.js +199 -20
- package/dist/plugin-renderer-3d-text.esm.js.map +1 -1
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -22,6 +22,40 @@ import manifest from '@combos-fun/plugin-renderer-3d-text/plugin-manifest';
|
|
|
22
22
|
// require.resolve('@combos-fun/plugin-renderer-3d-text/agent-skill')
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
## Host-driven i18n
|
|
26
|
+
|
|
27
|
+
Same host contract as `@combos-fun/plugin-renderer-text`. Configure the source
|
|
28
|
+
locale on the 3D text system. Locale names use BCP 47 tags.
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
const textSystem = new Text3DSystem({
|
|
32
|
+
sourceLocale: 'zh-CN',
|
|
33
|
+
sourceTexts: [
|
|
34
|
+
'{player} 获得了 {score} 分',
|
|
35
|
+
'开始游戏',
|
|
36
|
+
'下一屏文案',
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
new Text3D({
|
|
43
|
+
text: '{player} 获得了 {score} 分',
|
|
44
|
+
replacements: {
|
|
45
|
+
player: 'Alice',
|
|
46
|
+
score: 100,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The host injects `window.combos` into the game HTML head. The first
|
|
52
|
+
`requestI18n` runs in `beforeReady` and holds `combos-game:ready` / `start`
|
|
53
|
+
until the host replies. Put every later-screen template in `sourceTexts` so
|
|
54
|
+
those screens reuse the startup catalog instead of flashing source text.
|
|
55
|
+
Later undeclared catalog changes stay async and do not block.
|
|
56
|
+
Translation is applied only when the result is `needed: true`. Without the
|
|
57
|
+
injected SDK, the game stays on the source text.
|
|
58
|
+
|
|
25
59
|
## License
|
|
26
60
|
|
|
27
61
|
Internal workspace package, part of the Combos Fun engine monorepo.
|
package/agent-skill.md
CHANGED
|
@@ -12,11 +12,46 @@ import { Text3D, Text3DSystem, type Text3DParams } from '@combos-fun/plugin-rend
|
|
|
12
12
|
|
|
13
13
|
`componentName = 'Text3D'`; `systemName = 'Text3DSystem'`.
|
|
14
14
|
|
|
15
|
+
For dynamic, translatable text, keep values in named `replacements`; do not
|
|
16
|
+
concatenate them into `text` and do not invent translation IDs:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
score.addComponent(new Text3D({
|
|
20
|
+
text: '{player} scored {score} points',
|
|
21
|
+
replacements: { player: 'Alice', score: 100 },
|
|
22
|
+
fontSize: 0.4,
|
|
23
|
+
}));
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Enable host-driven translation with:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
new Text3DSystem({
|
|
30
|
+
sourceLocale: 'en-US',
|
|
31
|
+
sourceTexts: ['Play', 'Next stage unlocked'],
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Pass **every** later-screen template in `sourceTexts` so the first
|
|
36
|
+
`requestI18n` translates the full catalog before `ready`. New labels then
|
|
37
|
+
reuse that cache and do not flash the source language. You can also call
|
|
38
|
+
`textSystem.declareSourceTexts([...])` during `onSystemsBootstrapComplete`.
|
|
39
|
+
|
|
40
|
+
The source template itself is the translation lookup key. After labels exist,
|
|
41
|
+
the system checks that `window.combos.requestI18n` exists. The first
|
|
42
|
+
`requestI18n({ sourceLocale, sourceTexts })` runs in `beforeReady` and holds
|
|
43
|
+
game `ready` / `start` until the host replies. Later text that was not declared
|
|
44
|
+
requests again without blocking. Apply the result only when `needed: true`. Do
|
|
45
|
+
not post `i18n-ready` / `set-i18n` from this plugin. If no source locale or
|
|
46
|
+
method is present, placeholder replacement still works and source text stays
|
|
47
|
+
as-is.
|
|
48
|
+
|
|
15
49
|
## Parameters
|
|
16
50
|
|
|
17
51
|
| Field | Type | Default |
|
|
18
52
|
|-------|------|---------|
|
|
19
53
|
| `text` | `string` | `''` |
|
|
54
|
+
| `replacements` | `Record<string, string \| number>` | `{}` |
|
|
20
55
|
| `fontSize` | `number` | `0.5` |
|
|
21
56
|
| `color` | `number` | `0xffffff` |
|
|
22
57
|
| `anchorX` | `string` | `'center'` |
|
|
@@ -10,6 +10,7 @@ class Text3D extends engine.Component {
|
|
|
10
10
|
constructor() {
|
|
11
11
|
super(...arguments);
|
|
12
12
|
this.text = '';
|
|
13
|
+
this.replacements = {};
|
|
13
14
|
this.fontSize = 0.5;
|
|
14
15
|
this.color = 0xffffff;
|
|
15
16
|
this.anchorX = 'center';
|
|
@@ -25,8 +26,12 @@ class Text3D extends engine.Component {
|
|
|
25
26
|
}
|
|
26
27
|
static { this.componentName = 'Text3D'; }
|
|
27
28
|
init(obj) {
|
|
28
|
-
if (obj)
|
|
29
|
-
|
|
29
|
+
if (!obj)
|
|
30
|
+
return;
|
|
31
|
+
const { replacements, ...rest } = obj;
|
|
32
|
+
Object.assign(this, rest);
|
|
33
|
+
if (replacements)
|
|
34
|
+
this.replacements = { ...replacements };
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
37
|
tslib.__decorate([
|
|
@@ -155,17 +160,133 @@ tslib.__decorate([
|
|
|
155
160
|
})
|
|
156
161
|
], Text3D.prototype, "rotationZ", void 0);
|
|
157
162
|
|
|
163
|
+
/** Host-injected global. The SDK itself is not part of this repo. */
|
|
164
|
+
const COMBOS_HOST_SDK = 'combos';
|
|
165
|
+
function hasCombosRequestI18n(sdk = typeof window === 'undefined' ? undefined : window.combos) {
|
|
166
|
+
return !!sdk && typeof sdk.requestI18n === 'function';
|
|
167
|
+
}
|
|
168
|
+
function parseI18nResult(data) {
|
|
169
|
+
if (!data || typeof data !== 'object')
|
|
170
|
+
return { needed: false };
|
|
171
|
+
const input = data;
|
|
172
|
+
if (input.needed !== true)
|
|
173
|
+
return { needed: false };
|
|
174
|
+
if (typeof input.locale !== 'string' || !input.locale.trim()) {
|
|
175
|
+
return { needed: false };
|
|
176
|
+
}
|
|
177
|
+
if (!input.translations ||
|
|
178
|
+
typeof input.translations !== 'object' ||
|
|
179
|
+
Array.isArray(input.translations)) {
|
|
180
|
+
return { needed: false };
|
|
181
|
+
}
|
|
182
|
+
const entries = Object.entries(input.translations);
|
|
183
|
+
if (entries.some(([, value]) => typeof value !== 'string')) {
|
|
184
|
+
return { needed: false };
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
needed: true,
|
|
188
|
+
locale: input.locale.trim(),
|
|
189
|
+
translations: Object.fromEntries(entries),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
/** Ask the injected host SDK. Always resolves; missing method means no translation. */
|
|
193
|
+
async function requestHostI18n(request) {
|
|
194
|
+
if (typeof window === 'undefined' || !hasCombosRequestI18n(window.combos)) {
|
|
195
|
+
return { needed: false };
|
|
196
|
+
}
|
|
197
|
+
try {
|
|
198
|
+
return parseI18nResult(await window.combos.requestI18n(request));
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
return { needed: false };
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Keep identical to `@combos-fun/plugin-renderer-text` localization. */
|
|
206
|
+
const PLACEHOLDER_PATTERN = /\{([A-Za-z_$][\w$.-]*)\}/g;
|
|
207
|
+
function interpolateText(template, replacements) {
|
|
208
|
+
if (!replacements)
|
|
209
|
+
return template;
|
|
210
|
+
return template.replace(PLACEHOLDER_PATTERN, (placeholder, name) => {
|
|
211
|
+
if (!Object.prototype.hasOwnProperty.call(replacements, name)) {
|
|
212
|
+
return placeholder;
|
|
213
|
+
}
|
|
214
|
+
return String(replacements[name]);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
function localizeText(sourceText, replacements, sourceLocale, targetLocale, translations) {
|
|
218
|
+
const shouldTranslate = !!sourceLocale &&
|
|
219
|
+
!!targetLocale &&
|
|
220
|
+
sourceLocale.toLowerCase() !== targetLocale.toLowerCase();
|
|
221
|
+
const template = shouldTranslate && Object.prototype.hasOwnProperty.call(translations, sourceText)
|
|
222
|
+
? translations[sourceText]
|
|
223
|
+
: sourceText;
|
|
224
|
+
return interpolateText(template, replacements);
|
|
225
|
+
}
|
|
226
|
+
function addSourceTexts(target, texts) {
|
|
227
|
+
if (!texts)
|
|
228
|
+
return;
|
|
229
|
+
for (const text of texts) {
|
|
230
|
+
const source = typeof text === 'string' ? text.trim() : '';
|
|
231
|
+
if (source)
|
|
232
|
+
target.add(source);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function mergeTranslations(current, incoming) {
|
|
236
|
+
const next = { ...current };
|
|
237
|
+
for (const [key, value] of Object.entries(incoming)) {
|
|
238
|
+
if (typeof value === 'string')
|
|
239
|
+
next[key] = value;
|
|
240
|
+
}
|
|
241
|
+
return next;
|
|
242
|
+
}
|
|
243
|
+
|
|
158
244
|
let Text3DSystem = class Text3DSystem extends pluginRenderer3d.Renderer3D {
|
|
159
245
|
constructor() {
|
|
160
246
|
super(...arguments);
|
|
161
247
|
this.name = 'Text3DSystem';
|
|
162
248
|
this.texts = new Map();
|
|
163
249
|
this.poseBridges = new Map();
|
|
250
|
+
this.sourceLocale = '';
|
|
251
|
+
this.targetLocale = '';
|
|
252
|
+
this.translations = {};
|
|
253
|
+
this.seededSourceTexts = new Set();
|
|
254
|
+
this.lastRequestedSourceTexts = '';
|
|
255
|
+
this.i18nRequestScheduled = false;
|
|
256
|
+
this.i18nRequestId = 0;
|
|
257
|
+
this.firstI18nSettled = false;
|
|
164
258
|
}
|
|
165
259
|
static { this.systemName = 'Text3DSystem'; }
|
|
166
|
-
init() {
|
|
260
|
+
init(params) {
|
|
167
261
|
const renderer3DSystem = this.game.getSystem(pluginRenderer3d.Renderer3DSystem);
|
|
168
262
|
renderer3DSystem.rendererManager.register(this);
|
|
263
|
+
this.sourceLocale = params?.sourceLocale?.trim() ?? '';
|
|
264
|
+
this.targetLocale = this.sourceLocale;
|
|
265
|
+
this.declareSourceTexts(params?.sourceTexts);
|
|
266
|
+
}
|
|
267
|
+
/** Register extra source templates before or after ready. First request includes these. */
|
|
268
|
+
declareSourceTexts(texts) {
|
|
269
|
+
addSourceTexts(this.seededSourceTexts, texts);
|
|
270
|
+
this.scheduleI18nRequest();
|
|
271
|
+
}
|
|
272
|
+
async beforeReady() {
|
|
273
|
+
if (this.firstI18nSettled)
|
|
274
|
+
return;
|
|
275
|
+
this.update();
|
|
276
|
+
if (!this.sourceLocale) {
|
|
277
|
+
this.firstI18nSettled = true;
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
await this.requestI18nAndApply();
|
|
281
|
+
this.firstI18nSettled = true;
|
|
282
|
+
}
|
|
283
|
+
setI18n(locale, translations) {
|
|
284
|
+
const targetLocale = locale?.trim();
|
|
285
|
+
if (!targetLocale || !translations || typeof translations !== 'object')
|
|
286
|
+
return;
|
|
287
|
+
this.targetLocale = targetLocale;
|
|
288
|
+
this.translations = mergeTranslations(this.translations, translations);
|
|
289
|
+
this.refreshAllText();
|
|
169
290
|
}
|
|
170
291
|
componentChanged(changed) {
|
|
171
292
|
if (changed.componentName !== 'Text3D')
|
|
@@ -177,17 +298,17 @@ let Text3DSystem = class Text3DSystem extends pluginRenderer3d.Renderer3D {
|
|
|
177
298
|
this.handleRemove(changed.gameObject.id);
|
|
178
299
|
}
|
|
179
300
|
else {
|
|
180
|
-
this.handleChange(changed
|
|
301
|
+
this.handleChange(changed);
|
|
181
302
|
}
|
|
182
303
|
}
|
|
183
304
|
rendererUpdate(gameObject) {
|
|
184
305
|
const component = gameObject.getComponent(Text3D);
|
|
185
306
|
if (!component)
|
|
186
307
|
return;
|
|
187
|
-
const
|
|
188
|
-
if (!
|
|
308
|
+
const entry = this.texts.get(gameObject.id);
|
|
309
|
+
if (!entry)
|
|
189
310
|
return;
|
|
190
|
-
this.applyPose(gameObject, component,
|
|
311
|
+
this.applyPose(gameObject, component, entry.mesh);
|
|
191
312
|
}
|
|
192
313
|
handleAdd(gameObject, component) {
|
|
193
314
|
const textMesh = new troikaThreeText.Text();
|
|
@@ -195,27 +316,32 @@ let Text3DSystem = class Text3DSystem extends pluginRenderer3d.Renderer3D {
|
|
|
195
316
|
textMesh.sync();
|
|
196
317
|
pluginRenderer3d.tagObject3D(textMesh, gameObject.id);
|
|
197
318
|
this.threeContext.attachVisual(gameObject.id, textMesh, gameObject);
|
|
198
|
-
this.texts.set(gameObject.id, textMesh);
|
|
319
|
+
this.texts.set(gameObject.id, { mesh: textMesh, component });
|
|
199
320
|
this.poseBridges.set(gameObject.id, new pluginRenderer3d.VisualPoseBridge());
|
|
321
|
+
this.scheduleI18nRequest();
|
|
200
322
|
}
|
|
201
|
-
handleChange(
|
|
202
|
-
const
|
|
203
|
-
if (!
|
|
323
|
+
handleChange(changed) {
|
|
324
|
+
const entry = this.texts.get(changed.gameObject.id);
|
|
325
|
+
if (!entry)
|
|
204
326
|
return;
|
|
205
|
-
|
|
206
|
-
|
|
327
|
+
const component = changed.component;
|
|
328
|
+
entry.component = component;
|
|
329
|
+
this.syncTextProps(entry.mesh, component);
|
|
330
|
+
entry.mesh.sync();
|
|
331
|
+
if (changed.prop.prop[0] === 'text')
|
|
332
|
+
this.scheduleI18nRequest();
|
|
207
333
|
}
|
|
208
334
|
handleRemove(id) {
|
|
209
|
-
const
|
|
210
|
-
if (!
|
|
335
|
+
const entry = this.texts.get(id);
|
|
336
|
+
if (!entry)
|
|
211
337
|
return;
|
|
212
|
-
this.threeContext.detachVisual(id,
|
|
213
|
-
|
|
338
|
+
this.threeContext.detachVisual(id, entry.mesh);
|
|
339
|
+
entry.mesh.dispose();
|
|
214
340
|
this.texts.delete(id);
|
|
215
341
|
this.poseBridges.delete(id);
|
|
216
342
|
}
|
|
217
343
|
syncTextProps(textMesh, component) {
|
|
218
|
-
textMesh.text = component
|
|
344
|
+
textMesh.text = this.resolveText(component);
|
|
219
345
|
textMesh.fontSize = component.fontSize;
|
|
220
346
|
textMesh.color = component.color;
|
|
221
347
|
textMesh.anchorX = component.anchorX;
|
|
@@ -243,16 +369,69 @@ let Text3DSystem = class Text3DSystem extends pluginRenderer3d.Renderer3D {
|
|
|
243
369
|
textMesh.rotation.set(component.rotationX, component.rotationY, component.rotationZ);
|
|
244
370
|
}
|
|
245
371
|
onDestroy() {
|
|
372
|
+
this.i18nRequestId += 1;
|
|
373
|
+
this.firstI18nSettled = false;
|
|
246
374
|
for (const [id] of this.texts) {
|
|
247
375
|
this.handleRemove(id);
|
|
248
376
|
}
|
|
249
377
|
this.texts.clear();
|
|
250
378
|
}
|
|
379
|
+
resolveText(component) {
|
|
380
|
+
return localizeText(component.text, component.replacements, this.sourceLocale, this.targetLocale, this.translations);
|
|
381
|
+
}
|
|
382
|
+
collectSourceTexts() {
|
|
383
|
+
const sourceTexts = new Set(this.seededSourceTexts);
|
|
384
|
+
for (const entry of this.texts.values()) {
|
|
385
|
+
addSourceTexts(sourceTexts, [entry.component.text]);
|
|
386
|
+
}
|
|
387
|
+
return [...sourceTexts];
|
|
388
|
+
}
|
|
389
|
+
scheduleI18nRequest() {
|
|
390
|
+
if (!this.sourceLocale || !this.firstI18nSettled || this.i18nRequestScheduled)
|
|
391
|
+
return;
|
|
392
|
+
this.i18nRequestScheduled = true;
|
|
393
|
+
queueMicrotask(() => {
|
|
394
|
+
this.i18nRequestScheduled = false;
|
|
395
|
+
this.startI18nRequest();
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
startI18nRequest() {
|
|
399
|
+
if (!this.sourceLocale || !this.firstI18nSettled)
|
|
400
|
+
return;
|
|
401
|
+
const sourceTexts = this.collectSourceTexts();
|
|
402
|
+
const signature = [...sourceTexts].sort().join('\0');
|
|
403
|
+
if (signature === this.lastRequestedSourceTexts)
|
|
404
|
+
return;
|
|
405
|
+
void this.requestI18nAndApply();
|
|
406
|
+
}
|
|
407
|
+
async requestI18nAndApply() {
|
|
408
|
+
const sourceTexts = this.collectSourceTexts();
|
|
409
|
+
const signature = [...sourceTexts].sort().join('\0');
|
|
410
|
+
this.lastRequestedSourceTexts = signature;
|
|
411
|
+
const requestId = ++this.i18nRequestId;
|
|
412
|
+
const result = await requestHostI18n({
|
|
413
|
+
sourceLocale: this.sourceLocale,
|
|
414
|
+
sourceTexts,
|
|
415
|
+
});
|
|
416
|
+
if (requestId !== this.i18nRequestId)
|
|
417
|
+
return;
|
|
418
|
+
if (!result.needed)
|
|
419
|
+
return;
|
|
420
|
+
this.setI18n(result.locale, result.translations);
|
|
421
|
+
}
|
|
422
|
+
refreshAllText() {
|
|
423
|
+
for (const entry of this.texts.values()) {
|
|
424
|
+
entry.mesh.text = this.resolveText(entry.component);
|
|
425
|
+
entry.mesh.sync();
|
|
426
|
+
}
|
|
427
|
+
}
|
|
251
428
|
};
|
|
252
429
|
Text3DSystem = tslib.__decorate([
|
|
253
430
|
engine.decorators.componentObserver({
|
|
254
431
|
Text3D: [
|
|
255
|
-
'text',
|
|
432
|
+
'text',
|
|
433
|
+
{ prop: ['replacements'], deep: true },
|
|
434
|
+
'fontSize', 'color', 'anchorX', 'anchorY', 'maxWidth', 'font',
|
|
256
435
|
'positionX', 'positionY', 'positionZ',
|
|
257
436
|
'rotationX', 'rotationY', 'rotationZ',
|
|
258
437
|
],
|
|
@@ -260,6 +439,14 @@ Text3DSystem = tslib.__decorate([
|
|
|
260
439
|
], Text3DSystem);
|
|
261
440
|
var Text3DSystem_default = Text3DSystem;
|
|
262
441
|
|
|
442
|
+
exports.COMBOS_HOST_SDK = COMBOS_HOST_SDK;
|
|
263
443
|
exports.Text3D = Text3D;
|
|
264
444
|
exports.Text3DSystem = Text3DSystem_default;
|
|
445
|
+
exports.addSourceTexts = addSourceTexts;
|
|
446
|
+
exports.hasCombosRequestI18n = hasCombosRequestI18n;
|
|
447
|
+
exports.interpolateText = interpolateText;
|
|
448
|
+
exports.localizeText = localizeText;
|
|
449
|
+
exports.mergeTranslations = mergeTranslations;
|
|
450
|
+
exports.parseI18nResult = parseI18nResult;
|
|
451
|
+
exports.requestHostI18n = requestHostI18n;
|
|
265
452
|
//# sourceMappingURL=plugin-renderer-3d-text.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-renderer-3d-text.cjs.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { Component } from '@combos-fun/engine';\nimport { Field } from '@combos-fun/inspector-decorator';\n\nexport interface Text3DParams {\n text?: string;\n fontSize?: number;\n color?: number;\n anchorX?: string;\n anchorY?: string;\n maxWidth?: number;\n font?: string;\n positionX?: number;\n positionY?: number;\n positionZ?: number;\n rotationX?: number;\n rotationY?: number;\n rotationZ?: number;\n}\n\nexport default class Text3D extends Component<Text3DParams> {\n static componentName: string = 'Text3D';\n\n @Field({\n\n type: 'string',\n\n group: 'Text3D',\n\n label: 'text',\n\n description: 'Visible text content.',\n\n editor: 'text',\n\n })\n\n text: string = '';\n @Field({\n type: 'number',\n step: 0.01,\n group: 'Text3D',\n label: 'fontSize',\n description: 'Font size.',\n editor: 'number-stepper',\n })\n fontSize: number = 0.5;\n @Field({\n type: 'number',\n group: 'Text3D',\n label: 'color',\n description: 'Color value.',\n editor: 'number-stepper',\n })\n color: number = 0xffffff;\n @Field({\n type: 'string',\n group: 'Text3D',\n label: 'anchorX',\n description: 'Horizontal text anchor.',\n editor: 'text',\n })\n anchorX: string = 'center';\n @Field({\n type: 'string',\n group: 'Text3D',\n label: 'anchorY',\n description: 'Vertical text anchor.',\n editor: 'text',\n })\n anchorY: string = 'middle';\n @Field({\n type: 'number',\n step: 0.1,\n group: 'Text3D',\n label: 'maxWidth',\n description: 'Maximum text wrap width.',\n editor: 'number-stepper',\n })\n maxWidth: number = 0;\n @Field({\n type: 'string',\n group: 'Text3D',\n label: 'font',\n description: 'Font URL or path for troika-three-text (not an engine resource name).',\n editor: 'text',\n })\n font: string = '';\n @Field({\n type: 'number',\n step: 0.1,\n group: 'Text3D',\n label: 'positionX',\n description: 'Local X position.',\n editor: 'number-stepper',\n })\n positionX: number = 0;\n @Field({\n type: 'number',\n step: 0.1,\n group: 'Text3D',\n label: 'positionY',\n description: 'Local Y position.',\n editor: 'number-stepper',\n })\n positionY: number = 0;\n @Field({\n type: 'number',\n step: 0.1,\n group: 'Text3D',\n label: 'positionZ',\n description: 'Local Z position.',\n editor: 'number-stepper',\n })\n positionZ: number = 0;\n @Field({\n type: 'number',\n step: 0.01,\n group: 'Text3D',\n label: 'rotationX',\n description: 'Rotation around X in radians.',\n editor: 'number-stepper',\n })\n rotationX: number = 0;\n @Field({\n type: 'number',\n step: 0.01,\n group: 'Text3D',\n label: 'rotationY',\n description: 'Rotation around Y in radians.',\n editor: 'number-stepper',\n })\n rotationY: number = 0;\n @Field({\n type: 'number',\n step: 0.01,\n group: 'Text3D',\n label: 'rotationZ',\n description: 'Rotation around Z in radians.',\n editor: 'number-stepper',\n })\n rotationZ: number = 0;\n\n init(obj?: Text3DParams) {\n if (obj) Object.assign(this, obj);\n }\n}\n","import { decorators, ComponentChanged, OBSERVER_TYPE, GameObject } from '@combos-fun/engine';\nimport { Renderer3D, Renderer3DSystem, tagObject3D, Transform3D, VisualPoseBridge } from '@combos-fun/plugin-renderer-3d';\nimport { Text as TroikaText } from 'troika-three-text';\nimport Text3D from './component';\n\n@decorators.componentObserver({\n Text3D: [\n 'text', 'fontSize', 'color', 'anchorX', 'anchorY', 'maxWidth', 'font',\n 'positionX', 'positionY', 'positionZ',\n 'rotationX', 'rotationY', 'rotationZ',\n ],\n})\nexport default class Text3DSystem extends Renderer3D {\n static systemName = 'Text3DSystem';\n name: string = 'Text3DSystem';\n\n private texts: Map<number, TroikaText> = new Map();\n private poseBridges = new Map<number, VisualPoseBridge>();\n\n init() {\n const renderer3DSystem = this.game.getSystem(Renderer3DSystem) as Renderer3DSystem;\n renderer3DSystem.rendererManager.register(this);\n }\n\n componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'Text3D') return;\n\n if (changed.type === OBSERVER_TYPE.ADD) {\n this.handleAdd(changed.gameObject, changed.component as Text3D);\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.handleRemove(changed.gameObject.id);\n } else {\n this.handleChange(changed.gameObject.id, changed.component as Text3D);\n }\n }\n\n rendererUpdate(gameObject: GameObject) {\n const component = gameObject.getComponent(Text3D) as Text3D;\n if (!component) return;\n\n const textMesh = this.texts.get(gameObject.id);\n if (!textMesh) return;\n this.applyPose(gameObject, component, textMesh);\n }\n\n private handleAdd(gameObject: GameObject, component: Text3D) {\n const textMesh = new TroikaText();\n this.syncTextProps(textMesh, component);\n textMesh.sync();\n tagObject3D(textMesh, gameObject.id);\n\n this.threeContext.attachVisual(gameObject.id, textMesh, gameObject);\n this.texts.set(gameObject.id, textMesh);\n this.poseBridges.set(gameObject.id, new VisualPoseBridge());\n }\n\n private handleChange(id: number, component: Text3D) {\n const textMesh = this.texts.get(id);\n if (!textMesh) return;\n\n this.syncTextProps(textMesh, component);\n textMesh.sync();\n }\n\n private handleRemove(id: number) {\n const textMesh = this.texts.get(id);\n if (!textMesh) return;\n\n this.threeContext.detachVisual(id, textMesh);\n textMesh.dispose();\n this.texts.delete(id);\n this.poseBridges.delete(id);\n }\n\n private syncTextProps(textMesh: TroikaText, component: Text3D) {\n textMesh.text = component.text;\n textMesh.fontSize = component.fontSize;\n textMesh.color = component.color;\n textMesh.anchorX = component.anchorX;\n textMesh.anchorY = component.anchorY;\n if (component.maxWidth > 0) {\n textMesh.maxWidth = component.maxWidth;\n }\n if (component.font) {\n textMesh.font = component.font;\n }\n }\n\n private applyPose(gameObject: GameObject, component: Text3D, textMesh: TroikaText) {\n let bridge = this.poseBridges.get(gameObject.id);\n if (!bridge) {\n bridge = new VisualPoseBridge();\n this.poseBridges.set(gameObject.id, bridge);\n }\n const transform = gameObject.getComponent(Transform3D) as Transform3D | undefined;\n if (!bridge.sync(component, transform)) {\n textMesh.position.set(0, 0, 0);\n textMesh.rotation.set(0, 0, 0);\n return;\n }\n textMesh.position.set(component.positionX, component.positionY, component.positionZ);\n textMesh.rotation.set(component.rotationX, component.rotationY, component.rotationZ);\n }\n\n onDestroy() {\n for (const [id] of this.texts) {\n this.handleRemove(id);\n }\n this.texts.clear();\n }\n}\n"],"names":["Component","__decorate","Field","Renderer3D","Renderer3DSystem","OBSERVER_TYPE","TroikaText","tagObject3D","VisualPoseBridge","Transform3D","decorators"],"mappings":";;;;;;;;AAmBc,MAAO,MAAO,SAAQA,gBAAuB,CAAA;AAA3D,IAAA,WAAA,GAAA;;QAiBE,IAAA,CAAA,IAAI,GAAW,EAAE;QASjB,IAAA,CAAA,QAAQ,GAAW,GAAG;QAQtB,IAAA,CAAA,KAAK,GAAW,QAAQ;QAQxB,IAAA,CAAA,OAAO,GAAW,QAAQ;QAQ1B,IAAA,CAAA,OAAO,GAAW,QAAQ;QAS1B,IAAA,CAAA,QAAQ,GAAW,CAAC;QAQpB,IAAA,CAAA,IAAI,GAAW,EAAE;QASjB,IAAA,CAAA,SAAS,GAAW,CAAC;QASrB,IAAA,CAAA,SAAS,GAAW,CAAC;QASrB,IAAA,CAAA,SAAS,GAAW,CAAC;QASrB,IAAA,CAAA,SAAS,GAAW,CAAC;QASrB,IAAA,CAAA,SAAS,GAAW,CAAC;QASrB,IAAA,CAAA,SAAS,GAAW,CAAC;IAKvB;aA7HS,IAAA,CAAA,aAAa,GAAW,QAAX,CAAoB;AA0HxC,IAAA,IAAI,CAAC,GAAkB,EAAA;AACrB,QAAA,IAAI,GAAG;AAAE,YAAA,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC;IACnC;;AA5GAC,gBAAA,CAAA;AAdC,IAAAC,wBAAK,CAAC;AAE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G,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC;AACpF,QAAA,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC;IACtF;IAEA,SAAS,GAAA;QACP,KAAK,MAAM,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE;AAC7B,YAAA,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;QACvB;AACA,QAAA,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE;IACpB;;AAjGmB,YAAY,GAAAR,gBAAA,CAAA;IAPhCS,iBAAU,CAAC,iBAAiB,CAAC;AAC5B,QAAA,MAAM,EAAE;YACN,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM;YACrE,WAAW,EAAE,WAAW,EAAE,WAAW;YACrC,WAAW,EAAE,WAAW,EAAE,WAAW;AACtC,SAAA;KACF;AACoB,CAAA,EAAA,YAAY,CAkGhC;2BAlGoB,YAAY;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin-renderer-3d-text.cjs.js","sources":["../lib/component.ts","../lib/hostSdk.ts","../lib/localization.ts","../lib/system.ts"],"sourcesContent":["import { Component } from '@combos-fun/engine';\nimport { Field } from '@combos-fun/inspector-decorator';\nimport type { TextReplacements } from './localization';\n\nexport type { TextReplacementValue, TextReplacements } from './localization';\n\nexport interface Text3DParams {\n text?: string;\n /** Values substituted into named placeholders such as `{score}`. */\n replacements?: TextReplacements;\n fontSize?: number;\n color?: number;\n anchorX?: string;\n anchorY?: string;\n maxWidth?: number;\n font?: string;\n positionX?: number;\n positionY?: number;\n positionZ?: number;\n rotationX?: number;\n rotationY?: number;\n rotationZ?: number;\n}\n\nexport default class Text3D extends Component<Text3DParams> {\n static componentName: string = 'Text3D';\n\n @Field({\n\n type: 'string',\n\n group: 'Text3D',\n\n label: 'text',\n\n description: 'Visible text content.',\n\n editor: 'text',\n\n })\n\n text: string = '';\n\n replacements: TextReplacements = {};\n\n @Field({\n type: 'number',\n step: 0.01,\n group: 'Text3D',\n label: 'fontSize',\n description: 'Font size.',\n editor: 'number-stepper',\n })\n fontSize: number = 0.5;\n @Field({\n type: 'number',\n group: 'Text3D',\n label: 'color',\n description: 'Color value.',\n editor: 'number-stepper',\n })\n color: number = 0xffffff;\n @Field({\n type: 'string',\n group: 'Text3D',\n label: 'anchorX',\n description: 'Horizontal text anchor.',\n editor: 'text',\n })\n anchorX: string = 'center';\n @Field({\n type: 'string',\n group: 'Text3D',\n label: 'anchorY',\n description: 'Vertical text anchor.',\n editor: 'text',\n })\n anchorY: string = 'middle';\n @Field({\n type: 'number',\n step: 0.1,\n group: 'Text3D',\n label: 'maxWidth',\n description: 'Maximum text wrap width.',\n editor: 'number-stepper',\n })\n maxWidth: number = 0;\n @Field({\n type: 'string',\n group: 'Text3D',\n label: 'font',\n description: 'Font URL or path for troika-three-text (not an engine resource name).',\n editor: 'text',\n })\n font: string = '';\n @Field({\n type: 'number',\n step: 0.1,\n group: 'Text3D',\n label: 'positionX',\n description: 'Local X position.',\n editor: 'number-stepper',\n })\n positionX: number = 0;\n @Field({\n type: 'number',\n step: 0.1,\n group: 'Text3D',\n label: 'positionY',\n description: 'Local Y position.',\n editor: 'number-stepper',\n })\n positionY: number = 0;\n @Field({\n type: 'number',\n step: 0.1,\n group: 'Text3D',\n label: 'positionZ',\n description: 'Local Z position.',\n editor: 'number-stepper',\n })\n positionZ: number = 0;\n @Field({\n type: 'number',\n step: 0.01,\n group: 'Text3D',\n label: 'rotationX',\n description: 'Rotation around X in radians.',\n editor: 'number-stepper',\n })\n rotationX: number = 0;\n @Field({\n type: 'number',\n step: 0.01,\n group: 'Text3D',\n label: 'rotationY',\n description: 'Rotation around Y in radians.',\n editor: 'number-stepper',\n })\n rotationY: number = 0;\n @Field({\n type: 'number',\n step: 0.01,\n group: 'Text3D',\n label: 'rotationZ',\n description: 'Rotation around Z in radians.',\n editor: 'number-stepper',\n })\n rotationZ: number = 0;\n\n init(obj?: Text3DParams) {\n if (!obj) return;\n const { replacements, ...rest } = obj;\n Object.assign(this, rest);\n if (replacements) this.replacements = { ...replacements };\n }\n}\n","/** Keep identical to `@combos-fun/plugin-renderer-text` hostSdk. */\nimport type { TextTranslations } from './localization';\n\n/** Host-injected global. The SDK itself is not part of this repo. */\nexport const COMBOS_HOST_SDK = 'combos' as const;\n\nexport interface CombosI18nRequest {\n sourceLocale: string;\n sourceTexts: string[];\n}\n\nexport type CombosI18nResult =\n | { needed: false }\n | { needed: true; locale: string; translations: TextTranslations };\n\nexport interface CombosHostSdk {\n requestI18n?(request: CombosI18nRequest): Promise<CombosI18nResult>;\n}\n\ndeclare global {\n interface Window {\n combos?: CombosHostSdk;\n }\n}\n\nexport function hasCombosRequestI18n(\n sdk: CombosHostSdk | undefined | null = typeof window === 'undefined' ? undefined : window.combos,\n): sdk is CombosHostSdk & { requestI18n: NonNullable<CombosHostSdk['requestI18n']> } {\n return !!sdk && typeof sdk.requestI18n === 'function';\n}\n\nexport function parseI18nResult(data: unknown): CombosI18nResult {\n if (!data || typeof data !== 'object') return { needed: false };\n const input = data as {\n needed?: unknown;\n locale?: unknown;\n translations?: unknown;\n };\n if (input.needed !== true) return { needed: false };\n if (typeof input.locale !== 'string' || !input.locale.trim()) {\n return { needed: false };\n }\n if (\n !input.translations ||\n typeof input.translations !== 'object' ||\n Array.isArray(input.translations)\n ) {\n return { needed: false };\n }\n const entries = Object.entries(input.translations);\n if (entries.some(([, value]) => typeof value !== 'string')) {\n return { needed: false };\n }\n return {\n needed: true,\n locale: input.locale.trim(),\n translations: Object.fromEntries(entries) as TextTranslations,\n };\n}\n\n/** Ask the injected host SDK. Always resolves; missing method means no translation. */\nexport async function requestHostI18n(\n request: CombosI18nRequest,\n): Promise<CombosI18nResult> {\n if (typeof window === 'undefined' || !hasCombosRequestI18n(window.combos)) {\n return { needed: false };\n }\n try {\n return parseI18nResult(await window.combos.requestI18n(request));\n } catch {\n return { needed: false };\n }\n}\n","/** Keep identical to `@combos-fun/plugin-renderer-text` localization. */\n\nexport type TextReplacementValue = string | number;\nexport type TextReplacements = Record<string, TextReplacementValue>;\nexport type TextTranslations = Record<string, string>;\n\nconst PLACEHOLDER_PATTERN = /\\{([A-Za-z_$][\\w$.-]*)\\}/g;\n\nexport function interpolateText(\n template: string,\n replacements?: TextReplacements,\n): string {\n if (!replacements) return template;\n return template.replace(PLACEHOLDER_PATTERN, (placeholder, name: string) => {\n if (!Object.prototype.hasOwnProperty.call(replacements, name)) {\n return placeholder;\n }\n return String(replacements[name]);\n });\n}\n\nexport function localizeText(\n sourceText: string,\n replacements: TextReplacements | undefined,\n sourceLocale: string,\n targetLocale: string,\n translations: TextTranslations,\n): string {\n const shouldTranslate =\n !!sourceLocale &&\n !!targetLocale &&\n sourceLocale.toLowerCase() !== targetLocale.toLowerCase();\n const template =\n shouldTranslate && Object.prototype.hasOwnProperty.call(translations, sourceText)\n ? translations[sourceText]\n : sourceText;\n return interpolateText(template, replacements);\n}\n\nexport function addSourceTexts(\n target: Set<string>,\n texts?: Iterable<string | undefined | null>,\n) {\n if (!texts) return;\n for (const text of texts) {\n const source = typeof text === 'string' ? text.trim() : '';\n if (source) target.add(source);\n }\n}\n\nexport function mergeTranslations(\n current: TextTranslations,\n incoming: Record<string, unknown>,\n): TextTranslations {\n const next = { ...current };\n for (const [key, value] of Object.entries(incoming)) {\n if (typeof value === 'string') next[key] = value;\n }\n return next;\n}\n","import { decorators, ComponentChanged, OBSERVER_TYPE, GameObject } from '@combos-fun/engine';\nimport { Renderer3D, Renderer3DSystem, tagObject3D, Transform3D, VisualPoseBridge } from '@combos-fun/plugin-renderer-3d';\nimport { Text as TroikaText } from 'troika-three-text';\nimport Text3D from './component';\nimport { requestHostI18n } from './hostSdk';\nimport {\n addSourceTexts,\n localizeText,\n mergeTranslations,\n type TextTranslations,\n} from './localization';\n\nexport interface Text3DSystemParams {\n /** BCP 47 locale of the source text, for example `zh-CN`. Omit to disable host-driven i18n. */\n sourceLocale?: string;\n /**\n * All source templates to translate on first `requestI18n`, including copy\n * for screens that are not mounted yet. Later `Text3D` nodes reuse this catalog\n * and will not flash the source language.\n */\n sourceTexts?: string[];\n}\n\n@decorators.componentObserver({\n Text3D: [\n 'text',\n { prop: ['replacements'], deep: true },\n 'fontSize', 'color', 'anchorX', 'anchorY', 'maxWidth', 'font',\n 'positionX', 'positionY', 'positionZ',\n 'rotationX', 'rotationY', 'rotationZ',\n ],\n})\nexport default class Text3DSystem extends Renderer3D<Text3DSystemParams> {\n static systemName = 'Text3DSystem';\n name: string = 'Text3DSystem';\n\n private texts = new Map<number, { mesh: TroikaText; component: Text3D }>();\n private poseBridges = new Map<number, VisualPoseBridge>();\n private sourceLocale = '';\n private targetLocale = '';\n private translations: TextTranslations = {};\n private seededSourceTexts = new Set<string>();\n private lastRequestedSourceTexts = '';\n private i18nRequestScheduled = false;\n private i18nRequestId = 0;\n private firstI18nSettled = false;\n\n init(params?: Text3DSystemParams) {\n const renderer3DSystem = this.game.getSystem(Renderer3DSystem) as Renderer3DSystem;\n renderer3DSystem.rendererManager.register(this);\n this.sourceLocale = params?.sourceLocale?.trim() ?? '';\n this.targetLocale = this.sourceLocale;\n this.declareSourceTexts(params?.sourceTexts);\n }\n\n /** Register extra source templates before or after ready. First request includes these. */\n declareSourceTexts(texts?: string[]) {\n addSourceTexts(this.seededSourceTexts, texts);\n this.scheduleI18nRequest();\n }\n\n async beforeReady() {\n if (this.firstI18nSettled) return;\n this.update();\n if (!this.sourceLocale) {\n this.firstI18nSettled = true;\n return;\n }\n await this.requestI18nAndApply();\n this.firstI18nSettled = true;\n }\n\n setI18n(locale: string, translations: TextTranslations) {\n const targetLocale = locale?.trim();\n if (!targetLocale || !translations || typeof translations !== 'object') return;\n this.targetLocale = targetLocale;\n this.translations = mergeTranslations(this.translations, translations);\n this.refreshAllText();\n }\n\n componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'Text3D') return;\n\n if (changed.type === OBSERVER_TYPE.ADD) {\n this.handleAdd(changed.gameObject, changed.component as Text3D);\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.handleRemove(changed.gameObject.id);\n } else {\n this.handleChange(changed);\n }\n }\n\n rendererUpdate(gameObject: GameObject) {\n const component = gameObject.getComponent(Text3D) as Text3D;\n if (!component) return;\n\n const entry = this.texts.get(gameObject.id);\n if (!entry) return;\n this.applyPose(gameObject, component, entry.mesh);\n }\n\n private handleAdd(gameObject: GameObject, component: Text3D) {\n const textMesh = new TroikaText();\n this.syncTextProps(textMesh, component);\n textMesh.sync();\n tagObject3D(textMesh, gameObject.id);\n\n this.threeContext.attachVisual(gameObject.id, textMesh, gameObject);\n this.texts.set(gameObject.id, { mesh: textMesh, component });\n this.poseBridges.set(gameObject.id, new VisualPoseBridge());\n this.scheduleI18nRequest();\n }\n\n private handleChange(changed: ComponentChanged) {\n const entry = this.texts.get(changed.gameObject.id);\n if (!entry) return;\n const component = changed.component as Text3D;\n entry.component = component;\n this.syncTextProps(entry.mesh, component);\n entry.mesh.sync();\n if (changed.prop.prop[0] === 'text') this.scheduleI18nRequest();\n }\n\n private handleRemove(id: number) {\n const entry = this.texts.get(id);\n if (!entry) return;\n\n this.threeContext.detachVisual(id, entry.mesh);\n entry.mesh.dispose();\n this.texts.delete(id);\n this.poseBridges.delete(id);\n }\n\n private syncTextProps(textMesh: TroikaText, component: Text3D) {\n textMesh.text = this.resolveText(component);\n textMesh.fontSize = component.fontSize;\n textMesh.color = component.color;\n textMesh.anchorX = component.anchorX;\n textMesh.anchorY = component.anchorY;\n if (component.maxWidth > 0) {\n textMesh.maxWidth = component.maxWidth;\n }\n if (component.font) {\n textMesh.font = component.font;\n }\n }\n\n private applyPose(gameObject: GameObject, component: Text3D, textMesh: TroikaText) {\n let bridge = this.poseBridges.get(gameObject.id);\n if (!bridge) {\n bridge = new VisualPoseBridge();\n this.poseBridges.set(gameObject.id, bridge);\n }\n const transform = gameObject.getComponent(Transform3D) as Transform3D | undefined;\n if (!bridge.sync(component, transform)) {\n textMesh.position.set(0, 0, 0);\n textMesh.rotation.set(0, 0, 0);\n return;\n }\n textMesh.position.set(component.positionX, component.positionY, component.positionZ);\n textMesh.rotation.set(component.rotationX, component.rotationY, component.rotationZ);\n }\n\n onDestroy() {\n this.i18nRequestId += 1;\n this.firstI18nSettled = false;\n for (const [id] of this.texts) {\n this.handleRemove(id);\n }\n this.texts.clear();\n }\n\n private resolveText(component: Text3D): string {\n return localizeText(\n component.text,\n component.replacements,\n this.sourceLocale,\n this.targetLocale,\n this.translations,\n );\n }\n\n private collectSourceTexts(): string[] {\n const sourceTexts = new Set(this.seededSourceTexts);\n for (const entry of this.texts.values()) {\n addSourceTexts(sourceTexts, [entry.component.text]);\n }\n return [...sourceTexts];\n }\n\n private scheduleI18nRequest() {\n if (!this.sourceLocale || !this.firstI18nSettled || this.i18nRequestScheduled) return;\n this.i18nRequestScheduled = true;\n queueMicrotask(() => {\n this.i18nRequestScheduled = false;\n this.startI18nRequest();\n });\n }\n\n private startI18nRequest() {\n if (!this.sourceLocale || !this.firstI18nSettled) return;\n const sourceTexts = this.collectSourceTexts();\n const signature = [...sourceTexts].sort().join('\\0');\n if (signature === this.lastRequestedSourceTexts) return;\n void this.requestI18nAndApply();\n }\n\n private async requestI18nAndApply() {\n const sourceTexts = this.collectSourceTexts();\n const signature = [...sourceTexts].sort().join('\\0');\n this.lastRequestedSourceTexts = signature;\n const requestId = ++this.i18nRequestId;\n const result = await requestHostI18n({\n sourceLocale: this.sourceLocale,\n sourceTexts,\n });\n if (requestId !== this.i18nRequestId) return;\n if (!result.needed) return;\n this.setI18n(result.locale, result.translations);\n }\n\n private refreshAllText() {\n for (const entry of this.texts.values()) {\n entry.mesh.text = this.resolveText(entry.component);\n entry.mesh.sync();\n }\n }\n}\n"],"names":["Component","__decorate","Field","Renderer3D","Renderer3DSystem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,WAAW,EAAE,WAAW,EAAE,WAAW;YACrC,WAAW,EAAE,WAAW,EAAE,WAAW;AACtC,SAAA;KACF;AACoB,CAAA,EAAA,YAAY,CAmMhC;2BAnMoB,YAAY;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var e=require("tslib"),t=require("@combos-fun/engine"),o=require("@combos-fun/inspector-decorator"),s=require("@combos-fun/plugin-renderer-3d"),i=require("troika-three-text");class r extends t.Component{constructor(){super(...arguments),this.text="",this.replacements={},this.fontSize=.5,this.color=16777215,this.anchorX="center",this.anchorY="middle",this.maxWidth=0,this.font="",this.positionX=0,this.positionY=0,this.positionZ=0,this.rotationX=0,this.rotationY=0,this.rotationZ=0}static{this.componentName="Text3D"}init(e){if(!e)return;const{replacements:t,...o}=e;Object.assign(this,o),t&&(this.replacements={...t})}}e.__decorate([o.Field({type:"string",group:"Text3D",label:"text",description:"Visible text content.",editor:"text"})],r.prototype,"text",void 0),e.__decorate([o.Field({type:"number",step:.01,group:"Text3D",label:"fontSize",description:"Font size.",editor:"number-stepper"})],r.prototype,"fontSize",void 0),e.__decorate([o.Field({type:"number",group:"Text3D",label:"color",description:"Color value.",editor:"number-stepper"})],r.prototype,"color",void 0),e.__decorate([o.Field({type:"string",group:"Text3D",label:"anchorX",description:"Horizontal text anchor.",editor:"text"})],r.prototype,"anchorX",void 0),e.__decorate([o.Field({type:"string",group:"Text3D",label:"anchorY",description:"Vertical text anchor.",editor:"text"})],r.prototype,"anchorY",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Text3D",label:"maxWidth",description:"Maximum text wrap width.",editor:"number-stepper"})],r.prototype,"maxWidth",void 0),e.__decorate([o.Field({type:"string",group:"Text3D",label:"font",description:"Font URL or path for troika-three-text (not an engine resource name).",editor:"text"})],r.prototype,"font",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Text3D",label:"positionX",description:"Local X position.",editor:"number-stepper"})],r.prototype,"positionX",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Text3D",label:"positionY",description:"Local Y position.",editor:"number-stepper"})],r.prototype,"positionY",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Text3D",label:"positionZ",description:"Local Z position.",editor:"number-stepper"})],r.prototype,"positionZ",void 0),e.__decorate([o.Field({type:"number",step:.01,group:"Text3D",label:"rotationX",description:"Rotation around X in radians.",editor:"number-stepper"})],r.prototype,"rotationX",void 0),e.__decorate([o.Field({type:"number",step:.01,group:"Text3D",label:"rotationY",description:"Rotation around Y in radians.",editor:"number-stepper"})],r.prototype,"rotationY",void 0),e.__decorate([o.Field({type:"number",step:.01,group:"Text3D",label:"rotationZ",description:"Rotation around Z in radians.",editor:"number-stepper"})],r.prototype,"rotationZ",void 0);function n(e=("undefined"==typeof window?void 0:window.combos)){return!!e&&"function"==typeof e.requestI18n}function a(e){if(!e||"object"!=typeof e)return{needed:!1};const t=e;if(!0!==t.needed)return{needed:!1};if("string"!=typeof t.locale||!t.locale.trim())return{needed:!1};if(!t.translations||"object"!=typeof t.translations||Array.isArray(t.translations))return{needed:!1};const o=Object.entries(t.translations);return o.some(([,e])=>"string"!=typeof e)?{needed:!1}:{needed:!0,locale:t.locale.trim(),translations:Object.fromEntries(o)}}async function c(e){if("undefined"==typeof window||!n(window.combos))return{needed:!1};try{return a(await window.combos.requestI18n(e))}catch{return{needed:!1}}}const d=/\{([A-Za-z_$][\w$.-]*)\}/g;function p(e,t){return t?e.replace(d,(e,o)=>Object.prototype.hasOwnProperty.call(t,o)?String(t[o]):e):e}function l(e,t,o,s,i){return p(!!o&&!!s&&o.toLowerCase()!==s.toLowerCase()&&Object.prototype.hasOwnProperty.call(i,e)?i[e]:e,t)}function h(e,t){if(t)for(const o of t){const t="string"==typeof o?o.trim():"";t&&e.add(t)}}function u(e,t){const o={...e};for(const[e,s]of Object.entries(t))"string"==typeof s&&(o[e]=s);return o}let x=class extends s.Renderer3D{constructor(){super(...arguments),this.name="Text3DSystem",this.texts=new Map,this.poseBridges=new Map,this.sourceLocale="",this.targetLocale="",this.translations={},this.seededSourceTexts=new Set,this.lastRequestedSourceTexts="",this.i18nRequestScheduled=!1,this.i18nRequestId=0,this.firstI18nSettled=!1}static{this.systemName="Text3DSystem"}init(e){this.game.getSystem(s.Renderer3DSystem).rendererManager.register(this),this.sourceLocale=e?.sourceLocale?.trim()??"",this.targetLocale=this.sourceLocale,this.declareSourceTexts(e?.sourceTexts)}declareSourceTexts(e){h(this.seededSourceTexts,e),this.scheduleI18nRequest()}async beforeReady(){this.firstI18nSettled||(this.update(),this.sourceLocale?(await this.requestI18nAndApply(),this.firstI18nSettled=!0):this.firstI18nSettled=!0)}setI18n(e,t){const o=e?.trim();o&&t&&"object"==typeof t&&(this.targetLocale=o,this.translations=u(this.translations,t),this.refreshAllText())}componentChanged(e){"Text3D"===e.componentName&&(e.type===t.OBSERVER_TYPE.ADD?this.handleAdd(e.gameObject,e.component):e.type===t.OBSERVER_TYPE.REMOVE?this.handleRemove(e.gameObject.id):this.handleChange(e))}rendererUpdate(e){const t=e.getComponent(r);if(!t)return;const o=this.texts.get(e.id);o&&this.applyPose(e,t,o.mesh)}handleAdd(e,t){const o=new i.Text;this.syncTextProps(o,t),o.sync(),s.tagObject3D(o,e.id),this.threeContext.attachVisual(e.id,o,e),this.texts.set(e.id,{mesh:o,component:t}),this.poseBridges.set(e.id,new s.VisualPoseBridge),this.scheduleI18nRequest()}handleChange(e){const t=this.texts.get(e.gameObject.id);if(!t)return;const o=e.component;t.component=o,this.syncTextProps(t.mesh,o),t.mesh.sync(),"text"===e.prop.prop[0]&&this.scheduleI18nRequest()}handleRemove(e){const t=this.texts.get(e);t&&(this.threeContext.detachVisual(e,t.mesh),t.mesh.dispose(),this.texts.delete(e),this.poseBridges.delete(e))}syncTextProps(e,t){e.text=this.resolveText(t),e.fontSize=t.fontSize,e.color=t.color,e.anchorX=t.anchorX,e.anchorY=t.anchorY,t.maxWidth>0&&(e.maxWidth=t.maxWidth),t.font&&(e.font=t.font)}applyPose(e,t,o){let i=this.poseBridges.get(e.id);i||(i=new s.VisualPoseBridge,this.poseBridges.set(e.id,i));const r=e.getComponent(s.Transform3D);if(!i.sync(t,r))return o.position.set(0,0,0),void o.rotation.set(0,0,0);o.position.set(t.positionX,t.positionY,t.positionZ),o.rotation.set(t.rotationX,t.rotationY,t.rotationZ)}onDestroy(){this.i18nRequestId+=1,this.firstI18nSettled=!1;for(const[e]of this.texts)this.handleRemove(e);this.texts.clear()}resolveText(e){return l(e.text,e.replacements,this.sourceLocale,this.targetLocale,this.translations)}collectSourceTexts(){const e=new Set(this.seededSourceTexts);for(const t of this.texts.values())h(e,[t.component.text]);return[...e]}scheduleI18nRequest(){this.sourceLocale&&this.firstI18nSettled&&!this.i18nRequestScheduled&&(this.i18nRequestScheduled=!0,queueMicrotask(()=>{this.i18nRequestScheduled=!1,this.startI18nRequest()}))}startI18nRequest(){if(!this.sourceLocale||!this.firstI18nSettled)return;[...this.collectSourceTexts()].sort().join("\0")!==this.lastRequestedSourceTexts&&this.requestI18nAndApply()}async requestI18nAndApply(){const e=this.collectSourceTexts(),t=[...e].sort().join("\0");this.lastRequestedSourceTexts=t;const o=++this.i18nRequestId,s=await c({sourceLocale:this.sourceLocale,sourceTexts:e});o===this.i18nRequestId&&s.needed&&this.setI18n(s.locale,s.translations)}refreshAllText(){for(const e of this.texts.values())e.mesh.text=this.resolveText(e.component),e.mesh.sync()}};x=e.__decorate([t.decorators.componentObserver({Text3D:["text",{prop:["replacements"],deep:!0},"fontSize","color","anchorX","anchorY","maxWidth","font","positionX","positionY","positionZ","rotationX","rotationY","rotationZ"]})],x);var m=x;exports.COMBOS_HOST_SDK="combos",exports.Text3D=r,exports.Text3DSystem=m,exports.addSourceTexts=h,exports.hasCombosRequestI18n=n,exports.interpolateText=p,exports.localizeText=l,exports.mergeTranslations=u,exports.parseI18nResult=a,exports.requestHostI18n=c;
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { Component, ComponentChanged, GameObject } from '@combos-fun/engine';
|
|
2
2
|
import { Renderer3D } from '@combos-fun/plugin-renderer-3d';
|
|
3
3
|
|
|
4
|
+
/** Keep identical to `@combos-fun/plugin-renderer-text` localization. */
|
|
5
|
+
type TextReplacementValue = string | number;
|
|
6
|
+
type TextReplacements = Record<string, TextReplacementValue>;
|
|
7
|
+
type TextTranslations = Record<string, string>;
|
|
8
|
+
declare function interpolateText(template: string, replacements?: TextReplacements): string;
|
|
9
|
+
declare function localizeText(sourceText: string, replacements: TextReplacements | undefined, sourceLocale: string, targetLocale: string, translations: TextTranslations): string;
|
|
10
|
+
declare function addSourceTexts(target: Set<string>, texts?: Iterable<string | undefined | null>): void;
|
|
11
|
+
declare function mergeTranslations(current: TextTranslations, incoming: Record<string, unknown>): TextTranslations;
|
|
12
|
+
|
|
4
13
|
interface Text3DParams {
|
|
5
14
|
text?: string;
|
|
15
|
+
/** Values substituted into named placeholders such as `{score}`. */
|
|
16
|
+
replacements?: TextReplacements;
|
|
6
17
|
fontSize?: number;
|
|
7
18
|
color?: number;
|
|
8
19
|
anchorX?: string;
|
|
@@ -19,6 +30,7 @@ interface Text3DParams {
|
|
|
19
30
|
declare class Text3D extends Component<Text3DParams> {
|
|
20
31
|
static componentName: string;
|
|
21
32
|
text: string;
|
|
33
|
+
replacements: TextReplacements;
|
|
22
34
|
fontSize: number;
|
|
23
35
|
color: number;
|
|
24
36
|
anchorX: string;
|
|
@@ -34,12 +46,34 @@ declare class Text3D extends Component<Text3DParams> {
|
|
|
34
46
|
init(obj?: Text3DParams): void;
|
|
35
47
|
}
|
|
36
48
|
|
|
37
|
-
|
|
49
|
+
interface Text3DSystemParams {
|
|
50
|
+
/** BCP 47 locale of the source text, for example `zh-CN`. Omit to disable host-driven i18n. */
|
|
51
|
+
sourceLocale?: string;
|
|
52
|
+
/**
|
|
53
|
+
* All source templates to translate on first `requestI18n`, including copy
|
|
54
|
+
* for screens that are not mounted yet. Later `Text3D` nodes reuse this catalog
|
|
55
|
+
* and will not flash the source language.
|
|
56
|
+
*/
|
|
57
|
+
sourceTexts?: string[];
|
|
58
|
+
}
|
|
59
|
+
declare class Text3DSystem extends Renderer3D<Text3DSystemParams> {
|
|
38
60
|
static systemName: string;
|
|
39
61
|
name: string;
|
|
40
62
|
private texts;
|
|
41
63
|
private poseBridges;
|
|
42
|
-
|
|
64
|
+
private sourceLocale;
|
|
65
|
+
private targetLocale;
|
|
66
|
+
private translations;
|
|
67
|
+
private seededSourceTexts;
|
|
68
|
+
private lastRequestedSourceTexts;
|
|
69
|
+
private i18nRequestScheduled;
|
|
70
|
+
private i18nRequestId;
|
|
71
|
+
private firstI18nSettled;
|
|
72
|
+
init(params?: Text3DSystemParams): void;
|
|
73
|
+
/** Register extra source templates before or after ready. First request includes these. */
|
|
74
|
+
declareSourceTexts(texts?: string[]): void;
|
|
75
|
+
beforeReady(): Promise<void>;
|
|
76
|
+
setI18n(locale: string, translations: TextTranslations): void;
|
|
43
77
|
componentChanged(changed: ComponentChanged): void;
|
|
44
78
|
rendererUpdate(gameObject: GameObject): void;
|
|
45
79
|
private handleAdd;
|
|
@@ -48,7 +82,43 @@ declare class Text3DSystem extends Renderer3D {
|
|
|
48
82
|
private syncTextProps;
|
|
49
83
|
private applyPose;
|
|
50
84
|
onDestroy(): void;
|
|
85
|
+
private resolveText;
|
|
86
|
+
private collectSourceTexts;
|
|
87
|
+
private scheduleI18nRequest;
|
|
88
|
+
private startI18nRequest;
|
|
89
|
+
private requestI18nAndApply;
|
|
90
|
+
private refreshAllText;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Keep identical to `@combos-fun/plugin-renderer-text` hostSdk. */
|
|
94
|
+
|
|
95
|
+
/** Host-injected global. The SDK itself is not part of this repo. */
|
|
96
|
+
declare const COMBOS_HOST_SDK: "combos";
|
|
97
|
+
interface CombosI18nRequest {
|
|
98
|
+
sourceLocale: string;
|
|
99
|
+
sourceTexts: string[];
|
|
100
|
+
}
|
|
101
|
+
type CombosI18nResult = {
|
|
102
|
+
needed: false;
|
|
103
|
+
} | {
|
|
104
|
+
needed: true;
|
|
105
|
+
locale: string;
|
|
106
|
+
translations: TextTranslations;
|
|
107
|
+
};
|
|
108
|
+
interface CombosHostSdk {
|
|
109
|
+
requestI18n?(request: CombosI18nRequest): Promise<CombosI18nResult>;
|
|
110
|
+
}
|
|
111
|
+
declare global {
|
|
112
|
+
interface Window {
|
|
113
|
+
combos?: CombosHostSdk;
|
|
114
|
+
}
|
|
51
115
|
}
|
|
116
|
+
declare function hasCombosRequestI18n(sdk?: CombosHostSdk | undefined | null): sdk is CombosHostSdk & {
|
|
117
|
+
requestI18n: NonNullable<CombosHostSdk['requestI18n']>;
|
|
118
|
+
};
|
|
119
|
+
declare function parseI18nResult(data: unknown): CombosI18nResult;
|
|
120
|
+
/** Ask the injected host SDK. Always resolves; missing method means no translation. */
|
|
121
|
+
declare function requestHostI18n(request: CombosI18nRequest): Promise<CombosI18nResult>;
|
|
52
122
|
|
|
53
|
-
export { Text3D, Text3DSystem };
|
|
54
|
-
export type { Text3DParams };
|
|
123
|
+
export { COMBOS_HOST_SDK, Text3D, Text3DSystem, addSourceTexts, hasCombosRequestI18n, interpolateText, localizeText, mergeTranslations, parseI18nResult, requestHostI18n };
|
|
124
|
+
export type { CombosHostSdk, CombosI18nRequest, CombosI18nResult, Text3DParams, Text3DSystemParams, TextReplacementValue, TextReplacements, TextTranslations };
|
|
@@ -8,6 +8,7 @@ class Text3D extends Component {
|
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
10
10
|
this.text = '';
|
|
11
|
+
this.replacements = {};
|
|
11
12
|
this.fontSize = 0.5;
|
|
12
13
|
this.color = 0xffffff;
|
|
13
14
|
this.anchorX = 'center';
|
|
@@ -23,8 +24,12 @@ class Text3D extends Component {
|
|
|
23
24
|
}
|
|
24
25
|
static { this.componentName = 'Text3D'; }
|
|
25
26
|
init(obj) {
|
|
26
|
-
if (obj)
|
|
27
|
-
|
|
27
|
+
if (!obj)
|
|
28
|
+
return;
|
|
29
|
+
const { replacements, ...rest } = obj;
|
|
30
|
+
Object.assign(this, rest);
|
|
31
|
+
if (replacements)
|
|
32
|
+
this.replacements = { ...replacements };
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
35
|
__decorate([
|
|
@@ -153,17 +158,133 @@ __decorate([
|
|
|
153
158
|
})
|
|
154
159
|
], Text3D.prototype, "rotationZ", void 0);
|
|
155
160
|
|
|
161
|
+
/** Host-injected global. The SDK itself is not part of this repo. */
|
|
162
|
+
const COMBOS_HOST_SDK = 'combos';
|
|
163
|
+
function hasCombosRequestI18n(sdk = typeof window === 'undefined' ? undefined : window.combos) {
|
|
164
|
+
return !!sdk && typeof sdk.requestI18n === 'function';
|
|
165
|
+
}
|
|
166
|
+
function parseI18nResult(data) {
|
|
167
|
+
if (!data || typeof data !== 'object')
|
|
168
|
+
return { needed: false };
|
|
169
|
+
const input = data;
|
|
170
|
+
if (input.needed !== true)
|
|
171
|
+
return { needed: false };
|
|
172
|
+
if (typeof input.locale !== 'string' || !input.locale.trim()) {
|
|
173
|
+
return { needed: false };
|
|
174
|
+
}
|
|
175
|
+
if (!input.translations ||
|
|
176
|
+
typeof input.translations !== 'object' ||
|
|
177
|
+
Array.isArray(input.translations)) {
|
|
178
|
+
return { needed: false };
|
|
179
|
+
}
|
|
180
|
+
const entries = Object.entries(input.translations);
|
|
181
|
+
if (entries.some(([, value]) => typeof value !== 'string')) {
|
|
182
|
+
return { needed: false };
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
needed: true,
|
|
186
|
+
locale: input.locale.trim(),
|
|
187
|
+
translations: Object.fromEntries(entries),
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/** Ask the injected host SDK. Always resolves; missing method means no translation. */
|
|
191
|
+
async function requestHostI18n(request) {
|
|
192
|
+
if (typeof window === 'undefined' || !hasCombosRequestI18n(window.combos)) {
|
|
193
|
+
return { needed: false };
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
return parseI18nResult(await window.combos.requestI18n(request));
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
return { needed: false };
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** Keep identical to `@combos-fun/plugin-renderer-text` localization. */
|
|
204
|
+
const PLACEHOLDER_PATTERN = /\{([A-Za-z_$][\w$.-]*)\}/g;
|
|
205
|
+
function interpolateText(template, replacements) {
|
|
206
|
+
if (!replacements)
|
|
207
|
+
return template;
|
|
208
|
+
return template.replace(PLACEHOLDER_PATTERN, (placeholder, name) => {
|
|
209
|
+
if (!Object.prototype.hasOwnProperty.call(replacements, name)) {
|
|
210
|
+
return placeholder;
|
|
211
|
+
}
|
|
212
|
+
return String(replacements[name]);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
function localizeText(sourceText, replacements, sourceLocale, targetLocale, translations) {
|
|
216
|
+
const shouldTranslate = !!sourceLocale &&
|
|
217
|
+
!!targetLocale &&
|
|
218
|
+
sourceLocale.toLowerCase() !== targetLocale.toLowerCase();
|
|
219
|
+
const template = shouldTranslate && Object.prototype.hasOwnProperty.call(translations, sourceText)
|
|
220
|
+
? translations[sourceText]
|
|
221
|
+
: sourceText;
|
|
222
|
+
return interpolateText(template, replacements);
|
|
223
|
+
}
|
|
224
|
+
function addSourceTexts(target, texts) {
|
|
225
|
+
if (!texts)
|
|
226
|
+
return;
|
|
227
|
+
for (const text of texts) {
|
|
228
|
+
const source = typeof text === 'string' ? text.trim() : '';
|
|
229
|
+
if (source)
|
|
230
|
+
target.add(source);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
function mergeTranslations(current, incoming) {
|
|
234
|
+
const next = { ...current };
|
|
235
|
+
for (const [key, value] of Object.entries(incoming)) {
|
|
236
|
+
if (typeof value === 'string')
|
|
237
|
+
next[key] = value;
|
|
238
|
+
}
|
|
239
|
+
return next;
|
|
240
|
+
}
|
|
241
|
+
|
|
156
242
|
let Text3DSystem = class Text3DSystem extends Renderer3D {
|
|
157
243
|
constructor() {
|
|
158
244
|
super(...arguments);
|
|
159
245
|
this.name = 'Text3DSystem';
|
|
160
246
|
this.texts = new Map();
|
|
161
247
|
this.poseBridges = new Map();
|
|
248
|
+
this.sourceLocale = '';
|
|
249
|
+
this.targetLocale = '';
|
|
250
|
+
this.translations = {};
|
|
251
|
+
this.seededSourceTexts = new Set();
|
|
252
|
+
this.lastRequestedSourceTexts = '';
|
|
253
|
+
this.i18nRequestScheduled = false;
|
|
254
|
+
this.i18nRequestId = 0;
|
|
255
|
+
this.firstI18nSettled = false;
|
|
162
256
|
}
|
|
163
257
|
static { this.systemName = 'Text3DSystem'; }
|
|
164
|
-
init() {
|
|
258
|
+
init(params) {
|
|
165
259
|
const renderer3DSystem = this.game.getSystem(Renderer3DSystem);
|
|
166
260
|
renderer3DSystem.rendererManager.register(this);
|
|
261
|
+
this.sourceLocale = params?.sourceLocale?.trim() ?? '';
|
|
262
|
+
this.targetLocale = this.sourceLocale;
|
|
263
|
+
this.declareSourceTexts(params?.sourceTexts);
|
|
264
|
+
}
|
|
265
|
+
/** Register extra source templates before or after ready. First request includes these. */
|
|
266
|
+
declareSourceTexts(texts) {
|
|
267
|
+
addSourceTexts(this.seededSourceTexts, texts);
|
|
268
|
+
this.scheduleI18nRequest();
|
|
269
|
+
}
|
|
270
|
+
async beforeReady() {
|
|
271
|
+
if (this.firstI18nSettled)
|
|
272
|
+
return;
|
|
273
|
+
this.update();
|
|
274
|
+
if (!this.sourceLocale) {
|
|
275
|
+
this.firstI18nSettled = true;
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
await this.requestI18nAndApply();
|
|
279
|
+
this.firstI18nSettled = true;
|
|
280
|
+
}
|
|
281
|
+
setI18n(locale, translations) {
|
|
282
|
+
const targetLocale = locale?.trim();
|
|
283
|
+
if (!targetLocale || !translations || typeof translations !== 'object')
|
|
284
|
+
return;
|
|
285
|
+
this.targetLocale = targetLocale;
|
|
286
|
+
this.translations = mergeTranslations(this.translations, translations);
|
|
287
|
+
this.refreshAllText();
|
|
167
288
|
}
|
|
168
289
|
componentChanged(changed) {
|
|
169
290
|
if (changed.componentName !== 'Text3D')
|
|
@@ -175,17 +296,17 @@ let Text3DSystem = class Text3DSystem extends Renderer3D {
|
|
|
175
296
|
this.handleRemove(changed.gameObject.id);
|
|
176
297
|
}
|
|
177
298
|
else {
|
|
178
|
-
this.handleChange(changed
|
|
299
|
+
this.handleChange(changed);
|
|
179
300
|
}
|
|
180
301
|
}
|
|
181
302
|
rendererUpdate(gameObject) {
|
|
182
303
|
const component = gameObject.getComponent(Text3D);
|
|
183
304
|
if (!component)
|
|
184
305
|
return;
|
|
185
|
-
const
|
|
186
|
-
if (!
|
|
306
|
+
const entry = this.texts.get(gameObject.id);
|
|
307
|
+
if (!entry)
|
|
187
308
|
return;
|
|
188
|
-
this.applyPose(gameObject, component,
|
|
309
|
+
this.applyPose(gameObject, component, entry.mesh);
|
|
189
310
|
}
|
|
190
311
|
handleAdd(gameObject, component) {
|
|
191
312
|
const textMesh = new Text();
|
|
@@ -193,27 +314,32 @@ let Text3DSystem = class Text3DSystem extends Renderer3D {
|
|
|
193
314
|
textMesh.sync();
|
|
194
315
|
tagObject3D(textMesh, gameObject.id);
|
|
195
316
|
this.threeContext.attachVisual(gameObject.id, textMesh, gameObject);
|
|
196
|
-
this.texts.set(gameObject.id, textMesh);
|
|
317
|
+
this.texts.set(gameObject.id, { mesh: textMesh, component });
|
|
197
318
|
this.poseBridges.set(gameObject.id, new VisualPoseBridge());
|
|
319
|
+
this.scheduleI18nRequest();
|
|
198
320
|
}
|
|
199
|
-
handleChange(
|
|
200
|
-
const
|
|
201
|
-
if (!
|
|
321
|
+
handleChange(changed) {
|
|
322
|
+
const entry = this.texts.get(changed.gameObject.id);
|
|
323
|
+
if (!entry)
|
|
202
324
|
return;
|
|
203
|
-
|
|
204
|
-
|
|
325
|
+
const component = changed.component;
|
|
326
|
+
entry.component = component;
|
|
327
|
+
this.syncTextProps(entry.mesh, component);
|
|
328
|
+
entry.mesh.sync();
|
|
329
|
+
if (changed.prop.prop[0] === 'text')
|
|
330
|
+
this.scheduleI18nRequest();
|
|
205
331
|
}
|
|
206
332
|
handleRemove(id) {
|
|
207
|
-
const
|
|
208
|
-
if (!
|
|
333
|
+
const entry = this.texts.get(id);
|
|
334
|
+
if (!entry)
|
|
209
335
|
return;
|
|
210
|
-
this.threeContext.detachVisual(id,
|
|
211
|
-
|
|
336
|
+
this.threeContext.detachVisual(id, entry.mesh);
|
|
337
|
+
entry.mesh.dispose();
|
|
212
338
|
this.texts.delete(id);
|
|
213
339
|
this.poseBridges.delete(id);
|
|
214
340
|
}
|
|
215
341
|
syncTextProps(textMesh, component) {
|
|
216
|
-
textMesh.text = component
|
|
342
|
+
textMesh.text = this.resolveText(component);
|
|
217
343
|
textMesh.fontSize = component.fontSize;
|
|
218
344
|
textMesh.color = component.color;
|
|
219
345
|
textMesh.anchorX = component.anchorX;
|
|
@@ -241,16 +367,69 @@ let Text3DSystem = class Text3DSystem extends Renderer3D {
|
|
|
241
367
|
textMesh.rotation.set(component.rotationX, component.rotationY, component.rotationZ);
|
|
242
368
|
}
|
|
243
369
|
onDestroy() {
|
|
370
|
+
this.i18nRequestId += 1;
|
|
371
|
+
this.firstI18nSettled = false;
|
|
244
372
|
for (const [id] of this.texts) {
|
|
245
373
|
this.handleRemove(id);
|
|
246
374
|
}
|
|
247
375
|
this.texts.clear();
|
|
248
376
|
}
|
|
377
|
+
resolveText(component) {
|
|
378
|
+
return localizeText(component.text, component.replacements, this.sourceLocale, this.targetLocale, this.translations);
|
|
379
|
+
}
|
|
380
|
+
collectSourceTexts() {
|
|
381
|
+
const sourceTexts = new Set(this.seededSourceTexts);
|
|
382
|
+
for (const entry of this.texts.values()) {
|
|
383
|
+
addSourceTexts(sourceTexts, [entry.component.text]);
|
|
384
|
+
}
|
|
385
|
+
return [...sourceTexts];
|
|
386
|
+
}
|
|
387
|
+
scheduleI18nRequest() {
|
|
388
|
+
if (!this.sourceLocale || !this.firstI18nSettled || this.i18nRequestScheduled)
|
|
389
|
+
return;
|
|
390
|
+
this.i18nRequestScheduled = true;
|
|
391
|
+
queueMicrotask(() => {
|
|
392
|
+
this.i18nRequestScheduled = false;
|
|
393
|
+
this.startI18nRequest();
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
startI18nRequest() {
|
|
397
|
+
if (!this.sourceLocale || !this.firstI18nSettled)
|
|
398
|
+
return;
|
|
399
|
+
const sourceTexts = this.collectSourceTexts();
|
|
400
|
+
const signature = [...sourceTexts].sort().join('\0');
|
|
401
|
+
if (signature === this.lastRequestedSourceTexts)
|
|
402
|
+
return;
|
|
403
|
+
void this.requestI18nAndApply();
|
|
404
|
+
}
|
|
405
|
+
async requestI18nAndApply() {
|
|
406
|
+
const sourceTexts = this.collectSourceTexts();
|
|
407
|
+
const signature = [...sourceTexts].sort().join('\0');
|
|
408
|
+
this.lastRequestedSourceTexts = signature;
|
|
409
|
+
const requestId = ++this.i18nRequestId;
|
|
410
|
+
const result = await requestHostI18n({
|
|
411
|
+
sourceLocale: this.sourceLocale,
|
|
412
|
+
sourceTexts,
|
|
413
|
+
});
|
|
414
|
+
if (requestId !== this.i18nRequestId)
|
|
415
|
+
return;
|
|
416
|
+
if (!result.needed)
|
|
417
|
+
return;
|
|
418
|
+
this.setI18n(result.locale, result.translations);
|
|
419
|
+
}
|
|
420
|
+
refreshAllText() {
|
|
421
|
+
for (const entry of this.texts.values()) {
|
|
422
|
+
entry.mesh.text = this.resolveText(entry.component);
|
|
423
|
+
entry.mesh.sync();
|
|
424
|
+
}
|
|
425
|
+
}
|
|
249
426
|
};
|
|
250
427
|
Text3DSystem = __decorate([
|
|
251
428
|
decorators.componentObserver({
|
|
252
429
|
Text3D: [
|
|
253
|
-
'text',
|
|
430
|
+
'text',
|
|
431
|
+
{ prop: ['replacements'], deep: true },
|
|
432
|
+
'fontSize', 'color', 'anchorX', 'anchorY', 'maxWidth', 'font',
|
|
254
433
|
'positionX', 'positionY', 'positionZ',
|
|
255
434
|
'rotationX', 'rotationY', 'rotationZ',
|
|
256
435
|
],
|
|
@@ -258,5 +437,5 @@ Text3DSystem = __decorate([
|
|
|
258
437
|
], Text3DSystem);
|
|
259
438
|
var Text3DSystem_default = Text3DSystem;
|
|
260
439
|
|
|
261
|
-
export { Text3D, Text3DSystem_default as Text3DSystem };
|
|
440
|
+
export { COMBOS_HOST_SDK, Text3D, Text3DSystem_default as Text3DSystem, addSourceTexts, hasCombosRequestI18n, interpolateText, localizeText, mergeTranslations, parseI18nResult, requestHostI18n };
|
|
262
441
|
//# sourceMappingURL=plugin-renderer-3d-text.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-renderer-3d-text.esm.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { Component } from '@combos-fun/engine';\nimport { Field } from '@combos-fun/inspector-decorator';\n\nexport interface Text3DParams {\n text?: string;\n fontSize?: number;\n color?: number;\n anchorX?: string;\n anchorY?: string;\n maxWidth?: number;\n font?: string;\n positionX?: number;\n positionY?: number;\n positionZ?: number;\n rotationX?: number;\n rotationY?: number;\n rotationZ?: number;\n}\n\nexport default class Text3D extends Component<Text3DParams> {\n static componentName: string = 'Text3D';\n\n @Field({\n\n type: 'string',\n\n group: 'Text3D',\n\n label: 'text',\n\n description: 'Visible text content.',\n\n editor: 'text',\n\n })\n\n text: string = '';\n @Field({\n type: 'number',\n step: 0.01,\n group: 'Text3D',\n label: 'fontSize',\n description: 'Font size.',\n editor: 'number-stepper',\n })\n fontSize: number = 0.5;\n @Field({\n type: 'number',\n group: 'Text3D',\n label: 'color',\n description: 'Color value.',\n editor: 'number-stepper',\n })\n color: number = 0xffffff;\n @Field({\n type: 'string',\n group: 'Text3D',\n label: 'anchorX',\n description: 'Horizontal text anchor.',\n editor: 'text',\n })\n anchorX: string = 'center';\n @Field({\n type: 'string',\n group: 'Text3D',\n label: 'anchorY',\n description: 'Vertical text anchor.',\n editor: 'text',\n })\n anchorY: string = 'middle';\n @Field({\n type: 'number',\n step: 0.1,\n group: 'Text3D',\n label: 'maxWidth',\n description: 'Maximum text wrap width.',\n editor: 'number-stepper',\n })\n maxWidth: number = 0;\n @Field({\n type: 'string',\n group: 'Text3D',\n label: 'font',\n description: 'Font URL or path for troika-three-text (not an engine resource name).',\n editor: 'text',\n })\n font: string = '';\n @Field({\n type: 'number',\n step: 0.1,\n group: 'Text3D',\n label: 'positionX',\n description: 'Local X position.',\n editor: 'number-stepper',\n })\n positionX: number = 0;\n @Field({\n type: 'number',\n step: 0.1,\n group: 'Text3D',\n label: 'positionY',\n description: 'Local Y position.',\n editor: 'number-stepper',\n })\n positionY: number = 0;\n @Field({\n type: 'number',\n step: 0.1,\n group: 'Text3D',\n label: 'positionZ',\n description: 'Local Z position.',\n editor: 'number-stepper',\n })\n positionZ: number = 0;\n @Field({\n type: 'number',\n step: 0.01,\n group: 'Text3D',\n label: 'rotationX',\n description: 'Rotation around X in radians.',\n editor: 'number-stepper',\n })\n rotationX: number = 0;\n @Field({\n type: 'number',\n step: 0.01,\n group: 'Text3D',\n label: 'rotationY',\n description: 'Rotation around Y in radians.',\n editor: 'number-stepper',\n })\n rotationY: number = 0;\n @Field({\n type: 'number',\n step: 0.01,\n group: 'Text3D',\n label: 'rotationZ',\n description: 'Rotation around Z in radians.',\n editor: 'number-stepper',\n })\n rotationZ: number = 0;\n\n init(obj?: Text3DParams) {\n if (obj) Object.assign(this, obj);\n }\n}\n","import { decorators, ComponentChanged, OBSERVER_TYPE, GameObject } from '@combos-fun/engine';\nimport { Renderer3D, Renderer3DSystem, tagObject3D, Transform3D, VisualPoseBridge } from '@combos-fun/plugin-renderer-3d';\nimport { Text as TroikaText } from 'troika-three-text';\nimport Text3D from './component';\n\n@decorators.componentObserver({\n Text3D: [\n 'text', 'fontSize', 'color', 'anchorX', 'anchorY', 'maxWidth', 'font',\n 'positionX', 'positionY', 'positionZ',\n 'rotationX', 'rotationY', 'rotationZ',\n ],\n})\nexport default class Text3DSystem extends Renderer3D {\n static systemName = 'Text3DSystem';\n name: string = 'Text3DSystem';\n\n private texts: Map<number, TroikaText> = new Map();\n private poseBridges = new Map<number, VisualPoseBridge>();\n\n init() {\n const renderer3DSystem = this.game.getSystem(Renderer3DSystem) as Renderer3DSystem;\n renderer3DSystem.rendererManager.register(this);\n }\n\n componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'Text3D') return;\n\n if (changed.type === OBSERVER_TYPE.ADD) {\n this.handleAdd(changed.gameObject, changed.component as Text3D);\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.handleRemove(changed.gameObject.id);\n } else {\n this.handleChange(changed.gameObject.id, changed.component as Text3D);\n }\n }\n\n rendererUpdate(gameObject: GameObject) {\n const component = gameObject.getComponent(Text3D) as Text3D;\n if (!component) return;\n\n const textMesh = this.texts.get(gameObject.id);\n if (!textMesh) return;\n this.applyPose(gameObject, component, textMesh);\n }\n\n private handleAdd(gameObject: GameObject, component: Text3D) {\n const textMesh = new TroikaText();\n this.syncTextProps(textMesh, component);\n textMesh.sync();\n tagObject3D(textMesh, gameObject.id);\n\n this.threeContext.attachVisual(gameObject.id, textMesh, gameObject);\n this.texts.set(gameObject.id, textMesh);\n this.poseBridges.set(gameObject.id, new VisualPoseBridge());\n }\n\n private handleChange(id: number, component: Text3D) {\n const textMesh = this.texts.get(id);\n if (!textMesh) return;\n\n this.syncTextProps(textMesh, component);\n textMesh.sync();\n }\n\n private handleRemove(id: number) {\n const textMesh = this.texts.get(id);\n if (!textMesh) return;\n\n this.threeContext.detachVisual(id, textMesh);\n textMesh.dispose();\n this.texts.delete(id);\n this.poseBridges.delete(id);\n }\n\n private syncTextProps(textMesh: TroikaText, component: Text3D) {\n textMesh.text = component.text;\n textMesh.fontSize = component.fontSize;\n textMesh.color = component.color;\n textMesh.anchorX = component.anchorX;\n textMesh.anchorY = component.anchorY;\n if (component.maxWidth > 0) {\n textMesh.maxWidth = component.maxWidth;\n }\n if (component.font) {\n textMesh.font = component.font;\n }\n }\n\n private applyPose(gameObject: GameObject, component: Text3D, textMesh: TroikaText) {\n let bridge = this.poseBridges.get(gameObject.id);\n if (!bridge) {\n bridge = new VisualPoseBridge();\n this.poseBridges.set(gameObject.id, bridge);\n }\n const transform = gameObject.getComponent(Transform3D) as Transform3D | undefined;\n if (!bridge.sync(component, transform)) {\n textMesh.position.set(0, 0, 0);\n textMesh.rotation.set(0, 0, 0);\n return;\n }\n textMesh.position.set(component.positionX, component.positionY, component.positionZ);\n textMesh.rotation.set(component.rotationX, component.rotationY, component.rotationZ);\n }\n\n onDestroy() {\n for (const [id] of this.texts) {\n this.handleRemove(id);\n }\n this.texts.clear();\n }\n}\n"],"names":["TroikaText"],"mappings":";;;;;;AAmBc,MAAO,MAAO,SAAQ,SAAuB,CAAA;AAA3D,IAAA,WAAA,GAAA;;QAiBE,IAAA,CAAA,IAAI,GAAW,EAAE;QASjB,IAAA,CAAA,QAAQ,GAAW,GAAG;QAQtB,IAAA,CAAA,KAAK,GAAW,QAAQ;QAQxB,IAAA,CAAA,OAAO,GAAW,QAAQ;QAQ1B,IAAA,CAAA,OAAO,GAAW,QAAQ;QAS1B,IAAA,CAAA,QAAQ,GAAW,CAAC;QAQpB,IAAA,CAAA,IAAI,GAAW,EAAE;QASjB,IAAA,CAAA,SAAS,GAAW,CAAC;QASrB,IAAA,CAAA,SAAS,GAAW,CAAC;QASrB,IAAA,CAAA,SAAS,GAAW,CAAC;QASrB,IAAA,CAAA,SAAS,GAAW,CAAC;QASrB,IAAA,CAAA,SAAS,GAAW,CAAC;QASrB,IAAA,CAAA,SAAS,GAAW,CAAC;IAKvB;aA7HS,IAAA,CAAA,aAAa,GAAW,QAAX,CAAoB;AA0HxC,IAAA,IAAI,CAAC,GAAkB,EAAA;AACrB,QAAA,IAAI,GAAG;AAAE,YAAA,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC;IACnC;;AA5G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AE,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC;AACpF,QAAA,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC;IACtF;IAEA,SAAS,GAAA;QACP,KAAK,MAAM,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE;AAC7B,YAAA,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;QACvB;AACA,QAAA,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE;IACpB;;AAjGmB,YAAY,GAAA,UAAA,CAAA;IAPhC,UAAU,CAAC,iBAAiB,CAAC;AAC5B,QAAA,MAAM,EAAE;YACN,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM;YACrE,WAAW,EAAE,WAAW,EAAE,WAAW;YACrC,WAAW,EAAE,WAAW,EAAE,WAAW;AACtC,SAAA;KACF;AACoB,CAAA,EAAA,YAAY,CAkGhC;2BAlGoB,YAAY;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin-renderer-3d-text.esm.js","sources":["../lib/component.ts","../lib/hostSdk.ts","../lib/localization.ts","../lib/system.ts"],"sourcesContent":["import { Component } from '@combos-fun/engine';\nimport { Field } from '@combos-fun/inspector-decorator';\nimport type { TextReplacements } from './localization';\n\nexport type { TextReplacementValue, TextReplacements } from './localization';\n\nexport interface Text3DParams {\n text?: string;\n /** Values substituted into named placeholders such as `{score}`. */\n replacements?: TextReplacements;\n fontSize?: number;\n color?: number;\n anchorX?: string;\n anchorY?: string;\n maxWidth?: number;\n font?: string;\n positionX?: number;\n positionY?: number;\n positionZ?: number;\n rotationX?: number;\n rotationY?: number;\n rotationZ?: number;\n}\n\nexport default class Text3D extends Component<Text3DParams> {\n static componentName: string = 'Text3D';\n\n @Field({\n\n type: 'string',\n\n group: 'Text3D',\n\n label: 'text',\n\n description: 'Visible text content.',\n\n editor: 'text',\n\n })\n\n text: string = '';\n\n replacements: TextReplacements = {};\n\n @Field({\n type: 'number',\n step: 0.01,\n group: 'Text3D',\n label: 'fontSize',\n description: 'Font size.',\n editor: 'number-stepper',\n })\n fontSize: number = 0.5;\n @Field({\n type: 'number',\n group: 'Text3D',\n label: 'color',\n description: 'Color value.',\n editor: 'number-stepper',\n })\n color: number = 0xffffff;\n @Field({\n type: 'string',\n group: 'Text3D',\n label: 'anchorX',\n description: 'Horizontal text anchor.',\n editor: 'text',\n })\n anchorX: string = 'center';\n @Field({\n type: 'string',\n group: 'Text3D',\n label: 'anchorY',\n description: 'Vertical text anchor.',\n editor: 'text',\n })\n anchorY: string = 'middle';\n @Field({\n type: 'number',\n step: 0.1,\n group: 'Text3D',\n label: 'maxWidth',\n description: 'Maximum text wrap width.',\n editor: 'number-stepper',\n })\n maxWidth: number = 0;\n @Field({\n type: 'string',\n group: 'Text3D',\n label: 'font',\n description: 'Font URL or path for troika-three-text (not an engine resource name).',\n editor: 'text',\n })\n font: string = '';\n @Field({\n type: 'number',\n step: 0.1,\n group: 'Text3D',\n label: 'positionX',\n description: 'Local X position.',\n editor: 'number-stepper',\n })\n positionX: number = 0;\n @Field({\n type: 'number',\n step: 0.1,\n group: 'Text3D',\n label: 'positionY',\n description: 'Local Y position.',\n editor: 'number-stepper',\n })\n positionY: number = 0;\n @Field({\n type: 'number',\n step: 0.1,\n group: 'Text3D',\n label: 'positionZ',\n description: 'Local Z position.',\n editor: 'number-stepper',\n })\n positionZ: number = 0;\n @Field({\n type: 'number',\n step: 0.01,\n group: 'Text3D',\n label: 'rotationX',\n description: 'Rotation around X in radians.',\n editor: 'number-stepper',\n })\n rotationX: number = 0;\n @Field({\n type: 'number',\n step: 0.01,\n group: 'Text3D',\n label: 'rotationY',\n description: 'Rotation around Y in radians.',\n editor: 'number-stepper',\n })\n rotationY: number = 0;\n @Field({\n type: 'number',\n step: 0.01,\n group: 'Text3D',\n label: 'rotationZ',\n description: 'Rotation around Z in radians.',\n editor: 'number-stepper',\n })\n rotationZ: number = 0;\n\n init(obj?: Text3DParams) {\n if (!obj) return;\n const { replacements, ...rest } = obj;\n Object.assign(this, rest);\n if (replacements) this.replacements = { ...replacements };\n }\n}\n","/** Keep identical to `@combos-fun/plugin-renderer-text` hostSdk. */\nimport type { TextTranslations } from './localization';\n\n/** Host-injected global. The SDK itself is not part of this repo. */\nexport const COMBOS_HOST_SDK = 'combos' as const;\n\nexport interface CombosI18nRequest {\n sourceLocale: string;\n sourceTexts: string[];\n}\n\nexport type CombosI18nResult =\n | { needed: false }\n | { needed: true; locale: string; translations: TextTranslations };\n\nexport interface CombosHostSdk {\n requestI18n?(request: CombosI18nRequest): Promise<CombosI18nResult>;\n}\n\ndeclare global {\n interface Window {\n combos?: CombosHostSdk;\n }\n}\n\nexport function hasCombosRequestI18n(\n sdk: CombosHostSdk | undefined | null = typeof window === 'undefined' ? undefined : window.combos,\n): sdk is CombosHostSdk & { requestI18n: NonNullable<CombosHostSdk['requestI18n']> } {\n return !!sdk && typeof sdk.requestI18n === 'function';\n}\n\nexport function parseI18nResult(data: unknown): CombosI18nResult {\n if (!data || typeof data !== 'object') return { needed: false };\n const input = data as {\n needed?: unknown;\n locale?: unknown;\n translations?: unknown;\n };\n if (input.needed !== true) return { needed: false };\n if (typeof input.locale !== 'string' || !input.locale.trim()) {\n return { needed: false };\n }\n if (\n !input.translations ||\n typeof input.translations !== 'object' ||\n Array.isArray(input.translations)\n ) {\n return { needed: false };\n }\n const entries = Object.entries(input.translations);\n if (entries.some(([, value]) => typeof value !== 'string')) {\n return { needed: false };\n }\n return {\n needed: true,\n locale: input.locale.trim(),\n translations: Object.fromEntries(entries) as TextTranslations,\n };\n}\n\n/** Ask the injected host SDK. Always resolves; missing method means no translation. */\nexport async function requestHostI18n(\n request: CombosI18nRequest,\n): Promise<CombosI18nResult> {\n if (typeof window === 'undefined' || !hasCombosRequestI18n(window.combos)) {\n return { needed: false };\n }\n try {\n return parseI18nResult(await window.combos.requestI18n(request));\n } catch {\n return { needed: false };\n }\n}\n","/** Keep identical to `@combos-fun/plugin-renderer-text` localization. */\n\nexport type TextReplacementValue = string | number;\nexport type TextReplacements = Record<string, TextReplacementValue>;\nexport type TextTranslations = Record<string, string>;\n\nconst PLACEHOLDER_PATTERN = /\\{([A-Za-z_$][\\w$.-]*)\\}/g;\n\nexport function interpolateText(\n template: string,\n replacements?: TextReplacements,\n): string {\n if (!replacements) return template;\n return template.replace(PLACEHOLDER_PATTERN, (placeholder, name: string) => {\n if (!Object.prototype.hasOwnProperty.call(replacements, name)) {\n return placeholder;\n }\n return String(replacements[name]);\n });\n}\n\nexport function localizeText(\n sourceText: string,\n replacements: TextReplacements | undefined,\n sourceLocale: string,\n targetLocale: string,\n translations: TextTranslations,\n): string {\n const shouldTranslate =\n !!sourceLocale &&\n !!targetLocale &&\n sourceLocale.toLowerCase() !== targetLocale.toLowerCase();\n const template =\n shouldTranslate && Object.prototype.hasOwnProperty.call(translations, sourceText)\n ? translations[sourceText]\n : sourceText;\n return interpolateText(template, replacements);\n}\n\nexport function addSourceTexts(\n target: Set<string>,\n texts?: Iterable<string | undefined | null>,\n) {\n if (!texts) return;\n for (const text of texts) {\n const source = typeof text === 'string' ? text.trim() : '';\n if (source) target.add(source);\n }\n}\n\nexport function mergeTranslations(\n current: TextTranslations,\n incoming: Record<string, unknown>,\n): TextTranslations {\n const next = { ...current };\n for (const [key, value] of Object.entries(incoming)) {\n if (typeof value === 'string') next[key] = value;\n }\n return next;\n}\n","import { decorators, ComponentChanged, OBSERVER_TYPE, GameObject } from '@combos-fun/engine';\nimport { Renderer3D, Renderer3DSystem, tagObject3D, Transform3D, VisualPoseBridge } from '@combos-fun/plugin-renderer-3d';\nimport { Text as TroikaText } from 'troika-three-text';\nimport Text3D from './component';\nimport { requestHostI18n } from './hostSdk';\nimport {\n addSourceTexts,\n localizeText,\n mergeTranslations,\n type TextTranslations,\n} from './localization';\n\nexport interface Text3DSystemParams {\n /** BCP 47 locale of the source text, for example `zh-CN`. Omit to disable host-driven i18n. */\n sourceLocale?: string;\n /**\n * All source templates to translate on first `requestI18n`, including copy\n * for screens that are not mounted yet. Later `Text3D` nodes reuse this catalog\n * and will not flash the source language.\n */\n sourceTexts?: string[];\n}\n\n@decorators.componentObserver({\n Text3D: [\n 'text',\n { prop: ['replacements'], deep: true },\n 'fontSize', 'color', 'anchorX', 'anchorY', 'maxWidth', 'font',\n 'positionX', 'positionY', 'positionZ',\n 'rotationX', 'rotationY', 'rotationZ',\n ],\n})\nexport default class Text3DSystem extends Renderer3D<Text3DSystemParams> {\n static systemName = 'Text3DSystem';\n name: string = 'Text3DSystem';\n\n private texts = new Map<number, { mesh: TroikaText; component: Text3D }>();\n private poseBridges = new Map<number, VisualPoseBridge>();\n private sourceLocale = '';\n private targetLocale = '';\n private translations: TextTranslations = {};\n private seededSourceTexts = new Set<string>();\n private lastRequestedSourceTexts = '';\n private i18nRequestScheduled = false;\n private i18nRequestId = 0;\n private firstI18nSettled = false;\n\n init(params?: Text3DSystemParams) {\n const renderer3DSystem = this.game.getSystem(Renderer3DSystem) as Renderer3DSystem;\n renderer3DSystem.rendererManager.register(this);\n this.sourceLocale = params?.sourceLocale?.trim() ?? '';\n this.targetLocale = this.sourceLocale;\n this.declareSourceTexts(params?.sourceTexts);\n }\n\n /** Register extra source templates before or after ready. First request includes these. */\n declareSourceTexts(texts?: string[]) {\n addSourceTexts(this.seededSourceTexts, texts);\n this.scheduleI18nRequest();\n }\n\n async beforeReady() {\n if (this.firstI18nSettled) return;\n this.update();\n if (!this.sourceLocale) {\n this.firstI18nSettled = true;\n return;\n }\n await this.requestI18nAndApply();\n this.firstI18nSettled = true;\n }\n\n setI18n(locale: string, translations: TextTranslations) {\n const targetLocale = locale?.trim();\n if (!targetLocale || !translations || typeof translations !== 'object') return;\n this.targetLocale = targetLocale;\n this.translations = mergeTranslations(this.translations, translations);\n this.refreshAllText();\n }\n\n componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'Text3D') return;\n\n if (changed.type === OBSERVER_TYPE.ADD) {\n this.handleAdd(changed.gameObject, changed.component as Text3D);\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.handleRemove(changed.gameObject.id);\n } else {\n this.handleChange(changed);\n }\n }\n\n rendererUpdate(gameObject: GameObject) {\n const component = gameObject.getComponent(Text3D) as Text3D;\n if (!component) return;\n\n const entry = this.texts.get(gameObject.id);\n if (!entry) return;\n this.applyPose(gameObject, component, entry.mesh);\n }\n\n private handleAdd(gameObject: GameObject, component: Text3D) {\n const textMesh = new TroikaText();\n this.syncTextProps(textMesh, component);\n textMesh.sync();\n tagObject3D(textMesh, gameObject.id);\n\n this.threeContext.attachVisual(gameObject.id, textMesh, gameObject);\n this.texts.set(gameObject.id, { mesh: textMesh, component });\n this.poseBridges.set(gameObject.id, new VisualPoseBridge());\n this.scheduleI18nRequest();\n }\n\n private handleChange(changed: ComponentChanged) {\n const entry = this.texts.get(changed.gameObject.id);\n if (!entry) return;\n const component = changed.component as Text3D;\n entry.component = component;\n this.syncTextProps(entry.mesh, component);\n entry.mesh.sync();\n if (changed.prop.prop[0] === 'text') this.scheduleI18nRequest();\n }\n\n private handleRemove(id: number) {\n const entry = this.texts.get(id);\n if (!entry) return;\n\n this.threeContext.detachVisual(id, entry.mesh);\n entry.mesh.dispose();\n this.texts.delete(id);\n this.poseBridges.delete(id);\n }\n\n private syncTextProps(textMesh: TroikaText, component: Text3D) {\n textMesh.text = this.resolveText(component);\n textMesh.fontSize = component.fontSize;\n textMesh.color = component.color;\n textMesh.anchorX = component.anchorX;\n textMesh.anchorY = component.anchorY;\n if (component.maxWidth > 0) {\n textMesh.maxWidth = component.maxWidth;\n }\n if (component.font) {\n textMesh.font = component.font;\n }\n }\n\n private applyPose(gameObject: GameObject, component: Text3D, textMesh: TroikaText) {\n let bridge = this.poseBridges.get(gameObject.id);\n if (!bridge) {\n bridge = new VisualPoseBridge();\n this.poseBridges.set(gameObject.id, bridge);\n }\n const transform = gameObject.getComponent(Transform3D) as Transform3D | undefined;\n if (!bridge.sync(component, transform)) {\n textMesh.position.set(0, 0, 0);\n textMesh.rotation.set(0, 0, 0);\n return;\n }\n textMesh.position.set(component.positionX, component.positionY, component.positionZ);\n textMesh.rotation.set(component.rotationX, component.rotationY, component.rotationZ);\n }\n\n onDestroy() {\n this.i18nRequestId += 1;\n this.firstI18nSettled = false;\n for (const [id] of this.texts) {\n this.handleRemove(id);\n }\n this.texts.clear();\n }\n\n private resolveText(component: Text3D): string {\n return localizeText(\n component.text,\n component.replacements,\n this.sourceLocale,\n this.targetLocale,\n this.translations,\n );\n }\n\n private collectSourceTexts(): string[] {\n const sourceTexts = new Set(this.seededSourceTexts);\n for (const entry of this.texts.values()) {\n addSourceTexts(sourceTexts, [entry.component.text]);\n }\n return [...sourceTexts];\n }\n\n private scheduleI18nRequest() {\n if (!this.sourceLocale || !this.firstI18nSettled || this.i18nRequestScheduled) return;\n this.i18nRequestScheduled = true;\n queueMicrotask(() => {\n this.i18nRequestScheduled = false;\n this.startI18nRequest();\n });\n }\n\n private startI18nRequest() {\n if (!this.sourceLocale || !this.firstI18nSettled) return;\n const sourceTexts = this.collectSourceTexts();\n const signature = [...sourceTexts].sort().join('\\0');\n if (signature === this.lastRequestedSourceTexts) return;\n void this.requestI18nAndApply();\n }\n\n private async requestI18nAndApply() {\n const sourceTexts = this.collectSourceTexts();\n const signature = [...sourceTexts].sort().join('\\0');\n this.lastRequestedSourceTexts = signature;\n const requestId = ++this.i18nRequestId;\n const result = await requestHostI18n({\n sourceLocale: this.sourceLocale,\n sourceTexts,\n });\n if (requestId !== this.i18nRequestId) return;\n if (!result.needed) return;\n this.setI18n(result.locale, result.translations);\n }\n\n private refreshAllText() {\n for (const entry of this.texts.values()) {\n entry.mesh.text = this.resolveText(entry.component);\n entry.mesh.sync();\n }\n }\n}\n"],"names":["TroikaText"],"mappings":";;;;;;AAwBc,MAAO,MAAO,SAAQ,SAAuB,CAAA;AAA3D,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
2
|
"name": "@combos-fun/plugin-renderer-3d-text",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "3D text rendering, backed by troika-three-text",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-3d-text.esm.js",
|
|
@@ -28,9 +28,12 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"three": "^0.172.0",
|
|
30
30
|
"troika-three-text": "^0.52.3",
|
|
31
|
-
"@combos-fun/
|
|
32
|
-
"@combos-fun/
|
|
33
|
-
"@combos-fun/
|
|
31
|
+
"@combos-fun/plugin-renderer-3d": "0.1.5",
|
|
32
|
+
"@combos-fun/inspector-decorator": "0.1.5",
|
|
33
|
+
"@combos-fun/engine": "0.1.5"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"tsx": "^4.20.3"
|
|
34
37
|
},
|
|
35
38
|
"keywords": [
|
|
36
39
|
"combos-fun",
|
|
@@ -41,6 +44,7 @@
|
|
|
41
44
|
"font"
|
|
42
45
|
],
|
|
43
46
|
"scripts": {
|
|
44
|
-
"build": "node ../../scripts/build-package.mjs"
|
|
47
|
+
"build": "node ../../scripts/build-package.mjs",
|
|
48
|
+
"test": "node --import tsx --test test/*.test.ts"
|
|
45
49
|
}
|
|
46
50
|
}
|