@null3d/engine 0.0.0 → 0.1.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/README.md +109 -0
- package/THIRD-PARTY-NOTICES.txt +0 -1
- package/dist/wasm/single/null3d.js +19 -6
- package/dist/wasm/single/null3d_bg.wasm +0 -0
- package/dist/wasm/threaded/null3d.js +19 -6
- package/dist/wasm/threaded/null3d_bg.wasm +0 -0
- package/docs/api/animation.md +23 -67
- package/docs/api/assets.md +42 -26
- package/docs/api/cameras.md +8 -6
- package/docs/api/controls.md +46 -44
- package/docs/api/debug.md +13 -8
- package/docs/api/engine.md +17 -11
- package/docs/api/feature-draws.md +3 -3
- package/docs/api/feature-effects.md +3 -3
- package/docs/api/feature-instances.md +2 -2
- package/docs/api/features.md +14 -15
- package/docs/api/geometry.md +56 -75
- package/docs/api/grass.md +1 -1
- package/docs/api/impostors.md +120 -9
- package/docs/api/input.md +4 -11
- package/docs/api/lights.md +14 -38
- package/docs/api/lines.md +8 -25
- package/docs/api/materials.md +69 -70
- package/docs/api/math.md +6 -7
- package/docs/api/objects.md +13 -13
- package/docs/api/particles.md +2 -14
- package/docs/api/points.md +3 -25
- package/docs/api/post.md +22 -23
- package/docs/api/quality.md +11 -6
- package/docs/api/raycast.md +13 -32
- package/docs/api/reference/animation.md +9 -9
- package/docs/api/reference/assets.md +18 -18
- package/docs/api/reference/cameras.md +5 -2
- package/docs/api/reference/controls.md +75 -23
- package/docs/api/reference/debug.md +23 -8
- package/docs/api/reference/engine.md +22 -10
- package/docs/api/reference/geometry.md +161 -82
- package/docs/api/reference/grass.md +1 -1
- package/docs/api/reference/impostors.md +92 -1
- package/docs/api/reference/input.md +3 -3
- package/docs/api/reference/lights.md +9 -9
- package/docs/api/reference/lines.md +7 -7
- package/docs/api/reference/materials.md +48 -48
- package/docs/api/reference/math.md +22 -22
- package/docs/api/reference/objects.md +9 -9
- package/docs/api/reference/points.md +4 -4
- package/docs/api/reference/post.md +18 -18
- package/docs/api/reference/quality.md +7 -3
- package/docs/api/reference/raycast.md +6 -6
- package/docs/api/reference/render.md +2 -2
- package/docs/api/reference/scene.md +29 -26
- package/docs/api/reference/sketch.md +4 -0
- package/docs/api/reference/sound.md +203 -0
- package/docs/api/reference/sprites.md +5 -5
- package/docs/api/reference/terrain.md +2 -1
- package/docs/api/reference/textures.md +4 -4
- package/docs/api/reference/ui.md +3 -3
- package/docs/api/reference/vertex-draws.md +3 -3
- package/docs/api/reference/water.md +77 -6
- package/docs/api/reference/wind.md +2 -2
- package/docs/api/render.md +12 -10
- package/docs/api/scene.md +40 -29
- package/docs/api/sketch.md +64 -3
- package/docs/api/sound.md +169 -0
- package/docs/api/splats.md +7 -0
- package/docs/api/sprites.md +4 -20
- package/docs/api/tasks.md +2 -2
- package/docs/api/terrain.md +2 -14
- package/docs/api/textures.md +9 -9
- package/docs/api/ui.md +3 -15
- package/docs/api/water.md +198 -15
- package/docs/api/wind.md +5 -5
- package/docs/cli/null3d.md +93 -18
- package/docs/concepts/architecture.md +10 -10
- package/docs/concepts/assets.md +2 -19
- package/docs/concepts/backends.md +7 -5
- package/docs/concepts/color-management.md +15 -26
- package/docs/concepts/culling.md +1 -1
- package/docs/concepts/instances.md +5 -5
- package/docs/concepts/large-worlds.md +1 -1
- package/docs/concepts/lighting.md +50 -55
- package/docs/concepts/lod.md +2 -15
- package/docs/concepts/materials.md +16 -16
- package/docs/concepts/post-processing.md +7 -29
- package/docs/concepts/quality-preset-tables.md +53 -50
- package/docs/concepts/quality-presets.md +56 -27
- package/docs/concepts/render-graph.md +19 -14
- package/docs/concepts/render-layers.md +3 -17
- package/docs/concepts/shadows.md +10 -28
- package/docs/concepts/static-dynamic.md +2 -2
- package/docs/cookbook/index.md +1 -1
- package/docs/data/threejs-mapping.json +136 -102
- package/docs/errors/E1214.md +3 -3
- package/docs/errors/E1307.md +23 -0
- package/docs/errors/E1420.md +3 -3
- package/docs/errors/index.md +3 -2
- package/docs/getting-started/cdn.md +17 -1
- package/docs/getting-started/first-scene.md +1 -1
- package/docs/getting-started/hosting.md +50 -9
- package/docs/getting-started/install.md +8 -7
- package/docs/getting-started/network-use.md +10 -2
- package/docs/getting-started/project-structure.md +15 -6
- package/docs/getting-started/third-party-notices.md +8 -6
- package/docs/guides/accessibility.md +1 -1
- package/docs/guides/add-ons.md +3 -2
- package/docs/guides/agents.md +16 -5
- package/docs/guides/assets-pipeline.md +13 -12
- package/docs/guides/audio.md +109 -124
- package/docs/guides/car-paint.md +1 -1
- package/docs/guides/content-pages.md +10 -6
- package/docs/guides/custom-passes.md +9 -8
- package/docs/guides/custom-shaders.md +6 -3
- package/docs/guides/debugging.md +78 -4
- package/docs/guides/deploying.md +105 -5
- package/docs/guides/deterministic-simulation.md +1 -1
- package/docs/guides/first-use-shaders.md +4 -4
- package/docs/guides/loading-screens.md +78 -33
- package/docs/guides/multiple-views.md +41 -2
- package/docs/guides/performance.md +6 -3
- package/docs/guides/phones.md +12 -1
- package/docs/guides/physics.md +1 -1
- package/docs/guides/screens.md +7 -5
- package/docs/guides/start-time.md +328 -0
- package/docs/guides/testing.md +23 -5
- package/docs/guides/ui-overlays.md +3 -3
- package/docs/index.md +12 -8
- package/docs/pages.md +26 -23
- package/docs/porting/react-three-fiber.md +228 -5
- package/docs/porting/threejs-loop-and-threads.md +220 -6
- package/docs/porting/threejs-mapping.md +86 -84
- package/docs/porting/threejs-materials.md +212 -5
- package/docs/porting/threejs-overview.md +218 -5
- package/docs/porting/threejs-postprocessing.md +2 -2
- package/docs/porting/threejs-shaders.md +298 -5
- package/docs/porting/threejs-unsupported.md +82 -6
- package/docs/porting/verification.md +181 -5
- package/docs/shaders/builtins.md +1 -1
- package/docs/shaders/library.md +63 -39
- package/docs/shaders/surface-functions.md +11 -10
- package/docs/shaders/wgsl-rules.md +1 -1
- package/lib/debug/channel.d.ts +103 -0
- package/lib/debug/channel.js +269 -0
- package/lib/debug/debug.d.ts +9 -7
- package/lib/debug/draw.d.ts +9 -0
- package/lib/debug/draw.js +49 -2
- package/lib/debug/inspector.d.ts +60 -0
- package/lib/debug/inspector.js +475 -0
- package/lib/debug/stats-panel.d.ts +1 -1
- package/lib/debug/stats.d.ts +2 -3
- package/lib/errors/codes.js +8 -2
- package/lib/errors/engine-error.js +25 -10
- package/lib/errors/fixes.d.ts +1 -0
- package/lib/errors/fixes.js +3 -2
- package/lib/generated/core.d.ts +1 -1
- package/lib/generated/core.js +1 -1
- package/lib/gpu/early-builds.d.ts +68 -0
- package/lib/gpu/early-builds.js +158 -0
- package/lib/gpu/pipeline-name.d.ts +6 -0
- package/lib/gpu/pipeline-name.js +23 -0
- package/lib/gpu/webgl2/backend.d.ts +63 -2
- package/lib/gpu/webgl2/backend.js +226 -8
- package/lib/gpu/webgl2/programs.d.ts +18 -0
- package/lib/gpu/webgl2/programs.js +4 -1
- package/lib/gpu/webgpu/backend.d.ts +89 -2
- package/lib/gpu/webgpu/backend.js +255 -8
- package/lib/gpu/webgpu/pipelines.d.ts +13 -0
- package/lib/gpu/webgpu/pipelines.js +15 -1
- package/lib/index.d.ts +6 -4
- package/lib/index.js +3 -2
- package/lib/math/color.d.ts +5 -5
- package/lib/math/color.js +5 -5
- package/lib/math/mat4.d.ts +6 -12
- package/lib/math/mat4.js +6 -12
- package/lib/math/namespaces/quat.d.ts +3 -3
- package/lib/math/namespaces/quat.js +3 -3
- package/lib/math/quat.d.ts +8 -12
- package/lib/math/quat.js +8 -12
- package/lib/math/random.d.ts +2 -3
- package/lib/math/random.js +2 -3
- package/lib/math/types.d.ts +4 -4
- package/lib/math/vec3.d.ts +3 -6
- package/lib/math/vec3.js +3 -6
- package/lib/page/capabilities.d.ts +7 -7
- package/lib/page/capabilities.js +39 -25
- package/lib/page/check-store.d.ts +14 -2
- package/lib/page/check-store.js +34 -11
- package/lib/page/engine.d.ts +103 -26
- package/lib/page/engine.js +420 -97
- package/lib/page/first-frame.d.ts +16 -0
- package/lib/page/first-frame.js +35 -0
- package/lib/page/frame-stats.d.ts +34 -1
- package/lib/page/frame-stats.js +15 -0
- package/lib/page/label-loop.d.ts +7 -3
- package/lib/page/label-loop.js +17 -10
- package/lib/page/labels.d.ts +3 -3
- package/lib/page/pipeline-store.d.ts +25 -0
- package/lib/page/pipeline-store.js +84 -0
- package/lib/page/start-marker.d.ts +4 -1
- package/lib/page/start-marker.js +5 -2
- package/lib/page/switches.d.ts +32 -2
- package/lib/page/switches.js +9 -1
- package/lib/quality/check.d.ts +24 -3
- package/lib/quality/check.js +21 -7
- package/lib/quality/chooser.d.ts +6 -0
- package/lib/quality/chooser.js +8 -0
- package/lib/quality/governor.d.ts +98 -6
- package/lib/quality/governor.js +250 -20
- package/lib/quality/preset-docs.d.ts +16 -1
- package/lib/quality/preset-docs.js +3 -0
- package/lib/quality/presets.d.ts +84 -7
- package/lib/quality/presets.js +94 -2
- package/lib/render/draw.d.ts +3 -2
- package/lib/render/draw.js +15 -5
- package/lib/render/load-draw.d.ts +7 -5
- package/lib/render/load-draw.js +7 -5
- package/lib/render/loss.d.ts +28 -10
- package/lib/render/loss.js +50 -22
- package/lib/render/recovery.d.ts +20 -0
- package/lib/render/recovery.js +44 -4
- package/lib/render/renderer.d.ts +85 -9
- package/lib/render/renderer.js +181 -42
- package/lib/render/scene-renderer.d.ts +19 -1
- package/lib/render/scene-renderer.js +25 -1
- package/lib/render/webgl2-renderers.js +8 -5
- package/lib/render/webgpu-renderers.js +5 -4
- package/lib/scene/animation.d.ts +28 -32
- package/lib/scene/animation.js +12 -15
- package/lib/scene/assets.d.ts +61 -86
- package/lib/scene/assets.js +103 -236
- package/lib/scene/background.d.ts +14 -18
- package/lib/scene/background.js +5 -2
- package/lib/scene/color.d.ts +3 -3
- package/lib/scene/downloads.d.ts +2 -0
- package/lib/scene/downloads.js +371 -0
- package/lib/scene/environment.d.ts +7 -7
- package/lib/scene/environment.js +1 -1
- package/lib/scene/fake-call-values.js +1 -1
- package/lib/scene/fog.d.ts +11 -4
- package/lib/scene/fog.js +8 -2
- package/lib/scene/frame-cameras.d.ts +19 -0
- package/lib/scene/frame-cameras.js +58 -0
- package/lib/scene/gltf.d.ts +32 -2
- package/lib/scene/gltf.js +78 -49
- package/lib/scene/grading.d.ts +2 -2
- package/lib/scene/grading.js +3 -3
- package/lib/scene/ktx2.d.ts +9 -1
- package/lib/scene/ktx2.js +3 -2
- package/lib/scene/level-rule.d.ts +120 -0
- package/lib/scene/level-rule.js +130 -0
- package/lib/scene/lines.d.ts +13 -17
- package/lib/scene/lines.js +3 -3
- package/lib/scene/lut.d.ts +1 -2
- package/lib/scene/lut.js +1 -2
- package/lib/scene/picks.d.ts +2 -2
- package/lib/scene/pointer-events.d.ts +4 -7
- package/lib/scene/post.d.ts +38 -43
- package/lib/scene/post.js +4 -1
- package/lib/scene/prefab.d.ts +7 -8
- package/lib/scene/prefab.js +7 -8
- package/lib/scene/property-animation.d.ts +1 -1
- package/lib/scene/property-animation.js +1 -1
- package/lib/scene/queries.d.ts +7 -13
- package/lib/scene/resources.d.ts +225 -254
- package/lib/scene/resources.js +179 -81
- package/lib/scene/scene.d.ts +149 -118
- package/lib/scene/scene.js +196 -98
- package/lib/scene/serial-loads.d.ts +29 -0
- package/lib/scene/serial-loads.js +68 -0
- package/lib/scene/shader-preloads.d.ts +34 -0
- package/lib/scene/shader-preloads.js +38 -0
- package/lib/scene/sprites.d.ts +14 -17
- package/lib/scene/sprites.js +5 -6
- package/lib/scene/textures.d.ts +11 -12
- package/lib/scene/textures.js +9 -10
- package/lib/scene/time-of-day.d.ts +3 -4
- package/lib/scene/time-of-day.js +2 -3
- package/lib/scene/vertex-draws.d.ts +5 -4
- package/lib/scene/vertex-draws.js +7 -5
- package/lib/shader-artifact.json +1 -0
- package/lib/shared/core.d.ts +5 -0
- package/lib/shared/core.js +1 -0
- package/lib/shared/import-once.d.ts +6 -0
- package/lib/shared/import-once.js +19 -0
- package/lib/shared/metrics.d.ts +38 -0
- package/lib/shared/metrics.js +62 -1
- package/lib/shared/run-task.js +7 -1
- package/lib/shared/task-pending.d.ts +12 -0
- package/lib/shared/task-pending.js +61 -1
- package/lib/shared/tasks.js +79 -32
- package/lib/shared/version.d.ts +17 -1
- package/lib/shared/version.js +19 -1
- package/lib/shared/wasm.d.ts +12 -4
- package/lib/shared/wasm.js +50 -27
- package/lib/shared/worker-start.d.ts +7 -0
- package/lib/shared/worker-start.js +27 -0
- package/lib/sketch/define-sketch.d.ts +35 -0
- package/lib/sketch/input.d.ts +2 -2
- package/lib/sketch/preset-check.d.ts +20 -6
- package/lib/sketch/preset-check.js +42 -17
- package/lib/sketch/quality.d.ts +69 -11
- package/lib/sketch/quality.js +54 -13
- package/lib/sketch/runner.d.ts +76 -9
- package/lib/sketch/runner.js +385 -52
- package/lib/sketch/ui.d.ts +5 -8
- package/lib/workers/probe-worker.d.ts +5 -0
- package/lib/workers/probe-worker.js +13 -4
- package/lib/workers/protocol.d.ts +61 -13
- package/lib/workers/protocol.js +4 -0
- package/lib/workers/render-worker.js +25 -4
- package/lib/workers/sketch-worker.js +104 -15
- package/package.json +2 -2
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { type PresetCheck } from '../quality/check.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type QualityPreset } from '../quality/presets.js';
|
|
3
3
|
/** What the check needs from the sketch runner. */
|
|
4
4
|
export interface CheckHost {
|
|
5
5
|
/** The metrics buffer, whose rings hold the presented and the completed frames. */
|
|
6
6
|
metrics: ArrayBufferLike;
|
|
7
7
|
/** The preset that runs. */
|
|
8
8
|
readonly preset: QualityPreset;
|
|
9
|
-
/**
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Switches to the lighter preset `to`, and resolves once its first frame is on screen. `check`
|
|
11
|
+
* is the check's rounds so far, whose last missed its target, for the page to keep.
|
|
12
|
+
*/
|
|
13
|
+
lower(check: PresetCheck, to: QualityPreset): Promise<void>;
|
|
11
14
|
/**
|
|
12
15
|
* Draws a frame of the scene as it stands, and resolves once the thread that draws has taken
|
|
13
16
|
* it: with false when the engine stopped.
|
|
@@ -20,9 +23,20 @@ export interface CheckHost {
|
|
|
20
23
|
/** How many times the page showed again after it was hidden, or resumed after a pause. */
|
|
21
24
|
resumes(): number;
|
|
22
25
|
}
|
|
26
|
+
/** Where a check starts: its first preset, its target so far and its rounds so far. */
|
|
27
|
+
export type CheckStart = Pick<PresetCheck, 'from' | 'targetFps' | 'rounds'>;
|
|
28
|
+
/**
|
|
29
|
+
* Where a check of `preset` starts, before its first frame. Its target starts at `refreshHz`, the
|
|
30
|
+
* rate that the meter read then, once the meter has read one, and at most `maxTargetFps`.
|
|
31
|
+
* `resume` holds the rounds that an earlier start measured before its check ended: the check then
|
|
32
|
+
* goes on from them, and reports them with its own from the earlier start's first preset.
|
|
33
|
+
*/
|
|
34
|
+
export declare function checkStart(preset: QualityPreset, refreshHz: number, maxTargetFps: number, resume?: CheckStart): CheckStart;
|
|
23
35
|
/**
|
|
24
36
|
* Measures the preset that runs, and lowers it until one holds the target or the preset is Low.
|
|
25
|
-
*
|
|
26
|
-
*
|
|
37
|
+
* Each round starts once the GPU draws at play's rate. `begin` is where the check starts, as
|
|
38
|
+
* `checkStart` gives it; without it, the check starts from the preset that runs, with no target
|
|
39
|
+
* until the meter reads one. Resolves with what the check measured, or undefined when the engine
|
|
40
|
+
* stopped first.
|
|
27
41
|
*/
|
|
28
|
-
export declare function checkPreset(host: CheckHost,
|
|
42
|
+
export declare function checkPreset(host: CheckHost, begin?: CheckStart): Promise<PresetCheck | undefined>;
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
// The preset check, which the sketch runner loads after the first frame when the engine chose the
|
|
2
|
-
// preset itself.
|
|
3
|
-
// measured window, and reads the rates at which the
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
2
|
+
// preset itself. Once the first frame's pipelines are built and the GPU draws at play's rate, it
|
|
3
|
+
// draws the scene for a grace time, then for a measured window, and reads the rates at which the
|
|
4
|
+
// thread that draws presented frames and the GPU finished them. When the lower rate misses the
|
|
5
|
+
// target, it lowers the preset by one, or straight to Low when the rate is far below the target,
|
|
6
|
+
// waits for the new preset's first frame, and measures again. It ends at a preset that holds the
|
|
7
|
+
// target, or at Low, so the engine runs only a preset that the check measured. A round during which the page was hidden or
|
|
8
|
+
// paused measures again: a hidden page draws no frames, and the first frame after it carries the
|
|
9
|
+
// hidden time as its interval. The target starts at the refresh rate that the meter read before
|
|
10
|
+
// the check's frames began: a GPU that falls behind slows the frame callbacks, which then read as
|
|
11
|
+
// a slower display. A check can go on from the rounds that an earlier start measured before its
|
|
12
|
+
// check ended. The rules and the thresholds live in quality/check.ts.
|
|
8
13
|
import { CHECK_GRACE_MS, CHECK_SETTLE_FRAMES, CHECK_SETTLE_INTERVAL_MS, CHECK_SETTLE_WAIT_MS, CHECK_UPLOAD_WAIT_MS, CHECK_WINDOW_MS, frameRate, holdsTarget, raiseTarget, } from '../quality/check.js';
|
|
14
|
+
import { presetAfterMiss } from '../quality/presets.js';
|
|
9
15
|
import { RingSums, Role, refreshRate, SUM_INTERVAL_MS, SUM_RECORDS } from '../shared/metrics.js';
|
|
10
16
|
/** Draws frames until `until` returns false; resolves with false when the engine stopped. */
|
|
11
17
|
async function drawWhile(host, until) {
|
|
@@ -15,9 +21,10 @@ async function drawWhile(host, until) {
|
|
|
15
21
|
return true;
|
|
16
22
|
}
|
|
17
23
|
/**
|
|
18
|
-
* Draws frames after a lowering until the GPU has finished enough
|
|
19
|
-
* frame that carries the
|
|
20
|
-
*
|
|
24
|
+
* Draws frames after the first frame, and after a lowering, until the GPU has finished enough
|
|
25
|
+
* frames at play's rate. So the frame that carries the first frame's long finish, or the new
|
|
26
|
+
* preset's pipelines and remade shadow map, does not fall inside the next measured window.
|
|
27
|
+
* Resolves false when the engine stopped.
|
|
21
28
|
*/
|
|
22
29
|
async function settle(host) {
|
|
23
30
|
const completed = new RingSums(host.metrics, Role.Completion);
|
|
@@ -46,16 +53,34 @@ async function settle(host) {
|
|
|
46
53
|
const rounded = (fps) => Math.round(fps * 10) / 10;
|
|
47
54
|
/** The rate of the records that `sums` took in. */
|
|
48
55
|
const rateOf = (sums) => rounded(frameRate(sums.sums[SUM_RECORDS], sums.sums[SUM_INTERVAL_MS]));
|
|
56
|
+
/**
|
|
57
|
+
* Where a check of `preset` starts, before its first frame. Its target starts at `refreshHz`, the
|
|
58
|
+
* rate that the meter read then, once the meter has read one, and at most `maxTargetFps`.
|
|
59
|
+
* `resume` holds the rounds that an earlier start measured before its check ended: the check then
|
|
60
|
+
* goes on from them, and reports them with its own from the earlier start's first preset.
|
|
61
|
+
*/
|
|
62
|
+
export function checkStart(preset, refreshHz, maxTargetFps, resume) {
|
|
63
|
+
const targetFps = resume?.targetFps ?? 0;
|
|
64
|
+
return {
|
|
65
|
+
from: resume?.from ?? preset,
|
|
66
|
+
targetFps: refreshHz > 0 ? raiseTarget(targetFps, refreshHz, maxTargetFps) : targetFps,
|
|
67
|
+
rounds: [...(resume?.rounds ?? [])],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
49
70
|
/**
|
|
50
71
|
* Measures the preset that runs, and lowers it until one holds the target or the preset is Low.
|
|
51
|
-
*
|
|
52
|
-
*
|
|
72
|
+
* Each round starts once the GPU draws at play's rate. `begin` is where the check starts, as
|
|
73
|
+
* `checkStart` gives it; without it, the check starts from the preset that runs, with no target
|
|
74
|
+
* until the meter reads one. Resolves with what the check measured, or undefined when the engine
|
|
75
|
+
* stopped first.
|
|
53
76
|
*/
|
|
54
|
-
export async function checkPreset(host,
|
|
55
|
-
const from =
|
|
56
|
-
const rounds = [];
|
|
57
|
-
let targetFps =
|
|
58
|
-
|
|
77
|
+
export async function checkPreset(host, begin = { from: host.preset, targetFps: 0, rounds: [] }) {
|
|
78
|
+
const { from } = begin;
|
|
79
|
+
const rounds = [...begin.rounds];
|
|
80
|
+
let targetFps = begin.targetFps;
|
|
81
|
+
if (!(await settle(host)))
|
|
82
|
+
return undefined;
|
|
83
|
+
let start = performance.now();
|
|
59
84
|
for (;;) {
|
|
60
85
|
const resumes = host.resumes();
|
|
61
86
|
const graceEnd = start + CHECK_GRACE_MS;
|
|
@@ -86,7 +111,7 @@ export async function checkPreset(host, graceStart) {
|
|
|
86
111
|
rounds.push(round);
|
|
87
112
|
if (host.preset === 'low' || holdsTarget(round, targetFps))
|
|
88
113
|
break;
|
|
89
|
-
await host.lower();
|
|
114
|
+
await host.lower({ from, targetFps, rounds: [...rounds], reused: false }, presetAfterMiss(round, targetFps));
|
|
90
115
|
if (!(await settle(host)))
|
|
91
116
|
return undefined;
|
|
92
117
|
start = performance.now();
|
package/lib/sketch/quality.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { PresetCheck } from '../quality/check.js';
|
|
1
|
+
import type { PresetCheck, PresetCheckTiming } from '../quality/check.js';
|
|
2
2
|
import { type QualityPreset, type QualitySettingName, type QualitySettings } from '../quality/presets.js';
|
|
3
3
|
import type { TextureMemory } from '../scene/textures.js';
|
|
4
|
+
import type { Tier } from '../shared/tier.js';
|
|
4
5
|
/** The preset and the settings that the page starts a sketch with. */
|
|
5
6
|
export interface QualityStart {
|
|
6
7
|
preset: QualityPreset;
|
|
@@ -20,14 +21,43 @@ export interface QualityStart {
|
|
|
20
21
|
* page turns it on for phones and tablets, and a page option can turn it off (D-164).
|
|
21
22
|
*/
|
|
22
23
|
keepCopies?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* When the engine checks the preset after its first frame: during play, or before it, as the
|
|
26
|
+
* page chose. Without it, the engine checks no preset.
|
|
27
|
+
*/
|
|
28
|
+
check?: PresetCheckTiming;
|
|
29
|
+
/**
|
|
30
|
+
* The rounds that an earlier start of the sketch measured before its check ended, as the page
|
|
31
|
+
* stored them. The start runs the preset that they lowered to, and its check goes on from them.
|
|
32
|
+
*/
|
|
33
|
+
resume?: PresetCheck;
|
|
34
|
+
/**
|
|
35
|
+
* True when the page started in the lowest quality tier, through its start switch. The
|
|
36
|
+
* governor then gives the tier's settings back when the frames have room for its window.
|
|
37
|
+
*/
|
|
38
|
+
lowest?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* False when the page's `?tier=off` switch keeps the governor out of the lowest tier, so a
|
|
41
|
+
* test measures the presets alone. True or absent lets it enter when frames still miss.
|
|
42
|
+
*/
|
|
43
|
+
lowestAllowed?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The GPU path whose preset values apply, which WebGL2 overrides for some settings, such as its
|
|
46
|
+
* depth prepass. `setPreset` keeps those values, so a change inside one start does not lose them.
|
|
47
|
+
*/
|
|
48
|
+
tier?: Tier;
|
|
25
49
|
}
|
|
26
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* What the page learns after each change: the preset, the settings, and the check's result.
|
|
52
|
+
* `checked` marks the one update that ends the preset check, which carries the check's result
|
|
53
|
+
* when it measured one. Each lowering by the check carries the check's rounds so far, without
|
|
54
|
+
* `checked`, so the page keeps them should the check never end.
|
|
55
|
+
*/
|
|
27
56
|
export interface QualityUpdate {
|
|
28
57
|
preset: QualityPreset;
|
|
29
58
|
settings: QualitySettings;
|
|
30
59
|
check?: PresetCheck;
|
|
60
|
+
checked?: true;
|
|
31
61
|
}
|
|
32
62
|
/**
|
|
33
63
|
* Applies a change on the sketch's thread and tells the page of it. `changed` names the settings
|
|
@@ -86,6 +116,14 @@ export interface QualityGovernor {
|
|
|
86
116
|
* that the camera sees from far.
|
|
87
117
|
*/
|
|
88
118
|
readonly farAnimationInterval: number;
|
|
119
|
+
/**
|
|
120
|
+
* True while the lowest quality tier applies: the render scale's floor has fallen to a third,
|
|
121
|
+
* the sun's cast shadows and bloom are off, reflections draw at a quarter of the render size, and
|
|
122
|
+
* WebGL2 draws no depth prepass. The governor enters the tier when the scale has held at the
|
|
123
|
+
* preset's floor through its sustained window and the frames still miss. It leaves the tier
|
|
124
|
+
* when the frames keep room through the window that raises a step.
|
|
125
|
+
*/
|
|
126
|
+
readonly lowest: boolean;
|
|
89
127
|
}
|
|
90
128
|
/**
|
|
91
129
|
* A system of the sketch's own that the frame-budget governor scales, as `quality.setBudget` gets
|
|
@@ -278,6 +316,8 @@ export declare class SketchQuality implements Quality {
|
|
|
278
316
|
private readonly antialiasFixed;
|
|
279
317
|
readonly highest: QualityPreset;
|
|
280
318
|
private readonly textureCapMiB;
|
|
319
|
+
/** How many times the sketch asked for a preset, which ends a preset check that runs. */
|
|
320
|
+
private requests;
|
|
281
321
|
readonly governor: QualityGovernor;
|
|
282
322
|
/** The sketch's budgets for its own systems. */
|
|
283
323
|
readonly budgets: GameBudgets;
|
|
@@ -288,27 +328,41 @@ export declare class SketchQuality implements Quality {
|
|
|
288
328
|
constructor(start: QualityStart, apply: ApplyQuality, settle?: () => Promise<void>, scale?: () => number, governor?: QualityGovernor, textureMemory?: TextureMemory);
|
|
289
329
|
get renderScale(): number;
|
|
290
330
|
set(settings: Partial<QualitySettings>): Promise<void>;
|
|
331
|
+
/**
|
|
332
|
+
* Changes live settings for the frame-budget governor, which does not count them as the
|
|
333
|
+
* sketch's own: a preset that the sketch asks for replaces them, as it replaces those that the
|
|
334
|
+
* page's options do not give. The lowest quality tier's cuts and their return use it.
|
|
335
|
+
*/
|
|
336
|
+
setGoverned(settings: Partial<QualitySettings>): Promise<void>;
|
|
337
|
+
/** How many times the sketch asked for a preset with `setPreset`. */
|
|
338
|
+
get presetRequests(): number;
|
|
291
339
|
setPreset(preset: QualityPreset): Promise<void>;
|
|
292
340
|
/**
|
|
293
341
|
* Counts a setting as the sketch's own choice, for a call that sets it outside `set`, such as
|
|
294
342
|
* a texture upload budget below the setting's range.
|
|
295
343
|
*/
|
|
296
344
|
own(name: QualitySettingName): void;
|
|
345
|
+
/** True when the sketch chose the setting itself since the preset it last asked for. */
|
|
346
|
+
owns(name: QualitySettingName): boolean;
|
|
297
347
|
/**
|
|
298
348
|
* True when the page's options give the setting, or the sketch chose it itself since the preset
|
|
299
349
|
* it last asked for, rather than taking the preset's value.
|
|
300
350
|
*/
|
|
301
351
|
chose(name: keyof QualitySettings): boolean;
|
|
302
352
|
/**
|
|
303
|
-
* The preset check's step to
|
|
304
|
-
* and those that the sketch chose itself, keep their
|
|
353
|
+
* The preset check's step to a lighter preset: `next`, or the next lighter one without it. The
|
|
354
|
+
* settings that the page's options give, and those that the sketch chose itself, keep their
|
|
355
|
+
* values. A device can move to a lighter
|
|
305
356
|
* anti-aliasing mode while it runs, so the lower preset gives that too: the check lowers a
|
|
306
357
|
* tablet from Medium to Low, whose FXAA costs half of MSAA's draws. A heavier mode stays as the
|
|
307
|
-
* device started with it.
|
|
358
|
+
* device started with it. `check` is the check's rounds so far, which the page hears of with
|
|
359
|
+
* the lower preset.
|
|
308
360
|
*/
|
|
309
|
-
lower(): Promise<void>;
|
|
361
|
+
lower(check?: PresetCheck, next?: QualityPreset): Promise<void>;
|
|
310
362
|
/** The settings of `preset`, with `kept`'s values, under the device's texture memory cap. */
|
|
311
363
|
private presetValues;
|
|
364
|
+
/** The GPU path whose preset values apply, from the start. */
|
|
365
|
+
private readonly tier?;
|
|
312
366
|
setBudget(options: QualityBudgetOptions): QualityBudget;
|
|
313
367
|
onChange(handler: (quality: Quality) => void): () => void;
|
|
314
368
|
/**
|
|
@@ -316,8 +370,11 @@ export declare class SketchQuality implements Quality {
|
|
|
316
370
|
* memory budget's drops, at the next frame.
|
|
317
371
|
*/
|
|
318
372
|
governed(): void;
|
|
319
|
-
/**
|
|
320
|
-
|
|
373
|
+
/**
|
|
374
|
+
* Tells the page that the preset check has ended, with the preset and the settings, and with
|
|
375
|
+
* the check's result when it measured one.
|
|
376
|
+
*/
|
|
377
|
+
report(check: PresetCheck | undefined): void;
|
|
321
378
|
/**
|
|
322
379
|
* The change since the frame that last asked, once, for the handlers of a frame that runs the
|
|
323
380
|
* sketch: `NO_CHANGE`, `LIVE_CHANGE` or `RESTART_CHANGE`.
|
|
@@ -327,7 +384,8 @@ export declare class SketchQuality implements Quality {
|
|
|
327
384
|
takeRestart(): boolean;
|
|
328
385
|
/**
|
|
329
386
|
* Moves to `preset` with the values in `settings`, and applies the settings that change. A new
|
|
330
|
-
* preset, or a new value of a setting that is not live, restarts the preset.
|
|
387
|
+
* preset, or a new value of a setting that is not live, restarts the preset. `check` goes to
|
|
388
|
+
* the page with the change.
|
|
331
389
|
*/
|
|
332
390
|
private update;
|
|
333
391
|
}
|
package/lib/sketch/quality.js
CHANGED
|
@@ -145,6 +145,8 @@ export class SketchQuality {
|
|
|
145
145
|
antialiasFixed;
|
|
146
146
|
highest;
|
|
147
147
|
textureCapMiB;
|
|
148
|
+
/** How many times the sketch asked for a preset, which ends a preset check that runs. */
|
|
149
|
+
requests = 0;
|
|
148
150
|
governor;
|
|
149
151
|
/** The sketch's budgets for its own systems. */
|
|
150
152
|
budgets = new GameBudgets();
|
|
@@ -158,6 +160,7 @@ export class SketchQuality {
|
|
|
158
160
|
this.scale = scale;
|
|
159
161
|
this.textureMemory = textureMemory;
|
|
160
162
|
this.preset = start.preset;
|
|
163
|
+
this.tier = start.tier;
|
|
161
164
|
this.settings = { ...start.settings };
|
|
162
165
|
const kept = { ...start.options };
|
|
163
166
|
for (const [name, value] of Object.entries(startValues(start.settings)))
|
|
@@ -190,6 +193,9 @@ export class SketchQuality {
|
|
|
190
193
|
get farAnimationInterval() {
|
|
191
194
|
return settings.farAnimationInterval;
|
|
192
195
|
},
|
|
196
|
+
get lowest() {
|
|
197
|
+
return false;
|
|
198
|
+
},
|
|
193
199
|
};
|
|
194
200
|
}
|
|
195
201
|
get renderScale() {
|
|
@@ -199,16 +205,35 @@ export class SketchQuality {
|
|
|
199
205
|
checkSettings('quality.set()', settings, LIVE_SETTINGS);
|
|
200
206
|
const lowest = settings.minRenderScale ?? this.settings.minRenderScale;
|
|
201
207
|
const highest = settings.maxRenderScale ?? this.settings.maxRenderScale;
|
|
202
|
-
|
|
208
|
+
// The lowest quality tier caps the render scale. A floor that the sketch sets itself wins
|
|
209
|
+
// over that cap, which rises to the floor; a cap that the sketch set itself stays its own.
|
|
210
|
+
const raisesCap = lowest > highest &&
|
|
211
|
+
settings.maxRenderScale === undefined &&
|
|
212
|
+
this.governor.lowest &&
|
|
213
|
+
!this.owned.has('maxRenderScale');
|
|
214
|
+
if (lowest > highest && !raisesCap)
|
|
203
215
|
throw new EngineError('E1213', `quality.set() would give minRenderScale ${lowest}, above maxRenderScale ${highest}. Give both in one call to change them together.`);
|
|
204
216
|
for (const [name, value] of Object.entries(settings))
|
|
205
217
|
if (value !== undefined)
|
|
206
218
|
this.owned.add(name);
|
|
219
|
+
return this.update(this.preset, raisesCap ? { ...settings, maxRenderScale: lowest } : settings);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Changes live settings for the frame-budget governor, which does not count them as the
|
|
223
|
+
* sketch's own: a preset that the sketch asks for replaces them, as it replaces those that the
|
|
224
|
+
* page's options do not give. The lowest quality tier's cuts and their return use it.
|
|
225
|
+
*/
|
|
226
|
+
setGoverned(settings) {
|
|
207
227
|
return this.update(this.preset, settings);
|
|
208
228
|
}
|
|
229
|
+
/** How many times the sketch asked for a preset with `setPreset`. */
|
|
230
|
+
get presetRequests() {
|
|
231
|
+
return this.requests;
|
|
232
|
+
}
|
|
209
233
|
setPreset(preset) {
|
|
210
234
|
const wanted = presetArgument(preset);
|
|
211
235
|
const next = presetIndex(wanted) > presetIndex(this.highest) ? this.highest : wanted;
|
|
236
|
+
this.requests++;
|
|
212
237
|
this.owned.clear();
|
|
213
238
|
return this.update(next, this.presetValues(next, this.options));
|
|
214
239
|
}
|
|
@@ -219,6 +244,10 @@ export class SketchQuality {
|
|
|
219
244
|
own(name) {
|
|
220
245
|
this.owned.add(name);
|
|
221
246
|
}
|
|
247
|
+
/** True when the sketch chose the setting itself since the preset it last asked for. */
|
|
248
|
+
owns(name) {
|
|
249
|
+
return this.owned.has(name);
|
|
250
|
+
}
|
|
222
251
|
/**
|
|
223
252
|
* True when the page's options give the setting, or the sketch chose it itself since the preset
|
|
224
253
|
* it last asked for, rather than taking the preset's value.
|
|
@@ -227,14 +256,15 @@ export class SketchQuality {
|
|
|
227
256
|
return this.options[name] !== undefined || this.owned.has(name);
|
|
228
257
|
}
|
|
229
258
|
/**
|
|
230
|
-
* The preset check's step to
|
|
231
|
-
* and those that the sketch chose itself, keep their
|
|
259
|
+
* The preset check's step to a lighter preset: `next`, or the next lighter one without it. The
|
|
260
|
+
* settings that the page's options give, and those that the sketch chose itself, keep their
|
|
261
|
+
* values. A device can move to a lighter
|
|
232
262
|
* anti-aliasing mode while it runs, so the lower preset gives that too: the check lowers a
|
|
233
263
|
* tablet from Medium to Low, whose FXAA costs half of MSAA's draws. A heavier mode stays as the
|
|
234
|
-
* device started with it.
|
|
264
|
+
* device started with it. `check` is the check's rounds so far, which the page hears of with
|
|
265
|
+
* the lower preset.
|
|
235
266
|
*/
|
|
236
|
-
lower() {
|
|
237
|
-
const next = lowered(this.preset, 1);
|
|
267
|
+
lower(check, next = lowered(this.preset, 1)) {
|
|
238
268
|
const kept = { ...this.options };
|
|
239
269
|
const current = this.settings;
|
|
240
270
|
for (const name of this.owned)
|
|
@@ -247,12 +277,14 @@ export class SketchQuality {
|
|
|
247
277
|
// keeps it too, and the settings never name a mode that the canvas is not drawing.
|
|
248
278
|
this.options.antialias = wanted;
|
|
249
279
|
}
|
|
250
|
-
return this.update(next, this.presetValues(next, kept));
|
|
280
|
+
return this.update(next, this.presetValues(next, kept), check);
|
|
251
281
|
}
|
|
252
282
|
/** The settings of `preset`, with `kept`'s values, under the device's texture memory cap. */
|
|
253
283
|
presetValues(preset, kept) {
|
|
254
|
-
return capTextureMemory(presetSettings(preset, kept), kept, this.textureCapMiB);
|
|
284
|
+
return capTextureMemory(presetSettings(preset, kept, this.tier), kept, this.textureCapMiB);
|
|
255
285
|
}
|
|
286
|
+
/** The GPU path whose preset values apply, from the start. */
|
|
287
|
+
tier;
|
|
256
288
|
setBudget(options) {
|
|
257
289
|
return this.budgets.set(options);
|
|
258
290
|
}
|
|
@@ -267,9 +299,17 @@ export class SketchQuality {
|
|
|
267
299
|
governed() {
|
|
268
300
|
this.change = Math.max(this.change, LIVE_CHANGE);
|
|
269
301
|
}
|
|
270
|
-
/**
|
|
302
|
+
/**
|
|
303
|
+
* Tells the page that the preset check has ended, with the preset and the settings, and with
|
|
304
|
+
* the check's result when it measured one.
|
|
305
|
+
*/
|
|
271
306
|
report(check) {
|
|
272
|
-
this.apply({
|
|
307
|
+
this.apply({
|
|
308
|
+
preset: this.preset,
|
|
309
|
+
settings: { ...this.settings },
|
|
310
|
+
...(check && { check }),
|
|
311
|
+
checked: true,
|
|
312
|
+
}, []);
|
|
273
313
|
}
|
|
274
314
|
/**
|
|
275
315
|
* The change since the frame that last asked, once, for the handlers of a frame that runs the
|
|
@@ -288,9 +328,10 @@ export class SketchQuality {
|
|
|
288
328
|
}
|
|
289
329
|
/**
|
|
290
330
|
* Moves to `preset` with the values in `settings`, and applies the settings that change. A new
|
|
291
|
-
* preset, or a new value of a setting that is not live, restarts the preset.
|
|
331
|
+
* preset, or a new value of a setting that is not live, restarts the preset. `check` goes to
|
|
332
|
+
* the page with the change.
|
|
292
333
|
*/
|
|
293
|
-
update(preset, settings) {
|
|
334
|
+
update(preset, settings, check) {
|
|
294
335
|
const current = this.settings;
|
|
295
336
|
const changed = [];
|
|
296
337
|
let restart = preset !== this.preset;
|
|
@@ -308,7 +349,7 @@ export class SketchQuality {
|
|
|
308
349
|
this.change = restart ? RESTART_CHANGE : Math.max(this.change, LIVE_CHANGE);
|
|
309
350
|
if (restart)
|
|
310
351
|
this.restart = true;
|
|
311
|
-
this.apply({ preset, settings: { ...this.settings } }, changed);
|
|
352
|
+
this.apply({ preset, settings: { ...this.settings }, ...(check && { check }) }, changed);
|
|
312
353
|
return restart ? this.settle() : Promise.resolve();
|
|
313
354
|
}
|
|
314
355
|
}
|
package/lib/sketch/runner.d.ts
CHANGED
|
@@ -100,6 +100,15 @@ export declare class SketchRunner {
|
|
|
100
100
|
private callbacks;
|
|
101
101
|
/** True once the setup function has returned. */
|
|
102
102
|
private setUp;
|
|
103
|
+
/** The downloads of the sketch's list, once a live setup began or took them. */
|
|
104
|
+
private listed;
|
|
105
|
+
/** Resolves the sketch's `engine.firstFrame`, until it has. */
|
|
106
|
+
private firstFrameReached;
|
|
107
|
+
/**
|
|
108
|
+
* True while a development build watches the sketch's loads for one that waits for another:
|
|
109
|
+
* during the setup function of a live start.
|
|
110
|
+
*/
|
|
111
|
+
private watchesLoads;
|
|
103
112
|
/** The frames that warm-ups during the setup published, one after another, as the last one's number. */
|
|
104
113
|
private setupFrames;
|
|
105
114
|
private readonly clock;
|
|
@@ -142,6 +151,8 @@ export declare class SketchRunner {
|
|
|
142
151
|
*/
|
|
143
152
|
private jobWindowUs;
|
|
144
153
|
private jobWindowFrames;
|
|
154
|
+
/** The sketch time at which the window's first frame arrived, in seconds. */
|
|
155
|
+
private jobWindowStart;
|
|
145
156
|
/** The sketch time at which the sketch thread times its parallel loops again, while they pause. */
|
|
146
157
|
private jobPauseUntil;
|
|
147
158
|
/** Whether the core times the parallel loops that the sketch thread hands out. */
|
|
@@ -183,6 +194,10 @@ export declare class SketchRunner {
|
|
|
183
194
|
private readonly frameTimes;
|
|
184
195
|
/** The governor's count of changes when the core last took the settings that its steps move. */
|
|
185
196
|
private stepChanges;
|
|
197
|
+
/** The governor's count of tier changes when the sketch last took the tier's settings. */
|
|
198
|
+
private tierChanges;
|
|
199
|
+
/** The settings that the tier replaced, to give back when it leaves, or undefined outside it. */
|
|
200
|
+
private tierRestore;
|
|
186
201
|
/** The budgets' count of changes when the governor last took the steps that they allow. */
|
|
187
202
|
private budgetChanges;
|
|
188
203
|
/** The sketch's post-processing settings, which say whether bloom is on. */
|
|
@@ -231,6 +246,16 @@ export declare class SketchRunner {
|
|
|
231
246
|
private heldScale;
|
|
232
247
|
/** The sketch's debug drawing, in development builds only, which is also its `ctx.debug`. */
|
|
233
248
|
private readonly debugDraw;
|
|
249
|
+
/**
|
|
250
|
+
* The development build's inspection channel, which the in-page inspector and the MCP server
|
|
251
|
+
* call. A release build holds none of it.
|
|
252
|
+
*/
|
|
253
|
+
private channel;
|
|
254
|
+
/**
|
|
255
|
+
* Runs an inspection call, in a development build only: the page's `engine.inspect`, and the
|
|
256
|
+
* sketch worker's answer to the debug channel. The property is absent in a release build.
|
|
257
|
+
*/
|
|
258
|
+
inspect?: (call: string, args?: unknown) => Promise<unknown>;
|
|
234
259
|
/** The sketch's labels, which each frame projects. */
|
|
235
260
|
private readonly ui;
|
|
236
261
|
/** True once the sketch thread has warned that the grid cells ran out. */
|
|
@@ -252,6 +277,17 @@ export declare class SketchRunner {
|
|
|
252
277
|
* time, or a replay, which steps through a recording.
|
|
253
278
|
*/
|
|
254
279
|
private readonly holdsFrames;
|
|
280
|
+
/**
|
|
281
|
+
* True while the preset check measures the frames of play. The governor waits until it ends, so
|
|
282
|
+
* the check measures each preset at the full render scale.
|
|
283
|
+
*/
|
|
284
|
+
private checking;
|
|
285
|
+
/**
|
|
286
|
+
* The refresh rate that the thread that draws measured when the sketch's setup returned, before
|
|
287
|
+
* the frames of play loaded the GPU, or 0 before it measured one. The preset check's target and
|
|
288
|
+
* the governor's start from it.
|
|
289
|
+
*/
|
|
290
|
+
private setupRefreshHz;
|
|
255
291
|
readonly context: SketchContext;
|
|
256
292
|
/**
|
|
257
293
|
* Starts the engine on the core's thread. `holdSeconds` starts hold mode at that sketch time: it
|
|
@@ -262,17 +298,39 @@ export declare class SketchRunner {
|
|
|
262
298
|
constructor(post: PagePoster, metrics: ArrayBufferLike, sketch: SketchCore, holdSeconds?: number | undefined, holdScript?: HoldScript | undefined, replay?: ReplayProgram, record?: boolean, debugView?: string);
|
|
263
299
|
/**
|
|
264
300
|
* Runs the sketch's setup function, which returns the sketch's callbacks. When the page asks for
|
|
265
|
-
*
|
|
266
|
-
*
|
|
301
|
+
* the preset check before play, the check follows, and the setup resolves after it. When it asks
|
|
302
|
+
* for the check during play, the check starts as the setup resolves, and measures the frames
|
|
303
|
+
* that the frame loop draws from then on. In hold mode, it then steps the sketch to the held time
|
|
304
|
+
* (see `hold`). Options out of range fail with E1214 before the setup function runs. A live
|
|
305
|
+
* start's listed files are downloading by then; hold mode, a replay and a recording leave each
|
|
306
|
+
* file to its load, so their order stays as without the list.
|
|
267
307
|
*/
|
|
268
308
|
setup(sketch: SketchDefinition): Promise<void>;
|
|
309
|
+
/**
|
|
310
|
+
* The preset check during play: the frame loop draws the scene and runs the sketch, and the
|
|
311
|
+
* check measures its frames. The governor waits until the check ends. A preset that the sketch
|
|
312
|
+
* asks for itself ends the check, which then reports no result: the sketch chose its preset.
|
|
313
|
+
*/
|
|
314
|
+
private checkDuringPlay;
|
|
269
315
|
/**
|
|
270
316
|
* The preset check, after the setup: the first frame draws with every pipeline built, then the
|
|
271
|
-
* check measures the scene
|
|
272
|
-
*
|
|
273
|
-
*
|
|
317
|
+
* check measures the scene, and lowers the preset where the device cannot hold its frame rate.
|
|
318
|
+
* `drawFrame` resolves once the thread that draws has taken one more frame: a frame that it
|
|
319
|
+
* publishes of the scene as the setup built it, before play, or the frame loop's next frame,
|
|
320
|
+
* during play. It resolves with false when the check must stop. The check's code loads after the
|
|
321
|
+
* first frame, while the scene keeps drawing. A check that cannot load leaves the preset as it
|
|
322
|
+
* is. It goes on from the rounds that an earlier start measured before its check ended, when the
|
|
323
|
+
* page gives them. While the engine runs, the page hears of each lowering with the rounds so
|
|
324
|
+
* far, and that the check ended, with its result when it measured one.
|
|
274
325
|
*/
|
|
275
326
|
private checkPreset;
|
|
327
|
+
/**
|
|
328
|
+
* Runs the preset check with `drawFrame`, as `checkPreset` says, once the thread that draws has
|
|
329
|
+
* built the pipelines that the scene needs; undefined when it stopped.
|
|
330
|
+
*/
|
|
331
|
+
private measurePreset;
|
|
332
|
+
/** Resolves the sketch's `engine.firstFrame`, once. */
|
|
333
|
+
private reachFirstFrame;
|
|
276
334
|
/** True once the setup function has returned, so the frame loop may step the sketch. */
|
|
277
335
|
get started(): boolean;
|
|
278
336
|
/**
|
|
@@ -305,7 +363,8 @@ export declare class SketchRunner {
|
|
|
305
363
|
/**
|
|
306
364
|
* Ends the sketch when the engine stops: runs its onDestroy, then makes every later call to the
|
|
307
365
|
* engine fail with E1420, so code that outlives the engine never reaches the next engine's core.
|
|
308
|
-
* It also gives the thread its own Math.random back, where hold mode seeded it
|
|
366
|
+
* It also gives the thread its own Math.random back, where hold mode seeded it, and ends hold
|
|
367
|
+
* mode's hold on the level plans, for a setup that failed before its hold.
|
|
309
368
|
*/
|
|
310
369
|
dispose(): void;
|
|
311
370
|
/**
|
|
@@ -339,8 +398,9 @@ export declare class SketchRunner {
|
|
|
339
398
|
/**
|
|
340
399
|
* Adds a frame's parallel work to the window, and at the window's end asks the page for twice
|
|
341
400
|
* the `asked` job workers, and at least 2, when the frames handed out enough work to share.
|
|
342
|
-
*
|
|
343
|
-
*
|
|
401
|
+
* The window ends at its frame count, or at its deadline once it holds enough frames, so a
|
|
402
|
+
* slow GPU asks as a fast one does. After a window with less, the loops go untimed for a
|
|
403
|
+
* while; once every job worker has been asked for, for good.
|
|
344
404
|
*/
|
|
345
405
|
private growJobs;
|
|
346
406
|
/** Starts or stops the core's timing of the parallel loops that this thread hands out. */
|
|
@@ -379,9 +439,16 @@ export declare class SketchRunner {
|
|
|
379
439
|
private setShadowQuality;
|
|
380
440
|
/**
|
|
381
441
|
* Gives the core the shadow settings and bloom's base after a step of the governor, and tells
|
|
382
|
-
* the sketch's change handlers of it.
|
|
442
|
+
* the sketch's change handlers of it. The lowest quality tier's settings come before those
|
|
443
|
+
* steps, so a step that the tier's cuts allow reads the values that it leaves.
|
|
383
444
|
*/
|
|
384
445
|
private applyGovernedSteps;
|
|
446
|
+
/**
|
|
447
|
+
* Applies the lowest quality tier's cuts when the governor enters it, and gives the settings
|
|
448
|
+
* back when it leaves. The sketch's own choice of a preset does not keep them: a preset gives
|
|
449
|
+
* the settings its own values again.
|
|
450
|
+
*/
|
|
451
|
+
private applyTierSettings;
|
|
385
452
|
/**
|
|
386
453
|
* Gives the governor the steps that the sketch's budgets allow, and moves the budgets to the
|
|
387
454
|
* governor's steps of their scale, which calls their `onScale` handlers.
|