@bitmagic/cli 0.1.64-dev.1 → 0.1.64-dev.11
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 +80 -5
- package/assets/blender-level/README.md +25 -0
- package/assets/blender-level/audit.py +232 -0
- package/assets/blender-level/bmlevel/__init__.py +294 -0
- package/assets/blender-level/bmlevel/core.py +438 -0
- package/assets/blender-level/bmlevel/scene_bpy.py +186 -0
- package/assets/blender-level/bmlevel/scene_null.py +44 -0
- package/assets/blender-level/example_level.py +80 -0
- package/assets/blender-level/find_blender.py +62 -0
- package/assets/blender-level/review.py +117 -0
- package/assets/blender-level/sync_world.py +85 -0
- package/assets/blender-level/tests/test_core.py +189 -0
- package/dist/assets/keep-glb.d.ts +20 -0
- package/dist/assets/keep-glb.js +45 -0
- package/dist/assets/keep-glb.js.map +1 -0
- package/dist/cli.d.ts +5 -0
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/assets.d.ts +3 -0
- package/dist/commands/assets.js +33 -3
- package/dist/commands/assets.js.map +1 -1
- package/dist/commands/cover.js +7 -1
- package/dist/commands/cover.js.map +1 -1
- package/dist/commands/forge.d.ts +2 -0
- package/dist/commands/forge.js +76 -12
- package/dist/commands/forge.js.map +1 -1
- package/dist/commands/generate.d.ts +88 -1
- package/dist/commands/generate.js +400 -21
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/init.d.ts +11 -0
- package/dist/commands/init.js +33 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/judge.d.ts +0 -11
- package/dist/commands/judge.js +15 -2
- package/dist/commands/judge.js.map +1 -1
- package/dist/commands/levels.d.ts +1 -1
- package/dist/commands/levels.js +14 -3
- package/dist/commands/levels.js.map +1 -1
- package/dist/commands/reference.js +5 -1
- package/dist/commands/reference.js.map +1 -1
- package/dist/commands/reset-account.js +2 -11
- package/dist/commands/reset-account.js.map +1 -1
- package/dist/commands/tools.d.ts +1 -0
- package/dist/commands/tools.js +73 -0
- package/dist/commands/tools.js.map +1 -0
- package/dist/commands/trailer.js +18 -4
- package/dist/commands/trailer.js.map +1 -1
- package/dist/editor/asset-detail-panel.d.ts +8 -3
- package/dist/editor/asset-detail-panel.js +11 -1
- package/dist/editor/asset-detail-panel.js.map +1 -1
- package/dist/editor/hud-replay-page.js +317 -22
- package/dist/editor/hud-replay-page.js.map +1 -1
- package/dist/editor/shell-page.js +117 -7
- package/dist/editor/shell-page.js.map +1 -1
- package/dist/forge/apply-modifications.js +70 -2
- package/dist/forge/apply-modifications.js.map +1 -1
- package/dist/forge/progress.d.ts +10 -0
- package/dist/forge/progress.js +7 -6
- package/dist/forge/progress.js.map +1 -1
- package/dist/forge/run-pipeline.d.ts +8 -0
- package/dist/forge/run-pipeline.js +37 -2
- package/dist/forge/run-pipeline.js.map +1 -1
- package/dist/forge/stream.d.ts +7 -1
- package/dist/forge/stream.js +5 -2
- package/dist/forge/stream.js.map +1 -1
- package/dist/forge/two-d-gate.d.ts +82 -0
- package/dist/forge/two-d-gate.js +232 -0
- package/dist/forge/two-d-gate.js.map +1 -0
- package/dist/generate/animation-from-video.d.ts +11 -3
- package/dist/generate/animation-from-video.js +12 -2
- package/dist/generate/animation-from-video.js.map +1 -1
- package/dist/generate/model.d.ts +11 -0
- package/dist/generate/model.js +41 -1
- package/dist/generate/model.js.map +1 -1
- package/dist/generate/prop.d.ts +9 -0
- package/dist/generate/prop.js +59 -9
- package/dist/generate/prop.js.map +1 -1
- package/dist/generate/video-review.d.ts +28 -0
- package/dist/generate/video-review.js +120 -0
- package/dist/generate/video-review.js.map +1 -0
- package/dist/project/art-style.d.ts +34 -0
- package/dist/project/art-style.js +63 -0
- package/dist/project/art-style.js.map +1 -0
- package/dist/prompt.d.ts +9 -0
- package/dist/prompt.js +36 -0
- package/dist/prompt.js.map +1 -0
- package/dist/publish/bundle.d.ts +12 -0
- package/dist/publish/bundle.js +32 -0
- package/dist/publish/bundle.js.map +1 -1
- package/dist/render/qr-png.d.ts +6 -3
- package/dist/render/qr-png.js +8 -8
- package/dist/render/qr-png.js.map +1 -1
- package/dist/scaffold/blender-level-skill-files.d.ts +26 -0
- package/dist/scaffold/blender-level-skill-files.js +570 -0
- package/dist/scaffold/blender-level-skill-files.js.map +1 -0
- package/dist/scaffold/claude-settings.js +2 -0
- package/dist/scaffold/claude-settings.js.map +1 -1
- package/dist/scaffold/project-files.d.ts +2 -1
- package/dist/scaffold/project-files.js +125 -42
- package/dist/scaffold/project-files.js.map +1 -1
- package/dist/scaffold/project.d.ts +9 -0
- package/dist/scaffold/project.js +29 -3
- package/dist/scaffold/project.js.map +1 -1
- package/dist/scaffold/reference-guidance.d.ts +1 -1
- package/dist/scaffold/reference-guidance.js +2 -1
- package/dist/scaffold/reference-guidance.js.map +1 -1
- package/dist/scaffold/skill-files.js +3 -1
- package/dist/scaffold/skill-files.js.map +1 -1
- package/dist/scaffold/unity-skill-files.js +1 -2
- package/dist/scaffold/unity-skill-files.js.map +1 -1
- package/dist/tools/bundles.d.ts +21 -0
- package/dist/tools/bundles.js +67 -0
- package/dist/tools/bundles.js.map +1 -0
- package/dist/trailer/ffmpeg.d.ts +10 -0
- package/dist/trailer/ffmpeg.js +51 -6
- package/dist/trailer/ffmpeg.js.map +1 -1
- package/dist/trailer/hud-raster.d.ts +12 -12
- package/dist/trailer/hud-raster.js +85 -32
- package/dist/trailer/hud-raster.js.map +1 -1
- package/dist/trailer/hud-state.d.ts +75 -4
- package/dist/trailer/hud-state.js +132 -17
- package/dist/trailer/hud-state.js.map +1 -1
- package/dist/trailer/io.d.ts +2 -0
- package/dist/trailer/io.js +6 -1
- package/dist/trailer/io.js.map +1 -1
- package/dist/trailer/link.d.ts +1 -0
- package/dist/trailer/link.js +15 -0
- package/dist/trailer/link.js.map +1 -0
- package/dist/trailer/make.d.ts +2 -0
- package/dist/trailer/make.js +1 -0
- package/dist/trailer/make.js.map +1 -1
- package/dist/trailer/merge.js +32 -11
- package/dist/trailer/merge.js.map +1 -1
- package/dist/trailer/music-beats.js +4 -39
- package/dist/trailer/music-beats.js.map +1 -1
- package/dist/trailer/render.d.ts +2 -0
- package/dist/trailer/render.js +94 -48
- package/dist/trailer/render.js.map +1 -1
- package/dist/trailer/timeline-types.d.ts +19 -0
- package/dist/trailer/timeline-types.js +42 -2
- package/dist/trailer/timeline-types.js.map +1 -1
- package/dist/trailer/title-raster.js +2 -1
- package/dist/trailer/title-raster.js.map +1 -1
- package/dist/trailer/titles.js +6 -1
- package/dist/trailer/titles.js.map +1 -1
- package/dist/trailer/video-chain.d.ts +96 -8
- package/dist/trailer/video-chain.js +183 -0
- package/dist/trailer/video-chain.js.map +1 -1
- package/dist/verify/browser.js +4 -1
- package/dist/verify/browser.js.map +1 -1
- package/package.json +4 -4
|
@@ -13,12 +13,23 @@
|
|
|
13
13
|
* default `server.cors` admits localhost origins, which is what makes the cross-origin module load
|
|
14
14
|
* work.
|
|
15
15
|
*
|
|
16
|
-
* Contract with `trailer/hud-raster.ts` (
|
|
16
|
+
* Contract with `trailer/hud-raster.ts` (the same one the web lane's `game/hud-replay.html` keeps):
|
|
17
17
|
* window.__hudReplayReady === true when the HUD is constructed
|
|
18
18
|
* window.__hudReplay.setViewport(w, h) size the surface to the recording
|
|
19
|
-
* window.__hudReplay.render(state)
|
|
19
|
+
* window.__hudReplay.render(state, ms, clip) apply a state snapshot (synchronous); `ms` is the
|
|
20
|
+
* keyframe's position on the SOURCE clock and `clip` the EDL
|
|
21
|
+
* clip it belongs to — together they seed animation phase
|
|
22
|
+
* (both optional; an older raster passes neither)
|
|
23
|
+
* window.__hudReplay.settle() promise: fonts/images loaded, or 1.5 s
|
|
20
24
|
*
|
|
21
|
-
* Same template-literal
|
|
25
|
+
* Same template-literal rules as the shell page: **no backticks** in the emitted output, and every
|
|
26
|
+
* backslash the emitted JS needs (regex escapes) is written doubled here, because an untagged
|
|
27
|
+
* template drops the backslash from an unknown escape like `\(`.
|
|
28
|
+
*
|
|
29
|
+
* The engine module is imported as a namespace and feature-detected: this page ships in the CLI
|
|
30
|
+
* and runs against whichever engine the project has vendored, so a named import of something that
|
|
31
|
+
* engine predates would fail the whole module load (and with it every overlay) rather than one
|
|
32
|
+
* optional nicety.
|
|
22
33
|
*/
|
|
23
34
|
import { CDN_IMPORTS } from '../scaffold/project-files.js';
|
|
24
35
|
import { importMapEntries } from '../scaffold/aliases.js';
|
|
@@ -34,6 +45,9 @@ export function renderHudReplayHtml(options) {
|
|
|
34
45
|
<html lang="en">
|
|
35
46
|
<head>
|
|
36
47
|
<meta charset="utf-8">
|
|
48
|
+
<!-- The page is served from the sidecar, but captured game sheets and widget markup reference
|
|
49
|
+
assets root-relatively against the GAME origin; the import map is already absolute. -->
|
|
50
|
+
<base href="http://localhost:${options.gamePort}/">
|
|
37
51
|
<title>HUD Replay (trailer overlay)</title>
|
|
38
52
|
<style>
|
|
39
53
|
/* Transparent everywhere — the renderer captures with omitBackground so only HUD pixels carry alpha. */
|
|
@@ -41,10 +55,16 @@ export function renderHudReplayHtml(options) {
|
|
|
41
55
|
/* The HUD fades itself in only on GameState.PLAYING, which never happens here; force it visible and
|
|
42
56
|
kill transitions so a screenshot taken immediately after render() is the settled frame. */
|
|
43
57
|
.hud-root { opacity: 1 !important; transition: none !important; }
|
|
58
|
+
/* First layer: an !important declaration beats every normal one whatever its specificity, so this
|
|
59
|
+
kills any game animation declared normally. A game rule that is itself !important escapes it,
|
|
60
|
+
and freezeMotion() below is what makes THOSE deterministic. Keeping the rule still pays — the
|
|
61
|
+
animations it suppresses are never created at all. */
|
|
44
62
|
.hud-root, .hud-root * { animation: none !important; transition: none !important; }
|
|
45
63
|
/* Gameplay layer holds the reticle/ESC hint — not part of a trailer overlay. */
|
|
46
64
|
.hud-gameplay-layer { display: none !important; }
|
|
47
65
|
</style>
|
|
66
|
+
<!-- Kept last in <head> after every captured-sheet injection; see enforceTransparentPageBackground(). -->
|
|
67
|
+
<style id="hud-replay-transparent">html, body { background: transparent !important; }</style>
|
|
48
68
|
<script type="importmap">
|
|
49
69
|
${JSON.stringify({ imports }, null, 2)}
|
|
50
70
|
</script>
|
|
@@ -52,38 +72,56 @@ ${JSON.stringify({ imports }, null, 2)}
|
|
|
52
72
|
<body>
|
|
53
73
|
<script type="module">
|
|
54
74
|
import { GameHUD } from 'engine/GameHUD.js';
|
|
55
|
-
import
|
|
75
|
+
import * as hudApi from 'engine/hud/index.js';
|
|
56
76
|
|
|
77
|
+
/** Rebuilt whenever the element set changes; kept between same-shape frames. */
|
|
57
78
|
var hud = null;
|
|
58
79
|
var builtKey = '';
|
|
80
|
+
/** The recorded theme currently applied, as JSON — re-applied only on change. */
|
|
81
|
+
var lastThemeJson = 'null';
|
|
59
82
|
|
|
60
83
|
function disposeHud() {
|
|
61
84
|
if (hud) { hud.dispose(); hud = null; }
|
|
85
|
+
// dispose() removes .hud-root/.hud-gameplay-layer, and a previous frame's toast stacks live inside those.
|
|
62
86
|
builtKey = '';
|
|
63
87
|
}
|
|
64
88
|
|
|
65
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Identity of a state's STRUCTURE (not its values): unchanged means mutate, changed means rebuild.
|
|
91
|
+
* Custom css is deliberately NOT part of it: it rides custom-html updates too, and applyValues writes
|
|
92
|
+
* it onto the live container — a per-frame style tick must mutate, never tear the whole HUD down.
|
|
93
|
+
*/
|
|
66
94
|
function structureKey(state) {
|
|
67
95
|
return JSON.stringify([
|
|
68
96
|
(state.elements || []).map(function (e) {
|
|
69
97
|
return [e.id, e.type, e.anchor, e.label == null ? null : e.label, e.icon == null ? null : e.icon,
|
|
70
98
|
e.color == null ? null : e.color, e.width == null ? null : e.width, e.showText == null ? null : e.showText,
|
|
71
|
-
e.iconSize == null ? null : e.iconSize
|
|
99
|
+
e.iconSize == null ? null : e.iconSize];
|
|
72
100
|
}),
|
|
73
101
|
state.health ? 'health' : null,
|
|
74
102
|
]);
|
|
75
103
|
}
|
|
76
104
|
|
|
105
|
+
/**
|
|
106
|
+
* setTheme, not applyThemeGlobals: the full path also writes the theme's decorations stylesheet, the
|
|
107
|
+
* data-hud-theme attribute and re-applies per-element overrides — applyThemeGlobals alone left the
|
|
108
|
+
* first build on the default theme's decorations and every element with the wrong overrides.
|
|
109
|
+
* Synchronous, so a screenshot right after render() sees the settled theme.
|
|
110
|
+
*/
|
|
111
|
+
function applyRecordedTheme(state) {
|
|
112
|
+
var json = JSON.stringify(state.theme == null ? null : state.theme);
|
|
113
|
+
if (json === lastThemeJson) return;
|
|
114
|
+
if (state.theme) hud.setTheme(state.theme);
|
|
115
|
+
lastThemeJson = json;
|
|
116
|
+
}
|
|
117
|
+
|
|
77
118
|
function buildFrom(state) {
|
|
78
119
|
disposeHud();
|
|
79
120
|
hud = new GameHUD();
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// synchronous, so a screenshot right after render() never catches the HUD mid-theme.
|
|
83
|
-
applyThemeGlobals(state.theme, { manageFontLink: true });
|
|
84
|
-
}
|
|
121
|
+
lastThemeJson = 'null';
|
|
122
|
+
applyRecordedTheme(state);
|
|
85
123
|
(state.elements || []).forEach(createElement);
|
|
86
|
-
if (state.health) hud.showHealth();
|
|
124
|
+
if (state.health) hud.showHealth(state.health.width !== undefined ? { width: state.health.width } : undefined);
|
|
87
125
|
builtKey = structureKey(state);
|
|
88
126
|
}
|
|
89
127
|
|
|
@@ -117,6 +155,128 @@ function createElement(el) {
|
|
|
117
155
|
}
|
|
118
156
|
}
|
|
119
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Mirror the recording's game-authored head stylesheets into this page. These are the selector
|
|
160
|
+
* rules custom-element markup depends on — without them the markup replays with browser-default
|
|
161
|
+
* styling. Synced by id (add/update/remove) rather than rebuilt: CSS applies live, so a sheet change
|
|
162
|
+
* never needs a HUD teardown, which is also why stylesheets stay out of structureKey.
|
|
163
|
+
*/
|
|
164
|
+
function applyStylesheets(state) {
|
|
165
|
+
var wanted = new Map();
|
|
166
|
+
(state.stylesheets || []).forEach(function (sheet) { wanted.set(sheet.id, sheet.css); });
|
|
167
|
+
document.head.querySelectorAll('style[data-hud-replay-sheet]').forEach(function (node) {
|
|
168
|
+
var id = node.dataset.hudReplaySheet;
|
|
169
|
+
if (!wanted.has(id)) { node.remove(); return; }
|
|
170
|
+
var css = wanted.get(id);
|
|
171
|
+
if (node.textContent !== css) node.textContent = css;
|
|
172
|
+
wanted.delete(id);
|
|
173
|
+
});
|
|
174
|
+
wanted.forEach(function (css, id) {
|
|
175
|
+
var node = document.createElement('style');
|
|
176
|
+
node.dataset.hudReplaySheet = id;
|
|
177
|
+
node.textContent = css;
|
|
178
|
+
document.head.appendChild(node);
|
|
179
|
+
});
|
|
180
|
+
enforceTransparentPageBackground();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Keep the page background transparent whatever the captured sheets say.
|
|
185
|
+
*
|
|
186
|
+
* A game's head stylesheet is captured whole, and real ones carry page-level rules — body { background }
|
|
187
|
+
* is ordinary game theming. Injected here it paints the page, and Playwright's omitBackground does
|
|
188
|
+
* NOT override an author background (it only clears the base canvas colour), so every overlay PNG
|
|
189
|
+
* comes out as an opaque full-frame rectangle covering the footage. Measured, not theorised.
|
|
190
|
+
*
|
|
191
|
+
* Two layers, because one is not enough: the harness's own <style> re-appended LAST wins on document
|
|
192
|
+
* order against an equal-specificity rule; the style ATTRIBUTE outranks every author rule regardless
|
|
193
|
+
* of specificity, which "html body { ... !important }" (0,0,2) and ":root { ... !important }" (0,1,0)
|
|
194
|
+
* need, since both beat the harness sheet's "html, body" (0,0,1). Deliberate inline style: the
|
|
195
|
+
* cascade offers nothing else a captured sheet cannot outrank. The background shorthand is required
|
|
196
|
+
* (background-color alone leaves a captured background-image painting), and both the root element and
|
|
197
|
+
* body need it: a :root background propagates to the canvas when body is transparent.
|
|
198
|
+
*/
|
|
199
|
+
function enforceTransparentPageBackground() {
|
|
200
|
+
var override = document.getElementById('hud-replay-transparent');
|
|
201
|
+
if (override && override !== document.head.lastElementChild) document.head.appendChild(override);
|
|
202
|
+
[document.documentElement, document.body].forEach(function (el) {
|
|
203
|
+
el.style.setProperty('background', 'transparent', 'important');
|
|
204
|
+
el.style.setProperty('background-image', 'none', 'important');
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Freeze every animation at a deterministic phase.
|
|
210
|
+
*
|
|
211
|
+
* The CSS kill rule in <head> only reaches normal declarations; a game rule that is itself
|
|
212
|
+
* !important ("#hud-custom-gauge .needle { animation: spin 2s linear infinite !important }") keeps
|
|
213
|
+
* running and screenshots would catch whatever phase wall-clock happened to be at.
|
|
214
|
+
*
|
|
215
|
+
* Phase is time since the animation STARTED, which the harness does not know — so it uses the
|
|
216
|
+
* keyframe at which it first saw the animation as the start (the op that inserted the markup lands
|
|
217
|
+
* at most one keyframe earlier), on the SOURCE clock so a speed ramp keeps footage and motion in
|
|
218
|
+
* lockstep. Animations already present at a clip's first keyframe get absolute source time instead:
|
|
219
|
+
* they began before the clip, and for a loop that is the phase the player saw. The first-seen map
|
|
220
|
+
* is reset per clip because keyframes are rasterized in EDL order, not source order. No paint flush
|
|
221
|
+
* is needed: page.screenshot() forces a commit.
|
|
222
|
+
*/
|
|
223
|
+
var animationStarts = new Map();
|
|
224
|
+
/** The clip the previous render() belonged to; a change resets the first-seen map above. */
|
|
225
|
+
var lastClipIndex = null;
|
|
226
|
+
|
|
227
|
+
function animationKey(animation) {
|
|
228
|
+
var target = animation.effect ? animation.effect.target : null;
|
|
229
|
+
var container = target && target.closest ? target.closest('.hud-element') : null;
|
|
230
|
+
// Index path from the container to the target: several nodes in one container can run the same
|
|
231
|
+
// animation name at different times (a stack of "+100" popups).
|
|
232
|
+
var path = [];
|
|
233
|
+
var node = target;
|
|
234
|
+
while (node && node !== container && node.parentNode) {
|
|
235
|
+
path.unshift(Array.prototype.indexOf.call(node.parentNode.childNodes, node));
|
|
236
|
+
node = node.parentNode;
|
|
237
|
+
}
|
|
238
|
+
return (container ? container.id : '') + '|' + path.join('.') + '|' + animation.animationName;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function freezeMotion(frameTimeMs, clipStart) {
|
|
242
|
+
document.getAnimations().forEach(function (animation) {
|
|
243
|
+
if (typeof CSSTransition !== 'undefined' && animation instanceof CSSTransition) {
|
|
244
|
+
// A transition is a state change in flight, not a point on the replay timeline — land it on
|
|
245
|
+
// its end state. Seeding an early frameTimeMs would freeze it mid-fade instead.
|
|
246
|
+
try { animation.finish(); } catch (e) { animation.cancel(); }
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
var key = animationKey(animation);
|
|
250
|
+
var start = animationStarts.get(key);
|
|
251
|
+
if (start === undefined) {
|
|
252
|
+
start = clipStart ? 0 : frameTimeMs;
|
|
253
|
+
animationStarts.set(key, start);
|
|
254
|
+
}
|
|
255
|
+
// pause() first: assigning currentTime to a running animation only shifts its start time.
|
|
256
|
+
// Seeking a pending animation cancels its pending task and lands it exactly.
|
|
257
|
+
animation.pause();
|
|
258
|
+
animation.currentTime = Math.max(0, frameTimeMs - start);
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Show/hide without destroying a recorded display.
|
|
264
|
+
*
|
|
265
|
+
* Blanking display to '' looks harmless but is not: a custom element's css routinely carries
|
|
266
|
+
* "display: flex" (the docs' own example does), and clearing it drops the widget to the UA default
|
|
267
|
+
* block, so a two-column widget replays as two stacked rows. Only ever WRITE 'none', and only clear
|
|
268
|
+
* a 'none' when the state says visible — which the reducer decides from the most recent of the css
|
|
269
|
+
* snapshot's own display and the show/hide ops, in frame order (hud-state.ts), so clearing here
|
|
270
|
+
* happens exactly when the game itself cleared it.
|
|
271
|
+
*/
|
|
272
|
+
function applyVisibility(root, visible) {
|
|
273
|
+
if (visible === false) {
|
|
274
|
+
root.style.display = 'none';
|
|
275
|
+
} else if (root.style.display === 'none') {
|
|
276
|
+
root.style.display = '';
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
120
280
|
function setText(root, selector, value) {
|
|
121
281
|
if (value === undefined || value === null) return;
|
|
122
282
|
var node = root.querySelector(selector);
|
|
@@ -129,7 +289,7 @@ function applyValues(state) {
|
|
|
129
289
|
var element = hud.getElement(el.id);
|
|
130
290
|
if (!element) return;
|
|
131
291
|
var root = element.container;
|
|
132
|
-
root
|
|
292
|
+
applyVisibility(root, el.visible);
|
|
133
293
|
switch (el.type) {
|
|
134
294
|
case 'counter':
|
|
135
295
|
setText(root, '.hud-counter__value', el.text);
|
|
@@ -153,6 +313,13 @@ function applyValues(state) {
|
|
|
153
313
|
}
|
|
154
314
|
case 'custom':
|
|
155
315
|
if (typeof el.html === 'string' && root.innerHTML !== el.html) root.innerHTML = el.html;
|
|
316
|
+
// The recorded container cssText (create-time, and per-update since the recorder started
|
|
317
|
+
// carrying it). cssText overwrites wholesale — including any display captured while the
|
|
318
|
+
// widget was game-hidden — so the show/hide verdict is re-asserted after: it owns visibility.
|
|
319
|
+
if (typeof el.css === 'string' && root.style.cssText !== el.css) {
|
|
320
|
+
root.style.cssText = el.css;
|
|
321
|
+
applyVisibility(root, el.visible);
|
|
322
|
+
}
|
|
156
323
|
break;
|
|
157
324
|
default:
|
|
158
325
|
break;
|
|
@@ -160,7 +327,7 @@ function applyValues(state) {
|
|
|
160
327
|
});
|
|
161
328
|
|
|
162
329
|
if (state.health) {
|
|
163
|
-
hud.showHealth();
|
|
330
|
+
hud.showHealth(state.health.width !== undefined ? { width: state.health.width } : undefined);
|
|
164
331
|
hud.updateHealth(state.health.current, state.health.max);
|
|
165
332
|
var container = document.getElementById('hud-health-container');
|
|
166
333
|
if (container) {
|
|
@@ -174,23 +341,135 @@ function applyValues(state) {
|
|
|
174
341
|
if (hudRoot) hudRoot.style.display = state.hudVisible === false ? 'none' : '';
|
|
175
342
|
}
|
|
176
343
|
|
|
177
|
-
/**
|
|
344
|
+
/**
|
|
345
|
+
* Toasts are transient and stack-managed, and the engine's own showToast arms wall-clock removal
|
|
346
|
+
* timers. The replay owns visibility, so render them as plain toast-classed nodes in fresh stacks
|
|
347
|
+
* each frame — one stack per anchor, with the same newest-top rule and per-toast theme override the
|
|
348
|
+
* engine applies (GameHUD.showToast). Recordings that predate the anchor field land on top-center.
|
|
349
|
+
*/
|
|
178
350
|
function applyToasts(state) {
|
|
179
351
|
document.querySelectorAll('.hud-replay-toasts').forEach(function (stale) { stale.remove(); });
|
|
180
352
|
var toasts = state.toasts || [];
|
|
181
353
|
if (!toasts.length) return;
|
|
182
|
-
var
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
354
|
+
var override = state.theme && state.theme.elements ? state.theme.elements.toast : undefined;
|
|
355
|
+
// Base colours come from the APPLIED theme, exactly as the engine's own applyElementOverride passes
|
|
356
|
+
// this.current.colors: a partial override is resolved against the full palette. Feature-detected —
|
|
357
|
+
// an engine from before this export just gets unthemed toasts, not a dead page.
|
|
358
|
+
var applied = hud.getTheme();
|
|
359
|
+
var applyOverride = typeof hudApi.applyPartialThemeProperties === 'function' ? hudApi.applyPartialThemeProperties : null;
|
|
360
|
+
var stacks = new Map();
|
|
186
361
|
toasts.forEach(function (toast) {
|
|
362
|
+
var anchor = toast.anchor || 'top-center';
|
|
363
|
+
var stack = stacks.get(anchor);
|
|
364
|
+
if (!stack) {
|
|
365
|
+
var anchorEl = document.querySelector('.hud-anchor-' + anchor)
|
|
366
|
+
|| document.querySelector('.hud-anchor-top-center')
|
|
367
|
+
|| document.querySelector('.hud-root');
|
|
368
|
+
if (!anchorEl) return;
|
|
369
|
+
stack = document.createElement('div');
|
|
370
|
+
stack.className = (anchor.indexOf('top') === 0 ? 'hud-toast-stack hud-toast-stack--newest-top' : 'hud-toast-stack') + ' hud-replay-toasts';
|
|
371
|
+
anchorEl.appendChild(stack);
|
|
372
|
+
stacks.set(anchor, stack);
|
|
373
|
+
}
|
|
187
374
|
var node = document.createElement('div');
|
|
188
375
|
node.className = 'hud-element hud-toast';
|
|
189
376
|
node.dataset.kind = toast.variant || 'info';
|
|
190
377
|
node.textContent = toast.message;
|
|
378
|
+
if (override && applied && applyOverride) applyOverride(node, override, applied.colors);
|
|
191
379
|
stack.appendChild(node);
|
|
192
380
|
});
|
|
193
|
-
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Everything render() may have started loading, settled — or 1.5 s, whichever comes first. The
|
|
385
|
+
* screenshot that follows render() must not catch fallback type or a half-loaded image, but a dead
|
|
386
|
+
* URL must not stall the whole raster either, so image outcomes (success AND failure) are memoized:
|
|
387
|
+
* an unreachable image costs its timeout once, not once per keyframe.
|
|
388
|
+
*/
|
|
389
|
+
var settledResources = new Set();
|
|
390
|
+
/** Hrefs whose wait hit the deadline — retried only when they can still help. */
|
|
391
|
+
var timedOutResources = new Set();
|
|
392
|
+
var SETTLE_TIMEOUT_MS = 1500;
|
|
393
|
+
|
|
394
|
+
/** Resolves 'settled' when the work finished, 'timeout' when the deadline won. */
|
|
395
|
+
function withDeadline(promise) {
|
|
396
|
+
var timer = null;
|
|
397
|
+
var deadline = new Promise(function (resolve) { timer = setTimeout(function () { resolve('timeout'); }, SETTLE_TIMEOUT_MS); });
|
|
398
|
+
return Promise.race([Promise.resolve(promise).then(function () { return 'settled'; }), deadline])
|
|
399
|
+
.finally(function () { if (timer !== null) clearTimeout(timer); });
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
function collectCssImageUrls() {
|
|
403
|
+
var urls = [];
|
|
404
|
+
var pattern = /url\\(\\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\\s*\\)/g;
|
|
405
|
+
document.querySelectorAll('.hud-root, .hud-root *').forEach(function (node) {
|
|
406
|
+
var style = getComputedStyle(node);
|
|
407
|
+
['background-image', 'border-image-source'].forEach(function (prop) {
|
|
408
|
+
var value = style.getPropertyValue(prop);
|
|
409
|
+
if (!value || value === 'none') return;
|
|
410
|
+
var match;
|
|
411
|
+
while ((match = pattern.exec(value)) !== null) {
|
|
412
|
+
var url = match[1] || match[2] || match[3] || '';
|
|
413
|
+
if (url && url.indexOf('data:') !== 0) urls.push(url);
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
return urls;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function settle() {
|
|
421
|
+
var waits = [];
|
|
422
|
+
|
|
423
|
+
// The font is keyed off the LIVE link's readiness, not a per-href memo: a deadline win means the
|
|
424
|
+
// font is slow, not absent (memoizing it would leave keyframe 0 on fallback type and every later
|
|
425
|
+
// one on the real face — a visible swap mid-trailer), and every structural rebuild disposes the
|
|
426
|
+
// HUD, which removes this link and creates a fresh one at the same href that has yet to parse.
|
|
427
|
+
// Only a genuine timeout is remembered, so a truly dead font costs 1.5 s once, not per keyframe.
|
|
428
|
+
var fontLink = document.getElementById('hud-active-font');
|
|
429
|
+
if (fontLink && !fontLink.sheet && !timedOutResources.has(fontLink.href)) {
|
|
430
|
+
var href = fontLink.href;
|
|
431
|
+
waits.push(withDeadline(new Promise(function (resolve) {
|
|
432
|
+
fontLink.addEventListener('load', resolve, { once: true });
|
|
433
|
+
fontLink.addEventListener('error', resolve, { once: true });
|
|
434
|
+
}).then(function () { return document.fonts.ready; })).then(function (outcome) {
|
|
435
|
+
if (outcome === 'timeout') timedOutResources.add(href);
|
|
436
|
+
}));
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
document.querySelectorAll('.hud-root img').forEach(function (img) {
|
|
440
|
+
var src = img.currentSrc || img.src;
|
|
441
|
+
if (!src || src.indexOf('data:') === 0 || settledResources.has(src)) return;
|
|
442
|
+
waits.push(withDeadline(img.decode().catch(function () {})).then(function () { settledResources.add(src); }));
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
collectCssImageUrls().forEach(function (url) {
|
|
446
|
+
if (settledResources.has(url)) return;
|
|
447
|
+
waits.push(withDeadline(new Promise(function (resolve) {
|
|
448
|
+
var probe = new Image();
|
|
449
|
+
probe.onload = resolve;
|
|
450
|
+
probe.onerror = resolve;
|
|
451
|
+
probe.src = url;
|
|
452
|
+
})).then(function () { settledResources.add(url); }));
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
// Fonts the injected game sheets bring in (@font-face, @import) load lazily once text using them
|
|
456
|
+
// is styled — the computed-style walk above just forced that — and only document.fonts.ready
|
|
457
|
+
// knows about them. Free when nothing is loading. A face that never arrives is remembered by
|
|
458
|
+
// family after one deadline, or every keyframe would pay the full timeout for it.
|
|
459
|
+
var unresolved = [];
|
|
460
|
+
document.fonts.forEach(function (face) {
|
|
461
|
+
if (face.status === 'loading' && !timedOutResources.has('font-family:' + face.family)) unresolved.push(face.family);
|
|
462
|
+
});
|
|
463
|
+
if (unresolved.length || document.fonts.status === 'loading') {
|
|
464
|
+
waits.push(withDeadline(document.fonts.ready).then(function (outcome) {
|
|
465
|
+
if (outcome !== 'timeout') return;
|
|
466
|
+
document.fonts.forEach(function (face) {
|
|
467
|
+
if (face.status === 'loading') timedOutResources.add('font-family:' + face.family);
|
|
468
|
+
});
|
|
469
|
+
}));
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
return waits.length ? Promise.all(waits).then(function () { return true; }) : Promise.resolve(true);
|
|
194
473
|
}
|
|
195
474
|
|
|
196
475
|
window.__hudReplay = {
|
|
@@ -198,18 +477,34 @@ window.__hudReplay = {
|
|
|
198
477
|
document.body.style.width = width + 'px';
|
|
199
478
|
document.body.style.height = height + 'px';
|
|
200
479
|
},
|
|
201
|
-
render: function (state) {
|
|
480
|
+
render: function (state, frameTimeMs, clipIndex) {
|
|
481
|
+
var clipStart = clipIndex !== lastClipIndex;
|
|
482
|
+
if (clipStart) {
|
|
483
|
+
lastClipIndex = clipIndex;
|
|
484
|
+
animationStarts.clear();
|
|
485
|
+
}
|
|
202
486
|
var key = structureKey(state);
|
|
203
|
-
if (!hud || key !== builtKey)
|
|
487
|
+
if (!hud || key !== builtKey) {
|
|
488
|
+
buildFrom(state);
|
|
489
|
+
} else {
|
|
490
|
+
// A theme change without a structure change (mid-recording setTheme) must not force a
|
|
491
|
+
// rebuild — setTheme re-applies the overrides on the live elements itself.
|
|
492
|
+
applyRecordedTheme(state);
|
|
493
|
+
}
|
|
494
|
+
applyStylesheets(state);
|
|
204
495
|
applyValues(state);
|
|
205
496
|
applyToasts(state);
|
|
497
|
+
// Last: every step above can create elements, and a replaced element brings a fresh running animation.
|
|
498
|
+
freezeMotion(typeof frameTimeMs === 'number' ? frameTimeMs : 0, clipStart);
|
|
206
499
|
return true;
|
|
207
500
|
},
|
|
501
|
+
settle: settle,
|
|
208
502
|
};
|
|
209
503
|
|
|
210
504
|
// Build an empty HUD up front so the first render() has styles injected and the anchor grid in place.
|
|
211
505
|
hud = new GameHUD();
|
|
212
506
|
builtKey = structureKey({ elements: [] });
|
|
507
|
+
enforceTransparentPageBackground();
|
|
213
508
|
window.__hudReplayReady = true;
|
|
214
509
|
</script>
|
|
215
510
|
</body>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hud-replay-page.js","sourceRoot":"","sources":["../../src/editor/hud-replay-page.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"hud-replay-page.js","sourceRoot":"","sources":["../../src/editor/hud-replay-page.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAO1D,oGAAoG;AACpG,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,MAAM,MAAM,GAAG,oBAAoB,QAAQ,EAAE,CAAC;IAC9C,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAC9B,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,CACvF,CAAC;IACF,OAAO,EAAE,GAAG,WAAW,EAAE,GAAG,KAAK,EAAE,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,OAA6B;IAC/D,MAAM,OAAO,GAAG,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACrD,OAAO;;;;;;+BAMsB,OAAO,CAAC,QAAQ;;;;;;;;;;;;;;;;;;;EAmB7C,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2brC,CAAC;AACF,CAAC"}
|
|
@@ -1374,6 +1374,7 @@ ${ASSET_DETAIL_HTML}
|
|
|
1374
1374
|
image: '🖼', skybox: '🖼',
|
|
1375
1375
|
glb: '🧊', gltf: '🧊', 'polygon-mesh': '🧊', vxl: '🧊', voxels: '🧊',
|
|
1376
1376
|
animation: '🏃', 'animation-video': '🎥', audio: '🔊', sound: '🔊', 'sound-effect': '🔊', music: '🎵',
|
|
1377
|
+
video: '🎬',
|
|
1377
1378
|
vwld: '🗺', spz: '✨'
|
|
1378
1379
|
};
|
|
1379
1380
|
|
|
@@ -1614,6 +1615,21 @@ ${ASSET_DETAIL_HTML}
|
|
|
1614
1615
|
|
|
1615
1616
|
var MAX_VXL_PREVIEW_BYTES = 8 * 1024 * 1024;
|
|
1616
1617
|
|
|
1618
|
+
/**
|
|
1619
|
+
* Which of a clip's two renditions to play.
|
|
1620
|
+
*
|
|
1621
|
+
* The forger stores every clip twice, and the VP9 sibling is the one worth fetching where the
|
|
1622
|
+
* browser takes it: same picture, ~6x smaller (757 KB against 4.5 MB on a measured 5 s 720p
|
|
1623
|
+
* clip), and bitmagic dev drives Chrome, which decodes VP9 natively. canPlayType only
|
|
1624
|
+
* promises the codec, never the file, so every caller keeps the mp4 as the fallback.
|
|
1625
|
+
*/
|
|
1626
|
+
function videoSourceFor(asset) {
|
|
1627
|
+
var mp4 = typeof asset.url === 'string' ? asset.url : '';
|
|
1628
|
+
var webm = typeof asset.webmUrl === 'string' ? asset.webmUrl : '';
|
|
1629
|
+
if (webm === '') return mp4;
|
|
1630
|
+
return document.createElement('video').canPlayType('video/webm; codecs="vp9"') ? webm : mp4;
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1617
1633
|
/** The mesh route: the asset itself, or the GLB a voxelized one was baked from. */
|
|
1618
1634
|
function glbJobFor(asset) {
|
|
1619
1635
|
var glb = asset.sourceGlbUrl || asset.url;
|
|
@@ -1634,6 +1650,18 @@ ${ASSET_DETAIL_HTML}
|
|
|
1634
1650
|
return { kind: 'vxl', url: url };
|
|
1635
1651
|
}
|
|
1636
1652
|
|
|
1653
|
+
/**
|
|
1654
|
+
* The clip route. Unlike its two neighbours this one is NOT drawn by the engine — see
|
|
1655
|
+
* grabVideoPoster. It is listed as a job anyway so a video row goes through the same queue,
|
|
1656
|
+
* the same disk cache and the same hasPreview path every other tile already uses.
|
|
1657
|
+
*/
|
|
1658
|
+
function videoJobFor(asset) {
|
|
1659
|
+
if (String(asset.type || '').toLowerCase() !== 'video') return null;
|
|
1660
|
+
var url = videoSourceFor(asset);
|
|
1661
|
+
if (typeof url !== 'string' || !/\\.(mp4|webm)(\\?|$)/i.test(url)) return null;
|
|
1662
|
+
return { kind: 'video', url: url };
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1637
1665
|
/**
|
|
1638
1666
|
* How the engine should draw this asset's thumbnail, or null when there is nothing to draw.
|
|
1639
1667
|
*
|
|
@@ -1652,7 +1680,7 @@ ${ASSET_DETAIL_HTML}
|
|
|
1652
1680
|
* answer for something with no appearance.
|
|
1653
1681
|
*/
|
|
1654
1682
|
function previewJobFor(asset) {
|
|
1655
|
-
return glbJobFor(asset) || vxlJobFor(asset);
|
|
1683
|
+
return glbJobFor(asset) || vxlJobFor(asset) || videoJobFor(asset);
|
|
1656
1684
|
}
|
|
1657
1685
|
|
|
1658
1686
|
function assetRow(asset, isFresh, hasPreview) {
|
|
@@ -1812,6 +1840,61 @@ ${ASSET_DETAIL_HTML}
|
|
|
1812
1840
|
return await_('VOXEL_PREVIEW_RESPONSE', 15000);
|
|
1813
1841
|
}
|
|
1814
1842
|
|
|
1843
|
+
/** A poster is a thumbnail, not a frame grab for keeps: 256px on the long edge. */
|
|
1844
|
+
var POSTER_MAX_EDGE = 256;
|
|
1845
|
+
|
|
1846
|
+
/**
|
|
1847
|
+
* A clip's poster, drawn HERE rather than by the engine — a video is not a mesh, and this page
|
|
1848
|
+
* can already decode one. Answers in the same shape the two engine renderers do, so the queue
|
|
1849
|
+
* below does not care which drew it.
|
|
1850
|
+
*
|
|
1851
|
+
* The canvas does not taint: the asset host serves 'access-control-allow-origin: *' (checked
|
|
1852
|
+
* against a stored clip), which is what 'crossOrigin' here asks it to honour. Without that
|
|
1853
|
+
* attribute the draw would succeed and toDataURL would throw.
|
|
1854
|
+
*
|
|
1855
|
+
* Seeks a tenth of the way in rather than taking frame zero — a generated clip often opens on a
|
|
1856
|
+
* fade from black, and a black tile is the thing this whole preview cache exists to avoid.
|
|
1857
|
+
*/
|
|
1858
|
+
function grabVideoPoster(url, requestId) {
|
|
1859
|
+
return new Promise(function (resolve) {
|
|
1860
|
+
var probe = document.createElement('video');
|
|
1861
|
+
var settled = false;
|
|
1862
|
+
var timer = null;
|
|
1863
|
+
function finish(previewBase64) {
|
|
1864
|
+
if (settled) return;
|
|
1865
|
+
settled = true;
|
|
1866
|
+
if (timer) clearTimeout(timer);
|
|
1867
|
+
probe.removeAttribute('src');
|
|
1868
|
+
resolve({ requestId: requestId, success: previewBase64 !== '', previewBase64: previewBase64 });
|
|
1869
|
+
}
|
|
1870
|
+
timer = setTimeout(function () { finish(''); }, 15000);
|
|
1871
|
+
probe.crossOrigin = 'anonymous';
|
|
1872
|
+
probe.muted = true;
|
|
1873
|
+
probe.preload = 'auto';
|
|
1874
|
+
probe.addEventListener('error', function () { finish(''); });
|
|
1875
|
+
probe.addEventListener('loadeddata', function () {
|
|
1876
|
+
probe.currentTime = Math.min(1, (probe.duration || 1) * 0.1);
|
|
1877
|
+
});
|
|
1878
|
+
probe.addEventListener('seeked', function () {
|
|
1879
|
+
try {
|
|
1880
|
+
var width = probe.videoWidth;
|
|
1881
|
+
var height = probe.videoHeight;
|
|
1882
|
+
if (!width || !height) { finish(''); return; }
|
|
1883
|
+
var scale = Math.min(1, POSTER_MAX_EDGE / Math.max(width, height));
|
|
1884
|
+
var canvas = document.createElement('canvas');
|
|
1885
|
+
canvas.width = Math.max(1, Math.round(width * scale));
|
|
1886
|
+
canvas.height = Math.max(1, Math.round(height * scale));
|
|
1887
|
+
canvas.getContext('2d').drawImage(probe, 0, 0, canvas.width, canvas.height);
|
|
1888
|
+
finish(canvas.toDataURL('image/png'));
|
|
1889
|
+
} catch (error) {
|
|
1890
|
+
// A tainted canvas or a codec the browser will not decode. Neither is worth a retry.
|
|
1891
|
+
finish('');
|
|
1892
|
+
}
|
|
1893
|
+
});
|
|
1894
|
+
probe.src = url;
|
|
1895
|
+
});
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1815
1898
|
async function drainPreviewQueue() {
|
|
1816
1899
|
if (previewRunning) return;
|
|
1817
1900
|
previewRunning = true;
|
|
@@ -1819,17 +1902,21 @@ ${ASSET_DETAIL_HTML}
|
|
|
1819
1902
|
try {
|
|
1820
1903
|
while (previewQueue.length > 0) {
|
|
1821
1904
|
// The engine can only draw once it exists. Anything queued before then waits for the next
|
|
1822
|
-
// pass rather than being dropped — refreshAssets re-queues on every render.
|
|
1823
|
-
|
|
1905
|
+
// pass rather than being dropped — refreshAssets re-queues on every render. A clip's
|
|
1906
|
+
// poster is drawn in this page, so it is the one kind that does not wait.
|
|
1907
|
+
var next = previewJobFor(previewQueue[0]);
|
|
1908
|
+
if (!loaded && next !== null && next.kind !== 'video') return;
|
|
1824
1909
|
var asset = previewQueue.shift();
|
|
1825
|
-
var job =
|
|
1910
|
+
var job = next;
|
|
1826
1911
|
if (job === null) continue;
|
|
1827
1912
|
|
|
1828
1913
|
previewRequestId += 1;
|
|
1829
1914
|
var requestId = 'preview-' + previewRequestId;
|
|
1830
|
-
var response = job.kind === '
|
|
1831
|
-
? await
|
|
1832
|
-
:
|
|
1915
|
+
var response = job.kind === 'video'
|
|
1916
|
+
? await grabVideoPoster(job.url, requestId)
|
|
1917
|
+
: job.kind === 'vxl'
|
|
1918
|
+
? await requestVoxelPreview(job.url, requestId)
|
|
1919
|
+
: await requestGlbPreview(job.url, requestId);
|
|
1833
1920
|
|
|
1834
1921
|
// The requestId is verified rather than assumed: a late answer from a request that already
|
|
1835
1922
|
// timed out would otherwise be cached under the NEXT asset's id, which is a wrong picture
|
|
@@ -1896,6 +1983,7 @@ ${ASSET_DETAIL_HTML}
|
|
|
1896
1983
|
var assetFrame = document.getElementById('asset-frame');
|
|
1897
1984
|
var assetImage = document.getElementById('asset-image');
|
|
1898
1985
|
var assetAudio = document.getElementById('asset-audio');
|
|
1986
|
+
var assetVideo = document.getElementById('asset-video');
|
|
1899
1987
|
var assetNote = document.getElementById('asset-note');
|
|
1900
1988
|
var assetFacts = document.getElementById('asset-facts');
|
|
1901
1989
|
var assetResetButton = document.getElementById('asset-reset');
|
|
@@ -1907,6 +1995,9 @@ ${ASSET_DETAIL_HTML}
|
|
|
1907
1995
|
|
|
1908
1996
|
var IMAGE_TYPES = { image: true, skybox: true };
|
|
1909
1997
|
var AUDIO_TYPES = { audio: true, sound: true, 'sound-effect': true };
|
|
1998
|
+
// Only one member today, but the same shape as its neighbours — and the same '=== true'
|
|
1999
|
+
// read, so a type of 'constructor' cannot find Object.prototype's own property and pass.
|
|
2000
|
+
var VIDEO_TYPES = { video: true };
|
|
1910
2001
|
|
|
1911
2002
|
/**
|
|
1912
2003
|
* What the VIEWER should load — which is not always what the thumbnail drew.
|
|
@@ -1952,6 +2043,10 @@ ${ASSET_DETAIL_HTML}
|
|
|
1952
2043
|
|
|
1953
2044
|
assetFacts.textContent = '';
|
|
1954
2045
|
fact('Size', formatSize(asset.size));
|
|
2046
|
+
fact('Length', typeof asset.durationSeconds === 'number' && asset.durationSeconds > 0
|
|
2047
|
+
? asset.durationSeconds.toFixed(1) + 's' : '');
|
|
2048
|
+
fact('Frame', typeof asset.width === 'number' && typeof asset.height === 'number'
|
|
2049
|
+
? asset.width + ' × ' + asset.height : '');
|
|
1955
2050
|
fact('Extent', dimensionsOf(asset));
|
|
1956
2051
|
fact('Voxels', typeof asset.voxelCount === 'number' ? String(asset.voxelCount) : '');
|
|
1957
2052
|
fact('Id', asset.id || '');
|
|
@@ -1975,6 +2070,16 @@ ${ASSET_DETAIL_HTML}
|
|
|
1975
2070
|
} else if (AUDIO_TYPES[type] === true && direct) {
|
|
1976
2071
|
assetAudio.src = direct;
|
|
1977
2072
|
assetAudio.classList.remove('hidden');
|
|
2073
|
+
} else if (VIDEO_TYPES[type] === true && direct) {
|
|
2074
|
+
// A clip is already the thing, like an image — no renderer, no iframe. The mp4 is wired to
|
|
2075
|
+
// the error event rather than left to chance: canPlayType answers for the codec, and a
|
|
2076
|
+
// WebM that fails for any other reason would otherwise be a black rectangle with no sound.
|
|
2077
|
+
assetVideo.onerror = function () {
|
|
2078
|
+
if (assetVideo.getAttribute('src') === direct) return;
|
|
2079
|
+
assetVideo.src = direct;
|
|
2080
|
+
};
|
|
2081
|
+
assetVideo.src = videoSourceFor(asset);
|
|
2082
|
+
assetVideo.classList.remove('hidden');
|
|
1978
2083
|
} else if (type === 'animation' && direct) {
|
|
1979
2084
|
// The clip plays on the engine's own block character — /animation-preview imports the
|
|
1980
2085
|
// project's debug/AnimationPreview.js, the module behind the Creator's clip preview.
|
|
@@ -2041,6 +2146,11 @@ ${ASSET_DETAIL_HTML}
|
|
|
2041
2146
|
assetImage.removeAttribute('src');
|
|
2042
2147
|
assetAudio.pause();
|
|
2043
2148
|
assetAudio.removeAttribute('src');
|
|
2149
|
+
// Same reason the iframe goes to about:blank: a dialog nobody is looking at must not keep
|
|
2150
|
+
// decoding video next to the game that wants the GPU.
|
|
2151
|
+
assetVideo.pause();
|
|
2152
|
+
assetVideo.onerror = null;
|
|
2153
|
+
assetVideo.removeAttribute('src');
|
|
2044
2154
|
if (assetPausedByOverlay) {
|
|
2045
2155
|
post('SET_PAUSE', { paused: false });
|
|
2046
2156
|
assetPausedByOverlay = false;
|