@null3d/engine 0.0.0 → 0.1.1
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 +25 -10
- package/dist/wasm/single/null3d_bg.wasm +0 -0
- package/dist/wasm/threaded/null3d.js +25 -10
- package/dist/wasm/threaded/null3d_bg.wasm +0 -0
- package/docs/api/animation.md +114 -86
- package/docs/api/assets.md +135 -49
- package/docs/api/cameras.md +45 -12
- package/docs/api/controls.md +88 -62
- package/docs/api/debug.md +116 -41
- package/docs/api/engine.md +117 -35
- package/docs/api/feature-draws.md +23 -17
- package/docs/api/feature-effects.md +11 -11
- package/docs/api/feature-instances.md +70 -19
- package/docs/api/features.md +77 -47
- package/docs/api/geometry.md +132 -82
- package/docs/api/grass.md +55 -13
- package/docs/api/impostors.md +175 -22
- package/docs/api/input.md +24 -18
- package/docs/api/lights.md +78 -51
- package/docs/api/lines.md +41 -33
- package/docs/api/materials.md +248 -121
- package/docs/api/math.md +12 -13
- package/docs/api/objects.md +47 -22
- package/docs/api/page.md +58 -7
- package/docs/api/particles.md +33 -20
- package/docs/api/points.md +19 -31
- package/docs/api/post.md +75 -42
- package/docs/api/quality.md +42 -17
- package/docs/api/raycast.md +65 -51
- package/docs/api/reference/animation.md +10 -11
- package/docs/api/reference/assets.md +25 -22
- package/docs/api/reference/cameras.md +8 -4
- package/docs/api/reference/controls.md +134 -25
- package/docs/api/reference/debug.md +81 -14
- package/docs/api/reference/engine.md +58 -17
- package/docs/api/reference/feature-draws.md +3 -4
- package/docs/api/reference/feature-effects.md +2 -3
- package/docs/api/reference/feature-instances.md +5 -4
- package/docs/api/reference/features.md +7 -4
- package/docs/api/reference/geometry.md +287 -97
- package/docs/api/reference/grass.md +63 -3
- package/docs/api/reference/impostors.md +208 -13
- package/docs/api/reference/input.md +4 -5
- package/docs/api/reference/lights.md +13 -12
- package/docs/api/reference/lines.md +10 -11
- package/docs/api/reference/materials.md +54 -53
- package/docs/api/reference/math.md +35 -24
- package/docs/api/reference/objects.md +11 -12
- package/docs/api/reference/particles.md +31 -6
- package/docs/api/reference/points.md +6 -7
- package/docs/api/reference/post.md +21 -20
- package/docs/api/reference/quality.md +8 -5
- package/docs/api/reference/raycast.md +7 -8
- package/docs/api/reference/render.md +5 -4
- package/docs/api/reference/scene.md +52 -30
- package/docs/api/reference/sketch.md +15 -11
- package/docs/api/reference/sound.md +234 -0
- package/docs/api/reference/splats.md +42 -3
- package/docs/api/reference/sprites.md +7 -8
- package/docs/api/reference/tasks.md +16 -3
- package/docs/api/reference/terrain.md +27 -5
- package/docs/api/reference/textures.md +5 -6
- package/docs/api/reference/three-compat.md +18 -7
- package/docs/api/reference/time.md +1 -2
- package/docs/api/reference/ui.md +12 -9
- package/docs/api/reference/vertex-draws.md +5 -6
- package/docs/api/reference/water.md +153 -9
- package/docs/api/reference/wind.md +17 -4
- package/docs/api/render.md +73 -29
- package/docs/api/scene.md +164 -60
- package/docs/api/sketch.md +102 -15
- package/docs/api/sound.md +205 -0
- package/docs/api/splats.md +46 -12
- package/docs/api/sprites.md +10 -24
- package/docs/api/tasks.md +33 -24
- package/docs/api/terrain.md +42 -22
- package/docs/api/textures.md +68 -19
- package/docs/api/three-compat.md +15 -7
- package/docs/api/time.md +3 -5
- package/docs/api/ui.md +19 -23
- package/docs/api/vertex-draws.md +13 -12
- package/docs/api/water.md +262 -35
- package/docs/api/wind.md +63 -17
- package/docs/cli/null3d.md +177 -27
- package/docs/concepts/architecture.md +73 -27
- package/docs/concepts/assets.md +57 -33
- package/docs/concepts/backends.md +69 -27
- package/docs/concepts/color-management.md +54 -36
- package/docs/concepts/culling.md +68 -47
- package/docs/concepts/handles.md +14 -5
- package/docs/concepts/instances.md +74 -25
- package/docs/concepts/large-worlds.md +18 -8
- package/docs/concepts/lighting.md +155 -87
- package/docs/concepts/lod.md +126 -44
- package/docs/concepts/materials.md +58 -27
- package/docs/concepts/particle-buffer.md +48 -35
- package/docs/concepts/post-processing.md +84 -43
- package/docs/concepts/quality-preset-tables.md +56 -52
- package/docs/concepts/quality-presets.md +164 -52
- package/docs/concepts/render-graph.md +69 -29
- package/docs/concepts/render-layers.md +11 -21
- package/docs/concepts/shadows.md +105 -52
- package/docs/concepts/static-dynamic.md +22 -7
- package/docs/cookbook/index.md +164 -120
- package/docs/data/threejs-mapping.json +362 -367
- package/docs/errors/E1101.md +23 -5
- package/docs/errors/E1102.md +11 -3
- package/docs/errors/E1103.md +11 -3
- package/docs/errors/E1104.md +11 -3
- package/docs/errors/E1105.md +13 -5
- package/docs/errors/E1106.md +11 -3
- package/docs/errors/E1107.md +15 -5
- package/docs/errors/E1108.md +11 -3
- package/docs/errors/E1109.md +32 -6
- package/docs/errors/E1110.md +23 -5
- package/docs/errors/E1111.md +11 -3
- package/docs/errors/E1112.md +11 -3
- package/docs/errors/E1203.md +12 -4
- package/docs/errors/E1204.md +11 -3
- package/docs/errors/E1205.md +11 -3
- package/docs/errors/E1206.md +28 -6
- package/docs/errors/E1207.md +11 -3
- package/docs/errors/E1208.md +12 -3
- package/docs/errors/E1209.md +11 -3
- package/docs/errors/E1213.md +27 -5
- package/docs/errors/E1214.md +14 -6
- package/docs/errors/E1215.md +31 -6
- package/docs/errors/E1216.md +31 -6
- package/docs/errors/E1217.md +29 -6
- package/docs/errors/E1218.md +22 -6
- package/docs/errors/E1219.md +11 -3
- package/docs/errors/E1220.md +24 -5
- package/docs/errors/E1221.md +24 -5
- package/docs/errors/E1222.md +11 -3
- package/docs/errors/E1223.md +39 -6
- package/docs/errors/E1224.md +11 -3
- package/docs/errors/E1225.md +11 -3
- package/docs/errors/E1301.md +11 -3
- package/docs/errors/E1302.md +11 -3
- package/docs/errors/E1303.md +11 -3
- package/docs/errors/E1304.md +11 -3
- package/docs/errors/E1305.md +13 -3
- package/docs/errors/E1306.md +11 -3
- package/docs/errors/E1307.md +40 -0
- package/docs/errors/E1401.md +11 -3
- package/docs/errors/E1402.md +13 -5
- package/docs/errors/E1403.md +11 -3
- package/docs/errors/E1404.md +13 -3
- package/docs/errors/E1405.md +15 -4
- package/docs/errors/E1406.md +31 -5
- package/docs/errors/E1407.md +11 -3
- package/docs/errors/E1408.md +11 -3
- package/docs/errors/E1409.md +11 -3
- package/docs/errors/E1410.md +13 -5
- package/docs/errors/E1411.md +11 -3
- package/docs/errors/E1412.md +29 -6
- package/docs/errors/E1413.md +11 -3
- package/docs/errors/E1414.md +11 -3
- package/docs/errors/E1415.md +11 -3
- package/docs/errors/E1416.md +27 -6
- package/docs/errors/E1417.md +11 -3
- package/docs/errors/E1418.md +12 -3
- package/docs/errors/E1419.md +13 -5
- package/docs/errors/E1420.md +14 -6
- package/docs/errors/E1421.md +11 -3
- package/docs/errors/E1422.md +12 -3
- package/docs/errors/E1423.md +12 -3
- package/docs/errors/E1424.md +24 -5
- package/docs/errors/E1425.md +11 -3
- package/docs/errors/E1426.md +11 -3
- package/docs/errors/E1430.md +11 -3
- package/docs/errors/E1431.md +11 -3
- package/docs/errors/E1432.md +11 -3
- package/docs/errors/E1433.md +11 -3
- package/docs/errors/E1434.md +15 -6
- package/docs/errors/E1435.md +11 -3
- package/docs/errors/E1436.md +11 -3
- package/docs/errors/E1437.md +14 -6
- package/docs/errors/E1501.md +41 -6
- package/docs/errors/E1502.md +13 -3
- package/docs/errors/E1503.md +11 -3
- package/docs/errors/E1504.md +11 -3
- package/docs/errors/E1505.md +23 -5
- package/docs/errors/E1506.md +11 -3
- package/docs/errors/index.md +54 -30
- package/docs/getting-started/cdn.md +32 -10
- package/docs/getting-started/first-scene.md +21 -13
- package/docs/getting-started/hosting.md +152 -63
- package/docs/getting-started/install.md +44 -28
- package/docs/getting-started/network-use.md +33 -15
- package/docs/getting-started/project-structure.md +33 -12
- package/docs/getting-started/third-party-notices.md +12 -14
- package/docs/guides/accessibility.md +5 -5
- package/docs/guides/add-ons.md +86 -15
- package/docs/guides/agents.md +16 -9
- package/docs/guides/assets-pipeline.md +259 -82
- package/docs/guides/audio.md +115 -128
- package/docs/guides/baked-light-data.md +44 -23
- package/docs/guides/car-paint.md +38 -32
- package/docs/guides/content-pages.md +63 -35
- package/docs/guides/custom-passes.md +65 -22
- package/docs/guides/custom-shaders.md +59 -39
- package/docs/guides/debugging.md +74 -10
- package/docs/guides/deploying.md +85 -6
- package/docs/guides/deterministic-simulation.md +24 -17
- package/docs/guides/first-use-shaders.md +83 -45
- package/docs/guides/lens-kit.md +29 -26
- package/docs/guides/loading-screens.md +132 -47
- package/docs/guides/multiple-views.md +63 -13
- package/docs/guides/performance.md +192 -38
- package/docs/guides/phones.md +78 -15
- package/docs/guides/physics.md +7 -11
- package/docs/guides/screens.md +47 -33
- package/docs/guides/start-time.md +363 -0
- package/docs/guides/testing.md +152 -95
- package/docs/guides/ui-overlays.md +19 -14
- package/docs/guides/video-textures.md +14 -13
- package/docs/images/api/animation/character.webp +0 -0
- package/docs/images/api/animation/look-at-ring.webp +0 -0
- package/docs/images/api/animation/morph-tulips.webp +0 -0
- package/docs/images/api/animation/skeleton-lines.webp +0 -0
- package/docs/images/api/controls/gizmo-handles.webp +0 -0
- package/docs/images/api/controls/walk-and-fly.webp +0 -0
- package/docs/images/api/debug/debug-shapes.webp +0 -0
- package/docs/images/api/debug/levels-view.webp +0 -0
- package/docs/images/api/engine/transparent-canvas.webp +0 -0
- package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
- package/docs/images/api/feature-instances/compute-instances.webp +0 -0
- package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
- package/docs/images/api/geometry/extra-shapes.webp +0 -0
- package/docs/images/api/geometry/generators.webp +0 -0
- package/docs/images/api/geometry/mesh-arrays.webp +0 -0
- package/docs/images/api/geometry/vertex-updates.webp +0 -0
- package/docs/images/api/grass/grass-grove.webp +0 -0
- package/docs/images/api/grass/grass-presets.webp +0 -0
- package/docs/images/api/grass/grass-shadow.webp +0 -0
- package/docs/images/api/impostors/impostor-handover.webp +0 -0
- package/docs/images/api/impostors/impostor-shadow.webp +0 -0
- package/docs/images/api/impostors/impostors-forest.webp +0 -0
- package/docs/images/api/lights/spot-cookies.webp +0 -0
- package/docs/images/api/lines/lines-lit.webp +0 -0
- package/docs/images/api/lines/lines-widths.webp +0 -0
- package/docs/images/api/materials/coat-and-sheen.webp +0 -0
- package/docs/images/api/materials/decals.webp +0 -0
- package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
- package/docs/images/api/materials/relief.webp +0 -0
- package/docs/images/api/materials/shader-inputs.webp +0 -0
- package/docs/images/api/materials/standard-grid.webp +0 -0
- package/docs/images/api/materials/subsurface.webp +0 -0
- package/docs/images/api/materials/translucency.webp +0 -0
- package/docs/images/api/objects/objects-turntable.webp +0 -0
- package/docs/images/api/particles/campfire.webp +0 -0
- package/docs/images/api/points/galaxy.webp +0 -0
- package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
- package/docs/images/api/render/fullscreen-glow.webp +0 -0
- package/docs/images/api/render/reflection-mirror.webp +0 -0
- package/docs/images/api/render/security-camera.webp +0 -0
- package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
- package/docs/images/api/sound/sound-demo.webp +0 -0
- package/docs/images/api/splats/splats-demo.webp +0 -0
- package/docs/images/api/sprites/sprites-lines.webp +0 -0
- package/docs/images/api/terrain/terrain-demo.webp +0 -0
- package/docs/images/api/textures/canvas-screen.webp +0 -0
- package/docs/images/api/textures/mipmaps.webp +0 -0
- package/docs/images/api/vertex-draws/rain.webp +0 -0
- package/docs/images/api/water/ocean.webp +0 -0
- package/docs/images/api/water/water-demo.webp +0 -0
- package/docs/images/api/water/water-rain.webp +0 -0
- package/docs/images/api/water/waterfall.webp +0 -0
- package/docs/images/concepts/assets/gltf-model.webp +0 -0
- package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
- package/docs/images/concepts/culling/far-from-origin.webp +0 -0
- package/docs/images/concepts/instances/instances.webp +0 -0
- package/docs/images/concepts/instances/per-row-colors.webp +0 -0
- package/docs/images/concepts/large-worlds/large-world.webp +0 -0
- package/docs/images/concepts/lighting/area-lights.webp +0 -0
- package/docs/images/concepts/lighting/atmosphere.webp +0 -0
- package/docs/images/concepts/lighting/environment.webp +0 -0
- package/docs/images/concepts/lighting/light-shafts.webp +0 -0
- package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
- package/docs/images/concepts/lod/forest.webp +0 -0
- package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
- package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
- package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
- package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
- package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
- package/docs/images/concepts/post-processing/sharpen.webp +0 -0
- package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
- package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
- package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
- package/docs/images/cookbook/index/picking.webp +0 -0
- package/docs/images/cookbook/index/time-of-day.webp +0 -0
- package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
- package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
- package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
- package/docs/images/guides/multiple-views/split-screen.webp +0 -0
- package/docs/images/guides/performance/overdraw-view.webp +0 -0
- package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
- package/docs/images/index/showcase-island.webp +0 -0
- package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
- package/docs/images/shaders/builtins/builtins.webp +0 -0
- package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
- package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
- package/docs/images/shots.json +2231 -0
- package/docs/index.md +18 -23
- package/docs/moves.json +1 -0
- package/docs/nav.json +300 -0
- package/docs/pages.md +230 -209
- package/docs/porting/react-three-fiber.md +225 -6
- package/docs/porting/threejs-loop-and-threads.md +217 -7
- package/docs/porting/threejs-mapping.md +1249 -233
- package/docs/porting/threejs-materials.md +218 -6
- package/docs/porting/threejs-overview.md +240 -7
- package/docs/porting/threejs-postprocessing.md +4 -8
- package/docs/porting/threejs-shaders.md +301 -6
- package/docs/porting/threejs-unsupported.md +83 -7
- package/docs/porting/verification.md +178 -6
- package/docs/shaders/builtins.md +15 -4
- package/docs/shaders/library.md +72 -45
- package/docs/shaders/surface-functions.md +59 -23
- package/docs/shaders/wgsl-rules.md +12 -5
- package/lib/debug/channel.d.ts +103 -0
- package/lib/debug/channel.js +269 -0
- package/lib/debug/debug.d.ts +11 -9
- package/lib/debug/draw.d.ts +11 -2
- package/lib/debug/draw.js +57 -6
- package/lib/debug/inspector.d.ts +60 -0
- package/lib/debug/inspector.js +475 -0
- package/lib/debug/overlay-look.d.ts +6 -0
- package/lib/debug/overlay-look.js +29 -7
- package/lib/debug/overlay.js +15 -11
- package/lib/debug/stats-options.d.ts +13 -0
- package/lib/debug/stats-panel.d.ts +22 -7
- package/lib/debug/stats-panel.js +80 -13
- package/lib/debug/stats.d.ts +2 -3
- package/lib/errors/codes.d.ts +17 -3
- package/lib/errors/codes.js +117 -105
- package/lib/errors/engine-error.js +25 -10
- package/lib/errors/fixes.d.ts +1 -0
- package/lib/errors/fixes.js +20 -19
- 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/variants.d.ts +8 -2
- package/lib/gpu/variants.js +39 -7
- 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 +5 -2
- 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 +28 -14
- package/lib/index.d.ts +7 -5
- 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 +8 -8
- 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 +117 -31
- package/lib/page/engine.js +438 -99
- 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 +26 -14
- 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/stats-switch.js +2 -0
- package/lib/page/switches.d.ts +38 -6
- package/lib/page/switches.js +29 -5
- 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/baked-light.d.ts +2 -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 +3 -3
- package/lib/scene/fog.d.ts +11 -4
- package/lib/scene/fog.js +8 -2
- package/lib/scene/frame-cameras.d.ts +35 -4
- package/lib/scene/frame-cameras.js +86 -10
- package/lib/scene/gltf.d.ts +33 -3
- 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 +121 -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/particles.d.ts +7 -3
- package/lib/scene/particles.js +3 -1
- package/lib/scene/picks.d.ts +2 -2
- package/lib/scene/pointer-events.d.ts +4 -7
- package/lib/scene/post.d.ts +39 -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 +238 -261
- package/lib/scene/resources.js +179 -81
- package/lib/scene/scene.d.ts +167 -120
- package/lib/scene/scene.js +243 -103
- 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 +11 -7
- package/lib/scene/time-of-day.js +11 -8
- 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/labels.d.ts +5 -2
- package/lib/shared/labels.js +5 -2
- package/lib/shared/metrics.d.ts +38 -0
- package/lib/shared/metrics.js +62 -1
- package/lib/shared/permutation-words.d.ts +2 -0
- package/lib/shared/permutation-words.js +8 -0
- package/lib/shared/recording.d.ts +13 -5
- package/lib/shared/recording.js +31 -10
- package/lib/shared/run-task.js +7 -1
- package/lib/shared/sketch-data.d.ts +9 -0
- package/lib/shared/sketch-data.js +57 -0
- 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 +51 -7
- package/lib/sketch/define-sketch.js +2 -1
- 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 +80 -9
- package/lib/sketch/runner.js +390 -52
- package/lib/sketch/ui.d.ts +5 -8
- package/lib/sketch/ui.js +4 -2
- package/lib/stats.d.ts +1 -0
- package/lib/workers/probe-worker.d.ts +5 -0
- package/lib/workers/probe-worker.js +13 -4
- package/lib/workers/protocol.d.ts +71 -13
- package/lib/workers/protocol.js +4 -0
- package/lib/workers/render-worker.js +29 -5
- package/lib/workers/sketch-worker.js +108 -16
- package/package.json +2 -2
package/lib/page/capabilities.js
CHANGED
|
@@ -293,12 +293,12 @@ function probeWebGL2(powerPreference, multiDraw = true) {
|
|
|
293
293
|
*/
|
|
294
294
|
const WORKER_PROBE_TIMEOUTS_MS = [5000, 10_000];
|
|
295
295
|
/**
|
|
296
|
-
* Runs the probe worker, with each of `timeoutsMs` in turn
|
|
297
|
-
* answer. A worker that fails to start is not tried again.
|
|
296
|
+
* Runs the probe worker on the GPU that `powerPreference` picks, with each of `timeoutsMs` in turn
|
|
297
|
+
* as its time limit while it gives no answer. A worker that fails to start is not tried again.
|
|
298
298
|
*/
|
|
299
|
-
export async function probeWorker(timeoutsMs = WORKER_PROBE_TIMEOUTS_MS) {
|
|
299
|
+
export async function probeWorker(timeoutsMs = WORKER_PROBE_TIMEOUTS_MS, powerPreference) {
|
|
300
300
|
for (const timeoutMs of timeoutsMs) {
|
|
301
|
-
const result = await probeWorkerOnce(timeoutMs);
|
|
301
|
+
const result = await probeWorkerOnce(timeoutMs, powerPreference);
|
|
302
302
|
if (!('failure' in result) || result.failure !== 'no-answer')
|
|
303
303
|
return result;
|
|
304
304
|
}
|
|
@@ -309,34 +309,39 @@ export async function probeWorker(timeoutsMs = WORKER_PROBE_TIMEOUTS_MS) {
|
|
|
309
309
|
};
|
|
310
310
|
}
|
|
311
311
|
/**
|
|
312
|
-
* The probe worker's
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
* so one full answer serves every later start
|
|
312
|
+
* The probe worker's answers that the page's engine starts share, by the power preference that
|
|
313
|
+
* picked the GPU they tested. Firefox makes a new WebGL2 context wait for the WebGL work that other
|
|
314
|
+
* contexts have queued, such as a shader link. On a software renderer an engine's links take
|
|
315
|
+
* seconds, so a start's probe can outlast its time limits while another engine on the page starts.
|
|
316
|
+
* A worker's abilities hold for the page's life, so one full answer serves every later start on
|
|
317
|
+
* the same GPU. A failure is not kept.
|
|
317
318
|
*/
|
|
318
|
-
|
|
319
|
+
const pageProbes = new Map();
|
|
319
320
|
/**
|
|
320
|
-
* The probe worker's answer for the page
|
|
321
|
-
* or a new probe's, with `timeoutsMs` as its time limits.
|
|
321
|
+
* The probe worker's answer for the page on the GPU that `powerPreference` picks: the kept answer,
|
|
322
|
+
* the answer of a probe that is running, or a new probe's, with `timeoutsMs` as its time limits.
|
|
322
323
|
*/
|
|
323
|
-
export function pageWorkerProbe(timeoutsMs = WORKER_PROBE_TIMEOUTS_MS) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
324
|
+
export function pageWorkerProbe(timeoutsMs = WORKER_PROBE_TIMEOUTS_MS, powerPreference) {
|
|
325
|
+
const kept = pageProbes.get(powerPreference);
|
|
326
|
+
if (kept)
|
|
327
|
+
return kept;
|
|
328
|
+
const probe = probeWorker(timeoutsMs, powerPreference);
|
|
329
|
+
pageProbes.set(powerPreference, probe);
|
|
328
330
|
void probe.then((result) => {
|
|
329
|
-
if ('failure' in result &&
|
|
330
|
-
|
|
331
|
+
if ('failure' in result && pageProbes.get(powerPreference) === probe)
|
|
332
|
+
pageProbes.delete(powerPreference);
|
|
331
333
|
});
|
|
332
334
|
return probe;
|
|
333
335
|
}
|
|
334
|
-
/** Drops the kept
|
|
336
|
+
/** Drops the kept answers, as after a lost GPU, so that the next start probes again. */
|
|
335
337
|
export function forgetWorkerProbe() {
|
|
336
|
-
|
|
338
|
+
pageProbes.clear();
|
|
337
339
|
}
|
|
338
|
-
/**
|
|
339
|
-
|
|
340
|
+
/**
|
|
341
|
+
* Runs one probe worker on the GPU that `powerPreference` picks, which must answer within
|
|
342
|
+
* `timeoutMs` of its script's start.
|
|
343
|
+
*/
|
|
344
|
+
function probeWorkerOnce(timeoutMs, powerPreference) {
|
|
340
345
|
return new Promise((resolve) => {
|
|
341
346
|
let worker;
|
|
342
347
|
try {
|
|
@@ -364,6 +369,8 @@ function probeWorkerOnce(timeoutMs) {
|
|
|
364
369
|
failure: 'failed-to-start',
|
|
365
370
|
error: message || 'the probe worker failed to start',
|
|
366
371
|
}));
|
|
372
|
+
// The worker reads this once its script runs, and probes then.
|
|
373
|
+
worker.postMessage({ powerPreference });
|
|
367
374
|
});
|
|
368
375
|
}
|
|
369
376
|
/**
|
|
@@ -372,7 +379,14 @@ function probeWorkerOnce(timeoutMs) {
|
|
|
372
379
|
* reports WebGL2 without `WEBGL_multi_draw`, as the ?multidraw=off switch asks.
|
|
373
380
|
*/
|
|
374
381
|
export async function probeCapabilities(powerPreference, hints = readDeviceHints(), multiDraw = true) {
|
|
375
|
-
const
|
|
382
|
+
const pending = Promise.all([
|
|
383
|
+
probeWebGPU(powerPreference),
|
|
384
|
+
pageWorkerProbe(WORKER_PROBE_TIMEOUTS_MS, powerPreference),
|
|
385
|
+
]);
|
|
386
|
+
// The WebGL2 test blocks this thread, so it runs while the adapter request and the probe worker
|
|
387
|
+
// are under way.
|
|
388
|
+
const webgl2 = probeWebGL2(powerPreference, multiDraw);
|
|
389
|
+
const [webgpu, worker] = await pending;
|
|
376
390
|
// The probe worker measures the draw paths on a device of its own, which the render worker's
|
|
377
391
|
// device answers the same way for the browser and the driver.
|
|
378
392
|
const probed = 'directDraws' in worker && webgpu.available;
|
|
@@ -389,7 +403,7 @@ export async function probeCapabilities(powerPreference, hints = readDeviceHints
|
|
|
389
403
|
transferControlToOffscreen: typeof HTMLCanvasElement === 'function' &&
|
|
390
404
|
'transferControlToOffscreen' in HTMLCanvasElement.prototype,
|
|
391
405
|
webgpu: { ...webgpu, directDraws, drawPath },
|
|
392
|
-
webgl2
|
|
406
|
+
webgl2,
|
|
393
407
|
worker,
|
|
394
408
|
};
|
|
395
409
|
}
|
|
@@ -9,6 +9,16 @@ export declare const STORED_CHECK_MS: number;
|
|
|
9
9
|
* larger canvas has more pixels to fill, and a smaller one may hold a heavier preset.
|
|
10
10
|
*/
|
|
11
11
|
export declare const STORED_CHECK_AREA_RATIO = 1.25;
|
|
12
|
+
/**
|
|
13
|
+
* True when a check's rounds end it: its last round held the target, or measured Low, which has no
|
|
14
|
+
* lighter preset. A check that lowered the preset after its last round has not ended.
|
|
15
|
+
*/
|
|
16
|
+
export declare function checkEnded(check: Pick<PresetCheck, 'targetFps' | 'rounds'>): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The preset that a check's rounds leave the engine at: the last round's preset when the check
|
|
19
|
+
* ended there, or else the one that the check lowered to after the last round missed its target.
|
|
20
|
+
*/
|
|
21
|
+
export declare function checkedPreset(check: Pick<PresetCheck, 'from' | 'targetFps' | 'rounds'>): QualityPreset;
|
|
12
22
|
/**
|
|
13
23
|
* The facts that a check's result depends on, apart from the canvas size, as one text: the check's
|
|
14
24
|
* rules, the GPU path and the preset that the check starts from, the frame rate cap, the highest
|
|
@@ -18,7 +28,8 @@ export declare const STORED_CHECK_AREA_RATIO = 1.25;
|
|
|
18
28
|
export declare function checkConditions(report: CapabilityReport, tier: Tier, from: QualityPreset, fps: number | undefined, maxTargetFps: number): string;
|
|
19
29
|
/**
|
|
20
30
|
* The stored result that applies to a start under `conditions` with a canvas of `area` CSS
|
|
21
|
-
* pixels at `now`, as a reused check, or undefined when none does.
|
|
31
|
+
* pixels at `now`, as a reused check, or undefined when none does. A check that has not ended
|
|
32
|
+
* gives its rounds so far, which the start's own check goes on from (`checkEnded`).
|
|
22
33
|
*/
|
|
23
34
|
export declare function reusableCheck(text: string | null, conditions: string, area: number, now: number): PresetCheck | undefined;
|
|
24
35
|
/** The stored preset check of one sketch, for one start of it. */
|
|
@@ -35,7 +46,8 @@ export declare class CheckStore {
|
|
|
35
46
|
/** The stored result that applies to this start, or undefined. */
|
|
36
47
|
read(now?: number): PresetCheck | undefined;
|
|
37
48
|
/**
|
|
38
|
-
* Stores
|
|
49
|
+
* Stores what a check of this start measured: its result once it ended, and its rounds so far
|
|
50
|
+
* each time it lowers the preset. It stores them when they were measured against at least the
|
|
39
51
|
* target that the check starts from under the highest target `maxTargetFps`.
|
|
40
52
|
*/
|
|
41
53
|
save(check: PresetCheck, maxTargetFps: number, now?: number): void;
|
package/lib/page/check-store.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
// The stored preset check: the result of each sketch's last preset check, kept in the page's
|
|
2
2
|
// localStorage, so that a later start of the sketch in the same browser on the same device takes
|
|
3
3
|
// the checked preset without measuring again. On a tablet the check takes about a second for each
|
|
4
|
-
// preset that it measures
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
// preset that it measures. A stored result applies only to a start that would check the same
|
|
5
|
+
// preset with the same rules, on a GPU and display that report the same facts, at a canvas size
|
|
6
|
+
// close to the measured one, within a week of the measurement. The store also keeps the rounds of
|
|
7
|
+
// a check that has not ended yet, each time the check lowers the preset, so a page that closes
|
|
8
|
+
// during the check loses no round: the next start begins at the lighter preset, and its own check
|
|
9
|
+
// goes on from there. A result measured against a target below the one that the engine starts
|
|
10
|
+
// from, as on a display in a power-saving mode, is not stored. The highest target that the page
|
|
11
|
+
// allows is one of the facts, so a result never applies to a start that defends another rate.
|
|
12
|
+
// Storage that cannot be read or written counts as empty. The GPU's names only tell one GPU from
|
|
13
|
+
// another here; the engine never decides anything from what they say.
|
|
14
|
+
import { CHECK_GRACE_MS, CHECK_HOLD_SHARE, CHECK_MAX_FPS, CHECK_UPLOAD_WAIT_MS, CHECK_WINDOW_MS, checkTargetFps, holdsTarget, } from '../quality/check.js';
|
|
15
|
+
import { presetAfterMiss, QUALITY_PRESETS } from '../quality/presets.js';
|
|
13
16
|
import { pageStorage } from './start-marker.js';
|
|
14
17
|
/** How long a stored check result applies, in ms: a week. */
|
|
15
18
|
export const STORED_CHECK_MS = 7 * 24 * 60 * 60 * 1000;
|
|
@@ -19,6 +22,24 @@ export const STORED_CHECK_MS = 7 * 24 * 60 * 60 * 1000;
|
|
|
19
22
|
*/
|
|
20
23
|
export const STORED_CHECK_AREA_RATIO = 1.25;
|
|
21
24
|
const KEY_PREFIX = 'null3d.check:';
|
|
25
|
+
/**
|
|
26
|
+
* True when a check's rounds end it: its last round held the target, or measured Low, which has no
|
|
27
|
+
* lighter preset. A check that lowered the preset after its last round has not ended.
|
|
28
|
+
*/
|
|
29
|
+
export function checkEnded(check) {
|
|
30
|
+
const last = check.rounds.at(-1);
|
|
31
|
+
return last !== undefined && (last.preset === 'low' || holdsTarget(last, check.targetFps));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The preset that a check's rounds leave the engine at: the last round's preset when the check
|
|
35
|
+
* ended there, or else the one that the check lowered to after the last round missed its target.
|
|
36
|
+
*/
|
|
37
|
+
export function checkedPreset(check) {
|
|
38
|
+
const last = check.rounds.at(-1);
|
|
39
|
+
if (!last)
|
|
40
|
+
return check.from;
|
|
41
|
+
return checkEnded(check) ? last.preset : presetAfterMiss(last, check.targetFps);
|
|
42
|
+
}
|
|
22
43
|
const isPreset = (value) => QUALITY_PRESETS.includes(value);
|
|
23
44
|
const isRound = (round) => round !== null &&
|
|
24
45
|
isPreset(round.preset) &&
|
|
@@ -81,7 +102,8 @@ export function checkConditions(report, tier, from, fps, maxTargetFps) {
|
|
|
81
102
|
}
|
|
82
103
|
/**
|
|
83
104
|
* The stored result that applies to a start under `conditions` with a canvas of `area` CSS
|
|
84
|
-
* pixels at `now`, as a reused check, or undefined when none does.
|
|
105
|
+
* pixels at `now`, as a reused check, or undefined when none does. A check that has not ended
|
|
106
|
+
* gives its rounds so far, which the start's own check goes on from (`checkEnded`).
|
|
85
107
|
*/
|
|
86
108
|
export function reusableCheck(text, conditions, area, now) {
|
|
87
109
|
const stored = parseStored(text);
|
|
@@ -123,7 +145,8 @@ export class CheckStore {
|
|
|
123
145
|
}
|
|
124
146
|
}
|
|
125
147
|
/**
|
|
126
|
-
* Stores
|
|
148
|
+
* Stores what a check of this start measured: its result once it ended, and its rounds so far
|
|
149
|
+
* each time it lowers the preset. It stores them when they were measured against at least the
|
|
127
150
|
* target that the check starts from under the highest target `maxTargetFps`.
|
|
128
151
|
*/
|
|
129
152
|
save(check, maxTargetFps, now = Date.now()) {
|
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';
|
|
@@ -32,6 +33,15 @@ export interface EngineOptions {
|
|
|
32
33
|
canvas: HTMLCanvasElement;
|
|
33
34
|
/** The sketch module, which runs in the sketch worker; `new URL('./sketch.ts', import.meta.url)`. */
|
|
34
35
|
sketch: URL | string;
|
|
36
|
+
/**
|
|
37
|
+
* Start data for the sketch, which its setup reads as `ctx.data`: the state that the page knows
|
|
38
|
+
* before the scene starts, such as the section that the address names, a saved color mode or a
|
|
39
|
+
* level number. It reaches the setup before the first frame, also in hold mode, where no message
|
|
40
|
+
* can. It takes plain JSON data: objects, arrays, strings, finite numbers, booleans and null, up
|
|
41
|
+
* to 64 KiB as JSON. Another value fails with E1213. A recording keeps it, and a replay gives
|
|
42
|
+
* the sketch the recorded data.
|
|
43
|
+
*/
|
|
44
|
+
sketchData?: unknown;
|
|
35
45
|
/**
|
|
36
46
|
* The quality preset: `auto`, the default, lets the engine choose one for the device, and
|
|
37
47
|
* `low`, `medium`, `high` or `ultra` names one. The GPU path caps it: WebGL2 and WebGPU's
|
|
@@ -48,6 +58,18 @@ export interface EngineOptions {
|
|
|
48
58
|
* E1213.
|
|
49
59
|
*/
|
|
50
60
|
targetFps?: TargetFps;
|
|
61
|
+
/**
|
|
62
|
+
* When the preset check measures, on a start where the engine checks the preset that it chose.
|
|
63
|
+
* With `during-play`, the default, the scene shows at its first frame: `createEngine` resolves
|
|
64
|
+
* once the setup has run, and `engine.firstFrame` once the GPU has finished the first frame. The
|
|
65
|
+
* check then measures the first frames of play, a lighter preset applies in front of the viewer,
|
|
66
|
+
* and `engine.presetChecked` resolves once the check has ended. With `before-play`, the check
|
|
67
|
+
* measures the scene that the setup built before the sketch's update runs, and `createEngine`
|
|
68
|
+
* resolves after it, so a loading screen hides the check and any change of preset. A start that
|
|
69
|
+
* takes the stored result of an earlier check, or that runs no check, plays at once either way.
|
|
70
|
+
* Another value fails with E1213. The `?preset-check=` switch wins over it.
|
|
71
|
+
*/
|
|
72
|
+
presetCheck?: PresetCheckTiming;
|
|
51
73
|
/**
|
|
52
74
|
* Cap for the device pixel ratio, a number from 0.5 up. Without it, the quality preset sets the
|
|
53
75
|
* cap. `ctx.quality.set` changes it during play.
|
|
@@ -112,8 +134,8 @@ export interface EngineOptions {
|
|
|
112
134
|
* shaded once, for its nearest surface. It saves GPU time in scenes where objects hide many
|
|
113
135
|
* others and shading costs much, and costs a second pass over the objects' vertices. Without
|
|
114
136
|
* 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.
|
|
137
|
+
* A sketch can change it during play with `quality.set`, and the `?prepass=on` or
|
|
138
|
+
* `?prepass=off` switch wins over this option. Another value fails with E1213.
|
|
117
139
|
*/
|
|
118
140
|
depthPrepass?: boolean;
|
|
119
141
|
/**
|
|
@@ -175,7 +197,8 @@ export interface EngineOptions {
|
|
|
175
197
|
* one more copy of each image in memory. False frees each copy once no frame reads it, and such
|
|
176
198
|
* a texture draws with its color alone until the sketch gives it texels again. Without this
|
|
177
199
|
* 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.
|
|
200
|
+
* is likeliest to lose its GPU. With copies, the engine also gives its GPU back while the browser
|
|
201
|
+
* keeps the page in its back/forward cache, and starts a new device when the page shows again.
|
|
179
202
|
*/
|
|
180
203
|
keepTextureCopies?: boolean;
|
|
181
204
|
/**
|
|
@@ -186,8 +209,8 @@ export interface EngineOptions {
|
|
|
186
209
|
transparent?: boolean;
|
|
187
210
|
/**
|
|
188
211
|
* False draws the scene into 8-bit color, where each material's shader applies the output
|
|
189
|
-
* transform, instead of HDR color, which the final pass tone maps. Both paths
|
|
190
|
-
* material's `toneMapped: false`, and the 8-bit path also
|
|
212
|
+
* transform, instead of HDR color, which the final pass tone maps. Both paths honor a
|
|
213
|
+
* material's `toneMapped: false`, and the 8-bit path also honors it on a blended surface. The
|
|
191
214
|
* default lets the engine pick the path from the device, which draws HDR color wherever it
|
|
192
215
|
* can. The `?hdr=off` switch takes the 8-bit path too.
|
|
193
216
|
*/
|
|
@@ -248,7 +271,9 @@ export interface EngineOptions {
|
|
|
248
271
|
* Called as the start reaches each stage, in this order: `core-download` as the engine core's
|
|
249
272
|
* file downloads, with the bytes that have arrived; `core` once the engine core is compiled and
|
|
250
273
|
* 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.
|
|
274
|
+
* GPU has finished the first frame after the setup. The preset check does not hold up either
|
|
275
|
+
* stage, unless the `presetCheck` option is `before-play`: `sketch` then comes after the check
|
|
276
|
+
* too. Before `core`, `core-download` reports the core file's bytes,
|
|
252
277
|
* and `memory-wait` comes when the browser has refused the engine's memory for 10 seconds. The
|
|
253
278
|
* engine then tries for about 35 seconds more before it fails with E1109. `progress` gives a
|
|
254
279
|
* stage's figures while it has some: the bytes of a download, measured against the length that
|
|
@@ -323,8 +348,8 @@ export interface EngineOptions {
|
|
|
323
348
|
* lets light through to its other side,
|
|
324
349
|
* `'subsurface'` with the first material with a `subsurfaceRadius` while the subsurface blur has
|
|
325
350
|
* 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
|
-
*
|
|
351
|
+
* the first material of the `weighted` blending, and `'occlusion'` with the first opaque
|
|
352
|
+
* material while GPU occlusion culling runs on WebGPU. WebGPU morphs in the skinning pass, so there
|
|
328
353
|
* `'morph'` loads the skinning shaders, and WebGL2 has no `'occlusion'` shaders to load. Listed
|
|
329
354
|
* features download beside the engine's own
|
|
330
355
|
* shaders, so the start waits only for the largest. The shaders that two or more listed features
|
|
@@ -460,16 +485,20 @@ export interface EngineMode {
|
|
|
460
485
|
/** The sketch time in seconds that hold mode holds the sketch at, or null for a live engine. */
|
|
461
486
|
hold: number | null;
|
|
462
487
|
/**
|
|
463
|
-
* The quality preset that the engine runs. The preset check can lower it
|
|
464
|
-
*
|
|
488
|
+
* The quality preset that the engine runs now. The preset check can lower it while it runs:
|
|
489
|
+
* during the first frames of play, or before `createEngine` resolves with the `presetCheck`
|
|
490
|
+
* option's `before-play`. `ctx.quality.setPreset` in the sketch changes it later. Once
|
|
491
|
+
* `engine.presetChecked` has resolved, it holds the preset that the check chose.
|
|
465
492
|
*/
|
|
466
493
|
preset: QualityPreset;
|
|
467
494
|
/**
|
|
468
|
-
* What the preset check measured, or null when no check ran
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
*
|
|
472
|
-
* its preset. `reused` is then true.
|
|
495
|
+
* What the preset check measured, or null while the check runs, and when no check ran or the
|
|
496
|
+
* sketch chose its own preset first. The engine checks the preset when it chose it from the
|
|
497
|
+
* device: after the first frame, it measures the frame rate of the scene, and lowers the preset
|
|
498
|
+
* until one holds the target. A later start of the sketch in the same browser on the same
|
|
499
|
+
* device takes the stored result instead, and starts at its preset. `reused` is then true. A
|
|
500
|
+
* start after a check that never ended starts at the preset that the check had lowered to, and
|
|
501
|
+
* its own check goes on from there, with the earlier rounds first.
|
|
473
502
|
*/
|
|
474
503
|
presetCheck: PresetCheck | null;
|
|
475
504
|
/**
|
|
@@ -519,10 +548,21 @@ export interface Engine {
|
|
|
519
548
|
/** How the engine runs on this device. */
|
|
520
549
|
readonly mode: EngineMode;
|
|
521
550
|
/**
|
|
522
|
-
* Resolves once the GPU has finished the first frame, so it is on screen: the
|
|
523
|
-
* a loading screen. It
|
|
551
|
+
* Resolves once the GPU has finished the first frame after the setup, so it is on screen: the
|
|
552
|
+
* moment to remove a loading screen. It rejects when the engine stops drawing first, with the
|
|
553
|
+
* failure that ended its frames, such as E1404 when the thread that draws fails at its first
|
|
554
|
+
* frame. A destroy before the first frame rejects it with E1420. A page that never waits for it
|
|
555
|
+
* gets no unhandled rejection.
|
|
524
556
|
*/
|
|
525
557
|
readonly firstFrame: Promise<void>;
|
|
558
|
+
/**
|
|
559
|
+
* Resolves once the preset check has ended, so `mode.preset` holds the preset that the check
|
|
560
|
+
* chose and `mode.presetCheck` what it measured. It has resolved when `createEngine` resolves
|
|
561
|
+
* where no check runs: for a preset that the page names, a stored result, Low, and hold mode,
|
|
562
|
+
* and with the `presetCheck` option's `before-play`. When the engine stops drawing first, it
|
|
563
|
+
* resolves then, and `mode.presetCheck` stays null.
|
|
564
|
+
*/
|
|
565
|
+
readonly presetChecked: Promise<void>;
|
|
526
566
|
/** The HTML elements that follow the labels the sketch tracks with `ui.trackLabel`. */
|
|
527
567
|
readonly labels: EngineLabels;
|
|
528
568
|
/**
|
|
@@ -549,11 +589,12 @@ export interface Engine {
|
|
|
549
589
|
* not carry on with a new device (E1302), or an engine thread failed (E1404). A custom shader's
|
|
550
590
|
* builds that a pipeline needs and that did not download fail the thread that draws with E1424.
|
|
551
591
|
* 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
|
-
*
|
|
592
|
+
* the GPU can also run out of memory (E1304) or reject the engine's work (E1305). On either GPU
|
|
593
|
+
* path, its driver can refuse to build a pipeline that draws objects of the scene twice (E1307).
|
|
594
|
+
* After these three the engine draws on without the objects that failed. The engine reports each
|
|
595
|
+
* failure once. A failure that no handler listened for when the engine reported it reaches the
|
|
596
|
+
* first handler that listens, so a failure that the app could not hear yet still arrives, and the
|
|
597
|
+
* engine also logs it to the console. A failure that ends the frames reaches these handlers before `onStop`'s. Returns a
|
|
557
598
|
* function that removes the handler.
|
|
558
599
|
*/
|
|
559
600
|
onFailure(handler: (error: EngineError) => void): () => void;
|
|
@@ -598,12 +639,22 @@ export interface Engine {
|
|
|
598
639
|
*/
|
|
599
640
|
measure(seconds: number, options?: MeasureOptions): Promise<FrameMetrics>;
|
|
600
641
|
/**
|
|
601
|
-
*
|
|
642
|
+
* Runs an inspection call against the live scene, for the in-page inspector and the MCP server:
|
|
643
|
+
* `objects`, `object`, `setObject`, `setMaterial`, `stats`, `errors`, `graph`, `setQuality`,
|
|
644
|
+
* `highlight` and `info`, with the arguments that [Debugging](../../guides/debugging.md#the-in-page-inspector)
|
|
645
|
+
* lists. The call runs between frames, in the thread that runs the sketch, and its value is
|
|
646
|
+
* JSON-safe. The page answers `capture` itself, with `{ png, bytes }`: the PNG image of the next
|
|
647
|
+
* 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
|
|
648
|
+
* release build leaves it out, so code that uses it must check for it first.
|
|
649
|
+
*/
|
|
650
|
+
inspect?(call: string, args?: unknown): Promise<unknown>;
|
|
651
|
+
/**
|
|
652
|
+
* Shows an overlay of figures over a right-hand corner of the canvas, or hides it with
|
|
602
653
|
* `false`: the GPU path, the frame rates, CPU time per frame of each thread, GPU time, draw
|
|
603
654
|
* calls, triangles and objects drawn, memory, and the page thread's long tasks and input delay.
|
|
604
655
|
* Its header is a button with the frame rate, which shows and hides the other figures. Options
|
|
605
|
-
* pick whether the overlay starts collapsed to its header
|
|
606
|
-
* the options it names. The page draws the overlay and updates it a few times a second, and its
|
|
656
|
+
* pick whether the overlay starts collapsed to its header, and its corner: the top right by
|
|
657
|
+
* default, or the bottom right. A call on a shown overlay changes the options it names. The page draws the overlay and updates it a few times a second, and its
|
|
607
658
|
* code downloads at the first call. While the other figures show, the engine times one frame in
|
|
608
659
|
* eleven on the GPU and reads back the counts of the objects that the GPU culls, which costs a
|
|
609
660
|
* little GPU time. The sketch's `debug.stats` shows and hides the same overlay, and the last
|
|
@@ -699,6 +750,13 @@ export interface Engine {
|
|
|
699
750
|
* the page to wait with no end.
|
|
700
751
|
*/
|
|
701
752
|
export declare const WORKER_REPLY_LIMIT_MS = 600000;
|
|
753
|
+
/**
|
|
754
|
+
* How long a copy of a worker whose script did not load may take to report its first reply. A
|
|
755
|
+
* script that loads reports in about a second on the slowest machines that run the tests, so a
|
|
756
|
+
* copy that has sent nothing by this time never ran: the page fails the start with E1405 rather
|
|
757
|
+
* than waiting for a worker that may never speak.
|
|
758
|
+
*/
|
|
759
|
+
export declare const RETRY_REPLY_MS = 10000;
|
|
702
760
|
interface TierChoice {
|
|
703
761
|
tier: Tier;
|
|
704
762
|
forceCompat: boolean;
|
|
@@ -724,9 +782,11 @@ interface WorkerEvents {
|
|
|
724
782
|
sketchError(error: Error): void;
|
|
725
783
|
/**
|
|
726
784
|
* 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.
|
|
785
|
+
* the engine then runs on without the thread. It ends hold mode's read-back of its frame too,
|
|
786
|
+
* unless `endsHold` is false: the frames never needed the thread, such as a job worker that did
|
|
787
|
+
* not start.
|
|
728
788
|
*/
|
|
729
|
-
failure(error: EngineError, endsStart?: boolean): void;
|
|
789
|
+
failure(error: EngineError, endsStart?: boolean, endsHold?: boolean): void;
|
|
730
790
|
/** The quality preset and settings after a change, and the preset check's result. */
|
|
731
791
|
quality(update: QualityUpdate): void;
|
|
732
792
|
/** The sketch asked to show or hide the stats overlay, or to change its options. */
|
|
@@ -743,12 +803,15 @@ interface WorkerEvents {
|
|
|
743
803
|
recording?(bytes: Uint8Array): void;
|
|
744
804
|
/** What a replay gave, after the sketch thread ran the recording's frames. */
|
|
745
805
|
replay?(result: ReplayResult): void;
|
|
806
|
+
/** The pipeline list of the pipelines that the first frame built, which the page stores. */
|
|
807
|
+
pipelineList?(list: Uint32Array): void;
|
|
746
808
|
}
|
|
747
809
|
/**
|
|
748
|
-
* The error of a GPU that ran out of memory (E1304)
|
|
749
|
-
* as "the render
|
|
810
|
+
* The error of a GPU that ran out of memory (E1304), rejected a command (E1305), or whose driver
|
|
811
|
+
* could not build a pipeline of the scene's objects (E1307), on `thread`, such as "the render
|
|
812
|
+
* worker". `message` names the pipeline for E1307.
|
|
750
813
|
*/
|
|
751
|
-
export declare function gpuFailure(thread: string,
|
|
814
|
+
export declare function gpuFailure(thread: string, kind: GpuErrorKind, message: string): EngineError;
|
|
752
815
|
/**
|
|
753
816
|
* A worker whose replies are routed: events to the page's handlers, answers to the oldest request.
|
|
754
817
|
* A failure that a started worker reports, or that ends it, reaches the page as E1404, or with its
|
|
@@ -767,6 +830,12 @@ export declare class EngineWorker {
|
|
|
767
830
|
*/
|
|
768
831
|
private readonly restart?;
|
|
769
832
|
private readonly waiting;
|
|
833
|
+
/**
|
|
834
|
+
* The inspection calls that wait for their answers, by their id. A production build never makes
|
|
835
|
+
* one, so the map is made at the first call.
|
|
836
|
+
*/
|
|
837
|
+
private inspectWaiters;
|
|
838
|
+
private nextInspect;
|
|
770
839
|
private readyPromise;
|
|
771
840
|
private readonly stoppedPromise;
|
|
772
841
|
private worker;
|
|
@@ -780,6 +849,8 @@ export declare class EngineWorker {
|
|
|
780
849
|
private scriptLoaded;
|
|
781
850
|
/** True once the page replaced a worker whose script did not load. */
|
|
782
851
|
private retried;
|
|
852
|
+
/** Clears the wait for the replacement worker's first reply, or undefined once it has one. */
|
|
853
|
+
private retryTimer;
|
|
783
854
|
/**
|
|
784
855
|
* The messages that the page sent before the worker reported that its script loaded. A worker
|
|
785
856
|
* that has not run its script cannot take them, so they wait here: a copy that replaces a
|
|
@@ -810,6 +881,14 @@ export declare class EngineWorker {
|
|
|
810
881
|
* shows which file failed.
|
|
811
882
|
*/
|
|
812
883
|
private startFailure;
|
|
884
|
+
/**
|
|
885
|
+
* What the page reports when the copy that replaced a worker whose script did not load has sent
|
|
886
|
+
* nothing within the wait. The first failure named the script; the copy's silence names it too,
|
|
887
|
+
* so a wrong path stays visible and a stall is not read as a wrong path.
|
|
888
|
+
*/
|
|
889
|
+
private stalledFailure;
|
|
890
|
+
/** Ends the wait for a replacement worker's first reply, once one arrives or the worker fails. */
|
|
891
|
+
private heardReply;
|
|
813
892
|
/**
|
|
814
893
|
* Drops the handlers that reach this engine, so a worker that the page keeps, such as a drawing
|
|
815
894
|
* worker parked with its canvas, holds none of the engine or its shared memory alive.
|
|
@@ -845,6 +924,13 @@ export declare class EngineWorker {
|
|
|
845
924
|
stopped(): Promise<void>;
|
|
846
925
|
/** Stops the worker, and fails each request that still waits for its answer. */
|
|
847
926
|
terminate(): void;
|
|
927
|
+
/**
|
|
928
|
+
* Runs a development build's inspection call in this worker, and waits for its answer. The
|
|
929
|
+
* worker answers with the value of the call, or why it failed.
|
|
930
|
+
*/
|
|
931
|
+
inspect(call: string, args?: unknown): Promise<unknown>;
|
|
932
|
+
/** Gives an inspection call its answer. */
|
|
933
|
+
private answerInspect;
|
|
848
934
|
/**
|
|
849
935
|
* Sends a request and waits for the worker's answer, which ends with a failure once the answer
|
|
850
936
|
* has taken longer than the wait's limit. The request keeps its place in the queue, so an answer
|