@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/quality/presets.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Tier } from '../shared/tier.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type PresetCheckRound, type PresetCheckTiming, type TargetFps } from './check.js';
|
|
3
3
|
/** Bytes in a mebibyte. */
|
|
4
4
|
export declare const MIB: number;
|
|
5
5
|
/**
|
|
@@ -131,11 +131,21 @@ export declare const QUALITY_SETTINGS: {
|
|
|
131
131
|
readonly max: 0.5;
|
|
132
132
|
};
|
|
133
133
|
};
|
|
134
|
+
readonly castShadows: {
|
|
135
|
+
readonly presets: readonly [true, true, true, true];
|
|
136
|
+
readonly changes: "live";
|
|
137
|
+
readonly values: "flag";
|
|
138
|
+
};
|
|
134
139
|
readonly bloomSize: {
|
|
135
140
|
readonly presets: readonly [64, 512, 512, 512];
|
|
136
141
|
readonly changes: "live";
|
|
137
142
|
readonly values: readonly [64, 128, 256, 512];
|
|
138
143
|
};
|
|
144
|
+
readonly bloom: {
|
|
145
|
+
readonly presets: readonly [true, true, true, true];
|
|
146
|
+
readonly changes: "live";
|
|
147
|
+
readonly values: "flag";
|
|
148
|
+
};
|
|
139
149
|
readonly aoScale: {
|
|
140
150
|
readonly presets: readonly [0, 0, 0.5, 0.5];
|
|
141
151
|
readonly changes: "live";
|
|
@@ -259,6 +269,11 @@ export declare const QUALITY_SETTINGS: {
|
|
|
259
269
|
readonly changes: "live";
|
|
260
270
|
readonly values: "flag";
|
|
261
271
|
};
|
|
272
|
+
readonly governorLevels: {
|
|
273
|
+
readonly presets: readonly [true, true, true, true];
|
|
274
|
+
readonly changes: "live";
|
|
275
|
+
readonly values: "flag";
|
|
276
|
+
};
|
|
262
277
|
readonly antialias: {
|
|
263
278
|
readonly presets: readonly ["fxaa", "msaa", "msaa", "msaa"];
|
|
264
279
|
readonly changes: "start";
|
|
@@ -310,7 +325,7 @@ export declare const QUALITY_SETTINGS: {
|
|
|
310
325
|
readonly depthPrepass: {
|
|
311
326
|
readonly presets: readonly [false, false, false, false];
|
|
312
327
|
readonly webgl2: readonly [true, true, true, true];
|
|
313
|
-
readonly changes: "
|
|
328
|
+
readonly changes: "live";
|
|
314
329
|
readonly values: "flag";
|
|
315
330
|
};
|
|
316
331
|
readonly gpuOcclusion: {
|
|
@@ -432,6 +447,13 @@ export interface QualitySettings {
|
|
|
432
447
|
* wider band costs a little more. 0 hands over at once. It changes during play.
|
|
433
448
|
*/
|
|
434
449
|
shadowCascadeBlend: number;
|
|
450
|
+
/**
|
|
451
|
+
* True while the scene draws the sun's cast shadows, which a sketch gives its directional
|
|
452
|
+
* lights' `castShadows` option. Every preset starts it on. The lowest quality tier turns it
|
|
453
|
+
* off when the frames still miss with the render scale at the preset's floor. It changes
|
|
454
|
+
* during play.
|
|
455
|
+
*/
|
|
456
|
+
castShadows: boolean;
|
|
435
457
|
/**
|
|
436
458
|
* The texels on the short side of the largest level of bloom's chain: 64, 128, 256 or 512. A
|
|
437
459
|
* smaller value costs less and keeps the glow's size, with a softer core. The base never takes
|
|
@@ -439,6 +461,12 @@ export interface QualitySettings {
|
|
|
439
461
|
* again.
|
|
440
462
|
*/
|
|
441
463
|
bloomSize: 64 | 128 | 256 | 512;
|
|
464
|
+
/**
|
|
465
|
+
* True while the sketch draws bloom's glow, which it turns on through `post.set`. Every preset
|
|
466
|
+
* starts it on. The lowest quality tier turns it off when the frames still miss with the render
|
|
467
|
+
* scale at the preset's floor. It changes during play.
|
|
468
|
+
*/
|
|
469
|
+
bloom: boolean;
|
|
442
470
|
/**
|
|
443
471
|
* The size of ambient occlusion's targets, as a share of the render size each way: 0.5, 0.25,
|
|
444
472
|
* or 0, which draws no ambient occlusion even when `post.set` turns it on. A smaller share costs
|
|
@@ -558,9 +586,10 @@ export interface QualitySettings {
|
|
|
558
586
|
*/
|
|
559
587
|
lodFade: boolean;
|
|
560
588
|
/**
|
|
561
|
-
* Whether `{ atmosphere }` backgrounds draw the physical sky from its tables. False draws
|
|
562
|
-
*
|
|
563
|
-
* physical sky's brightness, and keeps the haze on distant objects. It changes during
|
|
589
|
+
* Whether `{ atmosphere }` backgrounds draw the physical sky from its tables. False draws the
|
|
590
|
+
* analytic `{ sky }` background in its place, with the same sun, moon, air and clouds, matched
|
|
591
|
+
* to the physical sky's brightness, and keeps the haze on distant objects. It changes during
|
|
592
|
+
* play.
|
|
564
593
|
*/
|
|
565
594
|
physicalSky: boolean;
|
|
566
595
|
/**
|
|
@@ -585,6 +614,13 @@ export interface QualitySettings {
|
|
|
585
614
|
* other settings as set, as benchmarks and captures need. It changes during play.
|
|
586
615
|
*/
|
|
587
616
|
governor: boolean;
|
|
617
|
+
/**
|
|
618
|
+
* Whether the governor may raise `lodThreshold` as one of its steps, trading model detail for
|
|
619
|
+
* frames. True does, up to four doublings while a mesh has levels of detail. False leaves every
|
|
620
|
+
* model's level where its distance puts it, while the governor's other steps still run, so a
|
|
621
|
+
* model stays whole near the camera on a slow device. It changes during play.
|
|
622
|
+
*/
|
|
623
|
+
governorLevels: boolean;
|
|
588
624
|
/**
|
|
589
625
|
* How the engine smooths the edges of what it draws: `msaa` draws 4 samples per pixel, `fxaa`
|
|
590
626
|
* smooths edges in the final pass, and `none` leaves them sharp. The mode is fixed when the
|
|
@@ -643,8 +679,9 @@ export interface QualitySettings {
|
|
|
643
679
|
/**
|
|
644
680
|
* True when the engine draws the depth of the opaque objects before it shades them, so it
|
|
645
681
|
* shades each pixel once, for its nearest surface. Every preset turns it on for WebGL2 and off
|
|
646
|
-
* for WebGPU. The
|
|
647
|
-
*
|
|
682
|
+
* for WebGPU. The page's `depthPrepass` option of `createEngine` gives its first value. It
|
|
683
|
+
* changes during play, and ambient occlusion, contact shadows, the bounce light and
|
|
684
|
+
* screen-space reflections still draw the prepass while they run, as they read its depth.
|
|
648
685
|
*/
|
|
649
686
|
depthPrepass: boolean;
|
|
650
687
|
/**
|
|
@@ -697,8 +734,43 @@ export declare const LIVE_SETTINGS: readonly QualitySettingName[];
|
|
|
697
734
|
export declare function presetIndex(preset: QualityPreset): number;
|
|
698
735
|
/** `preset` lowered by `steps`, down to Low at most. */
|
|
699
736
|
export declare function lowered(preset: QualityPreset, steps: number): QualityPreset;
|
|
737
|
+
/**
|
|
738
|
+
* The preset that the preset check lowers to after `round` missed `targetFps`: Low when the round
|
|
739
|
+
* fell far below the target, or else the next lighter preset.
|
|
740
|
+
*/
|
|
741
|
+
export declare function presetAfterMiss(round: PresetCheckRound, targetFps: number): QualityPreset;
|
|
700
742
|
/** A setting's value on a preset, on the GPU path `tier`, or on WebGPU without it. */
|
|
701
743
|
export declare function presetValue<K extends QualitySettingName>(name: K, preset: QualityPreset, tier?: Tier): SettingValue<K>;
|
|
744
|
+
/**
|
|
745
|
+
* The lowest quality tier's render scale floor: a third of the canvas's width and height, below
|
|
746
|
+
* Low's half. The governor enters the tier when the render scale has held at the preset's floor
|
|
747
|
+
* through its sustained window and the judged frames still miss (D-382).
|
|
748
|
+
*/
|
|
749
|
+
export declare const LOWEST_TIER_SCALE: number;
|
|
750
|
+
/**
|
|
751
|
+
* The lowest quality tier's share of the render size for a reflection pass's texture each way: a
|
|
752
|
+
* quarter, which draws a sixteenth of the pixels of a full-size reflection.
|
|
753
|
+
*/
|
|
754
|
+
export declare const LOWEST_TIER_REFLECTION = 0.25;
|
|
755
|
+
/**
|
|
756
|
+
* The cuts that the lowest quality tier applies, on the GPU path `tier`: the render scale's floor
|
|
757
|
+
* at the tier's, unless the settings' floor is lower, the sun's cast shadows and bloom off, the
|
|
758
|
+
* reflection passes' textures at a quarter of the render size, and WebGL2's depth prepass off. A
|
|
759
|
+
* sketch that reads the settings sees them while the tier applies (D-382).
|
|
760
|
+
*/
|
|
761
|
+
export declare function lowestTierCuts(tier: Tier, min?: number): Partial<QualitySettings>;
|
|
762
|
+
/**
|
|
763
|
+
* The settings that a start in the lowest quality tier takes on the GPU path `tier`: the cuts,
|
|
764
|
+
* with the render scale fixed at the tier's floor. The four presets keep their own values, and the
|
|
765
|
+
* governor applies the same cuts when it enters the tier during play (D-382).
|
|
766
|
+
*/
|
|
767
|
+
export declare function lowestTierSettings(tier: Tier): Partial<QualitySettings>;
|
|
768
|
+
/**
|
|
769
|
+
* The settings that the lowest quality tier replaces, for a frame loop to give back when it
|
|
770
|
+
* leaves: the render scale's range, the sun's cast shadows, bloom, the reflection passes' share and the
|
|
771
|
+
* depth prepass.
|
|
772
|
+
*/
|
|
773
|
+
export declare function tierRestoreSettings(settings: QualitySettings): Partial<QualitySettings>;
|
|
702
774
|
/**
|
|
703
775
|
* The settings that a sketch starts with on `preset` and the GPU path `tier`: the preset's values,
|
|
704
776
|
* and the values in `options` where the page's options give them.
|
|
@@ -740,5 +812,10 @@ export declare function presetOption(value: unknown): QualityPreset | 'auto';
|
|
|
740
812
|
* none. Throws E1213 for a value other than `display` or a whole number from 1 up.
|
|
741
813
|
*/
|
|
742
814
|
export declare function targetFpsOption(value: unknown): TargetFps | undefined;
|
|
815
|
+
/**
|
|
816
|
+
* When the preset check measures, as `createEngine`'s `presetCheck` option names it, or undefined
|
|
817
|
+
* for no choice. Throws E1213 for a value that names no timing.
|
|
818
|
+
*/
|
|
819
|
+
export declare function presetCheckOption(value: unknown): PresetCheckTiming | undefined;
|
|
743
820
|
/** The preset that `quality.setPreset` got. Throws E1213 when it names no preset. */
|
|
744
821
|
export declare function presetArgument(value: unknown): QualityPreset;
|
package/lib/quality/presets.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// applies the setting. A setting that a sketch reads is also a member of QualitySettings, and a
|
|
8
8
|
// test keeps the two lists equal. A sketch changes only the settings that change during play.
|
|
9
9
|
import { EngineError } from '../errors/engine-error.js';
|
|
10
|
+
import { farBelowTarget, PRESET_CHECK_TIMINGS, } from './check.js';
|
|
10
11
|
/** Bytes in a mebibyte. */
|
|
11
12
|
export const MIB = 1024 * 1024;
|
|
12
13
|
/** The presets from the lightest to the heaviest. */
|
|
@@ -104,6 +105,14 @@ export const QUALITY_SETTINGS = {
|
|
|
104
105
|
changes: 'live',
|
|
105
106
|
values: { min: 0, max: 0.5 },
|
|
106
107
|
},
|
|
108
|
+
// The sun's cast shadows, which a sketch gives its directional lights' `castShadows` option.
|
|
109
|
+
// Every preset starts them on. The lowest quality tier turns them off when the frames still
|
|
110
|
+
// miss with the render scale at the preset's floor (D-382).
|
|
111
|
+
castShadows: {
|
|
112
|
+
presets: [true, true, true, true],
|
|
113
|
+
changes: 'live',
|
|
114
|
+
values: 'flag',
|
|
115
|
+
},
|
|
107
116
|
// The texels on the short side of the base of bloom's mip chain. The glow keeps its size at any
|
|
108
117
|
// base: a smaller base drops the chain's narrowest levels, which costs less and softens the
|
|
109
118
|
// glow's core. Low runs on phones at render scales down to 0.5, where a larger base would cost
|
|
@@ -116,6 +125,14 @@ export const QUALITY_SETTINGS = {
|
|
|
116
125
|
changes: 'live',
|
|
117
126
|
values: [64, 128, 256, 512],
|
|
118
127
|
},
|
|
128
|
+
// Whether the sketch draws bloom's glow, which it turns on through `post.set`. Every preset
|
|
129
|
+
// starts it on. The lowest quality tier turns it off when the frames still miss with the render
|
|
130
|
+
// scale at the preset's floor (D-382).
|
|
131
|
+
bloom: {
|
|
132
|
+
presets: [true, true, true, true],
|
|
133
|
+
changes: 'live',
|
|
134
|
+
values: 'flag',
|
|
135
|
+
},
|
|
119
136
|
// The size of ambient occlusion's targets, as a share of the render size each way: half on High
|
|
120
137
|
// and Ultra, and 0 on Low and Medium, where ambient occlusion draws nothing even when the sketch
|
|
121
138
|
// turns it on. A share above 0 draws a corner of the same targets, so it changes during play
|
|
@@ -316,6 +333,14 @@ export const QUALITY_SETTINGS = {
|
|
|
316
333
|
changes: 'live',
|
|
317
334
|
values: 'flag',
|
|
318
335
|
},
|
|
336
|
+
// Whether the governor may raise the level threshold as one of its steps, trading model detail
|
|
337
|
+
// for frames. False leaves every model's level where its distance puts it while the governor's
|
|
338
|
+
// other steps still run, for a scene whose models read badly at a coarse level near the camera.
|
|
339
|
+
governorLevels: {
|
|
340
|
+
presets: [true, true, true, true],
|
|
341
|
+
changes: 'live',
|
|
342
|
+
values: 'flag',
|
|
343
|
+
},
|
|
319
344
|
// FXAA on Low, which phones draw: MSAA's samples cost them more memory traffic.
|
|
320
345
|
antialias: {
|
|
321
346
|
presets: ['fxaa', 'msaa', 'msaa', 'msaa'],
|
|
@@ -380,11 +405,13 @@ export const QUALITY_SETTINGS = {
|
|
|
380
405
|
// The depth prepass trades a second pass over the opaque objects' vertices for shading each
|
|
381
406
|
// pixel once. WebGL2 draws it on every preset: on Apple GPUs, WebGL2 shades hidden pixels that
|
|
382
407
|
// the prepass's early depth rejection skips. The other paths leave it off: there the GPU removes
|
|
383
|
-
// hidden surfaces itself, and the second pass only adds time (D-43).
|
|
408
|
+
// hidden surfaces itself, and the second pass only adds time (D-43). The lowest quality tier
|
|
409
|
+
// turns it off on WebGL2, and it changes during play with no new pipelines where ambient
|
|
410
|
+
// occlusion, contact shadows, the bounce light and screen-space reflections draw it anyway.
|
|
384
411
|
depthPrepass: {
|
|
385
412
|
presets: [false, false, false, false],
|
|
386
413
|
webgl2: [true, true, true, true],
|
|
387
|
-
changes: '
|
|
414
|
+
changes: 'live',
|
|
388
415
|
values: 'flag',
|
|
389
416
|
},
|
|
390
417
|
// Two-phase occlusion culling on WebGPU: objects that large opaque objects hide do not draw. It
|
|
@@ -444,12 +471,68 @@ export function presetIndex(preset) {
|
|
|
444
471
|
export function lowered(preset, steps) {
|
|
445
472
|
return QUALITY_PRESETS[Math.max(0, presetIndex(preset) - steps)] ?? 'low';
|
|
446
473
|
}
|
|
474
|
+
/**
|
|
475
|
+
* The preset that the preset check lowers to after `round` missed `targetFps`: Low when the round
|
|
476
|
+
* fell far below the target, or else the next lighter preset.
|
|
477
|
+
*/
|
|
478
|
+
export function presetAfterMiss(round, targetFps) {
|
|
479
|
+
return farBelowTarget(round, targetFps) ? 'low' : lowered(round.preset, 1);
|
|
480
|
+
}
|
|
447
481
|
/** A setting's value on a preset, on the GPU path `tier`, or on WebGPU without it. */
|
|
448
482
|
export function presetValue(name, preset, tier) {
|
|
449
483
|
const setting = QUALITY_SETTINGS[name];
|
|
450
484
|
const values = (tier === 'webgl2' && setting.webgl2) || setting.presets;
|
|
451
485
|
return values[presetIndex(preset)];
|
|
452
486
|
}
|
|
487
|
+
/**
|
|
488
|
+
* The lowest quality tier's render scale floor: a third of the canvas's width and height, below
|
|
489
|
+
* Low's half. The governor enters the tier when the render scale has held at the preset's floor
|
|
490
|
+
* through its sustained window and the judged frames still miss (D-382).
|
|
491
|
+
*/
|
|
492
|
+
export const LOWEST_TIER_SCALE = 1 / 3;
|
|
493
|
+
/**
|
|
494
|
+
* The lowest quality tier's share of the render size for a reflection pass's texture each way: a
|
|
495
|
+
* quarter, which draws a sixteenth of the pixels of a full-size reflection.
|
|
496
|
+
*/
|
|
497
|
+
export const LOWEST_TIER_REFLECTION = 0.25;
|
|
498
|
+
/**
|
|
499
|
+
* The cuts that the lowest quality tier applies, on the GPU path `tier`: the render scale's floor
|
|
500
|
+
* at the tier's, unless the settings' floor is lower, the sun's cast shadows and bloom off, the
|
|
501
|
+
* reflection passes' textures at a quarter of the render size, and WebGL2's depth prepass off. A
|
|
502
|
+
* sketch that reads the settings sees them while the tier applies (D-382).
|
|
503
|
+
*/
|
|
504
|
+
export function lowestTierCuts(tier, min = LOWEST_TIER_SCALE) {
|
|
505
|
+
return {
|
|
506
|
+
minRenderScale: Math.min(min, LOWEST_TIER_SCALE),
|
|
507
|
+
castShadows: false,
|
|
508
|
+
bloom: false,
|
|
509
|
+
reflectionScale: LOWEST_TIER_REFLECTION,
|
|
510
|
+
...(tier === 'webgl2' ? { depthPrepass: false } : {}),
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* The settings that a start in the lowest quality tier takes on the GPU path `tier`: the cuts,
|
|
515
|
+
* with the render scale fixed at the tier's floor. The four presets keep their own values, and the
|
|
516
|
+
* governor applies the same cuts when it enters the tier during play (D-382).
|
|
517
|
+
*/
|
|
518
|
+
export function lowestTierSettings(tier) {
|
|
519
|
+
return { ...lowestTierCuts(tier), maxRenderScale: LOWEST_TIER_SCALE };
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* The settings that the lowest quality tier replaces, for a frame loop to give back when it
|
|
523
|
+
* leaves: the render scale's range, the sun's cast shadows, bloom, the reflection passes' share and the
|
|
524
|
+
* depth prepass.
|
|
525
|
+
*/
|
|
526
|
+
export function tierRestoreSettings(settings) {
|
|
527
|
+
return {
|
|
528
|
+
minRenderScale: settings.minRenderScale,
|
|
529
|
+
maxRenderScale: settings.maxRenderScale,
|
|
530
|
+
castShadows: settings.castShadows,
|
|
531
|
+
bloom: settings.bloom,
|
|
532
|
+
reflectionScale: settings.reflectionScale,
|
|
533
|
+
depthPrepass: settings.depthPrepass,
|
|
534
|
+
};
|
|
535
|
+
}
|
|
453
536
|
/**
|
|
454
537
|
* The settings that a sketch starts with on `preset` and the GPU path `tier`: the preset's values,
|
|
455
538
|
* and the values in `options` where the page's options give them.
|
|
@@ -580,6 +663,15 @@ export function targetFpsOption(value) {
|
|
|
580
663
|
return value;
|
|
581
664
|
throw new EngineError('E1213', `createEngine() got ${quoted(value)} for targetFps, which is not 'display' or a whole number from 1 up.`);
|
|
582
665
|
}
|
|
666
|
+
/**
|
|
667
|
+
* When the preset check measures, as `createEngine`'s `presetCheck` option names it, or undefined
|
|
668
|
+
* for no choice. Throws E1213 for a value that names no timing.
|
|
669
|
+
*/
|
|
670
|
+
export function presetCheckOption(value) {
|
|
671
|
+
if (value === undefined || PRESET_CHECK_TIMINGS.includes(value))
|
|
672
|
+
return value;
|
|
673
|
+
throw new EngineError('E1213', `createEngine() got ${quoted(value)} for presetCheck, which is not ${listOf(PRESET_CHECK_TIMINGS.map((name) => `'${name}'`))}.`);
|
|
674
|
+
}
|
|
583
675
|
/** The preset that `quality.setPreset` got. Throws E1213 when it names no preset. */
|
|
584
676
|
export function presetArgument(value) {
|
|
585
677
|
return namedPreset('quality.setPreset()', value, QUALITY_PRESETS);
|
package/lib/render/draw.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { SketchRunner } from '../sketch/runner.js';
|
|
|
2
2
|
import { type FramePacing, type LoopFault } from './loop.js';
|
|
3
3
|
import { Drawing } from './recovery.js';
|
|
4
4
|
import { type RenderCanvas, type Renderer, type RendererOptions } from './renderer.js';
|
|
5
|
-
export {
|
|
5
|
+
export { startEarly } from './renderer.js';
|
|
6
6
|
export interface DrawingSetup extends RendererOptions, FramePacing {
|
|
7
7
|
/** The canvas that this thread owns. */
|
|
8
8
|
canvas: RenderCanvas;
|
|
@@ -44,7 +44,8 @@ export interface DrawingSetup extends RendererOptions, FramePacing {
|
|
|
44
44
|
/**
|
|
45
45
|
* Starts drawing on this thread's canvas, with a new renderer after each GPU loss. The images for
|
|
46
46
|
* texture uploads come through the setup's port, or into its table from the sketch that this thread
|
|
47
|
-
* runs, and every renderer reads them.
|
|
47
|
+
* runs, and every renderer reads them. The first renderer takes the device that the setup's early
|
|
48
|
+
* start asked for, and the start destroys that device when the renderer does not take it.
|
|
48
49
|
*/
|
|
49
50
|
export declare function startDrawing(setup: DrawingSetup): Promise<Drawing<Renderer>>;
|
|
50
51
|
/**
|
package/lib/render/draw.js
CHANGED
|
@@ -9,27 +9,37 @@ import { ImageTable, receiveImages } from '../shared/images.js';
|
|
|
9
9
|
import { runDirectLoop } from './direct-loop.js';
|
|
10
10
|
import { emptySceneInput, HoldLoop, runRenderLoop } from './loop.js';
|
|
11
11
|
import { Drawing } from './recovery.js';
|
|
12
|
-
import { createRenderer } from './renderer.js';
|
|
13
|
-
export {
|
|
12
|
+
import { createRenderer, EarlyStart, } from './renderer.js';
|
|
13
|
+
export { startEarly } from './renderer.js';
|
|
14
14
|
/**
|
|
15
15
|
* Starts drawing on this thread's canvas, with a new renderer after each GPU loss. The images for
|
|
16
16
|
* texture uploads come through the setup's port, or into its table from the sketch that this thread
|
|
17
|
-
* runs, and every renderer reads them.
|
|
17
|
+
* runs, and every renderer reads them. The first renderer takes the device that the setup's early
|
|
18
|
+
* start asked for, and the start destroys that device when the renderer does not take it.
|
|
18
19
|
*/
|
|
19
20
|
export async function startDrawing(setup) {
|
|
20
21
|
const { canvas, control, metrics, sketch, hold = false, fault, presented } = setup;
|
|
21
22
|
const { slots } = controlViews(control);
|
|
23
|
+
const early = setup.early ?? new EarlyStart();
|
|
24
|
+
early.steps.mark('init');
|
|
25
|
+
early.steps.publish(metrics);
|
|
22
26
|
const imageTable = setup.imageTable ?? new ImageTable();
|
|
23
27
|
imageTable.loadGeneratorsWith(generatorLoader(setup.tier, (setup.cloudSteps ?? 0) > 0));
|
|
24
28
|
const receiving = setup.imagePort && receiveImages(setup.imagePort, imageTable, slots);
|
|
25
|
-
const options = { ...setup, imageTable };
|
|
29
|
+
const options = { ...setup, imageTable, early };
|
|
26
30
|
const create = () => createRenderer(canvas, options);
|
|
27
31
|
const run = (renderer) => hold
|
|
28
32
|
? new HoldLoop(slots, renderer, metrics, presented)
|
|
29
33
|
: sketch
|
|
30
34
|
? runDirectLoop(sketch, renderer, control, metrics, setup, fault, presented)
|
|
31
35
|
: runRenderLoop(renderer, control, metrics, setup, setup.imagePort, fault, presented);
|
|
32
|
-
|
|
36
|
+
let renderer;
|
|
37
|
+
try {
|
|
38
|
+
renderer = await create();
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
early.release();
|
|
42
|
+
}
|
|
33
43
|
// Firefox can fail to read an image that reached this thread while it made its first renderer,
|
|
34
44
|
// so the sketch thread sends its images only once the renderer exists.
|
|
35
45
|
receiving?.();
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DrawingPreload, EarlyStart } from './renderer.js';
|
|
2
2
|
export type DrawModule = typeof import('./draw.js');
|
|
3
3
|
/** Starts loading the renderer, so the download overlaps the thread's other startup work. */
|
|
4
4
|
export declare function loadDrawModule(): Promise<DrawModule>;
|
|
5
5
|
/**
|
|
6
|
-
* Starts the
|
|
7
|
-
*
|
|
8
|
-
* of
|
|
6
|
+
* Starts what the renderer that `preload` describes needs first, once the renderer's code has
|
|
7
|
+
* loaded through `draw`: the downloads of its shaders and of its GPU path's renderers, and on
|
|
8
|
+
* WebGPU the request for its device. The renderer reports a failure of any of them when it starts.
|
|
9
|
+
* Resolves with the start, which the thread hands to its renderer, or with undefined when the code
|
|
10
|
+
* did not load.
|
|
9
11
|
*/
|
|
10
|
-
export declare function
|
|
12
|
+
export declare function preloadDrawing(draw: Promise<DrawModule>, preload: DrawingPreload): Promise<EarlyStart | undefined>;
|
package/lib/render/load-draw.js
CHANGED
|
@@ -7,10 +7,12 @@ export function loadDrawModule() {
|
|
|
7
7
|
return awaitLater(import('./draw.js'));
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* Starts the
|
|
11
|
-
*
|
|
12
|
-
* of
|
|
10
|
+
* Starts what the renderer that `preload` describes needs first, once the renderer's code has
|
|
11
|
+
* loaded through `draw`: the downloads of its shaders and of its GPU path's renderers, and on
|
|
12
|
+
* WebGPU the request for its device. The renderer reports a failure of any of them when it starts.
|
|
13
|
+
* Resolves with the start, which the thread hands to its renderer, or with undefined when the code
|
|
14
|
+
* did not load.
|
|
13
15
|
*/
|
|
14
|
-
export function
|
|
15
|
-
draw.then((module) => module.
|
|
16
|
+
export function preloadDrawing(draw, preload) {
|
|
17
|
+
return draw.then((module) => module.startEarly(preload), () => undefined);
|
|
16
18
|
}
|
package/lib/render/loss.d.ts
CHANGED
|
@@ -11,21 +11,39 @@ export declare function contextLoss(canvas: OffscreenCanvas | HTMLCanvasElement,
|
|
|
11
11
|
/** Waits until a lost WebGL2 context comes back, and fails if it does not in time. */
|
|
12
12
|
export declare function contextRestored(gl: WebGL2RenderingContext): Promise<void>;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* What a GPU failure that the engine draws on after was: the GPU had no room for an object, it
|
|
15
|
+
* rejected a command, or its driver could not build a pipeline that draws objects of the scene.
|
|
16
16
|
*/
|
|
17
|
-
export type
|
|
17
|
+
export type GpuErrorKind = 'memory' | 'rejected' | 'pipeline';
|
|
18
|
+
/** Hears a GPU failure that the engine draws on after: its kind, and the GPU path's own text. */
|
|
19
|
+
export type GpuErrorReport = (kind: GpuErrorKind, message: string) => void;
|
|
18
20
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
21
|
+
* The message of a pipeline that the driver refused twice, as `GpuErrorReport` hears it: the
|
|
22
|
+
* pipeline's name, then the driver's reason, without the browser's lines of where in its code the
|
|
23
|
+
* reason arose.
|
|
22
24
|
*/
|
|
23
|
-
export declare
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
export declare function refusalText(pipeline: string, reason: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Reports the first GPU failure of each kind on one device to `report`. Later ones are counted,
|
|
28
|
+
* and development builds say once that more came.
|
|
29
|
+
*/
|
|
30
|
+
export declare class GpuReports {
|
|
31
|
+
private readonly report;
|
|
32
|
+
/** The failures of a kind that was reported already. */
|
|
26
33
|
repeated: number;
|
|
27
|
-
private reported;
|
|
34
|
+
private readonly reported;
|
|
28
35
|
private warned;
|
|
36
|
+
constructor(report?: GpuErrorReport);
|
|
37
|
+
/** Hears a failure of `kind`, with the GPU path's own text. */
|
|
38
|
+
hear(kind: GpuErrorKind, message: string): void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Listens for a device's uncaptured errors, which cost nothing per frame, and reports them as
|
|
42
|
+
* `GpuReports` does: an error that a `GPUOutOfMemoryError` carries as out of memory, and any other
|
|
43
|
+
* as rejected.
|
|
44
|
+
*/
|
|
45
|
+
export declare class GpuErrorWatch extends GpuReports {
|
|
46
|
+
private readonly device;
|
|
29
47
|
constructor(device: GPUDevice, report?: GpuErrorReport);
|
|
30
48
|
/**
|
|
31
49
|
* Stops listening, for a renderer that is destroyed. A page can keep a device reachable after
|
package/lib/render/loss.js
CHANGED
|
@@ -55,38 +55,66 @@ export function contextRestored(gl) {
|
|
|
55
55
|
target.addEventListener(name, done);
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
const KIND_TEXT = {
|
|
59
|
+
memory: 'the GPU ran out of memory',
|
|
60
|
+
rejected: 'the GPU rejected a command',
|
|
61
|
+
pipeline: "the GPU's driver could not build a pipeline",
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* The message of a pipeline that the driver refused twice, as `GpuErrorReport` hears it: the
|
|
65
|
+
* pipeline's name, then the driver's reason, without the browser's lines of where in its code the
|
|
66
|
+
* reason arose.
|
|
67
|
+
*/
|
|
68
|
+
export function refusalText(pipeline, reason) {
|
|
69
|
+
const said = reason.split('\n')[0]?.trim() || 'the driver gave no reason';
|
|
70
|
+
return `${pipeline}, so the objects that draw with it are missing. It failed twice, the second time alone: ${said.replace(/\.$/, '')}`;
|
|
71
|
+
}
|
|
72
|
+
/** Says a GPU failure when no report was asked for, so that it never goes unheard. */
|
|
73
|
+
function logGpuError(kind, message) {
|
|
74
|
+
console.error(`null3D: ${KIND_TEXT[kind]}: ${message}`);
|
|
61
75
|
}
|
|
62
76
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* builds say once that more came.
|
|
77
|
+
* Reports the first GPU failure of each kind on one device to `report`. Later ones are counted,
|
|
78
|
+
* and development builds say once that more came.
|
|
66
79
|
*/
|
|
67
|
-
export class
|
|
68
|
-
|
|
69
|
-
/** The
|
|
80
|
+
export class GpuReports {
|
|
81
|
+
report;
|
|
82
|
+
/** The failures of a kind that was reported already. */
|
|
70
83
|
repeated = 0;
|
|
71
|
-
reported = {
|
|
84
|
+
reported = { memory: false, rejected: false, pipeline: false };
|
|
72
85
|
warned = false;
|
|
73
|
-
constructor(
|
|
86
|
+
constructor(report = logGpuError) {
|
|
87
|
+
this.report = report;
|
|
88
|
+
}
|
|
89
|
+
/** Hears a failure of `kind`, with the GPU path's own text. */
|
|
90
|
+
hear(kind, message) {
|
|
91
|
+
if (!this.reported[kind]) {
|
|
92
|
+
this.reported[kind] = true;
|
|
93
|
+
this.report(kind, message);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
this.repeated++;
|
|
97
|
+
if (DEV && !this.warned) {
|
|
98
|
+
this.warned = true;
|
|
99
|
+
console.warn(`null3D: the GPU reported more failures after the first: ${message}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Listens for a device's uncaptured errors, which cost nothing per frame, and reports them as
|
|
105
|
+
* `GpuReports` does: an error that a `GPUOutOfMemoryError` carries as out of memory, and any other
|
|
106
|
+
* as rejected.
|
|
107
|
+
*/
|
|
108
|
+
export class GpuErrorWatch extends GpuReports {
|
|
109
|
+
device;
|
|
110
|
+
constructor(device, report) {
|
|
111
|
+
super(report);
|
|
74
112
|
this.device = device;
|
|
75
113
|
device.onuncapturederror = (event) => {
|
|
76
114
|
const { error } = event;
|
|
77
115
|
// Older browsers, and some workers, lack the class.
|
|
78
116
|
const outOfMemory = typeof GPUOutOfMemoryError === 'function' && error instanceof GPUOutOfMemoryError;
|
|
79
|
-
|
|
80
|
-
if (!this.reported[kind]) {
|
|
81
|
-
this.reported[kind] = true;
|
|
82
|
-
report(outOfMemory, error.message);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
this.repeated++;
|
|
86
|
-
if (DEV && !this.warned) {
|
|
87
|
-
this.warned = true;
|
|
88
|
-
console.warn(`null3D: the GPU reported more errors after the first: ${error.message}`);
|
|
89
|
-
}
|
|
117
|
+
this.hear(outOfMemory ? 'memory' : 'rejected', error.message);
|
|
90
118
|
};
|
|
91
119
|
}
|
|
92
120
|
/**
|
package/lib/render/recovery.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export declare class Drawing<R extends Recoverable> {
|
|
|
32
32
|
private live;
|
|
33
33
|
/** The recovery under way, which a stop waits for. */
|
|
34
34
|
private recovering;
|
|
35
|
+
/** True while the page sits in the back/forward cache, with no renderer. */
|
|
36
|
+
private released;
|
|
35
37
|
/**
|
|
36
38
|
* Starts drawing with `renderer`. `create` makes a replacement on the same canvas, `run` starts a
|
|
37
39
|
* loop with a renderer, and `fail` hears the reason when the engine gives up. Without
|
|
@@ -45,11 +47,29 @@ export declare class Drawing<R extends Recoverable> {
|
|
|
45
47
|
* and the stop releases it.
|
|
46
48
|
*/
|
|
47
49
|
private recover;
|
|
50
|
+
/**
|
|
51
|
+
* Makes a new renderer on the canvas, tells the sketch thread to create every GPU object again,
|
|
52
|
+
* and starts a new loop. Returns false when the engine stopped meanwhile, or when no device
|
|
53
|
+
* started, which `reason` explains to the page.
|
|
54
|
+
*/
|
|
55
|
+
private restart;
|
|
48
56
|
/**
|
|
49
57
|
* Resolves once the frame to capture is on the canvas. In hold mode, that is the held frame,
|
|
50
58
|
* which the loop draws when first asked. A live loop first takes a frame after this call.
|
|
51
59
|
*/
|
|
52
60
|
nextFrame(): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Gives the GPU back while the page sits in the browser's back/forward cache: stops the loop and
|
|
63
|
+
* destroys the renderer, with its textures, buffers and device. A small device then has the
|
|
64
|
+
* room for the next page. Hold mode, and a drawing that recovers from a loss or has stopped, keep
|
|
65
|
+
* what they have.
|
|
66
|
+
*/
|
|
67
|
+
enterPageCache(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Takes a new renderer once the page shows again after `enterPageCache`, as a recovery from a GPU loss
|
|
70
|
+
* does: the sketch thread records a frame that creates every GPU object again. It counts no loss.
|
|
71
|
+
*/
|
|
72
|
+
leavePageCache(): Promise<void>;
|
|
53
73
|
/** Acts out a loss of the GPU, which the engine then recovers from as from a real one. */
|
|
54
74
|
simulateLoss(): void;
|
|
55
75
|
/**
|