@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
package/lib/page/engine.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import type { StatsOverlayOptions, StatsRequest } from '../debug/stats-options.j
|
|
|
2
2
|
import { EngineError } from '../errors/engine-error.js';
|
|
3
3
|
import { type ShaderFeature } from '../generated/shader-features.js';
|
|
4
4
|
import type { DrawPathReason } from '../gpu/webgpu/draw-path-probe.js';
|
|
5
|
-
import { type PresetCheck, type TargetFps } from '../quality/check.js';
|
|
5
|
+
import { type PresetCheck, type PresetCheckTiming, type TargetFps } from '../quality/check.js';
|
|
6
6
|
import { type QualityPreset } from '../quality/presets.js';
|
|
7
|
+
import type { GpuErrorKind } from '../render/loss.js';
|
|
7
8
|
import type { Tier } from '../render/renderer.js';
|
|
8
9
|
import type { ReplayResult } from '../shared/recording.js';
|
|
9
10
|
import type { QualityUpdate } from '../sketch/quality.js';
|
|
@@ -48,6 +49,18 @@ export interface EngineOptions {
|
|
|
48
49
|
* E1213.
|
|
49
50
|
*/
|
|
50
51
|
targetFps?: TargetFps;
|
|
52
|
+
/**
|
|
53
|
+
* When the preset check measures, on a start where the engine checks the preset that it chose.
|
|
54
|
+
* With `during-play`, the default, the scene shows at its first frame: `createEngine` resolves
|
|
55
|
+
* once the setup has run, and `engine.firstFrame` once the GPU has finished the first frame. The
|
|
56
|
+
* check then measures the first frames of play, a lighter preset applies in front of the viewer,
|
|
57
|
+
* and `engine.presetChecked` resolves once the check has ended. With `before-play`, the check
|
|
58
|
+
* measures the scene that the setup built before the sketch's update runs, and `createEngine`
|
|
59
|
+
* resolves after it, so a loading screen hides the check and any change of preset. A start that
|
|
60
|
+
* takes the stored result of an earlier check, or that runs no check, plays at once either way.
|
|
61
|
+
* Another value fails with E1213. The `?preset-check=` switch wins over it.
|
|
62
|
+
*/
|
|
63
|
+
presetCheck?: PresetCheckTiming;
|
|
51
64
|
/**
|
|
52
65
|
* Cap for the device pixel ratio, a number from 0.5 up. Without it, the quality preset sets the
|
|
53
66
|
* cap. `ctx.quality.set` changes it during play.
|
|
@@ -112,8 +125,8 @@ export interface EngineOptions {
|
|
|
112
125
|
* shaded once, for its nearest surface. It saves GPU time in scenes where objects hide many
|
|
113
126
|
* others and shading costs much, and costs a second pass over the objects' vertices. Without
|
|
114
127
|
* it, the quality preset decides: every preset draws the prepass on WebGL2, and none on WebGPU.
|
|
115
|
-
*
|
|
116
|
-
* switch wins over this option. Another value fails with E1213.
|
|
128
|
+
* A sketch can change it during play with `quality.set`, and the `?prepass=on` or
|
|
129
|
+
* `?prepass=off` switch wins over this option. Another value fails with E1213.
|
|
117
130
|
*/
|
|
118
131
|
depthPrepass?: boolean;
|
|
119
132
|
/**
|
|
@@ -175,7 +188,8 @@ export interface EngineOptions {
|
|
|
175
188
|
* one more copy of each image in memory. False frees each copy once no frame reads it, and such
|
|
176
189
|
* a texture draws with its color alone until the sketch gives it texels again. Without this
|
|
177
190
|
* option, a phone and a tablet keep copies and a desktop does not, because a phone or a tablet
|
|
178
|
-
* is likeliest to lose its GPU.
|
|
191
|
+
* is likeliest to lose its GPU. With copies, the engine also gives its GPU back while the browser
|
|
192
|
+
* keeps the page in its back/forward cache, and starts a new device when the page shows again.
|
|
179
193
|
*/
|
|
180
194
|
keepTextureCopies?: boolean;
|
|
181
195
|
/**
|
|
@@ -248,7 +262,9 @@ export interface EngineOptions {
|
|
|
248
262
|
* Called as the start reaches each stage, in this order: `core-download` as the engine core's
|
|
249
263
|
* file downloads, with the bytes that have arrived; `core` once the engine core is compiled and
|
|
250
264
|
* the GPU paths are tested; `sketch` once the sketch's setup has run; and `first-frame` once the
|
|
251
|
-
* GPU has finished the first frame.
|
|
265
|
+
* GPU has finished the first frame after the setup. The preset check does not hold up either
|
|
266
|
+
* stage, unless the `presetCheck` option is `before-play`: `sketch` then comes after the check
|
|
267
|
+
* too. Before `core`, `core-download` reports the core file's bytes,
|
|
252
268
|
* and `memory-wait` comes when the browser has refused the engine's memory for 10 seconds. The
|
|
253
269
|
* engine then tries for about 35 seconds more before it fails with E1109. `progress` gives a
|
|
254
270
|
* stage's figures while it has some: the bytes of a download, measured against the length that
|
|
@@ -323,8 +339,8 @@ export interface EngineOptions {
|
|
|
323
339
|
* lets light through to its other side,
|
|
324
340
|
* `'subsurface'` with the first material with a `subsurfaceRadius` while the subsurface blur has
|
|
325
341
|
* taps, `'coat_sheen'` with the first material with a clear coat or a sheen, `'weighted'` with
|
|
326
|
-
* the first material of the `weighted` blending, and `'occlusion'` with the first opaque
|
|
327
|
-
*
|
|
342
|
+
* the first material of the `weighted` blending, and `'occlusion'` with the first opaque
|
|
343
|
+
* material while GPU occlusion culling runs on WebGPU. WebGPU morphs in the skinning pass, so there
|
|
328
344
|
* `'morph'` loads the skinning shaders, and WebGL2 has no `'occlusion'` shaders to load. Listed
|
|
329
345
|
* features download beside the engine's own
|
|
330
346
|
* shaders, so the start waits only for the largest. The shaders that two or more listed features
|
|
@@ -460,16 +476,20 @@ export interface EngineMode {
|
|
|
460
476
|
/** The sketch time in seconds that hold mode holds the sketch at, or null for a live engine. */
|
|
461
477
|
hold: number | null;
|
|
462
478
|
/**
|
|
463
|
-
* The quality preset that the engine runs. The preset check can lower it
|
|
464
|
-
*
|
|
479
|
+
* The quality preset that the engine runs now. The preset check can lower it while it runs:
|
|
480
|
+
* during the first frames of play, or before `createEngine` resolves with the `presetCheck`
|
|
481
|
+
* option's `before-play`. `ctx.quality.setPreset` in the sketch changes it later. Once
|
|
482
|
+
* `engine.presetChecked` has resolved, it holds the preset that the check chose.
|
|
465
483
|
*/
|
|
466
484
|
preset: QualityPreset;
|
|
467
485
|
/**
|
|
468
|
-
* What the preset check measured, or null when no check ran
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
*
|
|
472
|
-
* its preset. `reused` is then true.
|
|
486
|
+
* What the preset check measured, or null while the check runs, and when no check ran or the
|
|
487
|
+
* sketch chose its own preset first. The engine checks the preset when it chose it from the
|
|
488
|
+
* device: after the first frame, it measures the frame rate of the scene, and lowers the preset
|
|
489
|
+
* until one holds the target. A later start of the sketch in the same browser on the same
|
|
490
|
+
* device takes the stored result instead, and starts at its preset. `reused` is then true. A
|
|
491
|
+
* start after a check that never ended starts at the preset that the check had lowered to, and
|
|
492
|
+
* its own check goes on from there, with the earlier rounds first.
|
|
473
493
|
*/
|
|
474
494
|
presetCheck: PresetCheck | null;
|
|
475
495
|
/**
|
|
@@ -519,10 +539,21 @@ export interface Engine {
|
|
|
519
539
|
/** How the engine runs on this device. */
|
|
520
540
|
readonly mode: EngineMode;
|
|
521
541
|
/**
|
|
522
|
-
* Resolves once the GPU has finished the first frame, so it is on screen: the
|
|
523
|
-
* a loading screen. It
|
|
542
|
+
* Resolves once the GPU has finished the first frame after the setup, so it is on screen: the
|
|
543
|
+
* moment to remove a loading screen. It rejects when the engine stops drawing first, with the
|
|
544
|
+
* failure that ended its frames, such as E1404 when the thread that draws fails at its first
|
|
545
|
+
* frame. A destroy before the first frame rejects it with E1420. A page that never waits for it
|
|
546
|
+
* gets no unhandled rejection.
|
|
524
547
|
*/
|
|
525
548
|
readonly firstFrame: Promise<void>;
|
|
549
|
+
/**
|
|
550
|
+
* Resolves once the preset check has ended, so `mode.preset` holds the preset that the check
|
|
551
|
+
* chose and `mode.presetCheck` what it measured. It has resolved when `createEngine` resolves
|
|
552
|
+
* where no check runs: for a preset that the page names, a stored result, Low, and hold mode,
|
|
553
|
+
* and with the `presetCheck` option's `before-play`. When the engine stops drawing first, it
|
|
554
|
+
* resolves then, and `mode.presetCheck` stays null.
|
|
555
|
+
*/
|
|
556
|
+
readonly presetChecked: Promise<void>;
|
|
526
557
|
/** The HTML elements that follow the labels the sketch tracks with `ui.trackLabel`. */
|
|
527
558
|
readonly labels: EngineLabels;
|
|
528
559
|
/**
|
|
@@ -549,11 +580,12 @@ export interface Engine {
|
|
|
549
580
|
* not carry on with a new device (E1302), or an engine thread failed (E1404). A custom shader's
|
|
550
581
|
* builds that a pipeline needs and that did not download fail the thread that draws with E1424.
|
|
551
582
|
* After E1404 or E1424 the engine draws no new frames: destroy it and start a new one. On WebGPU,
|
|
552
|
-
* the GPU can also run out of memory (E1304) or reject the engine's work (E1305)
|
|
553
|
-
*
|
|
554
|
-
*
|
|
555
|
-
*
|
|
556
|
-
*
|
|
583
|
+
* the GPU can also run out of memory (E1304) or reject the engine's work (E1305). On either GPU
|
|
584
|
+
* path, its driver can refuse to build a pipeline that draws objects of the scene twice (E1307).
|
|
585
|
+
* After these three the engine draws on without the objects that failed. The engine reports each
|
|
586
|
+
* failure once. A failure that no handler listened for when the engine reported it reaches the
|
|
587
|
+
* first handler that listens, so a failure that the app could not hear yet still arrives, and the
|
|
588
|
+
* engine also logs it to the console. A failure that ends the frames reaches these handlers before `onStop`'s. Returns a
|
|
557
589
|
* function that removes the handler.
|
|
558
590
|
*/
|
|
559
591
|
onFailure(handler: (error: EngineError) => void): () => void;
|
|
@@ -597,6 +629,16 @@ export interface Engine {
|
|
|
597
629
|
* whose interval broke that many milliseconds, each with the frame's own GPU parts.
|
|
598
630
|
*/
|
|
599
631
|
measure(seconds: number, options?: MeasureOptions): Promise<FrameMetrics>;
|
|
632
|
+
/**
|
|
633
|
+
* Runs an inspection call against the live scene, for the in-page inspector and the MCP server:
|
|
634
|
+
* `objects`, `object`, `setObject`, `setMaterial`, `stats`, `errors`, `graph`, `setQuality`,
|
|
635
|
+
* `highlight` and `info`, with the arguments that [Debugging](../../guides/debugging.md#the-in-page-inspector)
|
|
636
|
+
* lists. The call runs between frames, in the thread that runs the sketch, and its value is
|
|
637
|
+
* JSON-safe. The page answers `capture` itself, with `{ png, bytes }`: the PNG image of the next
|
|
638
|
+
* frame as base64 text, and its size in bytes. The method exists only in a development build, which is the build that carries the channel; a
|
|
639
|
+
* release build leaves it out, so code that uses it must check for it first.
|
|
640
|
+
*/
|
|
641
|
+
inspect?(call: string, args?: unknown): Promise<unknown>;
|
|
600
642
|
/**
|
|
601
643
|
* Shows an overlay of figures over the top-right corner of the canvas, or hides it with
|
|
602
644
|
* `false`: the GPU path, the frame rates, CPU time per frame of each thread, GPU time, draw
|
|
@@ -699,6 +741,13 @@ export interface Engine {
|
|
|
699
741
|
* the page to wait with no end.
|
|
700
742
|
*/
|
|
701
743
|
export declare const WORKER_REPLY_LIMIT_MS = 600000;
|
|
744
|
+
/**
|
|
745
|
+
* How long a copy of a worker whose script did not load may take to report its first reply. A
|
|
746
|
+
* script that loads reports in about a second on the slowest machines that run the tests, so a
|
|
747
|
+
* copy that has sent nothing by this time never ran: the page fails the start with E1405 rather
|
|
748
|
+
* than waiting for a worker that may never speak.
|
|
749
|
+
*/
|
|
750
|
+
export declare const RETRY_REPLY_MS = 10000;
|
|
702
751
|
interface TierChoice {
|
|
703
752
|
tier: Tier;
|
|
704
753
|
forceCompat: boolean;
|
|
@@ -724,9 +773,11 @@ interface WorkerEvents {
|
|
|
724
773
|
sketchError(error: Error): void;
|
|
725
774
|
/**
|
|
726
775
|
* A failure of a thread. It ends a start that is still under way, unless `endsStart` is false:
|
|
727
|
-
* the engine then runs on without the thread.
|
|
776
|
+
* the engine then runs on without the thread. It ends hold mode's read-back of its frame too,
|
|
777
|
+
* unless `endsHold` is false: the frames never needed the thread, such as a job worker that did
|
|
778
|
+
* not start.
|
|
728
779
|
*/
|
|
729
|
-
failure(error: EngineError, endsStart?: boolean): void;
|
|
780
|
+
failure(error: EngineError, endsStart?: boolean, endsHold?: boolean): void;
|
|
730
781
|
/** The quality preset and settings after a change, and the preset check's result. */
|
|
731
782
|
quality(update: QualityUpdate): void;
|
|
732
783
|
/** The sketch asked to show or hide the stats overlay, or to change its options. */
|
|
@@ -743,12 +794,15 @@ interface WorkerEvents {
|
|
|
743
794
|
recording?(bytes: Uint8Array): void;
|
|
744
795
|
/** What a replay gave, after the sketch thread ran the recording's frames. */
|
|
745
796
|
replay?(result: ReplayResult): void;
|
|
797
|
+
/** The pipeline list of the pipelines that the first frame built, which the page stores. */
|
|
798
|
+
pipelineList?(list: Uint32Array): void;
|
|
746
799
|
}
|
|
747
800
|
/**
|
|
748
|
-
* The error of a GPU that ran out of memory (E1304)
|
|
749
|
-
* as "the render
|
|
801
|
+
* The error of a GPU that ran out of memory (E1304), rejected a command (E1305), or whose driver
|
|
802
|
+
* could not build a pipeline of the scene's objects (E1307), on `thread`, such as "the render
|
|
803
|
+
* worker". `message` names the pipeline for E1307.
|
|
750
804
|
*/
|
|
751
|
-
export declare function gpuFailure(thread: string,
|
|
805
|
+
export declare function gpuFailure(thread: string, kind: GpuErrorKind, message: string): EngineError;
|
|
752
806
|
/**
|
|
753
807
|
* A worker whose replies are routed: events to the page's handlers, answers to the oldest request.
|
|
754
808
|
* A failure that a started worker reports, or that ends it, reaches the page as E1404, or with its
|
|
@@ -767,6 +821,12 @@ export declare class EngineWorker {
|
|
|
767
821
|
*/
|
|
768
822
|
private readonly restart?;
|
|
769
823
|
private readonly waiting;
|
|
824
|
+
/**
|
|
825
|
+
* The inspection calls that wait for their answers, by their id. A production build never makes
|
|
826
|
+
* one, so the map is made at the first call.
|
|
827
|
+
*/
|
|
828
|
+
private inspectWaiters;
|
|
829
|
+
private nextInspect;
|
|
770
830
|
private readyPromise;
|
|
771
831
|
private readonly stoppedPromise;
|
|
772
832
|
private worker;
|
|
@@ -780,6 +840,8 @@ export declare class EngineWorker {
|
|
|
780
840
|
private scriptLoaded;
|
|
781
841
|
/** True once the page replaced a worker whose script did not load. */
|
|
782
842
|
private retried;
|
|
843
|
+
/** Clears the wait for the replacement worker's first reply, or undefined once it has one. */
|
|
844
|
+
private retryTimer;
|
|
783
845
|
/**
|
|
784
846
|
* The messages that the page sent before the worker reported that its script loaded. A worker
|
|
785
847
|
* that has not run its script cannot take them, so they wait here: a copy that replaces a
|
|
@@ -810,6 +872,14 @@ export declare class EngineWorker {
|
|
|
810
872
|
* shows which file failed.
|
|
811
873
|
*/
|
|
812
874
|
private startFailure;
|
|
875
|
+
/**
|
|
876
|
+
* What the page reports when the copy that replaced a worker whose script did not load has sent
|
|
877
|
+
* nothing within the wait. The first failure named the script; the copy's silence names it too,
|
|
878
|
+
* so a wrong path stays visible and a stall is not read as a wrong path.
|
|
879
|
+
*/
|
|
880
|
+
private stalledFailure;
|
|
881
|
+
/** Ends the wait for a replacement worker's first reply, once one arrives or the worker fails. */
|
|
882
|
+
private heardReply;
|
|
813
883
|
/**
|
|
814
884
|
* Drops the handlers that reach this engine, so a worker that the page keeps, such as a drawing
|
|
815
885
|
* worker parked with its canvas, holds none of the engine or its shared memory alive.
|
|
@@ -845,6 +915,13 @@ export declare class EngineWorker {
|
|
|
845
915
|
stopped(): Promise<void>;
|
|
846
916
|
/** Stops the worker, and fails each request that still waits for its answer. */
|
|
847
917
|
terminate(): void;
|
|
918
|
+
/**
|
|
919
|
+
* Runs a development build's inspection call in this worker, and waits for its answer. The
|
|
920
|
+
* worker answers with the value of the call, or why it failed.
|
|
921
|
+
*/
|
|
922
|
+
inspect(call: string, args?: unknown): Promise<unknown>;
|
|
923
|
+
/** Gives an inspection call its answer. */
|
|
924
|
+
private answerInspect;
|
|
848
925
|
/**
|
|
849
926
|
* Sends a request and waits for the worker's answer, which ends with a failure once the answer
|
|
850
927
|
* has taken longer than the wait's limit. The request keeps its place in the queue, so an answer
|