@oxy.so/bloom 7.31.1 → 7.33.0
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/assets/character-runtime/README.md +114 -19
- package/assets/character-runtime/authored-parts.mjs +754 -0
- package/assets/character-runtime/catalog-parts.mjs +362 -0
- package/assets/character-runtime/character-recipe.mjs +247 -0
- package/assets/character-runtime/clippo-geometry.mjs +679 -0
- package/assets/character-runtime/controller-mode.mjs +208 -0
- package/assets/character-runtime/cyclops-geometry.mjs +180 -0
- package/assets/character-runtime/legacy-engine.mjs +406 -54
- package/assets/character-runtime/legacy-geometry.mjs +242 -85
- package/assets/character-runtime/legacy-worker.mjs +82 -23
- package/assets/character-runtime/managed-avatar.mjs +12 -17
- package/assets/character-runtime/migrated-contours.mjs +2067 -0
- package/assets/character-runtime/migrated-faces.mjs +59 -0
- package/assets/character-runtime/pose-transition.mjs +523 -0
- package/assets/character-runtime/preparation-cache.mjs +60 -0
- package/assets/character-runtime/render-budget.mjs +5 -3
- package/assets/character-runtime/render-errors.mjs +180 -0
- package/assets/character-runtime/resolution.mjs +10 -0
- package/assets/character-runtime/runtime.mjs +744 -295
- package/assets/character-runtime/sha256.mjs +44 -0
- package/assets/character-runtime/shared-programs.mjs +534 -0
- package/assets/character-runtime/shared-surface.mjs +490 -0
- package/assets/character-runtime/shared-textures.mjs +420 -0
- package/assets/character-runtime/thumbnails/eyes/todd.png +0 -0
- package/docs/adoption-matrix.mdx +2 -2
- package/docs/agent-avatar.mdx +45 -7
- package/docs/agent-creator.mdx +13 -3
- package/docs/settings-modal.mdx +42 -8
- package/lib/commonjs/agent-avatar/AgentAvatar.js +1 -1
- package/lib/commonjs/agent-avatar/AgentAvatar.js.map +1 -1
- package/lib/commonjs/agent-avatar/CharacterAvatar.js +2 -1
- package/lib/commonjs/agent-avatar/CharacterAvatar.js.map +1 -1
- package/lib/commonjs/agent-avatar/character-colors.js +19 -0
- package/lib/commonjs/agent-avatar/character-colors.js.map +1 -0
- package/lib/commonjs/agent-avatar/character-shapes.js +106 -0
- package/lib/commonjs/agent-avatar/character-shapes.js.map +1 -0
- package/lib/commonjs/agent-avatar/config-character.js +4 -0
- package/lib/commonjs/agent-avatar/config-character.js.map +1 -1
- package/lib/commonjs/agent-avatar/legacy-recipe.js +19 -6
- package/lib/commonjs/agent-avatar/legacy-recipe.js.map +1 -1
- package/lib/commonjs/agent-creator/AgentCreatorBase.js +67 -107
- package/lib/commonjs/agent-creator/AgentCreatorBase.js.map +1 -1
- package/lib/commonjs/agent-creator/CharacterControls.js +23 -5
- package/lib/commonjs/agent-creator/CharacterControls.js.map +1 -1
- package/lib/commonjs/agent-creator/ClippoArtwork.js +64 -0
- package/lib/commonjs/agent-creator/ClippoArtwork.js.map +1 -0
- package/lib/commonjs/agent-creator/CyclopsArtwork.js +46 -0
- package/lib/commonjs/agent-creator/CyclopsArtwork.js.map +1 -0
- package/lib/commonjs/agent-creator/EmotionPicker.js +8 -1
- package/lib/commonjs/agent-creator/EmotionPicker.js.map +1 -1
- package/lib/commonjs/agent-creator/ShapeSilhouette.js +8 -1
- package/lib/commonjs/agent-creator/ShapeSilhouette.js.map +1 -1
- package/lib/commonjs/agent-creator/ToddArtwork.js +30 -0
- package/lib/commonjs/agent-creator/ToddArtwork.js.map +1 -0
- package/lib/commonjs/agent-creator/constants.js +16 -17
- package/lib/commonjs/agent-creator/constants.js.map +1 -1
- package/lib/commonjs/agent-creator/messages.js +1 -1
- package/lib/commonjs/agent-creator/messages.js.map +1 -1
- package/lib/commonjs/locale/translations/ar.js +1 -1
- package/lib/commonjs/locale/translations/ar.js.map +1 -1
- package/lib/commonjs/locale/translations/bn.js +1 -1
- package/lib/commonjs/locale/translations/bn.js.map +1 -1
- package/lib/commonjs/locale/translations/ca.js +1 -1
- package/lib/commonjs/locale/translations/ca.js.map +1 -1
- package/lib/commonjs/locale/translations/de.js +1 -1
- package/lib/commonjs/locale/translations/de.js.map +1 -1
- package/lib/commonjs/locale/translations/es.js +1 -1
- package/lib/commonjs/locale/translations/es.js.map +1 -1
- package/lib/commonjs/locale/translations/fr.js +1 -1
- package/lib/commonjs/locale/translations/fr.js.map +1 -1
- package/lib/commonjs/locale/translations/hi.js +1 -1
- package/lib/commonjs/locale/translations/hi.js.map +1 -1
- package/lib/commonjs/locale/translations/id.js +1 -1
- package/lib/commonjs/locale/translations/id.js.map +1 -1
- package/lib/commonjs/locale/translations/it.js +1 -1
- package/lib/commonjs/locale/translations/it.js.map +1 -1
- package/lib/commonjs/locale/translations/ja.js +1 -1
- package/lib/commonjs/locale/translations/ja.js.map +1 -1
- package/lib/commonjs/locale/translations/pt.js +1 -1
- package/lib/commonjs/locale/translations/pt.js.map +1 -1
- package/lib/commonjs/locale/translations/ru.js +1 -1
- package/lib/commonjs/locale/translations/ru.js.map +1 -1
- package/lib/commonjs/locale/translations/tr.js +1 -1
- package/lib/commonjs/locale/translations/tr.js.map +1 -1
- package/lib/commonjs/locale/translations/zh.js +1 -1
- package/lib/commonjs/locale/translations/zh.js.map +1 -1
- package/lib/commonjs/settings-modal/fields.js +19 -0
- package/lib/commonjs/settings-modal/fields.js.map +1 -0
- package/lib/commonjs/settings-modal/modal.js +51 -0
- package/lib/commonjs/settings-modal/modal.js.map +1 -0
- package/lib/module/agent-avatar/AgentAvatar.js +1 -1
- package/lib/module/agent-avatar/AgentAvatar.js.map +1 -1
- package/lib/module/agent-avatar/CharacterAvatar.js +2 -1
- package/lib/module/agent-avatar/CharacterAvatar.js.map +1 -1
- package/lib/module/agent-avatar/character-colors.js +15 -0
- package/lib/module/agent-avatar/character-colors.js.map +1 -0
- package/lib/module/agent-avatar/character-shapes.js +97 -0
- package/lib/module/agent-avatar/character-shapes.js.map +1 -0
- package/lib/module/agent-avatar/config-character.js +4 -0
- package/lib/module/agent-avatar/config-character.js.map +1 -1
- package/lib/module/agent-avatar/legacy-recipe.js +19 -6
- package/lib/module/agent-avatar/legacy-recipe.js.map +1 -1
- package/lib/module/agent-creator/AgentCreatorBase.js +69 -109
- package/lib/module/agent-creator/AgentCreatorBase.js.map +1 -1
- package/lib/module/agent-creator/CharacterControls.js +24 -6
- package/lib/module/agent-creator/CharacterControls.js.map +1 -1
- package/lib/module/agent-creator/ClippoArtwork.js +60 -0
- package/lib/module/agent-creator/ClippoArtwork.js.map +1 -0
- package/lib/module/agent-creator/CyclopsArtwork.js +42 -0
- package/lib/module/agent-creator/CyclopsArtwork.js.map +1 -0
- package/lib/module/agent-creator/EmotionPicker.js +8 -1
- package/lib/module/agent-creator/EmotionPicker.js.map +1 -1
- package/lib/module/agent-creator/ShapeSilhouette.js +8 -1
- package/lib/module/agent-creator/ShapeSilhouette.js.map +1 -1
- package/lib/module/agent-creator/ToddArtwork.js +26 -0
- package/lib/module/agent-creator/ToddArtwork.js.map +1 -0
- package/lib/module/agent-creator/constants.js +8 -16
- package/lib/module/agent-creator/constants.js.map +1 -1
- package/lib/module/agent-creator/messages.js +1 -1
- package/lib/module/agent-creator/messages.js.map +1 -1
- package/lib/module/locale/translations/ar.js +1 -1
- package/lib/module/locale/translations/ar.js.map +1 -1
- package/lib/module/locale/translations/bn.js +1 -1
- package/lib/module/locale/translations/bn.js.map +1 -1
- package/lib/module/locale/translations/ca.js +1 -1
- package/lib/module/locale/translations/ca.js.map +1 -1
- package/lib/module/locale/translations/de.js +1 -1
- package/lib/module/locale/translations/de.js.map +1 -1
- package/lib/module/locale/translations/es.js +1 -1
- package/lib/module/locale/translations/es.js.map +1 -1
- package/lib/module/locale/translations/fr.js +1 -1
- package/lib/module/locale/translations/fr.js.map +1 -1
- package/lib/module/locale/translations/hi.js +1 -1
- package/lib/module/locale/translations/hi.js.map +1 -1
- package/lib/module/locale/translations/id.js +1 -1
- package/lib/module/locale/translations/id.js.map +1 -1
- package/lib/module/locale/translations/it.js +1 -1
- package/lib/module/locale/translations/it.js.map +1 -1
- package/lib/module/locale/translations/ja.js +1 -1
- package/lib/module/locale/translations/ja.js.map +1 -1
- package/lib/module/locale/translations/pt.js +1 -1
- package/lib/module/locale/translations/pt.js.map +1 -1
- package/lib/module/locale/translations/ru.js +1 -1
- package/lib/module/locale/translations/ru.js.map +1 -1
- package/lib/module/locale/translations/tr.js +1 -1
- package/lib/module/locale/translations/tr.js.map +1 -1
- package/lib/module/locale/translations/zh.js +1 -1
- package/lib/module/locale/translations/zh.js.map +1 -1
- package/lib/module/settings-modal/fields.js +10 -0
- package/lib/module/settings-modal/fields.js.map +1 -0
- package/lib/module/settings-modal/modal.js +16 -0
- package/lib/module/settings-modal/modal.js.map +1 -0
- package/lib/typescript/commonjs/agent-avatar/AgentAvatar.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-avatar/CharacterAvatar.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-avatar/character-colors.d.ts +13 -0
- package/lib/typescript/commonjs/agent-avatar/character-colors.d.ts.map +1 -0
- package/lib/typescript/commonjs/agent-avatar/character-shapes.d.ts +19 -0
- package/lib/typescript/commonjs/agent-avatar/character-shapes.d.ts.map +1 -0
- package/lib/typescript/commonjs/agent-avatar/config-character.d.ts +4 -0
- package/lib/typescript/commonjs/agent-avatar/config-character.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-avatar/legacy-recipe.d.ts +2 -10
- package/lib/typescript/commonjs/agent-avatar/legacy-recipe.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/AgentCreatorBase.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/CharacterControls.d.ts +2 -1
- package/lib/typescript/commonjs/agent-creator/CharacterControls.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/ClippoArtwork.d.ts +6 -0
- package/lib/typescript/commonjs/agent-creator/ClippoArtwork.d.ts.map +1 -0
- package/lib/typescript/commonjs/agent-creator/CyclopsArtwork.d.ts +5 -0
- package/lib/typescript/commonjs/agent-creator/CyclopsArtwork.d.ts.map +1 -0
- package/lib/typescript/commonjs/agent-creator/EmotionPicker.d.ts +1 -0
- package/lib/typescript/commonjs/agent-creator/EmotionPicker.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/ShapeSilhouette.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/ToddArtwork.d.ts +6 -0
- package/lib/typescript/commonjs/agent-creator/ToddArtwork.d.ts.map +1 -0
- package/lib/typescript/commonjs/agent-creator/constants.d.ts +7 -15
- package/lib/typescript/commonjs/agent-creator/constants.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/messages.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/ar.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/bn.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/ca.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/de.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/es.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/fr.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/hi.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/id.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/it.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/ja.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/pt.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/ru.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/tr.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/zh.d.ts.map +1 -1
- package/lib/typescript/commonjs/settings-modal/fields.d.ts +9 -0
- package/lib/typescript/commonjs/settings-modal/fields.d.ts.map +1 -0
- package/lib/typescript/commonjs/settings-modal/modal.d.ts +15 -0
- package/lib/typescript/commonjs/settings-modal/modal.d.ts.map +1 -0
- package/lib/typescript/module/agent-avatar/AgentAvatar.d.ts.map +1 -1
- package/lib/typescript/module/agent-avatar/CharacterAvatar.d.ts.map +1 -1
- package/lib/typescript/module/agent-avatar/character-colors.d.ts +13 -0
- package/lib/typescript/module/agent-avatar/character-colors.d.ts.map +1 -0
- package/lib/typescript/module/agent-avatar/character-shapes.d.ts +19 -0
- package/lib/typescript/module/agent-avatar/character-shapes.d.ts.map +1 -0
- package/lib/typescript/module/agent-avatar/config-character.d.ts +4 -0
- package/lib/typescript/module/agent-avatar/config-character.d.ts.map +1 -1
- package/lib/typescript/module/agent-avatar/legacy-recipe.d.ts +2 -10
- package/lib/typescript/module/agent-avatar/legacy-recipe.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/AgentCreatorBase.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/CharacterControls.d.ts +2 -1
- package/lib/typescript/module/agent-creator/CharacterControls.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/ClippoArtwork.d.ts +6 -0
- package/lib/typescript/module/agent-creator/ClippoArtwork.d.ts.map +1 -0
- package/lib/typescript/module/agent-creator/CyclopsArtwork.d.ts +5 -0
- package/lib/typescript/module/agent-creator/CyclopsArtwork.d.ts.map +1 -0
- package/lib/typescript/module/agent-creator/EmotionPicker.d.ts +1 -0
- package/lib/typescript/module/agent-creator/EmotionPicker.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/ShapeSilhouette.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/ToddArtwork.d.ts +6 -0
- package/lib/typescript/module/agent-creator/ToddArtwork.d.ts.map +1 -0
- package/lib/typescript/module/agent-creator/constants.d.ts +7 -15
- package/lib/typescript/module/agent-creator/constants.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/messages.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/ar.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/bn.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/ca.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/de.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/es.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/fr.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/hi.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/id.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/it.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/ja.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/pt.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/ru.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/tr.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/zh.d.ts.map +1 -1
- package/lib/typescript/module/settings-modal/fields.d.ts +9 -0
- package/lib/typescript/module/settings-modal/fields.d.ts.map +1 -0
- package/lib/typescript/module/settings-modal/modal.d.ts +15 -0
- package/lib/typescript/module/settings-modal/modal.d.ts.map +1 -0
- package/package.json +35 -1
- package/src/agent-avatar/AgentAvatar.tsx +1 -5
- package/src/agent-avatar/CharacterAvatar.tsx +6 -1
- package/src/agent-avatar/character-colors.ts +12 -0
- package/src/agent-avatar/character-shapes.ts +116 -0
- package/src/agent-avatar/config-character.ts +14 -0
- package/src/agent-avatar/legacy-recipe.ts +21 -6
- package/src/agent-creator/AgentCreatorBase.tsx +110 -123
- package/src/agent-creator/CharacterControls.tsx +32 -7
- package/src/agent-creator/ClippoArtwork.tsx +44 -0
- package/src/agent-creator/CyclopsArtwork.tsx +21 -0
- package/src/agent-creator/EmotionPicker.tsx +18 -3
- package/src/agent-creator/ShapeSilhouette.tsx +14 -1
- package/src/agent-creator/ToddArtwork.tsx +25 -0
- package/src/agent-creator/constants.ts +8 -25
- package/src/agent-creator/messages.ts +2 -1
- package/src/locale/translations/ar.ts +2 -1
- package/src/locale/translations/bn.ts +2 -1
- package/src/locale/translations/ca.ts +2 -1
- package/src/locale/translations/de.ts +2 -1
- package/src/locale/translations/es.ts +2 -1
- package/src/locale/translations/fr.ts +2 -1
- package/src/locale/translations/hi.ts +2 -1
- package/src/locale/translations/id.ts +2 -1
- package/src/locale/translations/it.ts +2 -1
- package/src/locale/translations/ja.ts +2 -1
- package/src/locale/translations/pt.ts +2 -1
- package/src/locale/translations/ru.ts +2 -1
- package/src/locale/translations/tr.ts +2 -1
- package/src/locale/translations/zh.ts +2 -1
- package/src/settings-modal/fields.ts +8 -0
- package/src/settings-modal/modal.ts +34 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// The recovered engine polls glGetError after uploads and again after drawing.
|
|
2
|
+
// Poll once at the shared transaction boundary; deferred batches wait for the
|
|
3
|
+
// GPU without blocking JS before validating and publishing their pixels.
|
|
4
|
+
// Setup outside a batch keeps exact GL error semantics. No errors are ignored.
|
|
5
|
+
export function createRenderErrorBoundary(gl) {
|
|
6
|
+
let rendering = false;
|
|
7
|
+
let touched = false;
|
|
8
|
+
let pending = null;
|
|
9
|
+
let publishing = false;
|
|
10
|
+
function assertAvailable() {
|
|
11
|
+
if (pending && !rendering)
|
|
12
|
+
throw new Error(
|
|
13
|
+
'Character WebGL batch is pending; await waitForSharedRender()',
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
const methods = new Map([
|
|
17
|
+
[
|
|
18
|
+
'getError',
|
|
19
|
+
() => {
|
|
20
|
+
assertAvailable();
|
|
21
|
+
if (!rendering) return gl.getError();
|
|
22
|
+
touched = true;
|
|
23
|
+
return gl.NO_ERROR;
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
]);
|
|
27
|
+
const context = new Proxy(gl, {
|
|
28
|
+
get(target, key) {
|
|
29
|
+
if (methods.has(key)) return methods.get(key);
|
|
30
|
+
const value = Reflect.get(target, key, target);
|
|
31
|
+
if (typeof value !== 'function') return value;
|
|
32
|
+
methods.set(key, (...args) => {
|
|
33
|
+
assertAvailable();
|
|
34
|
+
if (rendering) touched = true;
|
|
35
|
+
return value.apply(target, args);
|
|
36
|
+
});
|
|
37
|
+
return methods.get(key);
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
function submit(operation) {
|
|
41
|
+
rendering = true;
|
|
42
|
+
touched = false;
|
|
43
|
+
let result, failure;
|
|
44
|
+
try {
|
|
45
|
+
result = operation();
|
|
46
|
+
if (result && typeof result.then === 'function')
|
|
47
|
+
throw new Error('Character WebGL submission must be synchronous');
|
|
48
|
+
} catch (error) {
|
|
49
|
+
failure = error;
|
|
50
|
+
} finally {
|
|
51
|
+
rendering = false;
|
|
52
|
+
}
|
|
53
|
+
return { result, failure };
|
|
54
|
+
}
|
|
55
|
+
function validate({ result, failure }) {
|
|
56
|
+
const errors = [];
|
|
57
|
+
for (let i = 0; touched && i < 32; i++) {
|
|
58
|
+
const error = gl.getError();
|
|
59
|
+
if (error === gl.NO_ERROR) break;
|
|
60
|
+
errors.push(`0x${error.toString(16)}`);
|
|
61
|
+
}
|
|
62
|
+
if (errors.length) {
|
|
63
|
+
const graphicsError = new Error(
|
|
64
|
+
`Character WebGL render failed: ${errors.join(', ')}`,
|
|
65
|
+
);
|
|
66
|
+
if (failure)
|
|
67
|
+
throw new AggregateError(
|
|
68
|
+
[failure, graphicsError],
|
|
69
|
+
graphicsError.message,
|
|
70
|
+
);
|
|
71
|
+
throw graphicsError;
|
|
72
|
+
}
|
|
73
|
+
if (failure) throw failure;
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
context,
|
|
78
|
+
assertAvailable,
|
|
79
|
+
assertReadable() {
|
|
80
|
+
if (pending && !publishing)
|
|
81
|
+
throw new Error('Character WebGL pixels are pending validation');
|
|
82
|
+
},
|
|
83
|
+
get pending() {
|
|
84
|
+
return pending !== null;
|
|
85
|
+
},
|
|
86
|
+
// Unrelated creation/cleanup waits for settlement, not the render result.
|
|
87
|
+
// Its owner observes the rejecting promise returned by renderDeferred.
|
|
88
|
+
wait() {
|
|
89
|
+
return pending
|
|
90
|
+
? pending.then(
|
|
91
|
+
() => {},
|
|
92
|
+
() => {},
|
|
93
|
+
)
|
|
94
|
+
: Promise.resolve();
|
|
95
|
+
},
|
|
96
|
+
render(operation) {
|
|
97
|
+
if (rendering) return operation();
|
|
98
|
+
assertAvailable();
|
|
99
|
+
return validate(submit(operation));
|
|
100
|
+
},
|
|
101
|
+
renderDeferred(
|
|
102
|
+
operation,
|
|
103
|
+
publish,
|
|
104
|
+
{ timeoutMs = 5000, pollIntervalMs = 4 } = {},
|
|
105
|
+
) {
|
|
106
|
+
if (pending || rendering)
|
|
107
|
+
return Promise.reject(
|
|
108
|
+
new Error('Character WebGL batch already in progress'),
|
|
109
|
+
);
|
|
110
|
+
let resolve, reject;
|
|
111
|
+
const completion = new Promise((yes, no) => {
|
|
112
|
+
resolve = yes;
|
|
113
|
+
reject = no;
|
|
114
|
+
});
|
|
115
|
+
pending = completion;
|
|
116
|
+
const submission = submit(operation);
|
|
117
|
+
let fence = null;
|
|
118
|
+
const started = performance.now();
|
|
119
|
+
function finish(failure) {
|
|
120
|
+
try {
|
|
121
|
+
if (fence) gl.deleteSync(fence);
|
|
122
|
+
fence = null;
|
|
123
|
+
if (failure) throw failure;
|
|
124
|
+
const result = validate(submission);
|
|
125
|
+
// Publish while the lock is held. A preparation waiter registered
|
|
126
|
+
// earlier must not mutate the atlas before these 2D copies finish.
|
|
127
|
+
publishing = true;
|
|
128
|
+
try {
|
|
129
|
+
const published = publish?.(result);
|
|
130
|
+
if (published && typeof published.then === 'function')
|
|
131
|
+
throw new Error(
|
|
132
|
+
'Character WebGL publication must be synchronous',
|
|
133
|
+
);
|
|
134
|
+
} finally {
|
|
135
|
+
publishing = false;
|
|
136
|
+
}
|
|
137
|
+
pending = null;
|
|
138
|
+
resolve(result);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
pending = null;
|
|
141
|
+
reject(error);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function poll() {
|
|
145
|
+
try {
|
|
146
|
+
if (gl.isContextLost())
|
|
147
|
+
throw new Error('Character WebGL context lost');
|
|
148
|
+
const status = gl.clientWaitSync(fence, 0, 0);
|
|
149
|
+
if (
|
|
150
|
+
status === gl.ALREADY_SIGNALED ||
|
|
151
|
+
status === gl.CONDITION_SATISFIED
|
|
152
|
+
) {
|
|
153
|
+
finish();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (status === gl.WAIT_FAILED)
|
|
157
|
+
throw new Error('Character WebGL fence wait failed');
|
|
158
|
+
if (performance.now() - started >= timeoutMs)
|
|
159
|
+
throw new Error('Character WebGL fence timed out');
|
|
160
|
+
setTimeout(poll, pollIntervalMs);
|
|
161
|
+
} catch (error) {
|
|
162
|
+
finish(error);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (!touched) {
|
|
166
|
+
finish();
|
|
167
|
+
return completion;
|
|
168
|
+
}
|
|
169
|
+
try {
|
|
170
|
+
fence = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
|
|
171
|
+
if (!fence) throw new Error('Character WebGL fence unavailable');
|
|
172
|
+
gl.flush();
|
|
173
|
+
setTimeout(poll, pollIntervalMs);
|
|
174
|
+
} catch (error) {
|
|
175
|
+
finish(error);
|
|
176
|
+
}
|
|
177
|
+
return completion;
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Tiny chat avatars do not need the same backing resolution as a profile/editor
|
|
2
|
+
// preview. Bound fragment work and atlas copies while retaining full-size detail.
|
|
3
|
+
export function characterPixels(
|
|
4
|
+
canvas,
|
|
5
|
+
dpr = globalThis.devicePixelRatio || 1,
|
|
6
|
+
) {
|
|
7
|
+
const size = Math.max(1, Math.min(canvas.clientWidth, canvas.clientHeight));
|
|
8
|
+
const scale = size <= 64 ? 1 : size <= 128 ? 1.5 : 2;
|
|
9
|
+
return Math.max(64, Math.min(512, Math.round(size * Math.min(dpr, scale))));
|
|
10
|
+
}
|