@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
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: api/reference/debug
|
|
3
3
|
title: "Debug drawing and stats: API reference"
|
|
4
|
-
|
|
5
|
-
since: "0.1"
|
|
4
|
+
generated: true
|
|
6
5
|
summary: "Every export of the Debug drawing and stats API, from the engine's doc comments."
|
|
7
6
|
---
|
|
8
7
|
|
|
@@ -16,17 +15,21 @@ summary: "Every export of the Debug drawing and stats API, from the engine's doc
|
|
|
16
15
|
function countPerSecond(intervalsMs: ArrayLike<number>, seconds = Math.floor(spanMs(intervalsMs) / 1000)): number[]
|
|
17
16
|
```
|
|
18
17
|
|
|
18
|
+
Import from `@null3d/engine/stats`.
|
|
19
|
+
|
|
19
20
|
Events in each whole second, from the intervals between them. An event falls in the second that the running sum of the intervals reaches at it. It counts the first `seconds` seconds, by default every second that has ended: the ones before the last event's second.
|
|
20
21
|
|
|
21
22
|
## `Debug`
|
|
22
23
|
|
|
23
24
|
Interface `Debug`.
|
|
24
25
|
|
|
25
|
-
Debug drawing and frame figures. The drawing calls draw lines that show where things are, such as bounds, directions and axes. Each draws for one frame only, so call it in `onUpdate` in every frame that needs the drawing. Lines are one pixel wide, and objects in front of them hide them. Colors take the same forms as material colors, and positions are in world space. The overlay of `stats` shows frame figures on the page, and `frameStats` gives the sketch the same figures.
|
|
26
|
+
Debug drawing and frame figures. The drawing calls draw lines that show where things are, such as bounds, directions and axes. Each draws for one frame only, so call it in `onUpdate` in every frame that needs the drawing. Lines are one pixel wide, and objects in front of them hide them. Colors take the same forms as material colors, and positions are in world space. The overlay of `stats` shows frame figures on the page, and `frameStats` gives the sketch the same figures.
|
|
27
|
+
|
|
28
|
+
Only development builds draw. In a release build every drawing call does nothing, and the build holds none of the drawing code, apart from one traversal of the scene's objects whose meshes have levels, which the culling spheres read. The calls `stats` and `frameStats` work in every build.
|
|
26
29
|
|
|
27
30
|
| Member | Description |
|
|
28
31
|
| --- | --- |
|
|
29
|
-
| `stats(show?: boolean \| StatsOverlayOptions): void` | Shows an overlay of frame figures over
|
|
32
|
+
| `stats(show?: boolean \| StatsOverlayOptions): void` | Shows an overlay of frame figures over a right-hand corner of the canvas, or hides it with `false`: the GPU path, the quality preset, the render scale, the frame rates, CPU time per frame of each thread and phase, GPU time, draw calls, triangles and objects drawn, memory, and the page thread's long tasks and input delay. Its header is a button with the frame rate, which shows and hides the other figures. Options pick whether the overlay starts collapsed to its header, and its corner: the top right by default, or the bottom right. The page draws the overlay and updates it a few times a second. Its code downloads at the first call. The page's `engine.stats` shows and hides the same overlay, and the last call wins. Each call sends a message to the page, so call it when the choice changes, not in every frame. |
|
|
30
33
|
| `frameStats(): FrameStats` | The figures that the stats overlay shows, for the sketch: means per frame over about the last half second. Call it each time you need figures, and read them from the object it returns. It allocates nothing, so a sketch can call it every frame. Its code downloads at the first call, so the figures are 0 until about half a second after that call. The first call also turns on the figures that the engine samples, for the engine's life: GPU time on one frame in eleven, the memory of textures and meshes, and on WebGPU the counts of the objects that the GPU culls. |
|
|
31
34
|
| `view(view: DebugViewName): void` | Draws the whole scene with one debug shading in place of every material, from the next frame on, until the next call. `'lit'` draws the materials again. `'normals'` shows each surface's world-space normal as a color, and `'depth'` its distance from the camera as a gray, white at the near plane and black at the far plane. `'overdraw'` adds light for each surface that covers a pixel, so bright pixels cost the most shading. `'wireframe'` draws each triangle's edges in its material's color. `'shadows'` shows how much of the main directional light's shadow falls on each surface, as a gray: black in full shadow, white in full light. Surfaces that face away from the sun are black, and surfaces that receive no shadows are white. `'motion'` shows how far each pixel's surface moved on the screen since the last frame, the camera's move included: its direction as the hue, red to the right, and its length as the brightness, full at 16 pixels. A still pixel is black. `'levels'` gives each level of detail a color of its own and dithers two colors where two levels hand over in a fading band. A source that the size rule or a draw range hid draws at its base level in a striped marker color, so the view shows what the culling dropped. The other views clear to black. Debug views use no tone mapping. A view may also be the name that an add-on registers in its feature description. Only development builds draw them: in a release build the call does nothing. A view's first frame builds its pipelines, so objects can be missing for a few frames after a change. |
|
|
32
35
|
| `cullingSpheres(show?: boolean): void` | Draws the bounding sphere that culling tests for each object whose mesh has levels of detail, from the next frame on, until the next call. It draws the first 128 such objects, so a forest of many copies does not fill the frame. Call it beside the `'levels'` view to see where each copy's culling sphere lies, and why the size rule hid one. Only development builds draw it. |
|
|
@@ -37,10 +40,10 @@ Debug drawing and frame figures. The drawing calls draw lines that show where th
|
|
|
37
40
|
| `sphere(center: Vec3Like, radius: number, color?: ColorInput): void` | Draws a sphere as three circles around its center, one in each plane of the world's axes. The default color is yellow. |
|
|
38
41
|
| `arrow(origin: Vec3Like, direction: Vec3Like, length?: number, color?: ColorInput): void` | Draws an arrow from `origin` in `direction`, `length` meters long, with a head at its tip. The direction needs no unit length. The default length is 1, and the default color is yellow. |
|
|
39
42
|
| `axes(target: Object3D \| Vec3Like, size?: number): void` | Draws x, y and z axes, in red, green and blue, `size` meters long: at a position, or on an object. An object's axes take its position and rotation in the frame they draw in, so they never lag behind it. The default size is 1. |
|
|
40
|
-
| `grid(size?: number, divisions?: number, options?: DebugGridOptions): void` | Draws a square grid on the horizontal plane through its center, `size` meters wide, with `divisions` cells along each side
|
|
41
|
-
| `frustum(camera: Camera, color?: ColorInput): void` | Draws the space that a camera sees: its near and far planes and the edges between them, in the canvas's shape. The camera takes its place in the frame it draws in. The default color is orange
|
|
43
|
+
| `grid(size?: number, divisions?: number, options?: DebugGridOptions): void` | Draws a square grid on the horizontal plane through its center, `size` meters wide, with `divisions` cells along each side. The defaults are 10 and 10. |
|
|
44
|
+
| `frustum(camera: Camera, color?: ColorInput): void` | Draws the space that a camera sees: its near and far planes and the edges between them, in the canvas's shape. The camera takes its place in the frame it draws in. The default color is orange. |
|
|
42
45
|
| `light(light: DirectionalLight, options?: DebugLightOptions): void` | Draws a directional light as a square that faces its light, with an arrow in the direction its light travels. The light takes its place and direction in the frame it draws in. |
|
|
43
|
-
| `skeleton(object: Object3D, color?: ColorInput): void` | Draws the skeleton that animates an object, such as the copy of a model that `scene.instantiate` made: a line from each joint of the model's skins to its parent joint, in the pose of the frame it draws in.
|
|
46
|
+
| `skeleton(object: Object3D, color?: ColorInput): void` | Draws the skeleton that animates an object, such as the copy of a model that `scene.instantiate` made: a line from each joint of the model's skins to its parent joint, in the pose of the frame it draws in. Each line is blue at the joint and green at its parent, unless `color` gives one color. An object without an animator draws nothing. |
|
|
44
47
|
|
|
45
48
|
## `DebugGridOptions`
|
|
46
49
|
|
|
@@ -51,8 +54,8 @@ Options for `debug.grid`.
|
|
|
51
54
|
| Member | Description |
|
|
52
55
|
| --- | --- |
|
|
53
56
|
| `center?: Vec3Like` | The center of the grid. The default is the origin. |
|
|
54
|
-
| `color?: ColorInput` | The color of the grid's lines. The default is `'#888888'
|
|
55
|
-
| `centerColor?: ColorInput` | The color of the two lines through the center. The default is `'#444444'`. |
|
|
57
|
+
| `color?: ColorInput` | The color of the grid's lines. The default is gray, `'#888888'`. |
|
|
58
|
+
| `centerColor?: ColorInput` | The color of the two lines through the center, which an even number of divisions draws. The default is `'#444444'`. |
|
|
56
59
|
|
|
57
60
|
## `DebugLightOptions`
|
|
58
61
|
|
|
@@ -82,6 +85,21 @@ type DebugViewName = DebugView | (string & {});
|
|
|
82
85
|
|
|
83
86
|
The name that `debug.view` takes: one of the engine's own views, or a view that an add-on feature registers.
|
|
84
87
|
|
|
88
|
+
## `DrawingStart`
|
|
89
|
+
|
|
90
|
+
Interface `DrawingStart`.
|
|
91
|
+
|
|
92
|
+
When the thread that draws reached each step of its start, in `FrameMetrics.load.drawingStart`: milliseconds from the start of page navigation, or null for a step that it has not reached or does not take.
|
|
93
|
+
|
|
94
|
+
| Member | Description |
|
|
95
|
+
| --- | --- |
|
|
96
|
+
| `requestMs: number \| null` | The page's message after the probe arrived. The thread then started the downloads of its renderers and shader files, and on WebGPU the request for its device. |
|
|
97
|
+
| `adapterMs: number \| null` | Its WebGPU adapter arrived. Null on WebGL2. |
|
|
98
|
+
| `deviceMs: number \| null` | Its WebGPU device arrived. Null on WebGL2. |
|
|
99
|
+
| `shadersMs: number \| null` | The shader file of its device arrived. |
|
|
100
|
+
| `initMs: number \| null` | The core and the thread's setup arrived from the page. |
|
|
101
|
+
| `rendererMs: number \| null` | Its first renderer was built, so its frame loop could start. |
|
|
102
|
+
|
|
85
103
|
## `EngineDebugView`
|
|
86
104
|
|
|
87
105
|
```ts
|
|
@@ -108,7 +126,7 @@ What `engine.measure` returns: the per-frame figures, memory, load time and down
|
|
|
108
126
|
| --- | --- |
|
|
109
127
|
| `seconds: number` | Length of the measurement. |
|
|
110
128
|
| `memory: MemoryStats` | The engine's WebAssembly memory and the JavaScript heap. |
|
|
111
|
-
| `load: { engineStartMs: number; probeMs: number; coreMs: number; firstFrameMs: number \| null; firstFrameDoneMs: number \| null; warmUpMs: number \| null; firstDrawMs: number \| null; firstFramePipelines: number \| null; firstFramePreset: string; }` | How long the engine took to start and to draw its first frame, in milliseconds. |
|
|
129
|
+
| `load: { engineStartMs: number; probeMs: number; coreMs: number; firstFrameMs: number \| null; firstFrameDoneMs: number \| null; warmUpMs: number \| null; firstDrawMs: number \| null; firstFramePipelines: number \| null; drawingStart: DrawingStart; firstFramePreset: string; }` | How long the engine took to start and to draw its first frame, in milliseconds. |
|
|
112
130
|
| `gpuLosses: number` | Times the browser took the GPU away since the engine started, and the engine carried on with a new device. `simulateGpuLoss` counts too. |
|
|
113
131
|
| `downloadBytes: { wasm: number \| null; }` | Bytes of the engine's WebAssembly file as the page downloaded it. |
|
|
114
132
|
| `lostRecords: number` | Frame records the page read too late; nonzero means some frames are missing from the figures. |
|
|
@@ -137,7 +155,7 @@ Figures of the running engine, as `debug.frameStats()` returns them and the stat
|
|
|
137
155
|
| `readonly gpuStepMs: number \| null` | The step between the GPU's timestamps, in milliseconds, when the browser rounds them, or null when they look exact. It is the greatest common divisor of the offsets that the timer reads back, not a constant of the device. The window that has no timed frame keeps the figure of the window before it. |
|
|
138
156
|
| `readonly gpuSteps: readonly FrameStatsStep[]` | The GPU time per frame of each step of the frame that the GPU timed one by one, in the order the frame runs them: the engine's own passes, by their step, and a sketch's pass by its place. A tile GPU overlaps the passes, so the steps do not add up to `gpuMs`. The engine times one frame in eleven and at most seven passes in it. The passes after them share one figure, named `later passes`, which no scope names. Empty on WebGL2, which times the whole frame alone. |
|
|
139
157
|
| `readonly drawCalls: number` | Mean draw calls per frame, over every pass. |
|
|
140
|
-
| `readonly triangles: number` | Mean triangles drawn per frame, over every pass: shadow maps and the depth prepass count as well as the passes that shade
|
|
158
|
+
| `readonly triangles: number` | Mean triangles drawn per frame, over every pass: shadow maps and the depth prepass count as well as the passes that shade. Lines count none. On WebGPU the GPU culls most objects, and the count of their triangles comes back from the GPU on one frame in eleven, a few frames late. |
|
|
141
159
|
| `readonly objects: number` | Mean objects drawn per frame, over every pass: each draw counts its instances, so an object counts once in each pass that draws it, such as a shadow cascade, and each part of a mesh with several materials counts once. On WebGPU the count of the objects that the GPU culls comes back from the GPU on one frame in eleven, a few frames late. |
|
|
142
160
|
| `readonly uploadBytes: number` | Mean bytes uploaded to the GPU per frame. |
|
|
143
161
|
| `readonly tier: Tier` | The GPU path the engine draws with. |
|
|
@@ -233,6 +251,8 @@ The page's own thread during a measurement: tasks that kept it busy for 50 ms or
|
|
|
233
251
|
|
|
234
252
|
Class `MainThreadWindow`.
|
|
235
253
|
|
|
254
|
+
Import from `@null3d/engine/stats`.
|
|
255
|
+
|
|
236
256
|
Watches the page's own thread in windows, one after another: its long tasks and its longest input delay. They come from the browser's long task and event timing entries, where the browser reports them.
|
|
237
257
|
|
|
238
258
|
| Member | Description |
|
|
@@ -256,12 +276,16 @@ What a measurement reports beyond its own figures, when the page asks for it.
|
|
|
256
276
|
function measurePageMemory(): Promise<MemoryMeasurement> | undefined
|
|
257
277
|
```
|
|
258
278
|
|
|
279
|
+
Import from `@null3d/engine/stats`.
|
|
280
|
+
|
|
259
281
|
One measurement of the memory of the whole page and its workers, as the browser gives it: the page's request in flight, or a new one. Like the samples, it lets every engine's job workers run the measurement. Undefined where the browser offers no measurement, or after the page stopped asking because the browser left its first request unanswered.
|
|
260
282
|
|
|
261
283
|
## `MemoryMeasurement`
|
|
262
284
|
|
|
263
285
|
Interface `MemoryMeasurement`.
|
|
264
286
|
|
|
287
|
+
Import from `@null3d/engine/stats`.
|
|
288
|
+
|
|
265
289
|
What the browser's measurement of the page's memory, `performance.measureUserAgentSpecificMemory`, resolves with: the bytes of the whole page, and the bytes of each part, with the scope and the script address of the thread that the part belongs to.
|
|
266
290
|
|
|
267
291
|
| Member | Description |
|
|
@@ -288,12 +312,16 @@ Memory figures of a measurement.
|
|
|
288
312
|
function pageHeapBytes(): number | null
|
|
289
313
|
```
|
|
290
314
|
|
|
315
|
+
Import from `@null3d/engine/stats`.
|
|
316
|
+
|
|
291
317
|
The JavaScript heap of the page's own thread in bytes, from `performance.memory`, or null where the browser does not have it.
|
|
292
318
|
|
|
293
319
|
## `PageMemory`
|
|
294
320
|
|
|
295
321
|
Interface `PageMemory`.
|
|
296
322
|
|
|
323
|
+
Import from `@null3d/engine/stats`.
|
|
324
|
+
|
|
297
325
|
The memory of the whole page and its workers, from the browser's own measurement, in `StatsMemory.page`.
|
|
298
326
|
|
|
299
327
|
| Member | Description |
|
|
@@ -305,6 +333,8 @@ The memory of the whole page and its workers, from the browser's own measurement
|
|
|
305
333
|
|
|
306
334
|
Class `PageMemorySampler`.
|
|
307
335
|
|
|
336
|
+
Import from `@null3d/engine/stats`.
|
|
337
|
+
|
|
308
338
|
Samples the memory of the whole page and its workers, one measurement after another with a gap of a few seconds, where the browser offers the measurement. `page` holds the newest figures. At most one measurement is in flight on the page. When the browser leaves the first one unanswered for two minutes, the page asks no more, and `page` is null until an answer comes after all.
|
|
309
339
|
|
|
310
340
|
| Member | Description |
|
|
@@ -321,6 +351,8 @@ Samples the memory of the whole page and its workers, one measurement after anot
|
|
|
321
351
|
function percentiles(samples: ArrayLike<number>): Percentiles
|
|
322
352
|
```
|
|
323
353
|
|
|
354
|
+
Import from `@null3d/engine/stats`.
|
|
355
|
+
|
|
324
356
|
The median, 95th and 99th percentiles and mean of per-frame samples. It sorts a copy, so call it outside frame code.
|
|
325
357
|
|
|
326
358
|
## `Percentiles`
|
|
@@ -361,6 +393,8 @@ A step of a frame that `engine.measure` times. The `update` step is the sketch's
|
|
|
361
393
|
function ratePerSecond(intervalsMs: ArrayLike<number>): number | null
|
|
362
394
|
```
|
|
363
395
|
|
|
396
|
+
Import from `@null3d/engine/stats`.
|
|
397
|
+
|
|
364
398
|
Events per second from the intervals between them: the count over the time they took, so a few long intervals lower the rate as much as they cost. Null without intervals.
|
|
365
399
|
|
|
366
400
|
## `SecondRates`
|
|
@@ -404,10 +438,20 @@ One engine thread's CPU time in a slow frame, and the phases that it spent the t
|
|
|
404
438
|
| `busyMs: number` | The thread's busy time in the frame. |
|
|
405
439
|
| `phases: { name: PhaseName; ms: number; }[]` | The phases that took time, in the order the engine's phases run. |
|
|
406
440
|
|
|
441
|
+
## `StatsCorner`
|
|
442
|
+
|
|
443
|
+
```ts
|
|
444
|
+
type StatsCorner = 'top-right' | 'bottom-right';
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
The corner of the canvas that the stats overlay's header button sits in. At the top right the card opens under the button, and at the bottom right it opens above it.
|
|
448
|
+
|
|
407
449
|
## `StatsFigures`
|
|
408
450
|
|
|
409
451
|
Interface `StatsFigures`.
|
|
410
452
|
|
|
453
|
+
Import from `@null3d/engine/stats`.
|
|
454
|
+
|
|
411
455
|
The figures that the stats overlay shows, in the form that `statsText` lays out. Means per frame are over the last window of frames, about half a second.
|
|
412
456
|
|
|
413
457
|
| Member | Description |
|
|
@@ -436,12 +480,16 @@ The figures that the stats overlay shows, in the form that `statsText` lays out.
|
|
|
436
480
|
type StatsFrameMode = 'pipelined' | 'low' | 'single' | 'one-thread';
|
|
437
481
|
```
|
|
438
482
|
|
|
439
|
-
|
|
483
|
+
Import from `@null3d/engine/stats`.
|
|
484
|
+
|
|
485
|
+
How the threads of a renderer share each frame's work, which a symbol before the target explains: `'pipelined'` and `'low'` are null3D's latency modes, `'single'` is null3D's single-thread build, and `'one-thread'` is a renderer that prepares and draws each frame on one thread.
|
|
440
486
|
|
|
441
487
|
## `StatsGpuStep`
|
|
442
488
|
|
|
443
489
|
Interface `StatsGpuStep`.
|
|
444
490
|
|
|
491
|
+
Import from `@null3d/engine/stats`.
|
|
492
|
+
|
|
445
493
|
One step of the frame's GPU work, in `StatsFigures.gpuSteps`.
|
|
446
494
|
|
|
447
495
|
| Member | Description |
|
|
@@ -453,6 +501,8 @@ One step of the frame's GPU work, in `StatsFigures.gpuSteps`.
|
|
|
453
501
|
|
|
454
502
|
Interface `StatsMainThread`.
|
|
455
503
|
|
|
504
|
+
Import from `@null3d/engine/stats`.
|
|
505
|
+
|
|
456
506
|
The page's own thread over the last few seconds, in `StatsFigures.mainThread`.
|
|
457
507
|
|
|
458
508
|
| Member | Description |
|
|
@@ -466,6 +516,8 @@ The page's own thread over the last few seconds, in `StatsFigures.mainThread`.
|
|
|
466
516
|
|
|
467
517
|
Interface `StatsMemory`.
|
|
468
518
|
|
|
519
|
+
Import from `@null3d/engine/stats`.
|
|
520
|
+
|
|
469
521
|
Memory figures in bytes, in `StatsFigures.memory`. Each is null where the page cannot know it, and the overlay then shows `n/a`.
|
|
470
522
|
|
|
471
523
|
| Member | Description |
|
|
@@ -480,6 +532,8 @@ Memory figures in bytes, in `StatsFigures.memory`. Each is null where the page c
|
|
|
480
532
|
|
|
481
533
|
Interface `StatsMemoryArea`.
|
|
482
534
|
|
|
535
|
+
Import from `@null3d/engine/stats`.
|
|
536
|
+
|
|
483
537
|
One area of the memory register, in `StatsFigures.memoryAreas`.
|
|
484
538
|
|
|
485
539
|
| Member | Description |
|
|
@@ -498,26 +552,32 @@ Options for the stats overlay, which `debug.stats`, `engine.stats` and the `stat
|
|
|
498
552
|
| Member | Description |
|
|
499
553
|
| --- | --- |
|
|
500
554
|
| `collapsed?: boolean` | True shows only the overlay's header, a button with the frame rate. A click or the Enter or Space key on it shows and hides the other figures. The default is false: every figure shows. |
|
|
555
|
+
| `corner?: StatsCorner` | The corner of the canvas that the header button sits in. The default is `'top-right'`. At `'bottom-right'` the button sits at the bottom of the part of the canvas on screen, clear of a phone's home bar, and the card opens above it. |
|
|
501
556
|
|
|
502
557
|
## `StatsPanel`
|
|
503
558
|
|
|
504
559
|
Class `StatsPanel`.
|
|
505
560
|
|
|
506
|
-
|
|
561
|
+
Import from `@null3d/engine/stats`.
|
|
562
|
+
|
|
563
|
+
The stats overlay's header and card over the top-right or bottom-right corner of a canvas, in the overlay's own look. The engine's overlay is one; a page that draws with another engine makes its own and fills it with its figures, so both show the same figures in the same place and look. The header's button opens and closes the card. Collapsed, the panel formats nothing but the frame rate.
|
|
507
564
|
|
|
508
565
|
| Member | Description |
|
|
509
566
|
| --- | --- |
|
|
510
567
|
| `readonly collapsed: boolean` | True while only the header shows. |
|
|
511
568
|
| `setCollapsed(collapsed: boolean): void` | Opens or closes the card, and tells `onToggle` when that changes. |
|
|
569
|
+
| `setCorner(corner: StatsCorner): void` | Moves the panel to another corner of the canvas. |
|
|
512
570
|
| `showRate(frames: number, fps: number, refreshHz: number, maxTargetFps = CHECK_MAX_FPS): void` | Shows the frame rate in the header: `frames` is 0 before the first window of frames ended. The rate is judged against null3D's target for the display's refresh rate, at most `maxTargetFps`. |
|
|
513
571
|
| `update(figures: StatsFigures, frame: StatsPanelFrame): void` | Shows a set of figures in the card. It does nothing while the panel is collapsed. |
|
|
514
|
-
| `follow(): void` | Keeps the panel on the canvas's
|
|
572
|
+
| `follow(): void` | Keeps the panel on its corner of the canvas and the card's height within the screen, and hides the panel while the canvas is off the page. Call it a few times a second, as the figures come. |
|
|
515
573
|
| `remove(): void` | Takes the panel off the page. |
|
|
516
574
|
|
|
517
575
|
## `StatsPanelFrame`
|
|
518
576
|
|
|
519
577
|
Interface `StatsPanelFrame`.
|
|
520
578
|
|
|
579
|
+
Import from `@null3d/engine/stats`.
|
|
580
|
+
|
|
521
581
|
How a panel judges and lays out one set of figures, in `StatsPanel.update`.
|
|
522
582
|
|
|
523
583
|
| Member | Description |
|
|
@@ -532,11 +592,14 @@ How a panel judges and lays out one set of figures, in `StatsPanel.update`.
|
|
|
532
592
|
|
|
533
593
|
Interface `StatsPanelOptions`.
|
|
534
594
|
|
|
595
|
+
Import from `@null3d/engine/stats`.
|
|
596
|
+
|
|
535
597
|
Options of a `StatsPanel`.
|
|
536
598
|
|
|
537
599
|
| Member | Description |
|
|
538
600
|
| --- | --- |
|
|
539
601
|
| `collapsed?: boolean` | True starts the panel with only its header, a button with the frame rate. The default is false. |
|
|
602
|
+
| `corner?: StatsCorner` | The corner of the canvas that the header button sits in. The default is `'top-right'`. At `'bottom-right'` the button sits at the bottom of the part of the canvas on screen, clear of a phone's home bar, and the card opens above it. |
|
|
540
603
|
| `onToggle?: (collapsed: boolean) => void` | Called when the panel opens or closes, with true for closed. A page samples its costly figures only while the panel is open. |
|
|
541
604
|
|
|
542
605
|
## `statsText`
|
|
@@ -545,12 +608,16 @@ Options of a `StatsPanel`.
|
|
|
545
608
|
function statsText(figures: StatsFigures): string
|
|
546
609
|
```
|
|
547
610
|
|
|
611
|
+
Import from `@null3d/engine/stats`.
|
|
612
|
+
|
|
548
613
|
The stats overlay's text for a set of figures: one figure group per line, in a fixed order. A figure that the page cannot know shows as `n/a`.
|
|
549
614
|
|
|
550
615
|
## `StatsThread`
|
|
551
616
|
|
|
552
617
|
Interface `StatsThread`.
|
|
553
618
|
|
|
619
|
+
Import from `@null3d/engine/stats`.
|
|
620
|
+
|
|
554
621
|
One thread's CPU time per frame, in `StatsFigures.threads`.
|
|
555
622
|
|
|
556
623
|
| Member | Description |
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: api/reference/engine
|
|
3
3
|
title: "Page API: createEngine: API reference"
|
|
4
|
-
|
|
5
|
-
since: "0.1"
|
|
4
|
+
generated: true
|
|
6
5
|
summary: "Every export of the Page API: createEngine API, from the engine's doc comments."
|
|
7
6
|
---
|
|
8
7
|
|
|
@@ -37,6 +36,11 @@ function checkAddonVersion(name: string, version: string): void
|
|
|
37
36
|
|
|
38
37
|
Checks that an add-on, built for `version` of the engine, runs against this engine's version, and throws E1432 when the two differ. An add-on calls it once, as its module loads, with its own package name and version. An add-on from another developer calls `checkPluginInterface` instead, with the range of plugin interface versions that it works with.
|
|
39
38
|
|
|
39
|
+
| Parameter | Description |
|
|
40
|
+
| --- | --- |
|
|
41
|
+
| `name` | The add-on's package name, such as `@null3d/controls`. |
|
|
42
|
+
| `version` | The add-on's version, which is the engine version it was built for. |
|
|
43
|
+
|
|
40
44
|
## `checkPluginInterface`
|
|
41
45
|
|
|
42
46
|
```ts
|
|
@@ -45,6 +49,11 @@ function checkPluginInterface(name: string, range: PluginInterfaceRange): void
|
|
|
45
49
|
|
|
46
50
|
Checks that an add-on from another developer works with this engine's plugin interface, and throws E1433 when the declared range does not hold `PLUGIN_INTERFACE_VERSION`. The add-on calls it once, as its module loads, with its own package name and the range it was built for.
|
|
47
51
|
|
|
52
|
+
| Parameter | Description |
|
|
53
|
+
| --- | --- |
|
|
54
|
+
| `name` | The add-on's package name, such as `@acme/splats`. |
|
|
55
|
+
| `range` | The plugin interface versions that the add-on works with, both included. |
|
|
56
|
+
|
|
48
57
|
## `createEngine`
|
|
49
58
|
|
|
50
59
|
```ts
|
|
@@ -59,7 +68,9 @@ Starts the engine on the page. It tests the device, picks the build and the GPU
|
|
|
59
68
|
type DepthMode = 'reversed' | 'reversed-gl' | 'standard';
|
|
60
69
|
```
|
|
61
70
|
|
|
62
|
-
How the GPU path stores depth. In `reversed` depth, the near plane stores 1 and the far plane 0, in a 32-bit float depth buffer. That keeps depth precise far from the camera.
|
|
71
|
+
How the GPU path stores depth. In `reversed` depth, the near plane stores 1 and the far plane 0, in a 32-bit float depth buffer. That keeps depth precise far from the camera.
|
|
72
|
+
|
|
73
|
+
WebGPU always draws it. WebGL2 draws it where the browser has the `EXT_clip_control` extension, which gives WebGL2 the depth range from 0 to 1 that WebGPU has. The `reversed-gl` mode keeps the same order, but in WebGL2's own depth range from -1 to 1, which loses most of the precision. In `standard` depth, the near plane stores 0 and the far plane 1.
|
|
63
74
|
|
|
64
75
|
## `DrawPathReason`
|
|
65
76
|
|
|
@@ -75,7 +86,19 @@ type DrawPathReason =
|
|
|
75
86
|
| 'webgl2';
|
|
76
87
|
```
|
|
77
88
|
|
|
78
|
-
Why WebGPU draws on the path that the engine takes, in `engine.capabilities.drawPath`:
|
|
89
|
+
Why WebGPU draws on the path that the engine takes, in `engine.capabilities.drawPath`:
|
|
90
|
+
|
|
91
|
+
- `probe-faster`: the start-up probe ran on an Apple GPU in WebKit and measured direct draws to
|
|
92
|
+
be clearly faster, so the engine draws directly.
|
|
93
|
+
- `probe-not-faster`: the probe ran there, and direct draws were not clearly faster.
|
|
94
|
+
- `probe-failed`: the probe ran there and could not measure, as when the device was too slow or
|
|
95
|
+
was lost.
|
|
96
|
+
- `not-apple-gpu-in-webkit`: the device is not an Apple GPU in Safari or in a browser on iPhone
|
|
97
|
+
or iPad. The probe did not run, and the engine draws indirectly.
|
|
98
|
+
- `software-renderer`: the browser draws on the CPU. The probe did not run.
|
|
99
|
+
- `no-probe`: the worker's WebGPU check gave no answer.
|
|
100
|
+
- `forced`: `?direct=on` or `?direct=off` chose the path.
|
|
101
|
+
- `webgl2`: the engine draws with WebGL2, which always draws directly.
|
|
79
102
|
|
|
80
103
|
## `Engine`
|
|
81
104
|
|
|
@@ -88,19 +111,21 @@ A running engine, as `createEngine` returns it.
|
|
|
88
111
|
| `readonly capabilities: EngineCapabilities` | The GPU path the engine chose, and what it offers. |
|
|
89
112
|
| `readonly report: CapabilityReport` | The full capability report, as plain JSON. |
|
|
90
113
|
| `readonly mode: EngineMode` | How the engine runs on this device. |
|
|
91
|
-
| `readonly firstFrame: Promise<void>` | Resolves once the GPU has finished the first frame, so it is on screen: the moment to remove a loading screen. It
|
|
114
|
+
| `readonly firstFrame: Promise<void>` | Resolves once the GPU has finished the first frame after the setup, so it is on screen: the moment to remove a loading screen. It rejects when the engine stops drawing first, with the failure that ended its frames, such as E1404 when the thread that draws fails at its first frame. A destroy before the first frame rejects it with E1420. A page that never waits for it gets no unhandled rejection. |
|
|
115
|
+
| `readonly presetChecked: Promise<void>` | Resolves once the preset check has ended, so `mode.preset` holds the preset that the check chose and `mode.presetCheck` what it measured. It has resolved when `createEngine` resolves where no check runs: for a preset that the page names, a stored result, Low, and hold mode, and with the `presetCheck` option's `before-play`. When the engine stops drawing first, it resolves then, and `mode.presetCheck` stays null. |
|
|
92
116
|
| `readonly labels: EngineLabels` | The HTML elements that follow the labels the sketch tracks with `ui.trackLabel`. |
|
|
93
117
|
| `registerVideo(video: HTMLVideoElement, options: VideoOptions): () => void` | Shows a video element on the page as a texture in the sketch, which makes it with `textures.fromVideo(name)`. The page sends the image of each frame that the video presents, as an `ImageBitmap` of the size that the options allow, and the sketch uploads it in its turn, within the frame's upload budget. The sketch asks for the frames when its texture follows the video, so a video that no texture shows sends none, and a paused video presents no frame, so it costs nothing. Returns a function that stops the frames, which the video's texture then keeps the last frame of. Throws E1213 for a name that another video holds, or an option out of range. |
|
|
94
118
|
| `postToSketch(name: string, data?: unknown, transfer?: Transferable[]): void` | Sends a message to the sketch, which receives it through `ctx.page.onMessage`. |
|
|
95
119
|
| `onSketchMessage(handler: (name: string, data: unknown) => void): () => void` | Receives the messages the sketch sends with `ctx.page.post`. When no handler listened from the start, the first handler also receives the messages sent before it was registered. Returns a function that removes the handler. |
|
|
96
|
-
| `onFailure(handler: (error: EngineError) => void): () => void` | Receives a failure after the engine started: the browser took the GPU away and the engine could not carry on with a new device (E1302), or an engine thread failed (E1404). A custom shader's builds that a pipeline needs and that did not download fail the thread that draws with E1424. After E1404 or E1424 the engine draws no new frames: destroy it and start a new one. On WebGPU, the GPU can also run out of memory (E1304) or reject the engine's work (E1305),
|
|
120
|
+
| `onFailure(handler: (error: EngineError) => void): () => void` | Receives a failure after the engine started: the browser took the GPU away and the engine could not carry on with a new device (E1302), or an engine thread failed (E1404). A custom shader's builds that a pipeline needs and that did not download fail the thread that draws with E1424. After E1404 or E1424 the engine draws no new frames: destroy it and start a new one. On WebGPU, the GPU can also run out of memory (E1304) or reject the engine's work (E1305). On either GPU path, its driver can refuse to build a pipeline that draws objects of the scene twice (E1307). After these three the engine draws on without the objects that failed. The engine reports each failure once. A failure that no handler listened for when the engine reported it reaches the first handler that listens, so a failure that the app could not hear yet still arrives, and the engine also logs it to the console. A failure that ends the frames reaches these handlers before `onStop`'s. Returns a function that removes the handler. |
|
|
97
121
|
| `onStop(handler: () => void): () => void` | Calls `handler` once, when the engine stops drawing for good: as `destroy()` begins, or at a failure after which it draws no new frames (E1302, E1404 or E1424). At such a failure, the `onFailure` handlers hear it first. A handler added after that runs at once. A handler that throws reaches the console, and the other handlers and the stop go on. Use it to end the page's own work for the engine, such as a frame loop that sends the sketch messages. Returns a function that removes the handler. |
|
|
98
122
|
| `onSketchError(handler: (error: Error) => void): () => void` | Receives each distinct error that the sketch's own code, or a core call in a frame, threw while the engine runs. The engine keeps drawing, so this error alone does not stop it: a frame whose update failed is counted in `measure().updateErrors` and left out of `measure().updatedFps`. The handler receives the errors reported after it was added. Returns a function that removes the handler. Without a handler, the error also reaches the console. |
|
|
99
123
|
| `setPaused(paused: boolean): void` | Pauses or resumes the sketch's frames. A pause also stops input: the sketch sees every key and button that was down come up, and input that comes during the pause never reaches it. |
|
|
100
124
|
| `detach(): void` | Takes the canvas off the page and pauses the engine. The engine keeps its threads, its GPU resources and the scene, and stops reading input. Use it when a single-page app leaves the view that shows the canvas, and `attach` when the view comes back. |
|
|
101
125
|
| `attach(container: Element): void` | Puts the canvas at the end of `container` and resumes the engine where it stopped, unless `setPaused(true)` paused it. |
|
|
102
126
|
| `measure(seconds: number, options?: MeasureOptions): Promise<FrameMetrics>` | Measures the running engine for a number of seconds, then returns CPU time per frame by thread and phase, GPU time, frame intervals, uploads, draw calls, memory and load time. The first call downloads the code that turns the frame records into these figures. `slowMs` adds the frames whose interval broke that many milliseconds, each with the frame's own GPU parts. |
|
|
103
|
-
| `
|
|
127
|
+
| `inspect?(call: string, args?: unknown): Promise<unknown>` | Runs an inspection call against the live scene, for the in-page inspector and the MCP server: `objects`, `object`, `setObject`, `setMaterial`, `stats`, `errors`, `graph`, `setQuality`, `highlight` and `info`, with the arguments that [Debugging](../../guides/debugging.md#the-in-page-inspector) lists. The call runs between frames, in the thread that runs the sketch, and its value is JSON-safe. The page answers `capture` itself, with `{ png, bytes }`: the PNG image of the next 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 release build leaves it out, so code that uses it must check for it first. |
|
|
128
|
+
| `stats(show?: boolean \| StatsOverlayOptions): void` | Shows an overlay of figures over a right-hand corner of the canvas, or hides it with `false`: the GPU path, the frame rates, CPU time per frame of each thread, GPU time, draw calls, triangles and objects drawn, memory, and the page thread's long tasks and input delay. Its header is a button with the frame rate, which shows and hides the other figures. Options pick whether the overlay starts collapsed to its header, and its corner: the top right by 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 code downloads at the first call. While the other figures show, the engine times one frame in eleven on the GPU and reads back the counts of the objects that the GPU culls, which costs a little GPU time. The sketch's `debug.stats` shows and hides the same overlay, and the last call wins. |
|
|
104
129
|
| `capture(): Promise<Blob>` | Resolves with an image of the next frame that the engine draws, as a PNG file. The thread that draws reads the frame back and encodes it, so the page's thread does no work for it when a worker draws. In hold mode it is an image of the held frame, whose pixels the page keeps, so the GPU draws nothing for it. While the engine is paused, the image shows the frame on the canvas. A hidden page draws no frames, so its image comes once the page shows again. When no new frame comes within a second or two, as after a sketch error, the image shows the frame drawn last. Fails with E1414 once the engine has stopped, when the thread that draws gives no answer within the engine's wait, or when that thread could not read the frame back, with the cause that the GPU gave, such as a lost device or too little memory. |
|
|
105
130
|
| `captureFrame(): Promise<{ width: number; height: number; pixels: Uint8Array; frame: number; }>` | Resolves with the pixels of the next frame that the engine draws, as RGBA8 rows, top row first, for tests. The thread that draws waits until its frame loop has taken a new frame, then draws that frame again offscreen and reads it back, so captures back to back give newer frames even where each readback holds that thread up. `frame` is the sketch frame that the capture drew: a capture that follows a scene change can hold the frame recorded before it, and a test that measures frames aligns them by this number. In hold mode, and while the engine is paused, it returns the frame on the canvas. A hidden page draws no frames, so its pixels come once the page shows again. When no new frame comes within a second or two, as after a sketch error, it returns the frame drawn last. It fails when the thread that draws gives no answer within the engine's wait, rather than waiting with no end. |
|
|
106
131
|
| `saveRecording(): Promise<Uint8Array \| undefined>` | Resolves with the recording of the session so far, or undefined when the page does not record one. A page records with the `?record` switch, which also puts a save button on the page. The file holds each frame's step and the input that the sketch read in it, from the session's first frame, so a `?replay` of it draws the same frames. Its format is the engine's own; save it to a file and open `?replay=<file>` to run it. Recording seeds the sketch thread's random numbers, so a recorded session draws the same frames when it replays. |
|
|
@@ -153,8 +178,8 @@ How the engine runs on this device: its build, its latency mode and its threads.
|
|
|
153
178
|
| `renderThread: 'render-worker' \| 'sketch-worker' \| 'main'` | The thread that owns the canvas and draws. |
|
|
154
179
|
| `jobWorkers: number` | The most job workers that share the engine's parallel work. The engine starts none at first, and starts them as the work grows. |
|
|
155
180
|
| `hold: number \| null` | The sketch time in seconds that hold mode holds the sketch at, or null for a live engine. |
|
|
156
|
-
| `preset: QualityPreset` | The quality preset that the engine runs. The preset check can lower it before `createEngine` resolves
|
|
157
|
-
| `presetCheck: PresetCheck \| null` | What the preset check measured, or null when no check ran. The engine checks the preset when it chose it from the device: after the first frame, it measures the frame rate of the scene
|
|
181
|
+
| `preset: QualityPreset` | The quality preset that the engine runs now. The preset check can lower it while it runs: during the first frames of play, or before `createEngine` resolves with the `presetCheck` option's `before-play`. `ctx.quality.setPreset` in the sketch changes it later. Once `engine.presetChecked` has resolved, it holds the preset that the check chose. |
|
|
182
|
+
| `presetCheck: PresetCheck \| null` | What the preset check measured, or null while the check runs, and when no check ran or the sketch chose its own preset first. The engine checks the preset when it chose it from the device: after the first frame, it measures the frame rate of the scene, and lowers the preset until one holds the target. A later start of the sketch in the same browser on the same device takes the stored result instead, and starts at its preset. `reused` is then true. A start after a check that never ended starts at the preset that the check had lowered to, and its own check goes on from there, with the earlier rounds first. |
|
|
158
183
|
| `crashedStarts: number` | The starts of this sketch before this one that crashed the tab, one after another, as the engine's note in `localStorage` records them. After one, the engine starts a preset lower, and after two at `low`. |
|
|
159
184
|
| `memoryMaximumMiB: number \| null` | The shared memory's maximum in MiB, or null for the single-threaded build, whose memory is not shared. |
|
|
160
185
|
| `renderFallback: RenderFallback \| null` | Why the page draws when a worker was meant to, or null when the thread that draws is the one that the options asked for. `report.worker` holds the probe's answer. |
|
|
@@ -170,8 +195,10 @@ Options for `createEngine`.
|
|
|
170
195
|
| --- | --- |
|
|
171
196
|
| `canvas: HTMLCanvasElement` | The canvas to draw into, sized by CSS. On a canvas that no CSS sizes, the engine sets the CSS width and height that it shows when the engine starts. One engine draws on a canvas at a time: a start on the canvas of an engine that is stopping, or still starting and then destroyed, waits for that engine to stop. A canvas whose engine runs on fails with E1419. |
|
|
172
197
|
| `sketch: URL \| string` | The sketch module, which runs in the sketch worker; `new URL('./sketch.ts', import.meta.url)`. |
|
|
198
|
+
| `sketchData?: unknown` | Start data for the sketch, which its setup reads as `ctx.data`: the state that the page knows before the scene starts, such as the section that the address names, a saved color mode or a level number. It reaches the setup before the first frame, also in hold mode, where no message can. It takes plain JSON data: objects, arrays, strings, finite numbers, booleans and null, up to 64 KiB as JSON. Another value fails with E1213. A recording keeps it, and a replay gives the sketch the recorded data. |
|
|
173
199
|
| `preset?: 'auto' \| QualityPreset` | The quality preset: `auto`, the default, lets the engine choose one for the device, and `low`, `medium`, `high` or `ultra` names one. The GPU path caps it: WebGL2 and WebGPU's compatibility mode run at most `medium`. After a start that crashed the tab, the engine starts a preset lower. Another value fails with E1213. The `?preset=` switch wins over it. |
|
|
174
200
|
| `targetFps?: TargetFps` | The frame rate that the engine defends: the preset check and the quality governor lower the quality when frames fall below it. Without it, the target is the display's refresh rate, at most 60. `display` targets the display's full rate, such as 120 or 144 for a game on a fast display. A whole number from 1 up caps the target at that rate. The engine draws at the display's rate in every case. The `?target-fps=` switch wins over it. Another value fails with E1213. |
|
|
201
|
+
| `presetCheck?: PresetCheckTiming` | When the preset check measures, on a start where the engine checks the preset that it chose. With `during-play`, the default, the scene shows at its first frame: `createEngine` resolves once the setup has run, and `engine.firstFrame` once the GPU has finished the first frame. The check then measures the first frames of play, a lighter preset applies in front of the viewer, and `engine.presetChecked` resolves once the check has ended. With `before-play`, the check measures the scene that the setup built before the sketch's update runs, and `createEngine` resolves after it, so a loading screen hides the check and any change of preset. A start that takes the stored result of an earlier check, or that runs no check, plays at once either way. Another value fails with E1213. The `?preset-check=` switch wins over it. |
|
|
175
202
|
| `maxPixelRatio?: number` | Cap for the device pixel ratio, a number from 0.5 up. Without it, the quality preset sets the cap. `ctx.quality.set` changes it during play. |
|
|
176
203
|
| `gpu?: 'auto' \| 'webgpu' \| 'webgl2'` | Forces a GPU tier, for testing only. |
|
|
177
204
|
| `powerPreference?: 'high-performance' \| 'low-power'` | Which GPU to draw with on a device that has two, such as a laptop with a separate graphics chip: `high-performance`, the default, for the faster one, or `low-power` to save battery. The browser treats it as a request. A device with one GPU ignores it. |
|
|
@@ -183,30 +210,30 @@ Options for `createEngine`.
|
|
|
183
210
|
| `shadowTileSize?: number` | Texels on each side of each tile of the shadow atlas: 256, 512, 1,024 or 2,048. Without it, the quality preset sets it. Another value fails with E1213. |
|
|
184
211
|
| `heroTileSize?: number` | Texels on each side of the tile that holds a directional light's hero shadow, for each light whose `shadow` options name no `heroTileSize`: 1,024, 2,048 or 4,096. Without it, the quality preset sets it. Another value fails with E1213. |
|
|
185
212
|
| `pointLightShadows?: boolean` | True makes point lights cast shadows, false keeps them from it. Without it, the quality preset decides: High and Ultra turn them on. Another value fails with E1213. |
|
|
186
|
-
| `depthPrepass?: boolean` | True to draw the depth of the opaque objects before the engine shades them, so each pixel is shaded once, for its nearest surface. It saves GPU time in scenes where objects hide many others and shading costs much, and costs a second pass over the objects' vertices. Without it, the quality preset decides: every preset draws the prepass on WebGL2, and none on WebGPU.
|
|
213
|
+
| `depthPrepass?: boolean` | True to draw the depth of the opaque objects before the engine shades them, so each pixel is shaded once, for its nearest surface. It saves GPU time in scenes where objects hide many others and shading costs much, and costs a second pass over the objects' vertices. Without it, the quality preset decides: every preset draws the prepass on WebGL2, and none on WebGPU. A sketch can change it during play with `quality.set`, and the `?prepass=on` or `?prepass=off` switch wins over this option. Another value fails with E1213. |
|
|
187
214
|
| `momentTransparency?: boolean` | True to blend the camera's blended surfaces in the moment transparency layer. It needs no sort and is nearer an exact back-to-front blend than `blending: 'weighted'` is, and it draws those surfaces twice. Every preset leaves it off, and the `?moments=on` or `?moments=off` switch wins over this option. It stays fixed while the engine runs. Another value fails with E1213. |
|
|
188
215
|
| `gpuOcclusion?: boolean` | True to run GPU occlusion culling on WebGPU: large opaque objects hide the objects that lie wholly behind them, so the GPU skips those. Each camera view draws the depth of the opaque objects that it showed in the last frame and that look large on the screen, and tests every object against it. `setOccluder(false)` keeps an object out of them. A check during play turns the extra passes off while they hide too little or make the GPU's frame longer, and on again when they pay. Without the option, the High and Ultra presets turn it on for desktops, and phones and tablets leave it off. It stays fixed while the engine runs, and the `?occlusion=on` or `?occlusion=off` switch wins over this option. WebGL2 and the depth prepass draw without it. Another value fails with E1213. |
|
|
189
216
|
| `morphTargets?: number` | The most morph target weights of each object that a WebGL2 device draws, a whole number from 1 to 256. Each object keeps the weights farthest from 0. Without it, the quality preset sets it. WebGPU draws every weight. Another value fails with E1213. |
|
|
190
217
|
| `cloudSteps?: number` | The steps of each ray of the sky's volumetric cloud tier when the engine starts, a whole number from 0 to 64. Above 0 the sky draws volumetric clouds in place of the flat layer, from the same cloud settings; 0 draws the flat layer. Without it, the quality preset sets it: 0 on Low and Medium, 32 on High and 48 on Ultra. It lets a page on WebGL2 or in compatibility mode, whose presets stop at Medium, draw the tier. The sky's environment map marches at most 16 steps, and draws them only when this option is above 0, because the map picks its tier's shaders at the page's start. A sketch can change the sky's count during play with `quality.set`. Another value fails with E1213. |
|
|
191
218
|
| `softwareOcclusion?: boolean` | True to run software occlusion culling on WebGL2: objects that `setOccluder(true)` marks hide the objects that lie wholly behind them, so the GPU skips those. False turns it off. Without it, the quality preset decides, and a sketch can change it during play with `quality.set`. The `?occlusion=on` or `?occlusion=off` switch wins over this option. WebGPU ignores it. Another value fails with E1213. |
|
|
192
219
|
| `textureMemoryMiB?: number` | The GPU memory in MiB that textures may take, a whole number from 64 to 16,384. Past it, the engine drops the largest mip levels of textures from files, and loads them again once room returns. Without it, the quality preset sets it: 256, 512, 1,024 or 2,048 from Low to Ultra, and at most 1,008 on phones and tablets. A sketch can change it during play with `quality.set`. Another value fails with E1213. |
|
|
193
|
-
| `keepTextureCopies?: boolean` | True keeps the engine's copy of each texture's texels after their upload, so a texture that maps an image draws with its map again after the browser takes the GPU away. It costs about one more copy of each image in memory. False frees each copy once no frame reads it, and such a texture draws with its color alone until the sketch gives it texels again. Without this option, a phone and a tablet keep copies and a desktop does not, because a phone or a tablet is likeliest to lose its GPU. |
|
|
220
|
+
| `keepTextureCopies?: boolean` | True keeps the engine's copy of each texture's texels after their upload, so a texture that maps an image draws with its map again after the browser takes the GPU away. It costs about one more copy of each image in memory. False frees each copy once no frame reads it, and such a texture draws with its color alone until the sketch gives it texels again. Without this option, a phone and a tablet keep copies and a desktop does not, because a phone or a tablet is likeliest to lose its GPU. With copies, the engine also gives its GPU back while the browser keeps the page in its back/forward cache, and starts a new device when the page shows again. |
|
|
194
221
|
| `transparent?: boolean` | True for a see-through canvas: the page shows through wherever no object draws, until the sketch sets a background color. The canvas holds premultiplied alpha, as a browser composites it. The default is false, an opaque canvas. |
|
|
195
|
-
| `hdr?: boolean` | False draws the scene into 8-bit color, where each material's shader applies the output transform, instead of HDR color, which the final pass tone maps. Both paths
|
|
222
|
+
| `hdr?: boolean` | False draws the scene into 8-bit color, where each material's shader applies the output transform, instead of HDR color, which the final pass tone maps. Both paths honor a material's `toneMapped: false`, and the 8-bit path also honors it on a blended surface. The default lets the engine pick the path from the device, which draws HDR color wherever it can. The `?hdr=off` switch takes the 8-bit path too. |
|
|
196
223
|
| `largeWorld?: boolean` | True for scenes that reach far beyond a city, such as a planet. Object positions then keep the precision of JavaScript's numbers at any distance from the origin: 0.03 mm or better. Without it, positions are 32-bit floats, which move in steps of 6 cm at 1,000 km from the origin and 0.5 m at the Earth's radius. It costs 12 bytes of memory per object and a little work in each position setter. The default is false. Instance batches need no mode: give each one an `origin` near its rows. |
|
|
197
224
|
| `sketchThread?: SketchThread` | The thread that runs the sketch's code and the engine core: `worker`, the default, or `main` for the page's main thread, where the sketch can reach the DOM. Use `main` for apps that work mostly with the DOM, and for debugging. The render worker still draws in pipelined mode, and the page draws in low-latency mode. The sketch's frames then share the page's thread with the page's own work, so each can slow the other. The single-threaded build always runs the sketch on the page's thread. The `?sketch-thread=` switch wins over this option. |
|
|
198
225
|
| `memory?: { maximumMiB: number; }` | The engine's memory. `maximumMiB` sets the most memory that the engine's threads share, in MiB: a whole number from 256 to 4096, 1024 by default. Another value fails with E1409. The browser reserves address space for the whole maximum when the engine starts. So a larger maximum leaves less room for other engines and WebAssembly modules on the page. Ask for more only when a scene needs it. The single-threaded build's memory is not shared, so this option does not change it. The `?memory=<MiB>` switch wins over it. |
|
|
199
226
|
| `maxLabels?: number` | The most HTML labels that the sketch can track at once with `ui.trackLabel`: a whole number from 1 to 65,536, 4,096 by default. Another value fails with E1213. The engine keeps three tables of 16 bytes per label in memory that its threads share, so 4,096 labels take 192 KB. |
|
|
200
227
|
| `maxLabels3d?: number` | The most labels that the sketch can track at once with `ui.trackLabel` whose `transform` is `'world'` or `'billboard'`: a whole number from 0 to 65,536, 256 by default. Another value fails with E1213. Each of them is a plane of the scene, which takes three tables of 52 bytes per label, so 256 of them take 40 KB. A sketch that tracks one more fails with E1219. |
|
|
201
228
|
| `expectedObjects?: number` | The number of objects that the scene will hold at most, when the sketch knows it: a whole number from 1 to 1,048,575. Another value fails with E1213. The scene then starts with room for that many, so it never grows during play. Without it, the scene starts with room for 1,023 objects. A scene grows on its own when it needs more: it doubles its room at the start of a frame once it is three quarters full. A create call that finds it full doubles it at once. Each growth copies the scene's tables, about 267 bytes per object, in one short pause. Set this option for a scene that creates many objects during play, so they never wait for one. |
|
|
202
|
-
| `onProgress?: (stage: StartupStage, progress?: StartupProgress) => void` | Called as the start reaches each stage, in this order: `core-download` as the engine core's file downloads, with the bytes that have arrived; `core` once the engine core is compiled and the GPU paths are tested; `sketch` once the sketch's setup has run; and `first-frame` once the GPU has finished the first frame. Before `core`, `core-download` reports the core file's bytes, and `memory-wait` comes when the browser has refused the engine's memory for 10 seconds. The engine then tries for about 35 seconds more before it fails with E1109. `progress` gives a stage's figures while it has some: the bytes of a download, measured against the length that the server announced. |
|
|
229
|
+
| `onProgress?: (stage: StartupStage, progress?: StartupProgress) => void` | Called as the start reaches each stage, in this order: `core-download` as the engine core's file downloads, with the bytes that have arrived; `core` once the engine core is compiled and the GPU paths are tested; `sketch` once the sketch's setup has run; and `first-frame` once the GPU has finished the first frame after the setup. The preset check does not hold up either stage, unless the `presetCheck` option is `before-play`: `sketch` then comes after the check too. Before `core`, `core-download` reports the core file's bytes, and `memory-wait` comes when the browser has refused the engine's memory for 10 seconds. The engine then tries for about 35 seconds more before it fails with E1109. `progress` gives a stage's figures while it has some: the bytes of a download, measured against the length that the server announced. |
|
|
203
230
|
| `onSketchMessage?: (name: string, data: unknown) => void` | Receives the messages the sketch sends with `ctx.page.post`, from the start of the sketch's setup. Use it for progress that the sketch reports while it loads. `engine.onSketchMessage` adds more handlers once the engine has started. |
|
|
204
231
|
| `onSketchError?: (error: Error) => void` | Receives each distinct error that the sketch's own code, or a core call in a frame, threw while the engine runs. The error's message holds the failure, such as `E1102: ...`. The engine keeps drawing and presenting frames, so the error alone does not stop it: a frame whose update failed is counted in `measure().updateErrors` and left out of `measure().updatedFps`. `engine.onSketchError` adds more handlers once the engine has started. Without a handler, the error also reaches the console. |
|
|
205
232
|
| `onWorkerRetry?: (worker: string, script: string) => void` | Called when a worker's script did not load before the worker's first message, and the engine started a second copy of it. The fault comes and goes, so the engine recovers on its own: the call names the worker, such as `render` or `job 2`, and the address of its script. The engine also warns in the console. Without a second copy that loads, the start fails with E1405, which names the worker and its script. |
|
|
206
233
|
| `signal?: AbortSignal` | Cancels a start in progress, for example when the user leaves the page. `createEngine` then stops the engine's threads and rejects with the signal's reason. |
|
|
207
234
|
| `hold?: number` | Starts the engine in hold mode for image tests, held at this many seconds of sketch time. The engine steps the sketch from 0 to the time in fixed steps of 1/60 second, with no frame loop. `math.random` and `Math.random` in the sketch's thread give the same numbers on every run, and the sketch gets no input: every key and button stays up. The engine then draws that one frame and reads it back, and `createEngine` resolves. The `?hold=<seconds>` switch overrides this time, and a bare `?hold` holds at it, or at 0 without it. |
|
|
208
235
|
| `input?: boolean` | False keeps the engine from listening for input, for a page whose input another library records, such as a game whose simulation replays a log of it. The engine's input then adds no listener: none for pointers, keys, the wheel, focus, page visibility, the pointer lock or gamepads. It captures no pointer on the canvas, and leaves the canvas's context menu to the browser. The engine keeps its listeners that take no input, such as the canvas watch's `visibilitychange`, after which the sketch's next step counts no hidden time. The sketch's `ctx.input` stays at rest: every key, button and action is up, `value` gives 0, `input.touches` is empty, and the pointer stays at the canvas's top-left corner with no movement, wheel or buttons. Objects get no pointer events, and `requestPointerLock` fails with E1426. A development build warns in the console, once for each kind, when the sketch reads `ctx.input`, gives an object a pointer event handler or imports `@null3d/controls`. The warning about the controls comes as they load in the sketch's thread, so it misses controls that another sketch in that thread loaded first. Two engines on the page's thread both hear a load by either one's sketch. The default is true. |
|
|
209
|
-
| `preload?: readonly ShaderFeature[]` | Features whose shaders load before the first frame, for a game that must fetch nothing while it plays. Each feature's shaders otherwise download the first time the sketch uses it: `'skinning'` with the first skinned mesh, `'morph'` with the first morphed mesh, `'bloom'` and `'ao'` when `post.set` turns them on, `'sprites'` and `'lines'` with the first batch, `'background'` with a texture, environment or cube map background, `'sky'` with the sky, `'coverage'` with the first masked material that MSAA smooths, `'hash'` with the first hashed material, `'cutout'` with the first masked object that casts shadows, which casts none until its shaders are built, `'transmission'` with the first material that lets light through, `'color_copy'` with the first step that reads the color of the frame before, which the preset's bounce light draws at its start, `'translucency'` with the first material that lets light through to its other side, `'subsurface'` with the first material with a `subsurfaceRadius` while the subsurface blur has taps, `'coat_sheen'` with the first material with a clear coat or a sheen, `'weighted'` with the first material of the `weighted` blending, and `'occlusion'` with the first opaque
|
|
236
|
+
| `preload?: readonly ShaderFeature[]` | Features whose shaders load before the first frame, for a game that must fetch nothing while it plays. Each feature's shaders otherwise download the first time the sketch uses it: `'skinning'` with the first skinned mesh, `'morph'` with the first morphed mesh, `'bloom'` and `'ao'` when `post.set` turns them on, `'sprites'` and `'lines'` with the first batch, `'background'` with a texture, environment or cube map background, `'sky'` with the sky, `'coverage'` with the first masked material that MSAA smooths, `'hash'` with the first hashed material, `'cutout'` with the first masked object that casts shadows, which casts none until its shaders are built, `'transmission'` with the first material that lets light through, `'color_copy'` with the first step that reads the color of the frame before, which the preset's bounce light draws at its start, `'translucency'` with the first material that lets light through to its other side, `'subsurface'` with the first material with a `subsurfaceRadius` while the subsurface blur has taps, `'coat_sheen'` with the first material with a clear coat or a sheen, `'weighted'` with the first material of the `weighted` blending, and `'occlusion'` with the first opaque material while GPU occlusion culling runs on WebGPU. WebGPU morphs in the skinning pass, so there `'morph'` loads the skinning shaders, and WebGL2 has no `'occlusion'` shaders to load. Listed features download beside the engine's own shaders, so the start waits only for the largest. The shaders that two or more listed features need together, such as a skinned mesh's with the alpha hash, download with them. Loading a glTF file with skins or morph targets, or making a batch, also starts its feature's download at once, before the objects draw. Throws E1421 for a name it does not know. |
|
|
210
237
|
| `stats?: boolean \| StatsOverlayOptions` | True or options show the stats overlay over the canvas from the first frame, as `engine.stats` does with the same value. The default is false. The `?stats` or `?stats=on` switch shows it too, with these options when they are given, and `?stats=off` hides it, whatever this option says. A held engine for image tests shows no overlay. |
|
|
211
238
|
| `still?: boolean` | False draws every frame of a view that holds still. By default such a view blends its frames into a sharper picture and then stops drawing until something changes. The `?still-camera=off` switch turns it off too, and hold mode draws without it. |
|
|
212
239
|
|
|
@@ -252,6 +279,7 @@ type ErrorCode =
|
|
|
252
279
|
| 'E1304'
|
|
253
280
|
| 'E1305'
|
|
254
281
|
| 'E1306'
|
|
282
|
+
| 'E1307'
|
|
255
283
|
| 'E1401'
|
|
256
284
|
| 'E1402'
|
|
257
285
|
| 'E1403'
|
|
@@ -432,6 +460,14 @@ Options for `engine.requestPointerLock`.
|
|
|
432
460
|
| --- | --- |
|
|
433
461
|
| `unadjustedMovement?: boolean` | True asks for the mouse's raw movement, without the speed-up that the system applies. Browsers that cannot give it refuse the lock with E1425. The default is false. |
|
|
434
462
|
|
|
463
|
+
## `PresetCheckTiming`
|
|
464
|
+
|
|
465
|
+
```ts
|
|
466
|
+
type PresetCheckTiming = 'during-play' | 'before-play';
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
When the preset check measures, as `createEngine`'s `presetCheck` option and the `?preset-check=` switch name it. With `during-play`, the default, the scene plays from its first frame, and the check measures the first frames of play. With `before-play`, the check measures before the sketch's update runs, and the start waits for it.
|
|
470
|
+
|
|
435
471
|
## `readDeviceHints`
|
|
436
472
|
|
|
437
473
|
```ts
|
|
@@ -446,7 +482,12 @@ Reads the device hints on the page's main thread, which workers cannot: they hav
|
|
|
446
482
|
type RenderFallback = WorkerProbeFailure['failure'] | 'no-surface';
|
|
447
483
|
```
|
|
448
484
|
|
|
449
|
-
Why the engine draws on the page's thread when its options asked a worker to draw:
|
|
485
|
+
Why the engine draws on the page's thread when its options asked a worker to draw:
|
|
486
|
+
- `no-answer`: the probe worker, and a second one after it, gave no answer within their time
|
|
487
|
+
limits. A stalled GPU call or a very busy machine causes this.
|
|
488
|
+
- `failed-to-start`: the probe worker's script failed to load or run.
|
|
489
|
+
- `no-surface`: a worker cannot draw with the GPU path here, as the browser offers no context of
|
|
490
|
+
it for an `OffscreenCanvas` in a worker.
|
|
450
491
|
|
|
451
492
|
## `ReplayResult`
|
|
452
493
|
|
|
@@ -549,7 +590,7 @@ The GPU path the engine draws with: core WebGPU, WebGPU in compatibility mode on
|
|
|
549
590
|
## `VERSION`
|
|
550
591
|
|
|
551
592
|
```ts
|
|
552
|
-
const VERSION: '0.
|
|
593
|
+
const VERSION: '0.1.1'
|
|
553
594
|
```
|
|
554
595
|
|
|
555
596
|
The engine version, which the WebAssembly core and this package always share.
|
|
@@ -603,7 +644,7 @@ What the browser's WebGPU offers, in `CapabilityReport.webgpu`.
|
|
|
603
644
|
| `wgslLanguageFeatures: string[]` | The WGSL language features the browser supports, sorted. |
|
|
604
645
|
| `preferredCanvasFormat: string \| null` | The canvas texture format the browser prefers, or null without WebGPU. |
|
|
605
646
|
| `transientAttachments: boolean` | True when the browser's WebGPU has the transient attachment texture usage (Chrome 146 and later). A render target with it can stay in a tile-based GPU's own memory. The engine gives it to the targets that live within one render pass, such as the multisampled color and depth. |
|
|
606
|
-
| `directDraws: boolean` | True when the start-up probe measured the device drawing a bucket faster with direct draws than with the engine's indirect draws, so the engine draws directly. The probe runs on a worker's device, and only on an Apple GPU in WebKit, whose validation of each indirect draw the direct path removes
|
|
647
|
+
| `directDraws: boolean` | True when the start-up probe measured the device drawing a bucket faster with direct draws than with the engine's indirect draws, so the engine draws directly. The probe runs on a worker's device, and only on an Apple GPU in WebKit, whose validation of each indirect draw the direct path removes. False on WebGL2. |
|
|
607
648
|
| `drawPath: DrawPathReason` | Why the probe chose that draw path, or why it did not measure. |
|
|
608
649
|
| `adapterInfo: { vendor: string; architecture: string; device: string; description: string; } \| null` | Reported for the record. The engine reads no meaning from it, and only compares it with an earlier start's, to tell whether a stored preset check came from the same GPU. |
|
|
609
650
|
| `error?: string` | Why the probe failed, when it did. |
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: api/reference/feature-draws
|
|
3
3
|
title: "Add-on feature draws: API reference"
|
|
4
|
-
|
|
5
|
-
since: "0.3"
|
|
4
|
+
generated: true
|
|
6
5
|
summary: "Every export of the Add-on feature draws API, from the engine's doc comments."
|
|
7
6
|
---
|
|
8
7
|
|
|
@@ -30,7 +29,7 @@ One add-on draw that a feature description declared. It draws its vertices with
|
|
|
30
29
|
|
|
31
30
|
## `FeatureDrawOptions`
|
|
32
31
|
|
|
33
|
-
Interface `FeatureDrawOptions`, which extends `Omit
|
|
32
|
+
Interface `FeatureDrawOptions`, which extends `Omit<ShaderOptions<Wgsl>, 'wgsl'>`.
|
|
34
33
|
|
|
35
34
|
Options of `scene.addFeatureDraw` besides the feature description. The shader and its uniforms take the options of `materials.shader`, so a draw takes every value and texture that a custom material takes. Where the draw sits, and where it sorts, come from the description.
|
|
36
35
|
|
|
@@ -71,7 +70,7 @@ A draw of many copies: one shape that the engine repeats once for each row of an
|
|
|
71
70
|
|
|
72
71
|
## `FeatureInstancesOptions`
|
|
73
72
|
|
|
74
|
-
Interface `FeatureInstancesOptions`, which extends `FeatureDrawOptions
|
|
73
|
+
Interface `FeatureInstancesOptions`, which extends `FeatureDrawOptions<Wgsl>`.
|
|
75
74
|
|
|
76
75
|
Options of `scene.addFeatureInstances`: the options of a draw, and the number of copies that the engine draws of its one shape. Each copy is a row of an instance batch, with its own place, color and values, which the add-on writes in the batch's arrays.
|
|
77
76
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: api/reference/feature-effects
|
|
3
3
|
title: "Add-on feature effects: API reference"
|
|
4
|
-
|
|
5
|
-
since: "0.3"
|
|
4
|
+
generated: true
|
|
6
5
|
summary: "Every export of the Add-on feature effects API, from the engine's doc comments."
|
|
7
6
|
---
|
|
8
7
|
|
|
@@ -27,6 +26,6 @@ A full-screen feature that `post.addFeatureEffect` placed: the effect while the
|
|
|
27
26
|
|
|
28
27
|
## `FeatureEffectOptions`
|
|
29
28
|
|
|
30
|
-
Interface `FeatureEffectOptions`, which extends `Omit
|
|
29
|
+
Interface `FeatureEffectOptions`, which extends `Omit<EffectOptions<Wgsl>, 'order'>`.
|
|
31
30
|
|
|
32
31
|
Options of `post.addFeatureEffect` besides the feature description: the pass's WGSL, its first uniform values and its textures, as `post.addEffect` takes them. The description gives the place where the pass runs, so the options take no order.
|