@null3d/engine 0.0.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +109 -0
- package/THIRD-PARTY-NOTICES.txt +0 -1
- package/dist/wasm/single/null3d.js +25 -10
- package/dist/wasm/single/null3d_bg.wasm +0 -0
- package/dist/wasm/threaded/null3d.js +25 -10
- package/dist/wasm/threaded/null3d_bg.wasm +0 -0
- package/docs/api/animation.md +114 -86
- package/docs/api/assets.md +135 -49
- package/docs/api/cameras.md +45 -12
- package/docs/api/controls.md +88 -62
- package/docs/api/debug.md +116 -41
- package/docs/api/engine.md +117 -35
- package/docs/api/feature-draws.md +23 -17
- package/docs/api/feature-effects.md +11 -11
- package/docs/api/feature-instances.md +70 -19
- package/docs/api/features.md +77 -47
- package/docs/api/geometry.md +132 -82
- package/docs/api/grass.md +55 -13
- package/docs/api/impostors.md +175 -22
- package/docs/api/input.md +24 -18
- package/docs/api/lights.md +78 -51
- package/docs/api/lines.md +41 -33
- package/docs/api/materials.md +248 -121
- package/docs/api/math.md +12 -13
- package/docs/api/objects.md +47 -22
- package/docs/api/page.md +58 -7
- package/docs/api/particles.md +33 -20
- package/docs/api/points.md +19 -31
- package/docs/api/post.md +75 -42
- package/docs/api/quality.md +42 -17
- package/docs/api/raycast.md +65 -51
- package/docs/api/reference/animation.md +10 -11
- package/docs/api/reference/assets.md +25 -22
- package/docs/api/reference/cameras.md +8 -4
- package/docs/api/reference/controls.md +134 -25
- package/docs/api/reference/debug.md +81 -14
- package/docs/api/reference/engine.md +58 -17
- package/docs/api/reference/feature-draws.md +3 -4
- package/docs/api/reference/feature-effects.md +2 -3
- package/docs/api/reference/feature-instances.md +5 -4
- package/docs/api/reference/features.md +7 -4
- package/docs/api/reference/geometry.md +287 -97
- package/docs/api/reference/grass.md +63 -3
- package/docs/api/reference/impostors.md +208 -13
- package/docs/api/reference/input.md +4 -5
- package/docs/api/reference/lights.md +13 -12
- package/docs/api/reference/lines.md +10 -11
- package/docs/api/reference/materials.md +54 -53
- package/docs/api/reference/math.md +35 -24
- package/docs/api/reference/objects.md +11 -12
- package/docs/api/reference/particles.md +31 -6
- package/docs/api/reference/points.md +6 -7
- package/docs/api/reference/post.md +21 -20
- package/docs/api/reference/quality.md +8 -5
- package/docs/api/reference/raycast.md +7 -8
- package/docs/api/reference/render.md +5 -4
- package/docs/api/reference/scene.md +52 -30
- package/docs/api/reference/sketch.md +15 -11
- package/docs/api/reference/sound.md +234 -0
- package/docs/api/reference/splats.md +42 -3
- package/docs/api/reference/sprites.md +7 -8
- package/docs/api/reference/tasks.md +16 -3
- package/docs/api/reference/terrain.md +27 -5
- package/docs/api/reference/textures.md +5 -6
- package/docs/api/reference/three-compat.md +18 -7
- package/docs/api/reference/time.md +1 -2
- package/docs/api/reference/ui.md +12 -9
- package/docs/api/reference/vertex-draws.md +5 -6
- package/docs/api/reference/water.md +153 -9
- package/docs/api/reference/wind.md +17 -4
- package/docs/api/render.md +73 -29
- package/docs/api/scene.md +164 -60
- package/docs/api/sketch.md +102 -15
- package/docs/api/sound.md +205 -0
- package/docs/api/splats.md +46 -12
- package/docs/api/sprites.md +10 -24
- package/docs/api/tasks.md +33 -24
- package/docs/api/terrain.md +42 -22
- package/docs/api/textures.md +68 -19
- package/docs/api/three-compat.md +15 -7
- package/docs/api/time.md +3 -5
- package/docs/api/ui.md +19 -23
- package/docs/api/vertex-draws.md +13 -12
- package/docs/api/water.md +262 -35
- package/docs/api/wind.md +63 -17
- package/docs/cli/null3d.md +177 -27
- package/docs/concepts/architecture.md +73 -27
- package/docs/concepts/assets.md +57 -33
- package/docs/concepts/backends.md +69 -27
- package/docs/concepts/color-management.md +54 -36
- package/docs/concepts/culling.md +68 -47
- package/docs/concepts/handles.md +14 -5
- package/docs/concepts/instances.md +74 -25
- package/docs/concepts/large-worlds.md +18 -8
- package/docs/concepts/lighting.md +155 -87
- package/docs/concepts/lod.md +126 -44
- package/docs/concepts/materials.md +58 -27
- package/docs/concepts/particle-buffer.md +48 -35
- package/docs/concepts/post-processing.md +84 -43
- package/docs/concepts/quality-preset-tables.md +56 -52
- package/docs/concepts/quality-presets.md +164 -52
- package/docs/concepts/render-graph.md +69 -29
- package/docs/concepts/render-layers.md +11 -21
- package/docs/concepts/shadows.md +105 -52
- package/docs/concepts/static-dynamic.md +22 -7
- package/docs/cookbook/index.md +164 -120
- package/docs/data/threejs-mapping.json +362 -367
- package/docs/errors/E1101.md +23 -5
- package/docs/errors/E1102.md +11 -3
- package/docs/errors/E1103.md +11 -3
- package/docs/errors/E1104.md +11 -3
- package/docs/errors/E1105.md +13 -5
- package/docs/errors/E1106.md +11 -3
- package/docs/errors/E1107.md +15 -5
- package/docs/errors/E1108.md +11 -3
- package/docs/errors/E1109.md +32 -6
- package/docs/errors/E1110.md +23 -5
- package/docs/errors/E1111.md +11 -3
- package/docs/errors/E1112.md +11 -3
- package/docs/errors/E1203.md +12 -4
- package/docs/errors/E1204.md +11 -3
- package/docs/errors/E1205.md +11 -3
- package/docs/errors/E1206.md +28 -6
- package/docs/errors/E1207.md +11 -3
- package/docs/errors/E1208.md +12 -3
- package/docs/errors/E1209.md +11 -3
- package/docs/errors/E1213.md +27 -5
- package/docs/errors/E1214.md +14 -6
- package/docs/errors/E1215.md +31 -6
- package/docs/errors/E1216.md +31 -6
- package/docs/errors/E1217.md +29 -6
- package/docs/errors/E1218.md +22 -6
- package/docs/errors/E1219.md +11 -3
- package/docs/errors/E1220.md +24 -5
- package/docs/errors/E1221.md +24 -5
- package/docs/errors/E1222.md +11 -3
- package/docs/errors/E1223.md +39 -6
- package/docs/errors/E1224.md +11 -3
- package/docs/errors/E1225.md +11 -3
- package/docs/errors/E1301.md +11 -3
- package/docs/errors/E1302.md +11 -3
- package/docs/errors/E1303.md +11 -3
- package/docs/errors/E1304.md +11 -3
- package/docs/errors/E1305.md +13 -3
- package/docs/errors/E1306.md +11 -3
- package/docs/errors/E1307.md +40 -0
- package/docs/errors/E1401.md +11 -3
- package/docs/errors/E1402.md +13 -5
- package/docs/errors/E1403.md +11 -3
- package/docs/errors/E1404.md +13 -3
- package/docs/errors/E1405.md +15 -4
- package/docs/errors/E1406.md +31 -5
- package/docs/errors/E1407.md +11 -3
- package/docs/errors/E1408.md +11 -3
- package/docs/errors/E1409.md +11 -3
- package/docs/errors/E1410.md +13 -5
- package/docs/errors/E1411.md +11 -3
- package/docs/errors/E1412.md +29 -6
- package/docs/errors/E1413.md +11 -3
- package/docs/errors/E1414.md +11 -3
- package/docs/errors/E1415.md +11 -3
- package/docs/errors/E1416.md +27 -6
- package/docs/errors/E1417.md +11 -3
- package/docs/errors/E1418.md +12 -3
- package/docs/errors/E1419.md +13 -5
- package/docs/errors/E1420.md +14 -6
- package/docs/errors/E1421.md +11 -3
- package/docs/errors/E1422.md +12 -3
- package/docs/errors/E1423.md +12 -3
- package/docs/errors/E1424.md +24 -5
- package/docs/errors/E1425.md +11 -3
- package/docs/errors/E1426.md +11 -3
- package/docs/errors/E1430.md +11 -3
- package/docs/errors/E1431.md +11 -3
- package/docs/errors/E1432.md +11 -3
- package/docs/errors/E1433.md +11 -3
- package/docs/errors/E1434.md +15 -6
- package/docs/errors/E1435.md +11 -3
- package/docs/errors/E1436.md +11 -3
- package/docs/errors/E1437.md +14 -6
- package/docs/errors/E1501.md +41 -6
- package/docs/errors/E1502.md +13 -3
- package/docs/errors/E1503.md +11 -3
- package/docs/errors/E1504.md +11 -3
- package/docs/errors/E1505.md +23 -5
- package/docs/errors/E1506.md +11 -3
- package/docs/errors/index.md +54 -30
- package/docs/getting-started/cdn.md +32 -10
- package/docs/getting-started/first-scene.md +21 -13
- package/docs/getting-started/hosting.md +152 -63
- package/docs/getting-started/install.md +44 -28
- package/docs/getting-started/network-use.md +33 -15
- package/docs/getting-started/project-structure.md +33 -12
- package/docs/getting-started/third-party-notices.md +12 -14
- package/docs/guides/accessibility.md +5 -5
- package/docs/guides/add-ons.md +86 -15
- package/docs/guides/agents.md +16 -9
- package/docs/guides/assets-pipeline.md +259 -82
- package/docs/guides/audio.md +115 -128
- package/docs/guides/baked-light-data.md +44 -23
- package/docs/guides/car-paint.md +38 -32
- package/docs/guides/content-pages.md +63 -35
- package/docs/guides/custom-passes.md +65 -22
- package/docs/guides/custom-shaders.md +59 -39
- package/docs/guides/debugging.md +74 -10
- package/docs/guides/deploying.md +85 -6
- package/docs/guides/deterministic-simulation.md +24 -17
- package/docs/guides/first-use-shaders.md +83 -45
- package/docs/guides/lens-kit.md +29 -26
- package/docs/guides/loading-screens.md +132 -47
- package/docs/guides/multiple-views.md +63 -13
- package/docs/guides/performance.md +192 -38
- package/docs/guides/phones.md +78 -15
- package/docs/guides/physics.md +7 -11
- package/docs/guides/screens.md +47 -33
- package/docs/guides/start-time.md +363 -0
- package/docs/guides/testing.md +152 -95
- package/docs/guides/ui-overlays.md +19 -14
- package/docs/guides/video-textures.md +14 -13
- package/docs/images/api/animation/character.webp +0 -0
- package/docs/images/api/animation/look-at-ring.webp +0 -0
- package/docs/images/api/animation/morph-tulips.webp +0 -0
- package/docs/images/api/animation/skeleton-lines.webp +0 -0
- package/docs/images/api/controls/gizmo-handles.webp +0 -0
- package/docs/images/api/controls/walk-and-fly.webp +0 -0
- package/docs/images/api/debug/debug-shapes.webp +0 -0
- package/docs/images/api/debug/levels-view.webp +0 -0
- package/docs/images/api/engine/transparent-canvas.webp +0 -0
- package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
- package/docs/images/api/feature-instances/compute-instances.webp +0 -0
- package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
- package/docs/images/api/geometry/extra-shapes.webp +0 -0
- package/docs/images/api/geometry/generators.webp +0 -0
- package/docs/images/api/geometry/mesh-arrays.webp +0 -0
- package/docs/images/api/geometry/vertex-updates.webp +0 -0
- package/docs/images/api/grass/grass-grove.webp +0 -0
- package/docs/images/api/grass/grass-presets.webp +0 -0
- package/docs/images/api/grass/grass-shadow.webp +0 -0
- package/docs/images/api/impostors/impostor-handover.webp +0 -0
- package/docs/images/api/impostors/impostor-shadow.webp +0 -0
- package/docs/images/api/impostors/impostors-forest.webp +0 -0
- package/docs/images/api/lights/spot-cookies.webp +0 -0
- package/docs/images/api/lines/lines-lit.webp +0 -0
- package/docs/images/api/lines/lines-widths.webp +0 -0
- package/docs/images/api/materials/coat-and-sheen.webp +0 -0
- package/docs/images/api/materials/decals.webp +0 -0
- package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
- package/docs/images/api/materials/relief.webp +0 -0
- package/docs/images/api/materials/shader-inputs.webp +0 -0
- package/docs/images/api/materials/standard-grid.webp +0 -0
- package/docs/images/api/materials/subsurface.webp +0 -0
- package/docs/images/api/materials/translucency.webp +0 -0
- package/docs/images/api/objects/objects-turntable.webp +0 -0
- package/docs/images/api/particles/campfire.webp +0 -0
- package/docs/images/api/points/galaxy.webp +0 -0
- package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
- package/docs/images/api/render/fullscreen-glow.webp +0 -0
- package/docs/images/api/render/reflection-mirror.webp +0 -0
- package/docs/images/api/render/security-camera.webp +0 -0
- package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
- package/docs/images/api/sound/sound-demo.webp +0 -0
- package/docs/images/api/splats/splats-demo.webp +0 -0
- package/docs/images/api/sprites/sprites-lines.webp +0 -0
- package/docs/images/api/terrain/terrain-demo.webp +0 -0
- package/docs/images/api/textures/canvas-screen.webp +0 -0
- package/docs/images/api/textures/mipmaps.webp +0 -0
- package/docs/images/api/vertex-draws/rain.webp +0 -0
- package/docs/images/api/water/ocean.webp +0 -0
- package/docs/images/api/water/water-demo.webp +0 -0
- package/docs/images/api/water/water-rain.webp +0 -0
- package/docs/images/api/water/waterfall.webp +0 -0
- package/docs/images/concepts/assets/gltf-model.webp +0 -0
- package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
- package/docs/images/concepts/culling/far-from-origin.webp +0 -0
- package/docs/images/concepts/instances/instances.webp +0 -0
- package/docs/images/concepts/instances/per-row-colors.webp +0 -0
- package/docs/images/concepts/large-worlds/large-world.webp +0 -0
- package/docs/images/concepts/lighting/area-lights.webp +0 -0
- package/docs/images/concepts/lighting/atmosphere.webp +0 -0
- package/docs/images/concepts/lighting/environment.webp +0 -0
- package/docs/images/concepts/lighting/light-shafts.webp +0 -0
- package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
- package/docs/images/concepts/lod/forest.webp +0 -0
- package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
- package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
- package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
- package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
- package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
- package/docs/images/concepts/post-processing/sharpen.webp +0 -0
- package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
- package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
- package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
- package/docs/images/cookbook/index/picking.webp +0 -0
- package/docs/images/cookbook/index/time-of-day.webp +0 -0
- package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
- package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
- package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
- package/docs/images/guides/multiple-views/split-screen.webp +0 -0
- package/docs/images/guides/performance/overdraw-view.webp +0 -0
- package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
- package/docs/images/index/showcase-island.webp +0 -0
- package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
- package/docs/images/shaders/builtins/builtins.webp +0 -0
- package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
- package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
- package/docs/images/shots.json +2231 -0
- package/docs/index.md +18 -23
- package/docs/moves.json +1 -0
- package/docs/nav.json +300 -0
- package/docs/pages.md +230 -209
- package/docs/porting/react-three-fiber.md +225 -6
- package/docs/porting/threejs-loop-and-threads.md +217 -7
- package/docs/porting/threejs-mapping.md +1249 -233
- package/docs/porting/threejs-materials.md +218 -6
- package/docs/porting/threejs-overview.md +240 -7
- package/docs/porting/threejs-postprocessing.md +4 -8
- package/docs/porting/threejs-shaders.md +301 -6
- package/docs/porting/threejs-unsupported.md +83 -7
- package/docs/porting/verification.md +178 -6
- package/docs/shaders/builtins.md +15 -4
- package/docs/shaders/library.md +72 -45
- package/docs/shaders/surface-functions.md +59 -23
- package/docs/shaders/wgsl-rules.md +12 -5
- package/lib/debug/channel.d.ts +103 -0
- package/lib/debug/channel.js +269 -0
- package/lib/debug/debug.d.ts +11 -9
- package/lib/debug/draw.d.ts +11 -2
- package/lib/debug/draw.js +57 -6
- package/lib/debug/inspector.d.ts +60 -0
- package/lib/debug/inspector.js +475 -0
- package/lib/debug/overlay-look.d.ts +6 -0
- package/lib/debug/overlay-look.js +29 -7
- package/lib/debug/overlay.js +15 -11
- package/lib/debug/stats-options.d.ts +13 -0
- package/lib/debug/stats-panel.d.ts +22 -7
- package/lib/debug/stats-panel.js +80 -13
- package/lib/debug/stats.d.ts +2 -3
- package/lib/errors/codes.d.ts +17 -3
- package/lib/errors/codes.js +117 -105
- package/lib/errors/engine-error.js +25 -10
- package/lib/errors/fixes.d.ts +1 -0
- package/lib/errors/fixes.js +20 -19
- package/lib/generated/core.d.ts +1 -1
- package/lib/generated/core.js +1 -1
- package/lib/gpu/early-builds.d.ts +68 -0
- package/lib/gpu/early-builds.js +158 -0
- package/lib/gpu/pipeline-name.d.ts +6 -0
- package/lib/gpu/pipeline-name.js +23 -0
- package/lib/gpu/variants.d.ts +8 -2
- package/lib/gpu/variants.js +39 -7
- package/lib/gpu/webgl2/backend.d.ts +63 -2
- package/lib/gpu/webgl2/backend.js +226 -8
- package/lib/gpu/webgl2/programs.d.ts +18 -0
- package/lib/gpu/webgl2/programs.js +5 -2
- package/lib/gpu/webgpu/backend.d.ts +89 -2
- package/lib/gpu/webgpu/backend.js +255 -8
- package/lib/gpu/webgpu/pipelines.d.ts +13 -0
- package/lib/gpu/webgpu/pipelines.js +28 -14
- package/lib/index.d.ts +7 -5
- package/lib/index.js +3 -2
- package/lib/math/color.d.ts +5 -5
- package/lib/math/color.js +5 -5
- package/lib/math/mat4.d.ts +6 -12
- package/lib/math/mat4.js +6 -12
- package/lib/math/namespaces/quat.d.ts +3 -3
- package/lib/math/namespaces/quat.js +3 -3
- package/lib/math/quat.d.ts +8 -12
- package/lib/math/quat.js +8 -12
- package/lib/math/random.d.ts +2 -3
- package/lib/math/random.js +2 -3
- package/lib/math/types.d.ts +4 -4
- package/lib/math/vec3.d.ts +3 -6
- package/lib/math/vec3.js +3 -6
- package/lib/page/capabilities.d.ts +8 -8
- package/lib/page/capabilities.js +39 -25
- package/lib/page/check-store.d.ts +14 -2
- package/lib/page/check-store.js +34 -11
- package/lib/page/engine.d.ts +117 -31
- package/lib/page/engine.js +438 -99
- package/lib/page/first-frame.d.ts +16 -0
- package/lib/page/first-frame.js +35 -0
- package/lib/page/frame-stats.d.ts +34 -1
- package/lib/page/frame-stats.js +15 -0
- package/lib/page/label-loop.d.ts +7 -3
- package/lib/page/label-loop.js +26 -14
- package/lib/page/labels.d.ts +3 -3
- package/lib/page/pipeline-store.d.ts +25 -0
- package/lib/page/pipeline-store.js +84 -0
- package/lib/page/start-marker.d.ts +4 -1
- package/lib/page/start-marker.js +5 -2
- package/lib/page/stats-switch.js +2 -0
- package/lib/page/switches.d.ts +38 -6
- package/lib/page/switches.js +29 -5
- package/lib/quality/check.d.ts +24 -3
- package/lib/quality/check.js +21 -7
- package/lib/quality/chooser.d.ts +6 -0
- package/lib/quality/chooser.js +8 -0
- package/lib/quality/governor.d.ts +98 -6
- package/lib/quality/governor.js +250 -20
- package/lib/quality/preset-docs.d.ts +16 -1
- package/lib/quality/preset-docs.js +3 -0
- package/lib/quality/presets.d.ts +84 -7
- package/lib/quality/presets.js +94 -2
- package/lib/render/draw.d.ts +3 -2
- package/lib/render/draw.js +15 -5
- package/lib/render/load-draw.d.ts +7 -5
- package/lib/render/load-draw.js +7 -5
- package/lib/render/loss.d.ts +28 -10
- package/lib/render/loss.js +50 -22
- package/lib/render/recovery.d.ts +20 -0
- package/lib/render/recovery.js +44 -4
- package/lib/render/renderer.d.ts +85 -9
- package/lib/render/renderer.js +181 -42
- package/lib/render/scene-renderer.d.ts +19 -1
- package/lib/render/scene-renderer.js +25 -1
- package/lib/render/webgl2-renderers.js +8 -5
- package/lib/render/webgpu-renderers.js +5 -4
- package/lib/scene/animation.d.ts +28 -32
- package/lib/scene/animation.js +12 -15
- package/lib/scene/assets.d.ts +61 -86
- package/lib/scene/assets.js +103 -236
- package/lib/scene/background.d.ts +14 -18
- package/lib/scene/background.js +5 -2
- package/lib/scene/baked-light.d.ts +2 -2
- package/lib/scene/color.d.ts +3 -3
- package/lib/scene/downloads.d.ts +2 -0
- package/lib/scene/downloads.js +371 -0
- package/lib/scene/environment.d.ts +7 -7
- package/lib/scene/environment.js +1 -1
- package/lib/scene/fake-call-values.js +3 -3
- package/lib/scene/fog.d.ts +11 -4
- package/lib/scene/fog.js +8 -2
- package/lib/scene/frame-cameras.d.ts +35 -4
- package/lib/scene/frame-cameras.js +86 -10
- package/lib/scene/gltf.d.ts +33 -3
- package/lib/scene/gltf.js +78 -49
- package/lib/scene/grading.d.ts +2 -2
- package/lib/scene/grading.js +3 -3
- package/lib/scene/ktx2.d.ts +9 -1
- package/lib/scene/ktx2.js +3 -2
- package/lib/scene/level-rule.d.ts +121 -0
- package/lib/scene/level-rule.js +130 -0
- package/lib/scene/lines.d.ts +13 -17
- package/lib/scene/lines.js +3 -3
- package/lib/scene/lut.d.ts +1 -2
- package/lib/scene/lut.js +1 -2
- package/lib/scene/particles.d.ts +7 -3
- package/lib/scene/particles.js +3 -1
- package/lib/scene/picks.d.ts +2 -2
- package/lib/scene/pointer-events.d.ts +4 -7
- package/lib/scene/post.d.ts +39 -43
- package/lib/scene/post.js +4 -1
- package/lib/scene/prefab.d.ts +7 -8
- package/lib/scene/prefab.js +7 -8
- package/lib/scene/property-animation.d.ts +1 -1
- package/lib/scene/property-animation.js +1 -1
- package/lib/scene/queries.d.ts +7 -13
- package/lib/scene/resources.d.ts +238 -261
- package/lib/scene/resources.js +179 -81
- package/lib/scene/scene.d.ts +167 -120
- package/lib/scene/scene.js +243 -103
- package/lib/scene/serial-loads.d.ts +29 -0
- package/lib/scene/serial-loads.js +68 -0
- package/lib/scene/shader-preloads.d.ts +34 -0
- package/lib/scene/shader-preloads.js +38 -0
- package/lib/scene/sprites.d.ts +14 -17
- package/lib/scene/sprites.js +5 -6
- package/lib/scene/textures.d.ts +11 -12
- package/lib/scene/textures.js +9 -10
- package/lib/scene/time-of-day.d.ts +11 -7
- package/lib/scene/time-of-day.js +11 -8
- package/lib/scene/vertex-draws.d.ts +5 -4
- package/lib/scene/vertex-draws.js +7 -5
- package/lib/shader-artifact.json +1 -0
- package/lib/shared/core.d.ts +5 -0
- package/lib/shared/core.js +1 -0
- package/lib/shared/import-once.d.ts +6 -0
- package/lib/shared/import-once.js +19 -0
- package/lib/shared/labels.d.ts +5 -2
- package/lib/shared/labels.js +5 -2
- package/lib/shared/metrics.d.ts +38 -0
- package/lib/shared/metrics.js +62 -1
- package/lib/shared/permutation-words.d.ts +2 -0
- package/lib/shared/permutation-words.js +8 -0
- package/lib/shared/recording.d.ts +13 -5
- package/lib/shared/recording.js +31 -10
- package/lib/shared/run-task.js +7 -1
- package/lib/shared/sketch-data.d.ts +9 -0
- package/lib/shared/sketch-data.js +57 -0
- package/lib/shared/task-pending.d.ts +12 -0
- package/lib/shared/task-pending.js +61 -1
- package/lib/shared/tasks.js +79 -32
- package/lib/shared/version.d.ts +17 -1
- package/lib/shared/version.js +19 -1
- package/lib/shared/wasm.d.ts +12 -4
- package/lib/shared/wasm.js +50 -27
- package/lib/shared/worker-start.d.ts +7 -0
- package/lib/shared/worker-start.js +27 -0
- package/lib/sketch/define-sketch.d.ts +51 -7
- package/lib/sketch/define-sketch.js +2 -1
- package/lib/sketch/input.d.ts +2 -2
- package/lib/sketch/preset-check.d.ts +20 -6
- package/lib/sketch/preset-check.js +42 -17
- package/lib/sketch/quality.d.ts +69 -11
- package/lib/sketch/quality.js +54 -13
- package/lib/sketch/runner.d.ts +80 -9
- package/lib/sketch/runner.js +390 -52
- package/lib/sketch/ui.d.ts +5 -8
- package/lib/sketch/ui.js +4 -2
- package/lib/stats.d.ts +1 -0
- package/lib/workers/probe-worker.d.ts +5 -0
- package/lib/workers/probe-worker.js +13 -4
- package/lib/workers/protocol.d.ts +71 -13
- package/lib/workers/protocol.js +4 -0
- package/lib/workers/render-worker.js +29 -5
- package/lib/workers/sketch-worker.js +108 -16
- package/package.json +2 -2
package/docs/api/sketch.md
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: api/sketch
|
|
3
3
|
title: "Sketch API: defineSketch and the context"
|
|
4
|
-
|
|
5
|
-
since: "0.1"
|
|
6
|
-
summary: "The context object: scene, assets, materials, geometry, textures, input, time, engine, quality, post, render, page, ui, debug; the callbacks."
|
|
4
|
+
summary: "The context object: the start data, scene, assets, materials, geometry, textures, input, time, engine, quality, post, render, page, ui, debug; the callbacks; the options, with the download list."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# Sketch API: defineSketch and the context
|
|
10
8
|
|
|
11
|
-
> Roadmap step 0.1, first released in null3D 0.1.0. The API is experimental, so it can still change between versions.
|
|
12
|
-
|
|
13
9
|
In null3D, a 3D scene is called a sketch. A sketch module builds the scene and updates it every frame, and its default export is `defineSketch(setup)`. The engine loads the module, calls `setup` once with the sketch's context, and then calls the callbacks that `setup` returns.
|
|
14
10
|
|
|
15
11
|
```ts
|
|
@@ -40,26 +36,42 @@ export default defineSketch(({ scene, geometry, materials, input, page }) => {
|
|
|
40
36
|
|
|
41
37
|
## Where the sketch runs
|
|
42
38
|
|
|
43
|
-
The page passes the module's address to `createEngine`, and the engine loads the module in the sketch worker. The sketch worker has no `document` and no `window`, so the page keeps the HTML and the two sides talk through [messages](page.md). On a page without cross-origin isolation, the engine runs the sketch on the page's own thread, with the same API ([Hosting and cross-origin isolation](../getting-started/hosting.md)).
|
|
39
|
+
The page passes the module's address to `createEngine`, and the engine loads the module in the sketch worker. The sketch worker has no `document` and no `window`, so the page keeps the HTML and the two sides talk through [messages](page.md). On a page without cross-origin isolation, the engine runs the sketch on the page's own thread, with the same API ([Hosting and cross-origin isolation](../getting-started/hosting.md)). The [hold mode demo](https://github.com/null3d-engine/null3d/tree/main/examples/hold-mode) runs the same sketch with a held frame.
|
|
40
|
+
|
|
41
|
+
Code at the top of the module can run before the engine has started, so it must not call the engine ([E1403](../errors/E1403.md)).
|
|
42
|
+
|
|
43
|
+
A module whose default export is not `defineSketch(...)` fails the start with [E1401](../errors/E1401.md). A module that does not load fails it with [E1410](../errors/E1410.md): the module did not download, or its code threw an error while it loaded. The engine imports a module that does not load once more, after a short wait, so a short break in the network does not fail the start.
|
|
44
|
+
|
|
45
|
+
<details>
|
|
46
|
+
<summary>Technical details: how the engine loads the module</summary>
|
|
47
|
+
|
|
48
|
+
The console notes the second import. Only a second failure gives E1410, with the first failure's reason. Code at the top of the module runs once, when the module loads, before the engine calls `setup`. The engine loads the module while it downloads its core, in the sketch worker or, in the single-threaded build, on the page. So the module's own imports and its top-level code take no time of their own on a slow network. Code there can also run when the start fails.
|
|
44
49
|
|
|
45
|
-
|
|
50
|
+
Work there must not need the engine. Every call that makes scene data goes through the setup's context. Work that needs no engine, such as a large table that the first view reads, can run there and overlap the download.
|
|
46
51
|
|
|
47
|
-
|
|
52
|
+
In hold mode, a replay and a recording, the engine loads the module only after it has started and seeded the thread's random numbers. There, code at the top of the module draws the same numbers from `Math.random` on every run ([Testing](../guides/testing.md#hold-mode)).
|
|
53
|
+
|
|
54
|
+
</details>
|
|
48
55
|
|
|
49
56
|
## The setup function
|
|
50
57
|
|
|
51
58
|
The engine calls `setup` once, with the context, before the first frame. `setup` returns the callbacks, or nothing when the sketch needs no frame callback. It can also be `async` and return them through a promise, for example to await data first. The first frame waits for the promise, and `createEngine` resolves only after it.
|
|
52
59
|
|
|
60
|
+
The setup reads the page's start data as `ctx.data`. It holds what the page knows before the scene starts, such as the section that its address names. With `defineSketch<Data>(setup)`, its type is `Data | undefined`. It is `undefined` when the page passes no `sketchData`. [Start data](page.md#start-data) shows both sides.
|
|
61
|
+
|
|
53
62
|
An error that `setup` throws ends the start: `createEngine` rejects with it. An engine error keeps its code, such as [E1204](../errors/E1204.md) for a color the engine cannot read. In the threaded build, any other error arrives as [E1405](../errors/E1405.md), with its message.
|
|
54
63
|
|
|
55
64
|
## Options
|
|
56
65
|
|
|
57
|
-
`defineSketch` takes options after the setup function. They set the fixed steps, which [Time](time.md#fixed-steps) explains.
|
|
66
|
+
`defineSketch` takes options after the setup function. They set the fixed steps, which [Time](time.md#fixed-steps) explains, and the files that the setup loads.
|
|
58
67
|
|
|
59
68
|
| Option | Default | What it sets |
|
|
60
69
|
| --- | --- | --- |
|
|
61
70
|
| `fixedRate` | 60 | Fixed steps per second of sketch time: how often `onFixedUpdate` runs |
|
|
62
71
|
| `maxFixedSteps` | 8 | The most fixed steps that one frame runs, after a slow frame |
|
|
72
|
+
| `lowestTier` | true | `false` keeps the governor out of its [lowest quality tier](../concepts/quality-presets.md#the-lowest-quality-tier), which cuts the render scale, shadows and bloom. Set it when the sketch's own code, not the GPU, makes frames slow: the cuts cannot make that code faster. The page's `?tier=off` switch does the same. |
|
|
73
|
+
| `downloads` | none | The files that the setup loads, which start to download as soon as the module has loaded ([The download list](#the-download-list)) |
|
|
74
|
+
| `serialLoadWarning` | true | False turns off a development build's warning for a load that waited for another one ([Loads one after another](#loads-one-after-another)) |
|
|
63
75
|
|
|
64
76
|
```ts
|
|
65
77
|
export default defineSketch(setup, { fixedRate: 120 });
|
|
@@ -67,10 +79,55 @@ export default defineSketch(setup, { fixedRate: 120 });
|
|
|
67
79
|
|
|
68
80
|
An option out of its range fails the start with [E1214](../errors/E1214.md), before the engine calls `setup`.
|
|
69
81
|
|
|
82
|
+
### The download list
|
|
83
|
+
|
|
84
|
+
A setup that awaits its files one after another waits for each download in turn. The `downloads` option names the files that the setup loads, so they download before the setup asks for them:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
// sketch.ts
|
|
88
|
+
import { defineSketch } from '@null3d/engine';
|
|
89
|
+
|
|
90
|
+
const SHIP = 'models/ship.glb';
|
|
91
|
+
const SKY = 'env/harbor.ktx2';
|
|
92
|
+
|
|
93
|
+
export default defineSketch(
|
|
94
|
+
async ({ assets, scene }) => {
|
|
95
|
+
const [ship, sky] = await Promise.all([assets.loadGltf(SHIP), assets.loadEnvironment(SKY)]);
|
|
96
|
+
scene.setEnvironment(sky);
|
|
97
|
+
scene.instantiate(ship);
|
|
98
|
+
},
|
|
99
|
+
{ downloads: [SHIP, SKY] },
|
|
100
|
+
);
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
A live start begins the downloads as soon as the module has loaded. That is often before the engine's core has arrived, so the files download while the engine starts. The setup's loads take the bytes that arrived or are on their way, and nothing downloads twice. Each address resolves against the page's address, as the loading calls' addresses do.
|
|
104
|
+
|
|
105
|
+
- List the files in the order that the setup needs them. Two download at a time, so the engine's own files, such as the shaders of the first frame, still find free connections to the server. A load of a later file moves it to the front of the list. While loads wait for listed files, up to four download at once, which still leaves connections for the engine's own files.
|
|
106
|
+
- Name only the files that the first frame waits for. A file that loads after the first frame takes bandwidth from the files that the first frame needs. Start its load when `engine.firstFrame` resolves instead ([The engine field](#the-engine-field)).
|
|
107
|
+
- A file that no load takes costs its download, and its bytes stay in memory until the engine stops. Nothing decodes it.
|
|
108
|
+
- Hold mode, a replay and a recording download each file at its load, as without the list, so their runs stay the same.
|
|
109
|
+
- `assets.onProgress` counts the listed files, also the bytes that arrived before the setup added the handler.
|
|
110
|
+
|
|
111
|
+
An entry that is not a file's address, such as an empty string, fails the start with [E1214](../errors/E1214.md). A listed file that does not download fails the load that takes it with [E1411](../errors/E1411.md).
|
|
112
|
+
|
|
113
|
+
### Loads one after another
|
|
114
|
+
|
|
115
|
+
A development build watches the setup's loads. Sometimes a load starts its download only after another load's file has arrived, while no other file downloads. The console then shows one warning that names both files. The two files could have downloaded together, and the first frame waited for the gap. Start both loads before you await either, as `Promise.all` does above, or name both files in `downloads`.
|
|
116
|
+
|
|
117
|
+
When the second file's address comes from the first file, as a level file names its models, the order is needed. A JSON file that holds the second file's name passes without a warning. For other such cases, pass `serialLoadWarning: false`.
|
|
118
|
+
|
|
119
|
+
<details>
|
|
120
|
+
<summary>Technical details: what the warning watches</summary>
|
|
121
|
+
|
|
122
|
+
An environment that the engine makes with no file counts as an earlier load too. A load that starts only after `assets.builtinEnvironment` or `assets.skyEnvironment` has finished could have started beside it. The engine watches only the loads of a live setup, not a model's own files and not loads after the first frame. A production build has no warning.
|
|
123
|
+
|
|
124
|
+
</details>
|
|
125
|
+
|
|
70
126
|
## The context
|
|
71
127
|
|
|
72
128
|
| Field | What it holds |
|
|
73
129
|
| --- | --- |
|
|
130
|
+
| `data` | The page's start data, or `undefined` when it passes none: [Start data](page.md#start-data) |
|
|
74
131
|
| `scene` | Objects, cameras, lights, instance batches and the background: [Scene](scene.md) |
|
|
75
132
|
| `geometry` | Mesh generators, such as `geometry.box` and `geometry.sphere` |
|
|
76
133
|
| `materials` | Material factories: [Materials](materials.md) |
|
|
@@ -78,21 +135,35 @@ An option out of its range fails the start with [E1214](../errors/E1214.md), bef
|
|
|
78
135
|
| `assets` | Downloads of textures, JSON and binary files, with preloads and progress: [Assets](assets.md) |
|
|
79
136
|
| `input` | Pointer, touch, keyboard and gamepad input, and action maps: [Input](input.md) |
|
|
80
137
|
| `post` | The tone mapping and the exposure: [Post-processing API](post.md) |
|
|
138
|
+
| `render` | The sketch's own render passes, such as a camera that draws into a texture: [Render graph API](render.md) |
|
|
81
139
|
| `quality` | The quality preset that the engine runs, and its settings: [Quality API](quality.md) |
|
|
82
140
|
| `time` | Sketch time in seconds, the frame's step and the frame number: [Time](time.md) |
|
|
83
141
|
| `engine` | The canvas's size, and what the device can do: [The engine field](#the-engine-field) |
|
|
84
142
|
| `preferences` | What the user's system asks of every page, such as less motion: [Accessibility](../guides/accessibility.md) |
|
|
85
143
|
| `page` | Messages to and from the page: [Messages between sketch and page](page.md) |
|
|
86
|
-
| `ui` | HTML labels that follow scene objects: [
|
|
144
|
+
| `ui` | HTML labels that follow scene objects: [Labels that follow objects](ui.md) |
|
|
87
145
|
| `debug` | Lines, boxes, spheres, axes, grids, frustums and lights, drawn for one frame in development builds: [Debug drawing and stats](debug.md) |
|
|
88
146
|
|
|
89
147
|
## The engine field
|
|
90
148
|
|
|
91
|
-
`engine.viewport` holds the canvas's size in CSS pixels, as `width` and `height`. Its `pixelRatio` gives the device pixels per CSS pixel that the engine draws with. That is the display's ratio, capped by the `maxPixelRatio` setting of [`ctx.quality`](quality.md). It is lower on a canvas too large for the GPU's largest texture at that ratio.
|
|
149
|
+
`engine.viewport` holds the canvas's size in CSS pixels, as `width` and `height`. Its `pixelRatio` gives the device pixels per CSS pixel that the engine draws with. That is the display's ratio, capped by the `maxPixelRatio` setting of [`ctx.quality`](quality.md). It is lower on a canvas too large for the GPU's largest texture at that ratio.
|
|
150
|
+
|
|
151
|
+
The engine reads the size at the start of each frame, so it stays the same throughout a frame. The object changes in place, so read its fields when you need them.
|
|
92
152
|
|
|
93
153
|
`engine.capabilities` holds the values of `engine.capabilities` on the page: the GPU path, its optional features and limits, the depth mode, and the most objects the device draws. [Page API: createEngine](engine.md#what-the-engine-reports) describes them. Check a capability before you use an optional feature, and never check GPU or browser names.
|
|
94
154
|
|
|
95
|
-
`engine.held` is true when the engine steps the sketch itself, as hold mode and a replay do. It is false when the sketch runs live.
|
|
155
|
+
`engine.held` is true when the engine steps the sketch itself, as hold mode and a replay do. It is false when the sketch runs live. Unlike `time.held`, it is true for the whole session, the setup included, and in a replay too.
|
|
156
|
+
|
|
157
|
+
A sketch that returns before its scene is complete waits for it when this is true. A held frame or a replay then shows the finished scene. A live page starts the work without awaiting it, and the result appears as it lands.
|
|
158
|
+
|
|
159
|
+
`engine.firstFrame` is a promise that resolves once the GPU has finished the engine's first frame, as `engine.firstFrame` does on the page. Start the downloads that the first frame does not need when it resolves; they then leave the network to the first frame's own files, such as its shaders. Never await the promise in the setup, because the first frame waits for the setup. The [Creek showcase](https://github.com/null3d-engine/null3d/tree/main/examples/showcase/creek) waits for it before it loads its models on a live page.
|
|
160
|
+
|
|
161
|
+
<details>
|
|
162
|
+
<summary>Technical details: firstFrame in hold mode and replays</summary>
|
|
163
|
+
|
|
164
|
+
A frame number is no such signal: the thread that draws can still be drawing the first frame while the sketch runs the second. In hold mode and a replay, the promise resolves once the engine has stepped the sketch to its last frame. No frame follows that one, so the work that it starts never changes what those modes show. The promise never resolves when the engine stops first.
|
|
165
|
+
|
|
166
|
+
</details>
|
|
96
167
|
|
|
97
168
|
```ts
|
|
98
169
|
export default defineSketch(({ scene, engine }) => {
|
|
@@ -103,6 +174,20 @@ export default defineSketch(({ scene, engine }) => {
|
|
|
103
174
|
});
|
|
104
175
|
```
|
|
105
176
|
|
|
177
|
+
A scene that adds far scenery after the first frame starts its download then, and in hold mode loads it in the setup:
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
// sketch.ts
|
|
181
|
+
import { defineSketch } from '@null3d/engine';
|
|
182
|
+
|
|
183
|
+
export default defineSketch(async ({ assets, engine, scene }) => {
|
|
184
|
+
const addForest = async () => scene.instantiate(await assets.loadGltf('models/forest.glb'));
|
|
185
|
+
// Build the first view here.
|
|
186
|
+
if (engine.held) await addForest(); // a held frame shows the finished scene
|
|
187
|
+
else void engine.firstFrame.then(addForest).catch((error) => console.error(error)); // the forest appears as it lands
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
106
191
|
## The callbacks
|
|
107
192
|
|
|
108
193
|
Each frame runs the callbacks in this order, and each callback is optional:
|
|
@@ -115,13 +200,15 @@ Each frame runs the callbacks in this order, and each callback is optional:
|
|
|
115
200
|
|
|
116
201
|
`step` is the length of a fixed step in seconds, 1/60 at the default rate. `dt` is the frame's step in seconds, the same value as `time.dt`. It is 0 in the first frame and after a pause, and it is never longer than a quarter second. [Time](time.md) gives the details.
|
|
117
202
|
|
|
203
|
+
`onDestroy()` runs once when the engine stops, on the sketch's thread, before its workers stop. Remove the timers, event listeners and message handlers that the sketch added outside the engine there. After it, every call to the engine fails with [E1420](../errors/E1420.md).
|
|
204
|
+
|
|
118
205
|
## When changes show
|
|
119
206
|
|
|
120
207
|
Setters take effect at once. Changes that `onFixedUpdate` and `onUpdate` make show in the frame that the engine draws next. Creating, destroying and reparenting objects take effect when the engine processes the frame, after `onUpdate` returns ([Scene](scene.md#when-changes-take-effect)).
|
|
121
208
|
|
|
122
|
-
In `onLateUpdate`, world positions already hold the frame's changes, so `getWorldPosition` gives the place where the frame draws an object. Setters that `onLateUpdate` calls also show in the same frame. Before it culls and draws, the engine updates the objects that they move and the objects below them. A camera that follows an object there does not lag a frame behind it.
|
|
209
|
+
In `onLateUpdate`, world positions already hold the frame's changes, so `getWorldPosition` gives the place where the frame draws an object. Setters that `onLateUpdate` calls also show in the same frame. Before it culls and draws, the engine updates the objects that they move and the objects below them. A camera that follows an object there does not lag a frame behind it.
|
|
123
210
|
|
|
124
|
-
The engine runs this second update only for a sketch with `onLateUpdate`, and then only for the objects that it moved and the objects below them.
|
|
211
|
+
The engine runs this second update only for a sketch with `onLateUpdate`, and then only for the objects that it moved and the objects below them. Structural changes that `onLateUpdate` makes, such as creating an object, take effect in the next frame.
|
|
125
212
|
|
|
126
213
|
## Example: a camera that follows a moving object
|
|
127
214
|
|
|
@@ -152,7 +239,7 @@ export default defineSketch(({ scene, geometry, materials, time }) => {
|
|
|
152
239
|
});
|
|
153
240
|
```
|
|
154
241
|
|
|
155
|
-
The camera moves in `onLateUpdate`, after the car's move in `onUpdate` reached its world position. In `onUpdate`, `getWorldPosition` would give the car's place in the previous frame, and the camera would trail it.
|
|
242
|
+
The camera moves in `onLateUpdate`, after the car's move in `onUpdate` reached its world position. In `onUpdate`, `getWorldPosition` would give the car's place in the previous frame, and the camera would trail it. The [input demo](https://github.com/null3d-engine/null3d/tree/main/examples/input) follows its walking robot with a camera in `onLateUpdate`.
|
|
156
243
|
|
|
157
244
|
## Errors in callbacks
|
|
158
245
|
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: api/sound
|
|
3
|
+
title: "Sound (@null3d/sound)"
|
|
4
|
+
summary: "createSound and connectSound: loops, groups and one-shots placed in the scene, played with the browser's audio and driven from the sketch on the audio thread."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Sound (@null3d/sound)
|
|
8
|
+
|
|
9
|
+
```mermaid
|
|
10
|
+
flowchart LR
|
|
11
|
+
sketch["Sketch worker<br/>createSound: loops,<br/>groups and shots"] -- "writes places, levels,<br/>rates and tones" --> table[("One shared<br/>table")]
|
|
12
|
+
table --> mixer["Audio thread<br/>the mixer"]
|
|
13
|
+
page["Page<br/>connectSound: files<br/>and audio nodes"] --> nodes["Each voice:<br/>source, filter,<br/>gain, panner"]
|
|
14
|
+
mixer -- "drives every voice<br/>in each quantum" --> nodes
|
|
15
|
+
nodes --> out["Speakers or<br/>headphones"]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`@null3d/sound` plays sound that follows the scene. A sketch makes its sounds and moves them as it moves its objects. The page plays them with the browser's audio, through the add-on's page half. A sound can come from a place, such as a waterfall or a car. It can also play in both ears alike, such as wind or rain.
|
|
19
|
+
|
|
20
|
+
The browser offers its audio only on the page's main thread, and the sketch runs in a worker. The add-on bridges the two.
|
|
21
|
+
|
|
22
|
+
<details>
|
|
23
|
+
<summary>Technical details: how the sketch reaches the audio thread</summary>
|
|
24
|
+
|
|
25
|
+
The sketch writes each sound's place, level, playback rate and tone into a table that the page shares. A mixer on the browser's audio thread, compiled from Rust to WebAssembly, reads that table and drives every voice. Where the page shares its memory with its workers, no frame sends a message, and the page's thread does no work while sounds play. A shot sends one message for each play.
|
|
26
|
+
|
|
27
|
+
</details>
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
bun add @null3d/sound
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
// sketch.ts
|
|
35
|
+
import { defineSketch } from '@null3d/engine';
|
|
36
|
+
import { createSound } from '@null3d/sound';
|
|
37
|
+
|
|
38
|
+
export default defineSketch((ctx) => {
|
|
39
|
+
const { scene } = ctx;
|
|
40
|
+
const camera = scene.createPerspectiveCamera({ position: [0, 1.6, 6], target: [0, 1, 0] });
|
|
41
|
+
scene.setActiveCamera(camera);
|
|
42
|
+
|
|
43
|
+
const sound = createSound(ctx, { listener: camera });
|
|
44
|
+
// A waterfall at a place, full within 4 m and gone by 120 m.
|
|
45
|
+
const fall = sound.loop({ file: '/sounds/waterfall.mp3', near: 4, far: 120 });
|
|
46
|
+
fall.setPosition(-20, 2, -30);
|
|
47
|
+
// Wind in both ears, whose level the sketch sets each frame.
|
|
48
|
+
const wind = sound.loop({ file: '/sounds/wind.mp3', positional: false, level: 0.5 });
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
onUpdate() {
|
|
52
|
+
wind.setLevel(0.4 + 0.2 * Math.sin(ctx.time.now * 0.3));
|
|
53
|
+
},
|
|
54
|
+
onLateUpdate() {
|
|
55
|
+
sound.update();
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
// page.ts
|
|
63
|
+
import { createEngine } from '@null3d/engine';
|
|
64
|
+
import { connectSound } from '@null3d/sound/page';
|
|
65
|
+
|
|
66
|
+
const engine = await createEngine({
|
|
67
|
+
canvas: document.querySelector('canvas')!,
|
|
68
|
+
sketch: new URL('./sketch.ts', import.meta.url),
|
|
69
|
+
});
|
|
70
|
+
const sound = connectSound(engine);
|
|
71
|
+
document.querySelector('#sound')!.addEventListener('click', () => void sound.start());
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Call `sound.update()` once a frame, in `onLateUpdate`. It reads the listener's place and turn in the world, which by then holds every move of the frame's `onUpdate`. A camera that moves in `onLateUpdate` itself is heard one frame later, which no ear can tell. A browser starts a page's audio only in answer to the user. So the page calls `start` from a click, a tap or a key. `connectSound(engine, { startOnInput: true })` starts it on the user's first input instead.
|
|
75
|
+
|
|
76
|
+
## The sketch's calls
|
|
77
|
+
|
|
78
|
+
| Call | What it does |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| `createSound(ctx, options)` | Makes the sketch's sounds. `listener` is required: the camera, or another object that hears. `capacity` is the emitters that the sounds hold together, 256 by default and 4,096 at most. `volume` sets every sound's volume, from 0 to 1. A sketch has one sound system at a time: a second call while the first lives throws E2504. |
|
|
81
|
+
| `loop(options)` | A sound that plays its file over and over. `positional: false` makes a bed that plays in both ears. `level`, `rate`, `tone` and `position` give its first values. |
|
|
82
|
+
| `group(options)` | `count` sounds that play one file, of which the loudest `voices` sound at once. Use it for the cars in a street or the bees of a swarm. |
|
|
83
|
+
| `shot(options)` | A sound that plays its file once for each call of its `play`, such as thunder. `voices` plays that many at once, 2 by default. A play past that count fades the oldest out quickly. Each play starts about 20 ms after the call, at its own level, place and pitch, or about 80 ms after it when it replaces a play that still sounds. |
|
|
84
|
+
| `setVolume(volume)` | The volume of every sound, from 0 to 1. |
|
|
85
|
+
| `update()` | Reads the listener's place and turn, and counts the frame. Call it once a frame. |
|
|
86
|
+
| `destroy()` | Stops every sound and closes the link to the page. The page then waits for the sketch's next sound system. |
|
|
87
|
+
| `connected` | True once the page's half has opened its link. |
|
|
88
|
+
|
|
89
|
+
A loop has `setLevel`, `setRate`, `setTone`, `setPosition` and `destroy`. A group has the same setters with a member's index first, such as `setPosition(index, x, y, z)`. A group also has the arrays `positions`, `levels`, `rates` and `tones`, which are views of the table. A sketch that keeps its places in one array copies them in one call, as in `cars.positions.set(places)`.
|
|
90
|
+
|
|
91
|
+
A shot has `play(x, y, z, level, rate)` and `destroy`. A destroyed sound's setters do nothing. Its arrays may then serve another sound, so a sketch drops them with the group.
|
|
92
|
+
|
|
93
|
+
The setters write numbers into the table and make no object, so a sketch may call them in every frame. `update` makes no object either. A sound made before the page connects plays once it does, and a sketch may make sounds at any time.
|
|
94
|
+
|
|
95
|
+
## The values of a sound
|
|
96
|
+
|
|
97
|
+
| Value | Range | What it does |
|
|
98
|
+
| --- | --- | --- |
|
|
99
|
+
| level | 0 and up, 1 by default | The sound's loudness. 0 silences it. |
|
|
100
|
+
| rate | 1 by default | The playback rate. 2 plays the file twice as fast and an octave higher. Tie it to a car's speed for its engine. |
|
|
101
|
+
| tone | 0 to 1, 1 by default | A low-pass filter. 1 plays the file as it is, and 0 keeps only its lows, from about 120 Hz down. Strong wind sounds brighter than a breeze, so raise its tone with its speed. |
|
|
102
|
+
| place | world units | Where the sound comes from. A bed that plays in both ears has no place. |
|
|
103
|
+
|
|
104
|
+
Each value eases toward the one that the sketch writes, so a change never clicks. The level, the tone and the rate each ease in about 80 ms. A level or a place that is not a finite number silences the sound until the sketch writes one that is. A rate or a tone that is not one plays the file at its own pitch and brightness.
|
|
105
|
+
|
|
106
|
+
## Distance
|
|
107
|
+
|
|
108
|
+
A sound's options take a placement:
|
|
109
|
+
|
|
110
|
+
| Option | What it does |
|
|
111
|
+
| --- | --- |
|
|
112
|
+
| `near` | The distance within which the sound plays at its full level. Beyond it the level falls with distance: at twice `near` it is half, at four times a quarter. |
|
|
113
|
+
| `far` | The distance at which the sound has faded out. The fade starts at 60% of it. |
|
|
114
|
+
| `muffle` | Whether the sound loses its highs as it nears `far`, as distant sounds do. It is on by default when `far` is given. |
|
|
115
|
+
|
|
116
|
+
A sound with neither distance keeps the level that the sketch gives it wherever the listener stands. Use that for a bed whose level the sketch works out itself, such as the sea, which grows louder as the camera nears the shore.
|
|
117
|
+
|
|
118
|
+
## Groups and their voices
|
|
119
|
+
|
|
120
|
+
A browser mixes a few dozen voices well, and a scene may have hundreds of sources of one kind. A group gives its members a few voices. The mixer ranks the members by their loudness where the listener stands, from their level and distance. It gives each voice to one of the loudest.
|
|
121
|
+
|
|
122
|
+
A voice keeps its member while that member stays close to the cut. So a voice does not flap between two members at the same distance. A voice that moves to another member fades out first, so its sound never jumps across the scene. It takes the new member's pitch before it fades in.
|
|
123
|
+
|
|
124
|
+
A group's voices add as power: three at full level sound about 5 dB louder than one. Give a group's points lower levels than a loop's. Write a mass of like sources as one loop, whose level follows the density around the camera, not one source for each object.
|
|
125
|
+
|
|
126
|
+
A group's voices play one file, each from a point of its own, so the copies never sound in step. Rates that differ for each member add no richness that the offsets do not already give. They also make the group's pitch change as the camera moves and the nearest members change. Keep the members at one rate, and use `setRate` for a source whose own speed differs, such as a car's engine.
|
|
127
|
+
|
|
128
|
+
The page plays 32 voices at most. A loop takes one voice, a group takes its `voices`, and a shot takes its `voices`, wherever free voices sit. A sketch that asks for more than 32 at once gets E2501, which names the count. While other voices are free, a destroyed sound's voices rest for a third of a second before another sound takes them. So their fade ends first.
|
|
129
|
+
|
|
130
|
+
## The page's calls
|
|
131
|
+
|
|
132
|
+
| Call | What it does |
|
|
133
|
+
| --- | --- |
|
|
134
|
+
| `connectSound(engine, options)` | Connects the page to the sketch's sounds. Call it once on a page, after `createEngine` resolves. `startOnInput` starts the audio on the user's first click, tap or key other than Escape, which are the inputs that let a browser start a page's audio. `muted` starts muted. |
|
|
135
|
+
| `start()` | Starts the audio. Call it in the handler of a click, a tap or a key. Called so, it resolves once the audio runs, and each sound fades in as its file arrives. Called outside an input, as a page that plays its sound by default does, it loads the files, and the browser holds the audio until the user's first click, tap or key. The sounds then start at once. |
|
|
136
|
+
| `setMuted(muted)` | Mutes or unmutes every sound. |
|
|
137
|
+
| `state` | `off` before `start`, then `starting` until the audio runs, `on`, `paused` while the engine is paused or the page is hidden, `interrupted` while the browser holds the audio until the user's next input, and `stopped` after the engine stops. |
|
|
138
|
+
| `onState(handler)` | Calls the handler at each change of the state, such as to label a sound button. Returns a function that removes the handler. |
|
|
139
|
+
| `stop()` | Stops the audio for good. The engine's stop does the same. |
|
|
140
|
+
|
|
141
|
+
The page loads nothing until `start` runs: no file, no audio and no mixer. The mixer's module is about 18 KB. Each file loads once, however many sounds play it. A file that fails to load leaves its sounds silent, and the console names the file. A mixer that fails on the audio thread stops the sound with a warning. So does a mixer module that the host answers with something else, such as its own page for a missing file.
|
|
142
|
+
|
|
143
|
+
While the browser holds the audio, the page starts no file. So the browser warns once, as the page makes the audio, and not for each voice. A shot that plays in that time is dropped. It would otherwise sound late, after the user's first input, long after the event that played it.
|
|
144
|
+
|
|
145
|
+
The [sound demo](https://github.com/null3d-engine/null3d/tree/main/examples/sound) shows a storm. Each strike's thunder plays from where the bolt struck, once sound could have reached the camera. A brook in it is a group of points.
|
|
146
|
+
|
|
147
|
+

|
|
148
|
+
|
|
149
|
+
The sound demo: thunder, rain and a brook.
|
|
150
|
+
|
|
151
|
+
## Pauses and hidden pages
|
|
152
|
+
|
|
153
|
+
When the sketch's frames stop, every sound fades out within about a second, and the page suspends the audio soon after. That happens when `engine.setPaused(true)` pauses the engine, when the browser hides the page, and when a sketch stops calling `update`. It also happens when the engine was paused before the sound started. The audio resumes, and the sounds fade back in, when the frames move again.
|
|
154
|
+
|
|
155
|
+
A browser can also take the audio away, as an iPhone does during a call. The state is then `interrupted`, and the page resumes the audio at the user's next input, or when the page shows again. A sound button calls `start` in that state rather than muting.
|
|
156
|
+
|
|
157
|
+
## Panning and the quality presets
|
|
158
|
+
|
|
159
|
+
A sound that comes from a place plays through the browser's panner. The High and Ultra presets use its HRTF model, which places a sound around the head on headphones. Low and Medium use equal-power panning, which places it between the speakers and costs less on the audio thread. A change of preset changes every voice's panning.
|
|
160
|
+
|
|
161
|
+
## Files
|
|
162
|
+
|
|
163
|
+
A relative address resolves against the page's address, as the engine's loaders do ([Assets](assets.md)). So `'sounds/sea.mp3'` on `https://example.com/game/` loads `https://example.com/game/sounds/sea.mp3`. An address from `new URL('./sea.mp3', import.meta.url)` resolves against the sketch module instead. A file made to loop joins its end to its start, as the sample loops do.
|
|
164
|
+
|
|
165
|
+
<details>
|
|
166
|
+
<summary>Technical details: what the add-on does with MP3 padding</summary>
|
|
167
|
+
|
|
168
|
+
MP3 decodes in every browser. An MP3 encoder adds samples at each end of a file, and records how many in a header in the file's first frame. Some browsers keep them as they decode. Safari keeps 576 samples at each end of a mono MP3, which dips at every join of a loop. The add-on reads the header and drops what the browser kept, so a loop joins with no gap. A file without that header loses only the silence at its ends, up to 2,048 samples.
|
|
169
|
+
|
|
170
|
+
</details>
|
|
171
|
+
|
|
172
|
+
## Browsers
|
|
173
|
+
|
|
174
|
+
- Firefox's audio listener has no place parameters. The mixer turns each sound's place into the listener's frame, so the listener stays still in every browser.
|
|
175
|
+
- An iPhone's silent switch mutes a page's audio unless the page plays media. The add-on sets the page's audio session to playback where Safari offers it.
|
|
176
|
+
- A page without cross-origin isolation runs the sketch on its own thread ([Hosting and cross-origin isolation](../getting-started/hosting.md)). There the page hands the mixer a copy of the table once per display frame. That costs the page's thread a copy of a few kilobytes, a message and a small view of the returned buffer in each frame.
|
|
177
|
+
|
|
178
|
+
## Costs and limits
|
|
179
|
+
|
|
180
|
+
- The mixer runs on the audio thread. Its work grows with the voices and with the members of each group, which it ranks every fourth render quantum. With 32 voices and a group of 200 moving members, it takes about 3 ms of work per second of audio. That figure comes from the mixer's module in Bun on a desktop computer.
|
|
181
|
+
- Each voice is a source, a filter, a gain and a panner. The panner's HRTF model costs the most of them, which is why the lighter presets drop it.
|
|
182
|
+
- A limiter on the page's output holds the mix under full scale. So sounds that sum, or a stereo sound panned to one side, never clip. It adds about 2 dB to quiet passages.
|
|
183
|
+
- The table holds 12 numbers for the listener and 6 for each emitter: 6 KB at the default capacity.
|
|
184
|
+
- The page plays 32 voices at once and the table holds 4,096 emitters at most.
|
|
185
|
+
|
|
186
|
+
## Errors
|
|
187
|
+
|
|
188
|
+
| Code | Cause |
|
|
189
|
+
| --- | --- |
|
|
190
|
+
| E2500 | A missing listener or file; a count, voices, capacity, volume, near or far that is not a valid number; far not above near; or a call on a destroyed sound system. |
|
|
191
|
+
| E2501 | More than 32 voices. |
|
|
192
|
+
| E2502 | No room in the table: raise `capacity`. |
|
|
193
|
+
| E2503 | A member index out of range. |
|
|
194
|
+
| E2504 | A second sound system. |
|
|
195
|
+
|
|
196
|
+
## Related pages
|
|
197
|
+
|
|
198
|
+
- [Assets](assets.md): loading the sound files.
|
|
199
|
+
- [Hosting and cross-origin isolation](../getting-started/hosting.md): the headers that the mixer needs.
|
|
200
|
+
- [Quality API](quality.md): the presets that drop the HRTF panner.
|
|
201
|
+
- [Loops, groups and shots](https://github.com/null3d-engine/null3d/tree/main/examples/sound): a thunderstorm on the moor, with positional thunder, rain and a brook.
|
|
202
|
+
|
|
203
|
+
## API reference
|
|
204
|
+
|
|
205
|
+
[The API reference](reference/sound.md) lists every export of this page with its type and description. The add-on's doc comments make it.
|
package/docs/api/splats.md
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: api/splats
|
|
3
3
|
title: Gaussian splats (@null3d/splats)
|
|
4
|
-
status: experimental
|
|
5
|
-
since: "0.3"
|
|
6
4
|
summary: "createSplats: SPZ files, streamed chunk files and KHR_gaussian_splatting models drawn as Gaussian splats, with detail levels, a budget that follows the preset and the GPU path, and a soft mix with meshes."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# Gaussian splats
|
|
10
8
|
|
|
11
|
-
> Roadmap step 0.3, first released in null3D 0.1.0. The API is experimental, so it can still change between versions.
|
|
12
|
-
|
|
13
9
|
```mermaid
|
|
14
10
|
flowchart LR
|
|
15
11
|
spz["An SPZ file"] --> read["decodeSpz"]
|
|
@@ -30,6 +26,10 @@ training run produces. A splat has a center, three principal spreads and a rotat
|
|
|
30
26
|
shape, and a color and an opacity. The add-on draws each one as a camera-facing card that covers
|
|
31
27
|
the splat's projected ellipse and fades as a Gaussian, so overlapping splats read as one surface.
|
|
32
28
|
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
The splats demo. On feature-draws, say the add-on makes the draw.
|
|
32
|
+
|
|
33
33
|
The add-on reads three kinds of file:
|
|
34
34
|
|
|
35
35
|
- **SPZ**, Niantic's packed form, in its gzip and zstd containers.
|
|
@@ -38,6 +38,12 @@ The add-on reads three kinds of file:
|
|
|
38
38
|
- **glTF** models that carry `KHR_gaussian_splatting`. Importing the add-on registers the reader for
|
|
39
39
|
every sketch of the thread, so `assets.loadGltf` loads such a model with no other call.
|
|
40
40
|
|
|
41
|
+
The package is an add-on. Install it beside the engine.
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
bun add @null3d/splats
|
|
45
|
+
```
|
|
46
|
+
|
|
41
47
|
```ts
|
|
42
48
|
import { defineSketch } from '@null3d/engine';
|
|
43
49
|
import { createSplats } from '@null3d/splats';
|
|
@@ -80,7 +86,9 @@ so the engine plans no levels for it.
|
|
|
80
86
|
A splat's shader computes the covariance that its spreads and rotation make, projects it to the
|
|
81
87
|
screen once for each corner of its card, and spans a camera-facing card along the ellipse's own
|
|
82
88
|
axes. All three of the splat's spreads add to that ellipse, so a flat splat seen edge on still gets
|
|
83
|
-
a card that covers it.
|
|
89
|
+
a card that covers it.
|
|
90
|
+
|
|
91
|
+
A pixel's place on the card is its distance from the center in standard
|
|
84
92
|
deviations, so a fragment fades by it with no math of its own, and the card is a Gaussian, not a
|
|
85
93
|
disc. A pixel too faint to show is dropped before it blends.
|
|
86
94
|
|
|
@@ -103,6 +111,7 @@ writes only the rows that its budget keeps.
|
|
|
103
111
|
cover the most surface: a splat's opacity times the area of its largest cross-section. A prefix of
|
|
104
112
|
a chunk is a coarser level of it: all of it, a half, a quarter and an eighth. As a chunk is built,
|
|
105
113
|
the add-on measures how much of the chunk's surface each prefix covers, seen from three directions.
|
|
114
|
+
|
|
106
115
|
A prefix grows the splats that it keeps by what it leaves uncovered, up to three times. So a scan's
|
|
107
116
|
ground of small flat splats draws as the same surface with fewer, larger splats rather than a
|
|
108
117
|
sparse one, and a dense cloud whose splats overlap barely grows.
|
|
@@ -111,13 +120,20 @@ sparse one, and a dense cloud whose splats overlap barely grows.
|
|
|
111
120
|
chunk draws. Every chunk the budget reaches keeps an eighth of itself first. The budget then
|
|
112
121
|
gives the nearest chunks a finer prefix, up to the level that their distance asks for. A chunk's
|
|
113
122
|
level follows its distance measured in the radius of the whole cloud, so a finer cut does not thin
|
|
114
|
-
the view. A budget too small for every level then thins the whole cloud.
|
|
123
|
+
the view. A budget too small for every level then thins the whole cloud.
|
|
124
|
+
|
|
125
|
+
A chunk nearer the camera
|
|
115
126
|
still keeps more of its splats than a far one. The budget stops the total. The selection and its
|
|
116
127
|
distance sort run in the add-on's Rust module on the job worker, so a large scene costs the
|
|
117
|
-
sketch's thread nothing.
|
|
128
|
+
sketch's thread nothing.
|
|
129
|
+
|
|
130
|
+
A change of the camera or of the budget starts a new selection. The core
|
|
118
131
|
then packs the chosen rows into the batch in its own memory, so a moved frame copies no rows
|
|
119
132
|
through the sketch's heap.
|
|
120
133
|
|
|
134
|
+
`createSplats` starts the selection's task and the SPZ reader as it starts, beside the download of
|
|
135
|
+
the index or the file. So the first selection and the first chunk's decode wait for neither download. In the splats demo on a simulated phone connection, the SPZ reader is ready at about 4.4 seconds and the first parts show at about 7 seconds.
|
|
136
|
+
|
|
121
137
|
The budget follows the quality preset. On each preset the add-on draws at most:
|
|
122
138
|
|
|
123
139
|
| Preset | WebGPU | WebGL2 |
|
|
@@ -134,7 +150,7 @@ preset's value, and `capacity` sets the rows that the batch holds.
|
|
|
134
150
|
|
|
135
151
|
The batch allocates its rows when `createSplats` runs, from the preset in use then. A move to a
|
|
136
152
|
higher preset after that draws no more splats, while a move to a lower one draws fewer. A scene
|
|
137
|
-
that offers
|
|
153
|
+
that offers a quality menu at run time passes `capacity` for the highest preset it may reach,
|
|
138
154
|
and pays that memory on every preset.
|
|
139
155
|
|
|
140
156
|
A splat's color is the light recorded with it, so the scene's lights do not relight a cloud. Splats
|
|
@@ -144,7 +160,9 @@ A whole file appears as its chunks are cut: the first chunks draw while the rest
|
|
|
144
160
|
large file never holds up a frame. `ready` resolves when every chunk of a file is ready. For a
|
|
145
161
|
stream, it resolves once the nearest chunks have arrived, which takes about a megabyte of files, or
|
|
146
162
|
the nearest chunk alone: the first view draws from those, and the cloud fills in as the rest
|
|
147
|
-
arrive.
|
|
163
|
+
arrive.
|
|
164
|
+
|
|
165
|
+
Call `update` once before you await it. `settle()` resolves once the chosen splats are
|
|
148
166
|
packed, and for a stream once the chunks that they need have arrived, which a still picture waits
|
|
149
167
|
for.
|
|
150
168
|
|
|
@@ -201,9 +219,24 @@ total size and `splats.loadedBytes` gives the part that has arrived.
|
|
|
201
219
|
| `chunkSplats(data, options)` | The chunks that `createSplats` draws, if you want them yourself |
|
|
202
220
|
| `parseStreamIndex(text, base)` | The chunks that a stream index names |
|
|
203
221
|
| `colorOfSh(dc, encoded?)` | The linear color of a first-band spherical-harmonic coefficient |
|
|
222
|
+
| `checkSplats(data, what)` | The same `data`, once its arrays hold the number of splats that it names. Otherwise it throws E2101, whose message names `what` |
|
|
223
|
+
| `SPLAT_EXTENSION` | The name of the glTF extension that the add-on reads, `'KHR_gaussian_splatting'` |
|
|
224
|
+
|
|
225
|
+
`update(eye)` chooses the splats that draw from the camera's position, and `setBudget(count)` caps the splats that draw below the preset's count. The other members are:
|
|
204
226
|
|
|
205
|
-
|
|
206
|
-
|
|
227
|
+
| Member | What it does |
|
|
228
|
+
| --- | --- |
|
|
229
|
+
| `update(eye)` | Chooses the splats that draw from the camera's position. Call it once a frame |
|
|
230
|
+
| `setBudget(count)` | Caps the splats that draw below the preset's count |
|
|
231
|
+
| `ready` | Resolves when the cloud can draw its first view |
|
|
232
|
+
| `settle()` | Resolves once the chosen splats are packed and their chunks have arrived |
|
|
233
|
+
| `total`, `drawn` | The splats that the cloud holds, and the splats that draw now |
|
|
234
|
+
| `chunks`, `loaded`, `failed` | The cloud's chunks, the ones that have loaded, and the ones that stayed unreachable |
|
|
235
|
+
| `bytes`, `loadedBytes` | The cloud's total size, and the part that has arrived |
|
|
236
|
+
| `feature`, `draw` | The add-on feature, whose settings, budget and figures the engine resolves, and the draw, whose batch rows are the splats that draw |
|
|
237
|
+
| `destroy()` | Frees the cloud |
|
|
238
|
+
|
|
239
|
+
The [API reference](reference/splats.md#splats) gives each member's type.
|
|
207
240
|
|
|
208
241
|
## Costs and limits
|
|
209
242
|
|
|
@@ -217,7 +250,7 @@ total size and `splats.loadedBytes` gives the part that has arrived.
|
|
|
217
250
|
- A glTF model's splats draw in the file's order inside each part. For a large cloud, use an SPZ
|
|
218
251
|
file or a splat stream, whose rows the engine sorts one by one.
|
|
219
252
|
- A splat casts no shadow and receives none.
|
|
220
|
-
- The cards need the scene's depth copy, which
|
|
253
|
+
- The cards need the scene's depth copy, which the splat cards' material makes. It
|
|
221
254
|
costs one full-screen pass and one texture of four bytes for each pixel.
|
|
222
255
|
- A stream spends one request for each chunk that the view needs. Keep the chunks large enough that
|
|
223
256
|
the requests do not dominate, and small enough that the first view arrives quickly: before that
|
|
@@ -250,6 +283,7 @@ total size and `splats.loadedBytes` gives the part that has arrived.
|
|
|
250
283
|
- [Add-on feature descriptions](features.md): the settings, budget and figures that the cloud
|
|
251
284
|
declares.
|
|
252
285
|
- [Assets](assets.md#extensions-that-add-ons-read): how an add-on reads a glTF extension.
|
|
286
|
+
- [Streaming and the budget](https://github.com/null3d-engine/null3d/tree/main/examples/splats): a 1.7 million splat scan of Bolton Priory, streamed nearest first within the preset's budget.
|
|
253
287
|
|
|
254
288
|
## API reference
|
|
255
289
|
|