@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/concepts/culling.md
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: concepts/culling
|
|
3
3
|
title: Culling
|
|
4
|
-
status: experimental
|
|
5
|
-
since: "0.1"
|
|
6
4
|
summary: "Frustum culling on the GPU on WebGPU, or on the job workers there when the device draws directly, and on the job workers on WebGL2; grid cells, whole cells out of view skipped first, positions relative to the camera, and occlusion culling: behind large opaque objects that the GPU picks on WebGPU, and behind marked blockers on WebGL2."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# Culling
|
|
10
8
|
|
|
11
|
-
> Roadmap step 0.1, first released in null3D 0.1.0. Step 0.2 adds occlusion culling. The API is experimental, so it can still change between versions.
|
|
12
|
-
|
|
13
9
|
```mermaid
|
|
14
10
|
flowchart LR
|
|
15
11
|
subgraph core["Engine core, each frame"]
|
|
@@ -29,15 +25,32 @@ flowchart LR
|
|
|
29
25
|
occlude --> draw["Draw the visible<br/>objects and rows"]
|
|
30
26
|
```
|
|
31
27
|
|
|
32
|
-
Culling finds the objects and instance rows in the camera's view, so the GPU draws only those. Occlusion culling also skips the objects that others hide. The engine tests each bounding sphere against the six planes of the view.
|
|
28
|
+
Culling finds the objects and instance rows in the camera's view, so the GPU draws only those. Occlusion culling also skips the objects that others hide. The engine tests each bounding sphere against the six planes of the view. The engine culls each [view](render-graph.md) separately, against that view's camera. A view is one of:
|
|
29
|
+
|
|
30
|
+
- the camera's view
|
|
31
|
+
- a shadow cascade's
|
|
32
|
+
- a shadow tile's
|
|
33
|
+
- a [scene pass](../api/render.md)'s
|
|
34
|
+
- one that [`scene.createView`](../api/scene.md#multiple-views) draws into a rectangle of the canvas
|
|
33
35
|
|
|
34
36
|
## How each path culls
|
|
35
37
|
|
|
36
|
-
On WebGPU the GPU culls the scene itself. A compute pass runs one GPU thread per object or instance row. Each thread adds its cell's offset to its bounding sphere and tests the sphere.
|
|
38
|
+
On WebGPU the GPU culls the scene itself. A compute pass runs one GPU thread per object or instance row. Each thread adds its cell's offset to its bounding sphere and tests the sphere.
|
|
39
|
+
|
|
40
|
+
An object in view joins its group: the objects that share a mesh and a material. The prerecorded draws read how many each group holds. The CPU's cost per frame stays almost flat as the scene grows. When the scene spreads over several grid cells, the pass runs only over the objects of the cells in view and over the moving objects.
|
|
41
|
+
|
|
42
|
+
On an Apple GPU in Safari, or in any browser on iPhone and iPad, a start-up measurement can find direct draws clearly faster. The job workers then cull on the CPU instead. They use the WebGL2 culling on the WebGPU path's own groups. Each group then draws with its known count. `engine.capabilities.directDraws` says which path the device took, and `engine.capabilities.drawPath` says why. The [Performance guide](../guides/performance.md#how-the-engine-batches-builds-pipelines-and-times-frames) explains how the engine batches.
|
|
43
|
+
|
|
44
|
+
<details>
|
|
45
|
+
<summary>Technical details: how the device picks a path</summary>
|
|
46
|
+
|
|
47
|
+
The start-up measurement takes the direct path only when that path measures at least 25% faster and at least 0.15 ms a frame faster. Other devices skip the measurement and cull on the GPU.
|
|
48
|
+
|
|
49
|
+
</details>
|
|
37
50
|
|
|
38
|
-
On
|
|
51
|
+
On WebGL2 there are no compute shaders, so the job workers cull on the CPU. They test four spheres per SIMD instruction and list the visible objects, 4 bytes each.
|
|
39
52
|
|
|
40
|
-
|
|
53
|
+
They test a static instance batch that has stopped changing in groups of 64 nearby rows, one test per group. Each group lies inside one grid cell. A group that is partly in view draws whole, and the GPU clips the rows outside. The job workers skip the objects and groups of the cells out of view.
|
|
41
54
|
|
|
42
55
|
[GPU tiers and backends](backends.md) describes each path's draw calls and uploads.
|
|
43
56
|
|
|
@@ -48,6 +61,24 @@ On WebGL2 there are no compute shaders, so the job workers cull on the CPU. They
|
|
|
48
61
|
- A morphed mesh culls with a sphere that its weights grow: each target's longest move, times its weight.
|
|
49
62
|
- Sprites, points and line segments cull as instance rows do, one sphere each. Sprites and points sized in CSS pixels, with `sizeAttenuation: false`, never cull, because their size in the world grows with their distance.
|
|
50
63
|
|
|
64
|
+
## Bounds that you set
|
|
65
|
+
|
|
66
|
+
By default, culling tests an object's mesh sphere. That sphere is around the center of the box that holds every vertex of its mesh. `mesh.center` and `mesh.radius` give it in the mesh's own space. The object's scale grows it, and its rotation turns it.
|
|
67
|
+
|
|
68
|
+
A shader that moves vertices, such as waves on water, can move them outside that sphere. Culling then hides the object while parts of it are still in view. Two mesh calls change what culling tests:
|
|
69
|
+
|
|
70
|
+
- `setBounds(center, radius)` gives the object a sphere of its own, with its center relative to the object's origin. Bounds that cover the moved vertices keep culling at work.
|
|
71
|
+
- `setFrustumCulled(false)` turns culling off for the object, so the engine draws it wherever it is.
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
// Waves lift the water's vertices by up to 2 m. A sphere 1 m higher and 1 m wider than the
|
|
75
|
+
// mesh's sphere holds every lifted vertex.
|
|
76
|
+
const [x, y, z] = waterMesh.center;
|
|
77
|
+
water.setBounds([x, y + 1, z], waterMesh.radius + 1);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Both calls rebuild the draw tables, so make them at setup. On WebGPU, each object with a sphere of its own draws from a group of its own, as the GPU tests one sphere per group. Skinned objects without morph targets are the exception: copies of one mesh and material share a group, whose sphere holds every copy's. On WebGL2, the job workers test each object's own sphere and the cost stays the same.
|
|
81
|
+
|
|
51
82
|
## GPU occlusion culling on WebGPU
|
|
52
83
|
|
|
53
84
|
The frustum test keeps every object in view, even one that a wall hides. On WebGPU, large opaque objects hide the objects behind them, and the GPU skips those. You mark nothing: the GPU picks the objects that hide others itself, among every opaque object and instance row. The GPU works in two phases in each frame, for each camera:
|
|
@@ -76,15 +107,22 @@ The pyramid holds the depth of objects drawn in this frame, at the detail that t
|
|
|
76
107
|
|
|
77
108
|
### The check during play
|
|
78
109
|
|
|
79
|
-
The extra passes cost GPU time: a depth draw of the occluders, a depth pyramid and a second culling pass.
|
|
110
|
+
The extra passes cost GPU time: a depth draw of the occluders, a depth pyramid and a second culling pass. So the engine checks during play whether they pay. About every 120 frames it runs a few frames the other way and compares.
|
|
111
|
+
|
|
112
|
+
The passes stay on while they hide at least a tenth of the objects that would draw. The frame must also take no longer with them, within 2%. Otherwise they stay off until a later check finds that they pay. While the view holds still, the check pauses, so the still-camera accumulation can finish.
|
|
113
|
+
|
|
114
|
+
`engine.measure` reports the objects that the culling hid as `occludedEntries`. That is the count of the newest frame whose counts came back, and 0 while the check keeps the passes off. The `?occlusion-check=off` switch keeps the passes on in every frame, for a test that compares the image with culling and without it.
|
|
115
|
+
|
|
116
|
+
<details>
|
|
117
|
+
<summary>Technical details: how the engine checks that occlusion culling pays</summary>
|
|
80
118
|
|
|
119
|
+
- Another program's work on the GPU can run in the gaps between the extra passes. So a frame with them can take longer although it draws less.
|
|
81
120
|
- The second phase counts the objects in view that would draw and those that the pyramid hid. A frame copies the counts, and the GPU sends them back a few frames later. Nothing waits for them.
|
|
82
|
-
-
|
|
83
|
-
- The passes stay on while they hide at least a tenth of the objects that would draw, and a frame with them takes no longer than one without, within 2%. Otherwise they stay off until a later check finds that they pay.
|
|
121
|
+
- A trial runs without the passes while they run, or with them while they do not. It compares the GPU's frame times, from each frame's submit to its completion, with the frames just before.
|
|
84
122
|
- The occluders' pass draws only the groups of objects that held occluders in the last few checks, so it draws nothing for the rest.
|
|
85
|
-
- While the view holds still,
|
|
123
|
+
- While the view holds still, nothing is copied and the passes stay as they are. The check starts again a little after the view moves.
|
|
86
124
|
|
|
87
|
-
|
|
125
|
+
</details>
|
|
88
126
|
|
|
89
127
|
### Where it runs
|
|
90
128
|
|
|
@@ -100,22 +138,6 @@ The extra passes cost GPU time: a depth draw of the occluders, a depth pyramid a
|
|
|
100
138
|
scene.createMesh({ mesh: sculpture, material: bronze, position: [0, 0, -8], occluder: false });
|
|
101
139
|
```
|
|
102
140
|
|
|
103
|
-
## Bounds that you set
|
|
104
|
-
|
|
105
|
-
By default, culling tests an object's mesh sphere: the sphere around the center of the box that holds every vertex of its mesh. `mesh.center` and `mesh.radius` give it in the mesh's own space. The object's scale grows it, and its rotation turns it. A shader that moves vertices, such as waves on water, can move them outside that sphere. Culling then hides the object while parts of it are still in view. Two mesh calls change what culling tests:
|
|
106
|
-
|
|
107
|
-
- `setBounds(center, radius)` gives the object a sphere of its own, with its center relative to the object's origin. Bounds that cover the moved vertices keep culling at work.
|
|
108
|
-
- `setFrustumCulled(false)` turns culling off for the object, so the engine draws it wherever it is.
|
|
109
|
-
|
|
110
|
-
```ts
|
|
111
|
-
// Waves lift the water's vertices by up to 2 m. A sphere 1 m higher and 1 m wider than the
|
|
112
|
-
// mesh's sphere holds every lifted vertex.
|
|
113
|
-
const [x, y, z] = waterMesh.center;
|
|
114
|
-
water.setBounds([x, y + 1, z], waterMesh.radius + 1);
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Both calls rebuild the draw tables, so make them at setup. On WebGPU, each object with a sphere of its own draws from a group of its own, as the GPU tests one sphere per group. Skinned objects without morph targets are the exception: copies of one mesh and material share a group, whose sphere holds every copy's. On WebGL2, the job workers test each object's own sphere and the cost stays the same.
|
|
118
|
-
|
|
119
141
|
## Software occlusion culling on WebGL2
|
|
120
142
|
|
|
121
143
|
Frustum culling keeps everything in the view, even what a building hides. On WebGL2, objects that you mark as blockers hide the objects behind them, so the GPU skips those too:
|
|
@@ -156,7 +178,14 @@ scene.instantiate(city, { occluder: false });
|
|
|
156
178
|
|
|
157
179
|
### Turn it on where it pays
|
|
158
180
|
|
|
159
|
-
Every quality preset leaves software occlusion culling off.
|
|
181
|
+
Every quality preset leaves software occlusion culling off. In S6, the engine's benchmark city, on three Android phones and an iPad, all on WebGL2, it cost at least 3.5 times what it saved. Most hidden entries were rows of instance batches whose other rows still showed, so the batch still drew.
|
|
182
|
+
|
|
183
|
+
<details>
|
|
184
|
+
<summary>Technical details: the S6 measurements</summary>
|
|
185
|
+
|
|
186
|
+
It hid 23% to 39% of the entries in view, but removed fewer than 3% of the draw calls. The job workers spent 7 to 22 ms more per frame, and the render worker saved 2.3 ms at most.
|
|
187
|
+
|
|
188
|
+
</details>
|
|
160
189
|
|
|
161
190
|
A scene whose few large blockers hide many separate meshes, each its own draw call, can gain where the city lost. So turn it on only when your scene measures a gain:
|
|
162
191
|
|
|
@@ -173,14 +202,7 @@ WebGPU picks its occluders itself for its own [occlusion culling on the GPU](#gp
|
|
|
173
202
|
|
|
174
203
|
## Grid cells
|
|
175
204
|
|
|
176
|
-
The engine divides space into cells 1,024 m wide.
|
|
177
|
-
|
|
178
|
-
- A root object takes the cell that holds its position. Its children take its cell.
|
|
179
|
-
- An instance row takes the cell that holds its position.
|
|
180
|
-
|
|
181
|
-
The engine keeps each world matrix relative to its cell's center, where 32-bit floats are precise to a fraction of a millimeter. Each frame it computes the offset from the camera to each cell in use, in 64-bit floats, and uploads one vector per cell. Each view gets the offsets from its own camera. The GPU adds an object's offset to its position, so every position it sees is relative to the camera. Positions near the camera keep the most precision.
|
|
182
|
-
|
|
183
|
-
When only the camera moves, static objects keep their data on the GPU, and only the offsets change. A scene inside one cell uploads one vector per frame.
|
|
205
|
+
The engine divides space into cells, cubes 1,024 m wide. A root object takes the cell that holds its position, and its children share it. An instance row takes the cell that holds its own position. [Large worlds and precision](large-worlds.md#grid-cells) explains how the cells keep positions precise.
|
|
184
206
|
|
|
185
207
|
## Skipping cells out of view
|
|
186
208
|
|
|
@@ -193,12 +215,16 @@ Most frames of a large world show a few of its cells. The engine then tests each
|
|
|
193
215
|
- A still object that changes grows its cell's box. One that moves into another cell rebuilds the cell order, as creating or destroying an object does. Keep objects that cross cells often dynamic.
|
|
194
216
|
- On WebGL2, a static batch whose rows change is tested row by row until it rests again. So is a static batch whose rows are spread so thinly over cells that its groups of 64 rows would be mostly empty.
|
|
195
217
|
|
|
196
|
-
A scene inside one cell has nothing to skip, and culls as it would without cells. The benchmark scene S1-cells spreads 100,000 still boxes over 8 x 8 cells and flies the camera low over them.
|
|
218
|
+
A scene inside one cell has nothing to skip, and culls as it would without cells. The benchmark scene S1-cells spreads 100,000 still boxes over 8 x 8 cells and flies the camera low over them. The [Performance guide](../guides/performance.md#large-worlds) gives what the cells saved in it.
|
|
197
219
|
|
|
198
220
|
## What this means for your sketch
|
|
199
221
|
|
|
200
222
|
Write world positions as usual, and the engine picks the cells:
|
|
201
223
|
|
|
224
|
+

|
|
225
|
+
|
|
226
|
+
2 cm keys 1,000 km from the origin, drawn without jitter.
|
|
227
|
+
|
|
202
228
|
```ts
|
|
203
229
|
const base = [250_000, 0, -80_000] as const;
|
|
204
230
|
const camera = scene.createPerspectiveCamera({
|
|
@@ -209,14 +235,7 @@ scene.setActiveCamera(camera);
|
|
|
209
235
|
scene.createMesh({ mesh: geometry.box(), material: stone, position: base });
|
|
210
236
|
```
|
|
211
237
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
- The engine stores positions as 32-bit floats. It places an object 100 km from the origin to within about 4 mm, and 1,000 km out to within about 3 cm. What it computes from those positions, such as a child's place under its parent, keeps its precision.
|
|
215
|
-
- A mesh's vertices are offsets from its object's origin, and they stay 32-bit. Put large coordinates in object positions, never in vertices.
|
|
216
|
-
- `getWorldPosition` and `getWorldMatrix` give 64-bit positions. Pass them a plain array or a `Float64Array`, because a `Float32Array` rounds them to 32 bits.
|
|
217
|
-
- At most 512 cells hold objects at once. An object in a cell past that stays in the origin cell, where its position keeps only 32-bit precision. The engine then warns once in the console.
|
|
218
|
-
|
|
219
|
-
For a world the size of a planet, `createEngine`'s `largeWorld` option keeps every position that you set exact. A batch's `origin` option keeps its rows precise far from the origin. [Large worlds and precision](large-worlds.md) explains both.
|
|
238
|
+
[Large worlds and precision](large-worlds.md) gives the precision figures and the limits, including the 512-cell cap. [Floating-origin geometry](large-worlds.md#floating-origin-geometry) says why vertices stay 32-bit, and [Objects and transforms](../api/objects.md) covers the world getters. For a world the size of a planet, `createEngine`'s `largeWorld` option keeps every position that you set exact, and a batch's `origin` option keeps its rows precise.
|
|
220
239
|
|
|
221
240
|
## Related pages
|
|
222
241
|
|
|
@@ -225,3 +244,5 @@ For a world the size of a planet, `createEngine`'s `largeWorld` option keeps eve
|
|
|
225
244
|
- [Static and dynamic objects](static-dynamic.md): which objects upload their data each frame.
|
|
226
245
|
- [Large worlds and precision](large-worlds.md): `largeWorld` mode and batch origins.
|
|
227
246
|
- [The demo far from the origin](https://github.com/null3d-engine/null3d/tree/main/examples/far-from-origin): keys 2 cm wide, 1,000 km from the origin, seen from 40 cm.
|
|
247
|
+
- [Row-by-row culling of a large batch](https://github.com/null3d-engine/null3d/tree/main/examples/instances): a dynamic batch of 100,000 rows, each culled on its own.
|
|
248
|
+
- [Bounds that follow the waves](https://github.com/null3d-engine/null3d/tree/main/examples/vertex-updates): `setBounds` on a pool whose waves lift its corners past the flat mesh's sphere.
|
package/docs/concepts/handles.md
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: concepts/handles
|
|
3
3
|
title: Handles and objects
|
|
4
|
-
status: experimental
|
|
5
|
-
since: "0.1"
|
|
6
4
|
summary: "30-bit handles; wrapper objects; stale-handle errors; keeping per-object data in your own arrays."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# Handles and objects
|
|
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
|
```mermaid
|
|
14
10
|
flowchart LR
|
|
15
11
|
handle["Handle<br/>a 30-bit integer"] --> slot["Slot index<br/>20 bits"]
|
|
@@ -72,7 +68,18 @@ crate.setPosition(0, 0, 0); // development build: throws E1101
|
|
|
72
68
|
|
|
73
69
|
In development builds, every call on an object apart from `describe` checks that the object still lives. A call on a destroyed object throws an `EngineError` with the code [E1101](../errors/E1101.md), which names the object and the frame it was destroyed in. Release builds leave this check out, so a transform setter costs only its memory writes.
|
|
74
70
|
|
|
75
|
-
A call on a destroyed object never changes the object that takes its slot, in any build.
|
|
71
|
+
A call on a destroyed object never changes the object that takes its slot, in any build. The call is still a bug in your sketch, so find it in a development build.
|
|
72
|
+
|
|
73
|
+
<details>
|
|
74
|
+
<summary>Technical details: what each build does with a destroyed object</summary>
|
|
75
|
+
|
|
76
|
+
Slot 0 is never used, so handle 0 means no object. When you destroy an object, its wrapper's setters switch to row 0. Its handle gets a generation that no live object gets, so it never matches a later object in its slot. In a release build, its setters then write to that unused row, and its light setters reach no light. A second `destroy()` frees nothing.
|
|
77
|
+
|
|
78
|
+
The engine core checks the generation of each change that waits for the next frame, and logs E1101 for a change to a destroyed object.
|
|
79
|
+
|
|
80
|
+
</details>
|
|
81
|
+
|
|
82
|
+
An instance batch's arrays throw [E1101](../errors/E1101.md) in every build once the batch is gone. The world getters throw it in every build from the frame after the destroy, and at once in development builds.
|
|
76
83
|
|
|
77
84
|
## Keep per-object data in your own arrays
|
|
78
85
|
|
|
@@ -91,3 +98,5 @@ Your loops then read your arrays and write the engine's arrays, and neither side
|
|
|
91
98
|
- [Static and dynamic objects](static-dynamic.md): when a write reaches the GPU.
|
|
92
99
|
- [Instances and batching](instances.md): rows instead of handles, for many copies of one mesh.
|
|
93
100
|
- [Architecture: threads and the frame](architecture.md): where the shared arrays live.
|
|
101
|
+
- [Wrapper objects and setters](https://github.com/null3d-engine/null3d/tree/main/examples/objects): crates move with setters between a turntable and the stage.
|
|
102
|
+
- [Per-object data in your own arrays](https://github.com/null3d-engine/null3d/tree/main/examples/math): a drone swarm keeps a weight for each of its 300 rows.
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: concepts/instances
|
|
3
3
|
title: Instances and batching
|
|
4
|
-
status: experimental
|
|
5
|
-
since: "0.1"
|
|
6
4
|
summary: "createInstances; typed-array views; markDirty; automatic batching; per-row colors and values."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# Instances and batching
|
|
10
8
|
|
|
11
|
-
> Roadmap step 0.1, first released in null3D 0.1.0. Step 0.2 adds shadows of batch rows, row colors and row values. The API is experimental, so it can still change between versions.
|
|
12
|
-
|
|
13
9
|
```mermaid
|
|
14
10
|
flowchart LR
|
|
15
11
|
code["Sketch code writes rows<br/>into typed arrays"] --> rows[("Batch rows<br/>positions, rotations, scales")]
|
|
@@ -23,6 +19,10 @@ An instance batch draws one mesh with one material many times. Each copy is a ro
|
|
|
23
19
|
|
|
24
20
|
Use a batch for many copies that you move in loops, such as particles, bullets, crowds, trees and rocks. Use separate objects from `scene.createMesh` when each copy needs a name, a parent or its own setters.
|
|
25
21
|
|
|
22
|
+

|
|
23
|
+
|
|
24
|
+
One dynamic batch: the sketch writes every column's height in every frame.
|
|
25
|
+
|
|
26
26
|
## Create a batch
|
|
27
27
|
|
|
28
28
|
```ts
|
|
@@ -54,6 +54,10 @@ export default defineSketch(({ scene, geometry, materials }) => {
|
|
|
54
54
|
| `values` | `false` | `true` adds a `values` array: four numbers for each row, which a custom material reads |
|
|
55
55
|
| `layers` | `1`, layer 0 | The [layers](render-layers.md) of every row, as a 32-bit mask |
|
|
56
56
|
| `origin` | `[0, 0, 0]` | The point that every row's position is relative to, kept at full precision: [Batch origins](large-worlds.md#batch-origins) |
|
|
57
|
+
| `castShadows` | `false` | `true` makes every row cast shadows: [Shadows](shadows.md) |
|
|
58
|
+
| `receiveShadows` | `false` | `true` makes shadows fall on every row |
|
|
59
|
+
| `occluder` | `true` | `false` keeps rows from hiding what lies behind them in GPU occlusion culling on WebGPU: [Which objects hide others](culling.md#which-objects-hide-others) |
|
|
60
|
+
| `ranges` | `false` | `true` adds a `ranges` array: a start and an end distance for each row, so each row draws in a band of its own: [Distance bands](lod.md#distance-bands) |
|
|
57
61
|
|
|
58
62
|
`count` is the batch's capacity, which never changes. All rows draw at first. A new batch computes every row in its first frame, so rows that you write before that frame need no mark.
|
|
59
63
|
|
|
@@ -66,12 +70,13 @@ export default defineSketch(({ scene, geometry, materials }) => {
|
|
|
66
70
|
| `scales` | 3 | The scale on each axis | 1, 1, 1 |
|
|
67
71
|
| `colors` | 4 | A linear color (r, g, b, a), with `colors: true` only | 1, 1, 1, 1 |
|
|
68
72
|
| `values` | 4 | Four numbers of your own, with `values: true` only | 0, 0, 0, 0 |
|
|
73
|
+
| `ranges` | 2 | A start and an end distance, with `ranges: true` only | 0 and infinity |
|
|
69
74
|
|
|
70
75
|
Row `i` starts at index `i * 3` in an array of 3 floats per row, and at `i * 4` in an array of 4. Rows have no parent, so each position is in world space, relative to the batch's `origin`. Far from the world's origin, give the batch an origin near its rows, so their 32-bit positions stay small and precise.
|
|
71
76
|
|
|
72
77
|
The arrays are `Float32Array` views of engine memory. The engine's memory can grow when the scene grows: new meshes, batches, materials and lights, and textures made or updated from data. In the single-threaded build, growth empties every older view, and a write to an empty view does nothing. So read the arrays from the batch each time you use them, such as at the start of `onUpdate`. Do not keep them from the setup. A read allocates nothing while the memory keeps its size.
|
|
73
78
|
|
|
74
|
-
To turn rows, write quaternions. The engine
|
|
79
|
+
To turn rows, write unit quaternions, whose length is 1. The engine uses a quaternion within about one per cent of unit length exactly as written, so a rounded rotation such as `[0, 0.38, 0, 0.92]` does not move. The engine does not correct an error inside that band: it can stretch or shear the row by up to about four per cent. The engine scales a quaternion further from unit length to unit length, so a mistyped one turns its row without stretching it. The [math helpers](../api/math.md) make unit quaternions without allocating:
|
|
75
80
|
|
|
76
81
|
```ts
|
|
77
82
|
import { defineSketch, quat } from '@null3d/engine';
|
|
@@ -127,19 +132,14 @@ trees.rotations.set(q, 42 * 4);
|
|
|
127
132
|
trees.markDirty(42, 1); // recompute and upload row 42 only
|
|
128
133
|
```
|
|
129
134
|
|
|
130
|
-
A mark past the batch's capacity throws [E1108](../errors/E1108.md). Development builds
|
|
135
|
+
A mark past the batch's capacity throws [E1108](../errors/E1108.md). Development builds also find rows that changed without a mark and raise [E1110](../errors/E1110.md), which names the row. Sprite and point batches get the same check, and release builds leave it out. A dynamic batch needs no marks, because it recomputes every row in use in every frame. [Static and dynamic objects](static-dynamic.md) compares what each kind uploads. The [terrain demo](https://github.com/null3d-engine/null3d/tree/main/examples/terrain) writes its boulders into a static batch and marks them once. The [custom shader inputs demo](https://github.com/null3d-engine/null3d/tree/main/examples/shader-inputs) does the same for its crystal spiral.
|
|
131
136
|
|
|
132
|
-
|
|
137
|
+
<details>
|
|
138
|
+
<summary>Technical details: how the unmarked-write check works</summary>
|
|
139
|
+
|
|
140
|
+
Before each batch update the check notes the marked rows. It then compares up to 4,096 drawn rows a frame, over all static batches, with the values it read before. The next frame takes the next rows, so a write is found within a few frames at a bounded cost per frame.
|
|
133
141
|
|
|
134
|
-
|
|
135
|
-
add-on. Call `batch.createChunkRows()` to make a writer. The writer stores a chunk's arrays in the
|
|
136
|
-
engine's memory once, at load. Call `writer.reserve(count)` with the number of chunks. Then call
|
|
137
|
-
`writer.write(slot, chunk)` for each chunk as it arrives. In each frame that the chosen rows
|
|
138
|
-
change, call `writer.pack(counts)` with one chosen count for each slot. The writer writes the first
|
|
139
|
-
`counts[slot]` rows of each chunk into the batch, in slot order, and sets the batch's active count.
|
|
140
|
-
The pack runs in the engine's core, so the sketch copies no rows and runs no loop over them. The
|
|
141
|
-
batch must own its rows' transforms: a part of a model, or a sprite or line batch, takes no chunked
|
|
142
|
-
rows. The writer's code loads on first use. `writer.destroy()` frees its chunks.
|
|
142
|
+
</details>
|
|
143
143
|
|
|
144
144
|
## Pools: draw only the rows in use
|
|
145
145
|
|
|
@@ -171,17 +171,36 @@ function remove(row: number): void {
|
|
|
171
171
|
}
|
|
172
172
|
```
|
|
173
173
|
|
|
174
|
-
Keep each row's own data, such as a velocity, in your own typed arrays in the same row order, and move it the same way. An active count past the capacity throws [E1108](../errors/E1108.md).
|
|
174
|
+
Keep each row's own data, such as a velocity, in your own typed arrays in the same row order, and move it the same way. An active count past the capacity throws [E1108](../errors/E1108.md). The [instancing demo](https://github.com/null3d-engine/null3d/tree/main/examples/instances) sets its active count from the quality preset and fills the rows from the middle out.
|
|
175
175
|
|
|
176
176
|
`destroy()` removes a batch at once and frees its rows. After it, stop using the batch and every array that you read from it. Its calls throw [E1101](../errors/E1101.md), and so do its array getters, such as `positions`, in every build. An array that you read before the destroy can point at memory that the engine gives to another batch.
|
|
177
177
|
|
|
178
178
|
## Culling
|
|
179
179
|
|
|
180
|
-
Each row has its own bounding sphere
|
|
180
|
+
Each row has its own bounding sphere: its center is the row's position, and its radius is the mesh's radius times the row's largest scale. A vertex shader that moves rows far from their origins, as traffic along a lane does, needs `setBoundingRadius(r)`. Without it, the engine culls rows that are still on the screen. The call rebuilds the engine's draw tables, so make it at setup. [Culling](culling.md#how-each-path-culls) explains how each GPU path culls.
|
|
181
|
+
|
|
182
|
+
<details>
|
|
183
|
+
<summary>Technical details: how rows are culled</summary>
|
|
184
|
+
|
|
185
|
+
- Each view culls row by row.
|
|
186
|
+
- On WebGPU a compute pass culls, and on direct-draw devices the job workers cull.
|
|
187
|
+
- The rows of a blended material are culled one by one on the job workers, on both paths, and sorted back to front.
|
|
188
|
+
- On WebGL2 a static batch at rest is tested in groups of 64 nearby rows inside one grid cell. A group that is partly in view draws whole, and the GPU clips the rows outside.
|
|
189
|
+
- Both paths skip the rows of static batches in grid cells out of view.
|
|
190
|
+
- On WebGL2, a frame that marks a static batch, and the frame after it, test that batch row by row with no cell skipped.
|
|
191
|
+
|
|
192
|
+
</details>
|
|
181
193
|
|
|
182
194
|
## Automatic batching
|
|
183
195
|
|
|
184
|
-
The engine groups what it draws by mesh and material. Objects from `scene.createMesh` and batch rows that share a mesh and a material draw together. They share instanced or indirect draws. So 500 crates from `createMesh` with one mesh and one material draw as cheaply as a batch of 500 rows. Some groups split
|
|
196
|
+
The engine groups what it draws by mesh and material. Objects from `scene.createMesh` and batch rows that share a mesh and a material draw together. They share instanced or indirect draws. So 500 crates from `createMesh` with one mesh and one material draw as cheaply as a batch of 500 rows. Some groups split:
|
|
197
|
+
|
|
198
|
+
- On WebGPU, an object with bounds of its own from `setBounds` draws apart from the others.
|
|
199
|
+
- Objects that are never culled draw apart from the culled ones, in a group of their own for each mesh and material.
|
|
200
|
+
- Objects and rows that receive shadows draw with other pipelines than those that do not, so they draw apart from them.
|
|
201
|
+
- On WebGL2, the rows of a dynamic batch and of a static batch at rest draw apart from objects with the same mesh and material.
|
|
202
|
+
|
|
203
|
+
Blended objects and rows draw in the transparent pass, sorted back to front. The [factory comparison](https://github.com/null3d-engine/null3d/tree/main/examples/compare/factory) builds each robot arm from separate meshes, and tells how null3D draws parts that share a mesh and a material together.
|
|
185
204
|
|
|
186
205
|
The difference is the sketch's own work on the CPU:
|
|
187
206
|
|
|
@@ -191,22 +210,40 @@ The difference is the sketch's own work on the CPU:
|
|
|
191
210
|
| Hierarchy | Parents and children | None: each row is in world space |
|
|
192
211
|
| Identity | A name and a handle each | A row number |
|
|
193
212
|
|
|
194
|
-
Some calls change the scene's structure
|
|
213
|
+
Some calls change the scene's structure. The next frame then rebuilds the engine's draw tables, which costs more than a normal frame. These calls rebuild:
|
|
214
|
+
|
|
215
|
+
- creating or destroying a batch or an object of any kind, lights included
|
|
216
|
+
- `setMaterial`, `setMesh`, `setParent`, `setDynamic`, `setBounds`, `setFrustumCulled`, `setCastShadows` and `setReceiveShadows`, on an object or a batch
|
|
217
|
+
- `texture.destroy()`, and `texture.update()` with an image of another size
|
|
218
|
+
- turning shadows on or off
|
|
219
|
+
- in development builds, a new [debug view](../api/debug.md)
|
|
220
|
+
|
|
221
|
+
They rebuild even when the value does not change, apart from a batch's `setCastShadows` and `setReceiveShadows`. These never rebuild the tables:
|
|
222
|
+
|
|
223
|
+
- transform setters and row writes
|
|
224
|
+
- `setVisible`, `setLayers`, `setActiveCount` and `setRenderOrder`
|
|
225
|
+
- the other setters of lights and cameras, and `material.set`
|
|
226
|
+
|
|
227
|
+
So create batches in the setup, and pool rows during play instead of creating batches.
|
|
195
228
|
|
|
196
229
|
## Limits
|
|
197
230
|
|
|
198
231
|
- Every row of a batch casts and receives shadows alike: give `castShadows` and `receiveShadows` to `createInstances`, or call `batch.setCastShadows(true)` and `batch.setReceiveShadows(true)`. Both are false by default. [Shadows](shadows.md) explains them. Sprite, point and line batches take no shadows.
|
|
199
|
-
- An engine holds up to
|
|
232
|
+
- An engine holds up to 512 instance batches, sprite, point and line batches included. One more throws [E1102](../errors/E1102.md).
|
|
200
233
|
- Every row counts toward the device's limit of objects and instance rows, whether it draws or not. `engine.capabilities.maxInstances` gives the limit. The places in the scene's object tables count toward it too, used or not. They start at 1,024 and double as the scene grows. So the batches of a scene hold at most the limit less those places. A `createInstances` call that would pass it throws [E1501](../errors/E1501.md).
|
|
201
234
|
- Each row takes about 210 bytes of engine memory, or about 300 with colors or values. When the engine cannot get more memory, `createInstances` throws [E1109](../errors/E1109.md). Rows with colors or values also take 32 bytes each of GPU memory.
|
|
202
235
|
- On WebGL2 the limit follows the largest texture the device allows. A device whose textures reach only 2,048 pixels, the least that WebGL2 allows, draws 1,048,576. That leaves 1,047,552 rows for batches beside a scene of up to 1,023 objects. [GPU tiers and backends](backends.md#the-portable-budget) gives the numbers.
|
|
203
236
|
- Development builds warn once in the console when a scene passes the number that every device of its GPU path draws. On WebGPU that is 2,097,152, the most that devices with WebGPU's default limits draw. On WebGL2 it is 1,048,576. The engine picks the GPU path for each device, so test a scene past 1,048,576 on both paths.
|
|
204
|
-
- A row costs the mesh's vertices in every pass that draws it. Many rows of a detailed mesh therefore cost more than their pixels suggest. A hull of 72 vertices drawn 30,000 times is 2,
|
|
237
|
+
- A row costs the mesh's vertices in every pass that draws it. Many rows of a detailed mesh therefore cost more than their pixels suggest. A hull of 72 vertices drawn 30,000 times is 2,160,000 vertex shader runs for one pass. A depth prepass draws the rows again, because the reflections and ambient occlusion turn one on. Share each vertex between the faces that meet at it where the shading allows a smooth surface. The same mesh with 24 vertices does a third of that work.
|
|
205
238
|
|
|
206
239
|
## Per-row colors
|
|
207
240
|
|
|
208
241
|
`colors: true` adds a `colors` array, with a linear RGBA color for each row, white at first. The color multiplies the material's base color and opacity, as a mesh's vertex colors do. So a white material shows each row's color, and a row's alpha below a masked material's cutoff hides the row. Convert an sRGB color, such as a hex string, with the color helpers in [Math helpers](../api/math.md).
|
|
209
242
|
|
|
243
|
+

|
|
244
|
+
|
|
245
|
+
Row colors multiply the material's color.
|
|
246
|
+
|
|
210
247
|
```ts
|
|
211
248
|
import { color, defineSketch } from '@null3d/engine';
|
|
212
249
|
|
|
@@ -230,7 +267,7 @@ A static batch draws a new color after `markDirty`, as it draws a new position.
|
|
|
230
267
|
|
|
231
268
|
## Per-row values
|
|
232
269
|
|
|
233
|
-
`values: true` adds a `values` array, with four numbers for each row, 0 at first. A [custom material](../guides/custom-shaders.md) reads its row's numbers as `object.values`, a `vec4f`, in its `vertexOffset` and `surface` functions. Use them for whatever changes from row to row: a phase of the wind, an age, a tint or a size. Objects from `scene.createMesh`, and batches without values, read zeros.
|
|
270
|
+
`values: true` adds a `values` array, with four numbers for each row, 0 at first. A [custom material](../guides/custom-shaders.md) reads its row's numbers as `object.values`, a `vec4f`, in its `vertexOffset` and `surface` functions. Use them for whatever changes from row to row: a phase of the wind, an age, a tint or a size. Objects from `scene.createMesh`, and batches without values, read zeros. The [instancing demo](https://github.com/null3d-engine/null3d/tree/main/examples/instances) draws its hover cars with the traffic lanes add-on, whose batches use values and whose shader moves each car.
|
|
234
271
|
|
|
235
272
|
```ts
|
|
236
273
|
import { defineSketch } from '@null3d/engine';
|
|
@@ -271,13 +308,25 @@ Rows with colors or values draw with shader builds of their own, which a page do
|
|
|
271
308
|
|
|
272
309
|
### A row's place and its batch's id
|
|
273
310
|
|
|
274
|
-
A custom material also reads each row's place in its batch as `input.instance`, from 0, in its `vertexOffset` and `surface` functions
|
|
311
|
+
A custom material also reads each row's place in its batch as `input.instance`, from 0, in its `vertexOffset` and `surface` functions. It needs no `values` array: a hue, a phase or a size that follows from the row's place costs the sketch nothing. Every row reads its batch's id as `object.id`, which is `batch.shaderId` in the sketch. [Built-in shader inputs](../shaders/builtins.md#object) describes both.
|
|
312
|
+
|
|
313
|
+
## Rows that arrive in chunks
|
|
314
|
+
|
|
315
|
+
An add-on can give the engine rows that arrive in pieces, such as the chunks of a Gaussian splat cloud. A chunk row writer stores each chunk in the engine's memory once. In each frame it then packs the rows that you choose into the batch, in the engine's core. So the sketch copies no rows and runs no loop over them.
|
|
316
|
+
|
|
317
|
+
1. `const writer = await batch.createChunkRows()` makes the writer. Its code loads on first use.
|
|
318
|
+
2. `writer.reserve(count)` makes room for `count` chunks. Call it again when the cloud gets more chunks.
|
|
319
|
+
3. `writer.write(slot, chunk)` stores one chunk when it arrives. Do not call it in a frame.
|
|
320
|
+
4. `writer.pack(counts)`, in each frame where the chosen rows change, takes one count for each slot. It writes the first `counts[slot]` rows of each chunk into the batch, in slot order, sets the batch's active count and returns that count.
|
|
321
|
+
5. `writer.destroy()` frees the chunks.
|
|
322
|
+
|
|
323
|
+
The batch must own its rows' transforms. A part of a model, or a sprite or line batch, takes no chunked rows.
|
|
275
324
|
|
|
276
325
|
## Related pages
|
|
277
326
|
|
|
278
327
|
- [Static and dynamic objects](static-dynamic.md): what each kind recomputes and uploads.
|
|
279
328
|
- [Handles and objects](handles.md): separate objects, and per-object data in your own arrays.
|
|
280
|
-
- [Scene](../api/scene.md): `createInstances
|
|
329
|
+
- [Scene](../api/scene.md): `createInstances`. [The API reference of instance batches](../api/reference/scene.md#instancebatch) lists every member of `InstanceBatch` and every option of `createInstances`.
|
|
281
330
|
- [Math helpers](../api/math.md): vectors, quaternions and colors for rows.
|
|
282
331
|
- [Sprites](../api/sprites.md): batches of quads that face the camera, with the same rows, marks and limits.
|
|
283
332
|
- [Points](../api/points.md): batches of squares of one size that face the camera, made of sprite rows.
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: concepts/large-worlds
|
|
3
3
|
title: Large worlds and precision
|
|
4
|
-
status: experimental
|
|
5
|
-
since: "0.2"
|
|
6
4
|
summary: "Cell-relative positions and per-frame camera-to-cell offsets; reversed depth; largeWorld mode; batch origins; floating-origin geometry."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# Large worlds and precision
|
|
10
8
|
|
|
11
|
-
> Roadmap step 0.2, 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
|
setters["Positions you set:<br/>JavaScript's 64-bit numbers"] -->|"largeWorld: true"| split["Whole cells and<br/>a small 32-bit rest"]
|
|
@@ -39,6 +35,10 @@ Lights, shadow cascades, raycasts, overlap queries, `screenToRay`, `worldToScree
|
|
|
39
35
|
|
|
40
36
|
Cells keep world matrices precise, but a position that you set is a 32-bit float by default. At the Earth's radius it moves in steps of 0.5 m before it reaches a cell. Start the engine with `largeWorld: true`, and the setters keep each position exact:
|
|
41
37
|
|
|
38
|
+

|
|
39
|
+
|
|
40
|
+
A road 6,378 km from the origin, in large-world mode.
|
|
41
|
+
|
|
42
42
|
```ts
|
|
43
43
|
// page.ts
|
|
44
44
|
const engine = await createEngine({ canvas, sketch, largeWorld: true });
|
|
@@ -94,9 +94,16 @@ Sprite, point and line batches take the same `origin` option. Batch origins work
|
|
|
94
94
|
|
|
95
95
|
A camera that moves far from the origin stays as smooth as one near it. Each frame, the engine computes the camera's offset to each cell in 64-bit numbers, so the offsets stay small and exact near the camera.
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
In large-world mode, a camera that flies past objects 1,000 km out or at the Earth's radius moves them on screen smoothly. It is as smooth as at the origin, on WebGPU, its compatibility mode and WebGL2. Without large-world mode, or when all 512 cells are in use ([Limits](#limits)), the same camera jitters. Positions then move in the coarse steps given at the top of this page.
|
|
98
|
+
|
|
99
|
+
<details>
|
|
100
|
+
<summary>Technical details: how the engine tests a moving camera</summary>
|
|
101
|
+
|
|
102
|
+
A test flies a camera sideways past six squares, 4 m to 35 m away, 12 cm per frame for 16 frames. It flies at the origin, 1,000 km out and at the Earth's radius, in large-world mode. Each square's image moves from frame to frame as it does at the origin, within 0.0001 pixels.
|
|
103
|
+
|
|
104
|
+
The same flight without large-world mode jitters. The camera's position moves in steps of about 6 cm at 1,000 km and 0.5 m at the Earth's radius. So the squares jump by up to 3.5 pixels at 1,000 km and 7.8 pixels at the Earth's radius.
|
|
98
105
|
|
|
99
|
-
|
|
106
|
+
</details>
|
|
100
107
|
|
|
101
108
|
## Floating-origin geometry
|
|
102
109
|
|
|
@@ -108,13 +115,15 @@ Shaders work the same way. The surface input's `relativePosition` is relative to
|
|
|
108
115
|
|
|
109
116
|
The engine draws reversed depth in a 32-bit float buffer on every GPU path. The far plane stores 0, where floating-point numbers are most precise. So far surfaces stay apart over long view distances, which large scenes need. On WebGL2 without the `EXT_clip_control` extension, reversed depth keeps WebGL2's range from -1 to 1, which is less precise. [Depth on each tier](backends.md#depth-on-each-tier) gives the distances, and `engine.capabilities.depth` says which depth the device draws.
|
|
110
117
|
|
|
111
|
-
|
|
118
|
+
The engine does not use logarithmic depth, which writes depth from the fragment shader and so turns off the GPU's early depth test.
|
|
112
119
|
|
|
113
120
|
## Limits
|
|
114
121
|
|
|
115
122
|
- At most 512 cells are in use at once, the origin's cell included. A cell is in use while an object or a row lies in it, and frees when the last one leaves. When all 512 are in use, an object or a row that enters a new cell goes into the origin's cell instead. There it has the precision of a 32-bit position. The engine then warns once in the console, as such content jitters far from the origin.
|
|
116
|
-
- Dense content fills the most objects and rows that a scene can draw before it fills the cells. A city of 20,000 objects per square kilometer reaches that most at about
|
|
123
|
+
- Dense content fills the most objects and rows that a scene can draw before it fills the cells. A city of 20,000 objects per square kilometer reaches that most at about 105 km² of flat ground. That needs a device with WebGPU's default limits, and it takes about 100 cells. On a device that allows the most, it reaches the limit at about 420 km², or about 400 cells. The property `engine.capabilities.maxInstances` gives the number for the device ([The portable budget](backends.md#the-portable-budget)).
|
|
124
|
+
- Content spread thin can reach it, such as one marker in each of 1,000 towns. Keep such content in fewer cells. Put far objects under a few parent objects, as children share their root's cell. Or create and destroy them as the camera moves.
|
|
117
125
|
- In large-world mode, positions reach about 2 × 10¹² m from the origin, the most whole cells that a 32-bit integer counts.
|
|
126
|
+
- `getWorldPosition` and `getWorldMatrix` return 64-bit positions, so pass a plain array or a `Float64Array`.
|
|
118
127
|
|
|
119
128
|
## Related pages
|
|
120
129
|
|
|
@@ -124,3 +133,4 @@ three.js offers logarithmic depth for large scenes. It writes depth from the fra
|
|
|
124
133
|
- [Engine](../api/engine.md): the `largeWorld` option of `createEngine`.
|
|
125
134
|
- [GPU tiers and backends](backends.md#depth-on-each-tier): depth on each tier.
|
|
126
135
|
- [The large world demo](https://github.com/null3d-engine/null3d/tree/main/examples/large-world): a drive along a road on the Earth's surface, in large-world mode with batch origins.
|
|
136
|
+
- [No `largeWorld` flag](https://github.com/null3d-engine/null3d/tree/main/examples/far-from-origin): 2 cm keys and a brass wheel, 1,000 km from the origin, seen from 40 cm.
|