@null3d/engine 0.0.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +109 -0
- package/THIRD-PARTY-NOTICES.txt +0 -1
- package/dist/wasm/single/null3d.js +25 -10
- package/dist/wasm/single/null3d_bg.wasm +0 -0
- package/dist/wasm/threaded/null3d.js +25 -10
- package/dist/wasm/threaded/null3d_bg.wasm +0 -0
- package/docs/api/animation.md +114 -86
- package/docs/api/assets.md +135 -49
- package/docs/api/cameras.md +45 -12
- package/docs/api/controls.md +88 -62
- package/docs/api/debug.md +116 -41
- package/docs/api/engine.md +117 -35
- package/docs/api/feature-draws.md +23 -17
- package/docs/api/feature-effects.md +11 -11
- package/docs/api/feature-instances.md +70 -19
- package/docs/api/features.md +77 -47
- package/docs/api/geometry.md +132 -82
- package/docs/api/grass.md +55 -13
- package/docs/api/impostors.md +175 -22
- package/docs/api/input.md +24 -18
- package/docs/api/lights.md +78 -51
- package/docs/api/lines.md +41 -33
- package/docs/api/materials.md +248 -121
- package/docs/api/math.md +12 -13
- package/docs/api/objects.md +47 -22
- package/docs/api/page.md +58 -7
- package/docs/api/particles.md +33 -20
- package/docs/api/points.md +19 -31
- package/docs/api/post.md +75 -42
- package/docs/api/quality.md +42 -17
- package/docs/api/raycast.md +65 -51
- package/docs/api/reference/animation.md +10 -11
- package/docs/api/reference/assets.md +25 -22
- package/docs/api/reference/cameras.md +8 -4
- package/docs/api/reference/controls.md +134 -25
- package/docs/api/reference/debug.md +81 -14
- package/docs/api/reference/engine.md +58 -17
- package/docs/api/reference/feature-draws.md +3 -4
- package/docs/api/reference/feature-effects.md +2 -3
- package/docs/api/reference/feature-instances.md +5 -4
- package/docs/api/reference/features.md +7 -4
- package/docs/api/reference/geometry.md +287 -97
- package/docs/api/reference/grass.md +63 -3
- package/docs/api/reference/impostors.md +208 -13
- package/docs/api/reference/input.md +4 -5
- package/docs/api/reference/lights.md +13 -12
- package/docs/api/reference/lines.md +10 -11
- package/docs/api/reference/materials.md +54 -53
- package/docs/api/reference/math.md +35 -24
- package/docs/api/reference/objects.md +11 -12
- package/docs/api/reference/particles.md +31 -6
- package/docs/api/reference/points.md +6 -7
- package/docs/api/reference/post.md +21 -20
- package/docs/api/reference/quality.md +8 -5
- package/docs/api/reference/raycast.md +7 -8
- package/docs/api/reference/render.md +5 -4
- package/docs/api/reference/scene.md +52 -30
- package/docs/api/reference/sketch.md +15 -11
- package/docs/api/reference/sound.md +234 -0
- package/docs/api/reference/splats.md +42 -3
- package/docs/api/reference/sprites.md +7 -8
- package/docs/api/reference/tasks.md +16 -3
- package/docs/api/reference/terrain.md +27 -5
- package/docs/api/reference/textures.md +5 -6
- package/docs/api/reference/three-compat.md +18 -7
- package/docs/api/reference/time.md +1 -2
- package/docs/api/reference/ui.md +12 -9
- package/docs/api/reference/vertex-draws.md +5 -6
- package/docs/api/reference/water.md +153 -9
- package/docs/api/reference/wind.md +17 -4
- package/docs/api/render.md +73 -29
- package/docs/api/scene.md +164 -60
- package/docs/api/sketch.md +102 -15
- package/docs/api/sound.md +205 -0
- package/docs/api/splats.md +46 -12
- package/docs/api/sprites.md +10 -24
- package/docs/api/tasks.md +33 -24
- package/docs/api/terrain.md +42 -22
- package/docs/api/textures.md +68 -19
- package/docs/api/three-compat.md +15 -7
- package/docs/api/time.md +3 -5
- package/docs/api/ui.md +19 -23
- package/docs/api/vertex-draws.md +13 -12
- package/docs/api/water.md +262 -35
- package/docs/api/wind.md +63 -17
- package/docs/cli/null3d.md +177 -27
- package/docs/concepts/architecture.md +73 -27
- package/docs/concepts/assets.md +57 -33
- package/docs/concepts/backends.md +69 -27
- package/docs/concepts/color-management.md +54 -36
- package/docs/concepts/culling.md +68 -47
- package/docs/concepts/handles.md +14 -5
- package/docs/concepts/instances.md +74 -25
- package/docs/concepts/large-worlds.md +18 -8
- package/docs/concepts/lighting.md +155 -87
- package/docs/concepts/lod.md +126 -44
- package/docs/concepts/materials.md +58 -27
- package/docs/concepts/particle-buffer.md +48 -35
- package/docs/concepts/post-processing.md +84 -43
- package/docs/concepts/quality-preset-tables.md +56 -52
- package/docs/concepts/quality-presets.md +164 -52
- package/docs/concepts/render-graph.md +69 -29
- package/docs/concepts/render-layers.md +11 -21
- package/docs/concepts/shadows.md +105 -52
- package/docs/concepts/static-dynamic.md +22 -7
- package/docs/cookbook/index.md +164 -120
- package/docs/data/threejs-mapping.json +362 -367
- package/docs/errors/E1101.md +23 -5
- package/docs/errors/E1102.md +11 -3
- package/docs/errors/E1103.md +11 -3
- package/docs/errors/E1104.md +11 -3
- package/docs/errors/E1105.md +13 -5
- package/docs/errors/E1106.md +11 -3
- package/docs/errors/E1107.md +15 -5
- package/docs/errors/E1108.md +11 -3
- package/docs/errors/E1109.md +32 -6
- package/docs/errors/E1110.md +23 -5
- package/docs/errors/E1111.md +11 -3
- package/docs/errors/E1112.md +11 -3
- package/docs/errors/E1203.md +12 -4
- package/docs/errors/E1204.md +11 -3
- package/docs/errors/E1205.md +11 -3
- package/docs/errors/E1206.md +28 -6
- package/docs/errors/E1207.md +11 -3
- package/docs/errors/E1208.md +12 -3
- package/docs/errors/E1209.md +11 -3
- package/docs/errors/E1213.md +27 -5
- package/docs/errors/E1214.md +14 -6
- package/docs/errors/E1215.md +31 -6
- package/docs/errors/E1216.md +31 -6
- package/docs/errors/E1217.md +29 -6
- package/docs/errors/E1218.md +22 -6
- package/docs/errors/E1219.md +11 -3
- package/docs/errors/E1220.md +24 -5
- package/docs/errors/E1221.md +24 -5
- package/docs/errors/E1222.md +11 -3
- package/docs/errors/E1223.md +39 -6
- package/docs/errors/E1224.md +11 -3
- package/docs/errors/E1225.md +11 -3
- package/docs/errors/E1301.md +11 -3
- package/docs/errors/E1302.md +11 -3
- package/docs/errors/E1303.md +11 -3
- package/docs/errors/E1304.md +11 -3
- package/docs/errors/E1305.md +13 -3
- package/docs/errors/E1306.md +11 -3
- package/docs/errors/E1307.md +40 -0
- package/docs/errors/E1401.md +11 -3
- package/docs/errors/E1402.md +13 -5
- package/docs/errors/E1403.md +11 -3
- package/docs/errors/E1404.md +13 -3
- package/docs/errors/E1405.md +15 -4
- package/docs/errors/E1406.md +31 -5
- package/docs/errors/E1407.md +11 -3
- package/docs/errors/E1408.md +11 -3
- package/docs/errors/E1409.md +11 -3
- package/docs/errors/E1410.md +13 -5
- package/docs/errors/E1411.md +11 -3
- package/docs/errors/E1412.md +29 -6
- package/docs/errors/E1413.md +11 -3
- package/docs/errors/E1414.md +11 -3
- package/docs/errors/E1415.md +11 -3
- package/docs/errors/E1416.md +27 -6
- package/docs/errors/E1417.md +11 -3
- package/docs/errors/E1418.md +12 -3
- package/docs/errors/E1419.md +13 -5
- package/docs/errors/E1420.md +14 -6
- package/docs/errors/E1421.md +11 -3
- package/docs/errors/E1422.md +12 -3
- package/docs/errors/E1423.md +12 -3
- package/docs/errors/E1424.md +24 -5
- package/docs/errors/E1425.md +11 -3
- package/docs/errors/E1426.md +11 -3
- package/docs/errors/E1430.md +11 -3
- package/docs/errors/E1431.md +11 -3
- package/docs/errors/E1432.md +11 -3
- package/docs/errors/E1433.md +11 -3
- package/docs/errors/E1434.md +15 -6
- package/docs/errors/E1435.md +11 -3
- package/docs/errors/E1436.md +11 -3
- package/docs/errors/E1437.md +14 -6
- package/docs/errors/E1501.md +41 -6
- package/docs/errors/E1502.md +13 -3
- package/docs/errors/E1503.md +11 -3
- package/docs/errors/E1504.md +11 -3
- package/docs/errors/E1505.md +23 -5
- package/docs/errors/E1506.md +11 -3
- package/docs/errors/index.md +54 -30
- package/docs/getting-started/cdn.md +32 -10
- package/docs/getting-started/first-scene.md +21 -13
- package/docs/getting-started/hosting.md +152 -63
- package/docs/getting-started/install.md +44 -28
- package/docs/getting-started/network-use.md +33 -15
- package/docs/getting-started/project-structure.md +33 -12
- package/docs/getting-started/third-party-notices.md +12 -14
- package/docs/guides/accessibility.md +5 -5
- package/docs/guides/add-ons.md +86 -15
- package/docs/guides/agents.md +16 -9
- package/docs/guides/assets-pipeline.md +259 -82
- package/docs/guides/audio.md +115 -128
- package/docs/guides/baked-light-data.md +44 -23
- package/docs/guides/car-paint.md +38 -32
- package/docs/guides/content-pages.md +63 -35
- package/docs/guides/custom-passes.md +65 -22
- package/docs/guides/custom-shaders.md +59 -39
- package/docs/guides/debugging.md +74 -10
- package/docs/guides/deploying.md +85 -6
- package/docs/guides/deterministic-simulation.md +24 -17
- package/docs/guides/first-use-shaders.md +83 -45
- package/docs/guides/lens-kit.md +29 -26
- package/docs/guides/loading-screens.md +132 -47
- package/docs/guides/multiple-views.md +63 -13
- package/docs/guides/performance.md +192 -38
- package/docs/guides/phones.md +78 -15
- package/docs/guides/physics.md +7 -11
- package/docs/guides/screens.md +47 -33
- package/docs/guides/start-time.md +363 -0
- package/docs/guides/testing.md +152 -95
- package/docs/guides/ui-overlays.md +19 -14
- package/docs/guides/video-textures.md +14 -13
- package/docs/images/api/animation/character.webp +0 -0
- package/docs/images/api/animation/look-at-ring.webp +0 -0
- package/docs/images/api/animation/morph-tulips.webp +0 -0
- package/docs/images/api/animation/skeleton-lines.webp +0 -0
- package/docs/images/api/controls/gizmo-handles.webp +0 -0
- package/docs/images/api/controls/walk-and-fly.webp +0 -0
- package/docs/images/api/debug/debug-shapes.webp +0 -0
- package/docs/images/api/debug/levels-view.webp +0 -0
- package/docs/images/api/engine/transparent-canvas.webp +0 -0
- package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
- package/docs/images/api/feature-instances/compute-instances.webp +0 -0
- package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
- package/docs/images/api/geometry/extra-shapes.webp +0 -0
- package/docs/images/api/geometry/generators.webp +0 -0
- package/docs/images/api/geometry/mesh-arrays.webp +0 -0
- package/docs/images/api/geometry/vertex-updates.webp +0 -0
- package/docs/images/api/grass/grass-grove.webp +0 -0
- package/docs/images/api/grass/grass-presets.webp +0 -0
- package/docs/images/api/grass/grass-shadow.webp +0 -0
- package/docs/images/api/impostors/impostor-handover.webp +0 -0
- package/docs/images/api/impostors/impostor-shadow.webp +0 -0
- package/docs/images/api/impostors/impostors-forest.webp +0 -0
- package/docs/images/api/lights/spot-cookies.webp +0 -0
- package/docs/images/api/lines/lines-lit.webp +0 -0
- package/docs/images/api/lines/lines-widths.webp +0 -0
- package/docs/images/api/materials/coat-and-sheen.webp +0 -0
- package/docs/images/api/materials/decals.webp +0 -0
- package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
- package/docs/images/api/materials/relief.webp +0 -0
- package/docs/images/api/materials/shader-inputs.webp +0 -0
- package/docs/images/api/materials/standard-grid.webp +0 -0
- package/docs/images/api/materials/subsurface.webp +0 -0
- package/docs/images/api/materials/translucency.webp +0 -0
- package/docs/images/api/objects/objects-turntable.webp +0 -0
- package/docs/images/api/particles/campfire.webp +0 -0
- package/docs/images/api/points/galaxy.webp +0 -0
- package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
- package/docs/images/api/render/fullscreen-glow.webp +0 -0
- package/docs/images/api/render/reflection-mirror.webp +0 -0
- package/docs/images/api/render/security-camera.webp +0 -0
- package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
- package/docs/images/api/sound/sound-demo.webp +0 -0
- package/docs/images/api/splats/splats-demo.webp +0 -0
- package/docs/images/api/sprites/sprites-lines.webp +0 -0
- package/docs/images/api/terrain/terrain-demo.webp +0 -0
- package/docs/images/api/textures/canvas-screen.webp +0 -0
- package/docs/images/api/textures/mipmaps.webp +0 -0
- package/docs/images/api/vertex-draws/rain.webp +0 -0
- package/docs/images/api/water/ocean.webp +0 -0
- package/docs/images/api/water/water-demo.webp +0 -0
- package/docs/images/api/water/water-rain.webp +0 -0
- package/docs/images/api/water/waterfall.webp +0 -0
- package/docs/images/concepts/assets/gltf-model.webp +0 -0
- package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
- package/docs/images/concepts/culling/far-from-origin.webp +0 -0
- package/docs/images/concepts/instances/instances.webp +0 -0
- package/docs/images/concepts/instances/per-row-colors.webp +0 -0
- package/docs/images/concepts/large-worlds/large-world.webp +0 -0
- package/docs/images/concepts/lighting/area-lights.webp +0 -0
- package/docs/images/concepts/lighting/atmosphere.webp +0 -0
- package/docs/images/concepts/lighting/environment.webp +0 -0
- package/docs/images/concepts/lighting/light-shafts.webp +0 -0
- package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
- package/docs/images/concepts/lod/forest.webp +0 -0
- package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
- package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
- package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
- package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
- package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
- package/docs/images/concepts/post-processing/sharpen.webp +0 -0
- package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
- package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
- package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
- package/docs/images/cookbook/index/picking.webp +0 -0
- package/docs/images/cookbook/index/time-of-day.webp +0 -0
- package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
- package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
- package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
- package/docs/images/guides/multiple-views/split-screen.webp +0 -0
- package/docs/images/guides/performance/overdraw-view.webp +0 -0
- package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
- package/docs/images/index/showcase-island.webp +0 -0
- package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
- package/docs/images/shaders/builtins/builtins.webp +0 -0
- package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
- package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
- package/docs/images/shots.json +2231 -0
- package/docs/index.md +18 -23
- package/docs/moves.json +1 -0
- package/docs/nav.json +300 -0
- package/docs/pages.md +230 -209
- package/docs/porting/react-three-fiber.md +225 -6
- package/docs/porting/threejs-loop-and-threads.md +217 -7
- package/docs/porting/threejs-mapping.md +1249 -233
- package/docs/porting/threejs-materials.md +218 -6
- package/docs/porting/threejs-overview.md +240 -7
- package/docs/porting/threejs-postprocessing.md +4 -8
- package/docs/porting/threejs-shaders.md +301 -6
- package/docs/porting/threejs-unsupported.md +83 -7
- package/docs/porting/verification.md +178 -6
- package/docs/shaders/builtins.md +15 -4
- package/docs/shaders/library.md +72 -45
- package/docs/shaders/surface-functions.md +59 -23
- package/docs/shaders/wgsl-rules.md +12 -5
- package/lib/debug/channel.d.ts +103 -0
- package/lib/debug/channel.js +269 -0
- package/lib/debug/debug.d.ts +11 -9
- package/lib/debug/draw.d.ts +11 -2
- package/lib/debug/draw.js +57 -6
- package/lib/debug/inspector.d.ts +60 -0
- package/lib/debug/inspector.js +475 -0
- package/lib/debug/overlay-look.d.ts +6 -0
- package/lib/debug/overlay-look.js +29 -7
- package/lib/debug/overlay.js +15 -11
- package/lib/debug/stats-options.d.ts +13 -0
- package/lib/debug/stats-panel.d.ts +22 -7
- package/lib/debug/stats-panel.js +80 -13
- package/lib/debug/stats.d.ts +2 -3
- package/lib/errors/codes.d.ts +17 -3
- package/lib/errors/codes.js +117 -105
- package/lib/errors/engine-error.js +25 -10
- package/lib/errors/fixes.d.ts +1 -0
- package/lib/errors/fixes.js +20 -19
- package/lib/generated/core.d.ts +1 -1
- package/lib/generated/core.js +1 -1
- package/lib/gpu/early-builds.d.ts +68 -0
- package/lib/gpu/early-builds.js +158 -0
- package/lib/gpu/pipeline-name.d.ts +6 -0
- package/lib/gpu/pipeline-name.js +23 -0
- package/lib/gpu/variants.d.ts +8 -2
- package/lib/gpu/variants.js +39 -7
- package/lib/gpu/webgl2/backend.d.ts +63 -2
- package/lib/gpu/webgl2/backend.js +226 -8
- package/lib/gpu/webgl2/programs.d.ts +18 -0
- package/lib/gpu/webgl2/programs.js +5 -2
- package/lib/gpu/webgpu/backend.d.ts +89 -2
- package/lib/gpu/webgpu/backend.js +255 -8
- package/lib/gpu/webgpu/pipelines.d.ts +13 -0
- package/lib/gpu/webgpu/pipelines.js +28 -14
- package/lib/index.d.ts +7 -5
- package/lib/index.js +3 -2
- package/lib/math/color.d.ts +5 -5
- package/lib/math/color.js +5 -5
- package/lib/math/mat4.d.ts +6 -12
- package/lib/math/mat4.js +6 -12
- package/lib/math/namespaces/quat.d.ts +3 -3
- package/lib/math/namespaces/quat.js +3 -3
- package/lib/math/quat.d.ts +8 -12
- package/lib/math/quat.js +8 -12
- package/lib/math/random.d.ts +2 -3
- package/lib/math/random.js +2 -3
- package/lib/math/types.d.ts +4 -4
- package/lib/math/vec3.d.ts +3 -6
- package/lib/math/vec3.js +3 -6
- package/lib/page/capabilities.d.ts +8 -8
- package/lib/page/capabilities.js +39 -25
- package/lib/page/check-store.d.ts +14 -2
- package/lib/page/check-store.js +34 -11
- package/lib/page/engine.d.ts +117 -31
- package/lib/page/engine.js +438 -99
- package/lib/page/first-frame.d.ts +16 -0
- package/lib/page/first-frame.js +35 -0
- package/lib/page/frame-stats.d.ts +34 -1
- package/lib/page/frame-stats.js +15 -0
- package/lib/page/label-loop.d.ts +7 -3
- package/lib/page/label-loop.js +26 -14
- package/lib/page/labels.d.ts +3 -3
- package/lib/page/pipeline-store.d.ts +25 -0
- package/lib/page/pipeline-store.js +84 -0
- package/lib/page/start-marker.d.ts +4 -1
- package/lib/page/start-marker.js +5 -2
- package/lib/page/stats-switch.js +2 -0
- package/lib/page/switches.d.ts +38 -6
- package/lib/page/switches.js +29 -5
- package/lib/quality/check.d.ts +24 -3
- package/lib/quality/check.js +21 -7
- package/lib/quality/chooser.d.ts +6 -0
- package/lib/quality/chooser.js +8 -0
- package/lib/quality/governor.d.ts +98 -6
- package/lib/quality/governor.js +250 -20
- package/lib/quality/preset-docs.d.ts +16 -1
- package/lib/quality/preset-docs.js +3 -0
- package/lib/quality/presets.d.ts +84 -7
- package/lib/quality/presets.js +94 -2
- package/lib/render/draw.d.ts +3 -2
- package/lib/render/draw.js +15 -5
- package/lib/render/load-draw.d.ts +7 -5
- package/lib/render/load-draw.js +7 -5
- package/lib/render/loss.d.ts +28 -10
- package/lib/render/loss.js +50 -22
- package/lib/render/recovery.d.ts +20 -0
- package/lib/render/recovery.js +44 -4
- package/lib/render/renderer.d.ts +85 -9
- package/lib/render/renderer.js +181 -42
- package/lib/render/scene-renderer.d.ts +19 -1
- package/lib/render/scene-renderer.js +25 -1
- package/lib/render/webgl2-renderers.js +8 -5
- package/lib/render/webgpu-renderers.js +5 -4
- package/lib/scene/animation.d.ts +28 -32
- package/lib/scene/animation.js +12 -15
- package/lib/scene/assets.d.ts +61 -86
- package/lib/scene/assets.js +103 -236
- package/lib/scene/background.d.ts +14 -18
- package/lib/scene/background.js +5 -2
- package/lib/scene/baked-light.d.ts +2 -2
- package/lib/scene/color.d.ts +3 -3
- package/lib/scene/downloads.d.ts +2 -0
- package/lib/scene/downloads.js +371 -0
- package/lib/scene/environment.d.ts +7 -7
- package/lib/scene/environment.js +1 -1
- package/lib/scene/fake-call-values.js +3 -3
- package/lib/scene/fog.d.ts +11 -4
- package/lib/scene/fog.js +8 -2
- package/lib/scene/frame-cameras.d.ts +35 -4
- package/lib/scene/frame-cameras.js +86 -10
- package/lib/scene/gltf.d.ts +33 -3
- package/lib/scene/gltf.js +78 -49
- package/lib/scene/grading.d.ts +2 -2
- package/lib/scene/grading.js +3 -3
- package/lib/scene/ktx2.d.ts +9 -1
- package/lib/scene/ktx2.js +3 -2
- package/lib/scene/level-rule.d.ts +121 -0
- package/lib/scene/level-rule.js +130 -0
- package/lib/scene/lines.d.ts +13 -17
- package/lib/scene/lines.js +3 -3
- package/lib/scene/lut.d.ts +1 -2
- package/lib/scene/lut.js +1 -2
- package/lib/scene/particles.d.ts +7 -3
- package/lib/scene/particles.js +3 -1
- package/lib/scene/picks.d.ts +2 -2
- package/lib/scene/pointer-events.d.ts +4 -7
- package/lib/scene/post.d.ts +39 -43
- package/lib/scene/post.js +4 -1
- package/lib/scene/prefab.d.ts +7 -8
- package/lib/scene/prefab.js +7 -8
- package/lib/scene/property-animation.d.ts +1 -1
- package/lib/scene/property-animation.js +1 -1
- package/lib/scene/queries.d.ts +7 -13
- package/lib/scene/resources.d.ts +238 -261
- package/lib/scene/resources.js +179 -81
- package/lib/scene/scene.d.ts +167 -120
- package/lib/scene/scene.js +243 -103
- package/lib/scene/serial-loads.d.ts +29 -0
- package/lib/scene/serial-loads.js +68 -0
- package/lib/scene/shader-preloads.d.ts +34 -0
- package/lib/scene/shader-preloads.js +38 -0
- package/lib/scene/sprites.d.ts +14 -17
- package/lib/scene/sprites.js +5 -6
- package/lib/scene/textures.d.ts +11 -12
- package/lib/scene/textures.js +9 -10
- package/lib/scene/time-of-day.d.ts +11 -7
- package/lib/scene/time-of-day.js +11 -8
- package/lib/scene/vertex-draws.d.ts +5 -4
- package/lib/scene/vertex-draws.js +7 -5
- package/lib/shader-artifact.json +1 -0
- package/lib/shared/core.d.ts +5 -0
- package/lib/shared/core.js +1 -0
- package/lib/shared/import-once.d.ts +6 -0
- package/lib/shared/import-once.js +19 -0
- package/lib/shared/labels.d.ts +5 -2
- package/lib/shared/labels.js +5 -2
- package/lib/shared/metrics.d.ts +38 -0
- package/lib/shared/metrics.js +62 -1
- package/lib/shared/permutation-words.d.ts +2 -0
- package/lib/shared/permutation-words.js +8 -0
- package/lib/shared/recording.d.ts +13 -5
- package/lib/shared/recording.js +31 -10
- package/lib/shared/run-task.js +7 -1
- package/lib/shared/sketch-data.d.ts +9 -0
- package/lib/shared/sketch-data.js +57 -0
- package/lib/shared/task-pending.d.ts +12 -0
- package/lib/shared/task-pending.js +61 -1
- package/lib/shared/tasks.js +79 -32
- package/lib/shared/version.d.ts +17 -1
- package/lib/shared/version.js +19 -1
- package/lib/shared/wasm.d.ts +12 -4
- package/lib/shared/wasm.js +50 -27
- package/lib/shared/worker-start.d.ts +7 -0
- package/lib/shared/worker-start.js +27 -0
- package/lib/sketch/define-sketch.d.ts +51 -7
- package/lib/sketch/define-sketch.js +2 -1
- package/lib/sketch/input.d.ts +2 -2
- package/lib/sketch/preset-check.d.ts +20 -6
- package/lib/sketch/preset-check.js +42 -17
- package/lib/sketch/quality.d.ts +69 -11
- package/lib/sketch/quality.js +54 -13
- package/lib/sketch/runner.d.ts +80 -9
- package/lib/sketch/runner.js +390 -52
- package/lib/sketch/ui.d.ts +5 -8
- package/lib/sketch/ui.js +4 -2
- package/lib/stats.d.ts +1 -0
- package/lib/workers/probe-worker.d.ts +5 -0
- package/lib/workers/probe-worker.js +13 -4
- package/lib/workers/protocol.d.ts +71 -13
- package/lib/workers/protocol.js +4 -0
- package/lib/workers/render-worker.js +29 -5
- package/lib/workers/sketch-worker.js +108 -16
- package/package.json +2 -2
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: api/reference/grass
|
|
3
3
|
title: "Grass (@null3d/grass): API reference"
|
|
4
|
-
|
|
5
|
-
since: "0.3"
|
|
4
|
+
generated: true
|
|
6
5
|
summary: "Every export of the Grass (@null3d/grass) API, from the engine's doc comments."
|
|
7
6
|
---
|
|
8
7
|
|
|
@@ -16,12 +15,23 @@ summary: "Every export of the Grass (@null3d/grass) API, from the engine's doc c
|
|
|
16
15
|
function createGrass(ctx: SketchContext, options: GrassOptions): Promise<Grass>
|
|
17
16
|
```
|
|
18
17
|
|
|
18
|
+
Import from `@null3d/grass`.
|
|
19
|
+
|
|
19
20
|
Makes the grass: one draw for each tuft shape, filled with the placed tufts, and the calls that draw a preset's share and give the blades the frame's air. A page awaits it in its setup.
|
|
20
21
|
|
|
22
|
+
| Parameter | Description |
|
|
23
|
+
| --- | --- |
|
|
24
|
+
| `ctx` | The sketch's context. |
|
|
25
|
+
| `options` | The ground, the area, the count and the seed. |
|
|
26
|
+
|
|
27
|
+
Returns: The grass's draws, ready to draw.
|
|
28
|
+
|
|
21
29
|
## `Grass`
|
|
22
30
|
|
|
23
31
|
Interface `Grass`.
|
|
24
32
|
|
|
33
|
+
Import from `@null3d/grass`.
|
|
34
|
+
|
|
25
35
|
The grass that `createGrass` made: the draws, and the calls that draw a preset's share and give them the frame's air.
|
|
26
36
|
|
|
27
37
|
| Member | Description |
|
|
@@ -36,6 +46,8 @@ The grass that `createGrass` made: the draws, and the calls that draw a preset's
|
|
|
36
46
|
|
|
37
47
|
Interface `GrassBladeShape`.
|
|
38
48
|
|
|
49
|
+
Import from `@null3d/grass`.
|
|
50
|
+
|
|
39
51
|
The shape of a cover's blades, which `createGrass` gives every blade in place of its own narrowing strip.
|
|
40
52
|
|
|
41
53
|
| Member | Description |
|
|
@@ -47,6 +59,8 @@ The shape of a cover's blades, which `createGrass` gives every blade in place of
|
|
|
47
59
|
|
|
48
60
|
Interface `GrassDraw`.
|
|
49
61
|
|
|
62
|
+
Import from `@null3d/grass`.
|
|
63
|
+
|
|
50
64
|
One shape's tufts: the rows that draw them and the draw that fills them.
|
|
51
65
|
|
|
52
66
|
| Member | Description |
|
|
@@ -58,6 +72,8 @@ One shape's tufts: the rows that draw them and the draw that fills them.
|
|
|
58
72
|
|
|
59
73
|
Interface `GrassMaterial`.
|
|
60
74
|
|
|
75
|
+
Import from `@null3d/grass`.
|
|
76
|
+
|
|
61
77
|
The part of a grass material that the grass itself sets.
|
|
62
78
|
|
|
63
79
|
| Member | Description |
|
|
@@ -68,6 +84,8 @@ The part of a grass material that the grass itself sets.
|
|
|
68
84
|
|
|
69
85
|
Interface `GrassOptions`.
|
|
70
86
|
|
|
87
|
+
Import from `@null3d/grass`.
|
|
88
|
+
|
|
71
89
|
What `createGrass` takes: the ground, the area, the count at the High preset, and the seed.
|
|
72
90
|
|
|
73
91
|
| Member | Description |
|
|
@@ -79,7 +97,7 @@ What `createGrass` takes: the ground, the area, the count at the High preset, an
|
|
|
79
97
|
| `readonly blades?: number` | The blades in each tuft. The default is 13. |
|
|
80
98
|
| `readonly segments?: number` | The segments of each blade. The default is 3. |
|
|
81
99
|
| `readonly shapes?: number` | The shapes of tuft, each one draw. The default is 1. |
|
|
82
|
-
| `readonly where?: (x: number, z: number) => boolean` | Says whether grass grows at a point, for ground that holds a road or a wall. Without
|
|
100
|
+
| `readonly where?: (x: number, z: number) => boolean` | Says whether grass grows at a point, as `mask` does, for ground that holds a road or a wall. A tuft grows only where both allow it. Without either, the slope alone decides. |
|
|
83
101
|
| `readonly color?: string` | The blades' color, which meets the ground's own at their roots. The default is a fresh green. |
|
|
84
102
|
| `readonly blade?: GrassBladeShape` | The shape that every blade takes: its width along its length and the fold of its keel. Give a plant's own blade with the plant's own color, so the cover reads as the same grass where the plant stands in it. Without it each blade narrows to a point from its root. |
|
|
85
103
|
| `readonly maxSlope?: number` | The steepest ground that a tuft grows on, as rise over run. The default is 0.6. |
|
|
@@ -96,22 +114,44 @@ What `createGrass` takes: the ground, the area, the count at the High preset, an
|
|
|
96
114
|
function hashAt(seed: number, a = 0, b = 0, c = 0, d = 0): number
|
|
97
115
|
```
|
|
98
116
|
|
|
117
|
+
Import from `@null3d/grass`.
|
|
118
|
+
|
|
99
119
|
The hash of a seed and up to four choice keys. The keys are mixed in order, so a choice names the thing, its part and the value it picks with a key of its own.
|
|
100
120
|
|
|
121
|
+
| Parameter | Description |
|
|
122
|
+
| --- | --- |
|
|
123
|
+
| `seed` | The seed. |
|
|
124
|
+
| `a` | The first key. |
|
|
125
|
+
| `b` | The second key. |
|
|
126
|
+
| `c` | The third key. |
|
|
127
|
+
| `d` | The fourth key. |
|
|
128
|
+
|
|
129
|
+
Returns: A 32-bit hash.
|
|
130
|
+
|
|
101
131
|
## `pcg`
|
|
102
132
|
|
|
103
133
|
```ts
|
|
104
134
|
function pcg(value: number): number
|
|
105
135
|
```
|
|
106
136
|
|
|
137
|
+
Import from `@null3d/grass`.
|
|
138
|
+
|
|
107
139
|
The permutation of one 32-bit value, with the same bits as the shaders' `pcg`.
|
|
108
140
|
|
|
141
|
+
| Parameter | Description |
|
|
142
|
+
| --- | --- |
|
|
143
|
+
| `value` | The value to hash. |
|
|
144
|
+
|
|
145
|
+
Returns: The hashed value.
|
|
146
|
+
|
|
109
147
|
## `PLANT_SWAY_DISTANCE`
|
|
110
148
|
|
|
111
149
|
```ts
|
|
112
150
|
const PLANT_SWAY_DISTANCE: Readonly<Record<QualityPreset, number>>
|
|
113
151
|
```
|
|
114
152
|
|
|
153
|
+
Import from `@null3d/grass`.
|
|
154
|
+
|
|
115
155
|
The distance from the camera out to which plants and grass sway, in meters, for each preset. A page reads it from the engine's preset, so a governor step that lowers the preset shortens the distance with it.
|
|
116
156
|
|
|
117
157
|
## `swayDistanceFor`
|
|
@@ -120,12 +160,32 @@ The distance from the camera out to which plants and grass sway, in meters, for
|
|
|
120
160
|
function swayDistanceFor(preset: QualityPreset): number
|
|
121
161
|
```
|
|
122
162
|
|
|
163
|
+
Import from `@null3d/grass`.
|
|
164
|
+
|
|
123
165
|
The distance from the camera out to which plants and grass sway at a preset, in meters. Pass it as `swayDistance` to `createGrass` and to a swaying plant's material, and again to `grass.setSwayDistance` when the preset changes.
|
|
124
166
|
|
|
167
|
+
| Parameter | Description |
|
|
168
|
+
| --- | --- |
|
|
169
|
+
| `preset` | The engine's quality preset. |
|
|
170
|
+
|
|
171
|
+
Returns: The distance that {@link PLANT_SWAY_DISTANCE} gives the preset.
|
|
172
|
+
|
|
125
173
|
## `unitAt`
|
|
126
174
|
|
|
127
175
|
```ts
|
|
128
176
|
function unitAt(seed: number, a = 0, b = 0, c = 0, d = 0): number
|
|
129
177
|
```
|
|
130
178
|
|
|
179
|
+
Import from `@null3d/grass`.
|
|
180
|
+
|
|
131
181
|
A choice between 0 and 1, from a seed and its keys. The top 24 bits of the hash make the value, so every device gets the same fraction.
|
|
182
|
+
|
|
183
|
+
| Parameter | Description |
|
|
184
|
+
| --- | --- |
|
|
185
|
+
| `seed` | The seed. |
|
|
186
|
+
| `a` | The first key. |
|
|
187
|
+
| `b` | The second key. |
|
|
188
|
+
| `c` | The third key. |
|
|
189
|
+
| `d` | The fourth key. |
|
|
190
|
+
|
|
191
|
+
Returns: A value in [0, 1).
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: api/reference/impostors
|
|
3
3
|
title: "Impostors (@null3d/impostors): API reference"
|
|
4
|
-
|
|
5
|
-
since: "0.2"
|
|
4
|
+
generated: true
|
|
6
5
|
summary: "Every export of the Impostors (@null3d/impostors) API, from the engine's doc comments."
|
|
7
6
|
---
|
|
8
7
|
|
|
@@ -16,7 +15,17 @@ summary: "Every export of the Impostors (@null3d/impostors) API, from the engine
|
|
|
16
15
|
function bakeImpostorAtlas(options: ImpostorBakeOptions): ImpostorBake
|
|
17
16
|
```
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
Import from `@null3d/impostors`.
|
|
19
|
+
|
|
20
|
+
Draws `parts` from every cell of `atlas` into the color and surface atlases, which it returns.
|
|
21
|
+
|
|
22
|
+
The bake is arithmetic over the arrays. It gives the same pixels on every device, so both GPU paths draw one card.
|
|
23
|
+
|
|
24
|
+
| Parameter | Description |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| `options` | The grid, the cells' size and the parts. |
|
|
27
|
+
|
|
28
|
+
Returns: The two atlases and the size of a card.
|
|
20
29
|
|
|
21
30
|
## `createImpostors`
|
|
22
31
|
|
|
@@ -24,7 +33,11 @@ Draws `parts` from every cell of `atlas` into the colour and surface atlases, wh
|
|
|
24
33
|
function createImpostors(ctx: ImpostorContext, options: ImpostorOptions): ImpostorBatch
|
|
25
34
|
```
|
|
26
35
|
|
|
27
|
-
|
|
36
|
+
Import from `@null3d/impostors`.
|
|
37
|
+
|
|
38
|
+
Makes a batch of impostor cards: one card per position, drawn from the three atlas views nearest the direction from the card toward the eye, and lit by the scene's lights. The cards need no `update` call: the material reads the eye from the frame's camera.
|
|
39
|
+
|
|
40
|
+
A card's turn, in `turn`, turns its views and its light by the same angle about the world's up, so a turned tree hands over to a card whose crown matches it. A batch that casts the sun's shadow cuts that shadow to the crown's shape, and a batch that receives shadows reads them at the surface that it shows.
|
|
28
41
|
|
|
29
42
|
## `decodeOctahedral`
|
|
30
43
|
|
|
@@ -32,6 +45,8 @@ Makes a batch of impostor cards: one card per position, drawn from the three atl
|
|
|
32
45
|
function decodeOctahedral(uv: OctahedralUv, out: [number, number, number] = [0, 0, 0]): Direction
|
|
33
46
|
```
|
|
34
47
|
|
|
48
|
+
Import from `@null3d/impostors`.
|
|
49
|
+
|
|
35
50
|
The unit direction that an octahedral coordinate pair names, the inverse of `encodeOctahedral`. Encoding the result gives the pair again, except on the square's outer edges, where the fold makes two points name one direction.
|
|
36
51
|
|
|
37
52
|
## `Direction`
|
|
@@ -40,6 +55,8 @@ The unit direction that an octahedral coordinate pair names, the inverse of `enc
|
|
|
40
55
|
type Direction = readonly [number, number, number];
|
|
41
56
|
```
|
|
42
57
|
|
|
58
|
+
Import from `@null3d/impostors`.
|
|
59
|
+
|
|
43
60
|
A direction, three numbers. It need not have length 1: this module makes it unit length.
|
|
44
61
|
|
|
45
62
|
## `EDGE_BAND`
|
|
@@ -48,6 +65,8 @@ A direction, three numbers. It need not have length 1: this module makes it unit
|
|
|
48
65
|
const EDGE_BAND: 0.08
|
|
49
66
|
```
|
|
50
67
|
|
|
68
|
+
Import from `@null3d/impostors`.
|
|
69
|
+
|
|
51
70
|
The share of a draw range's edge distance over which the engine dithers that edge. The dither's phase comes from each copy's own source. The mesh and the card are different sources, so their phases differ: a card that faded in while the mesh faded out would drop the pixels that both left out, and the background would show through the crown.
|
|
52
71
|
|
|
53
72
|
## `encodeImpostorSurface`
|
|
@@ -56,6 +75,8 @@ The share of a draw range's edge distance over which the engine dithers that edg
|
|
|
56
75
|
function encodeImpostorSurface(normal: Direction, depth: number, coverage = 1, out: Uint8Array = new Uint8Array(4)): Uint8Array
|
|
57
76
|
```
|
|
58
77
|
|
|
78
|
+
Import from `@null3d/impostors`.
|
|
79
|
+
|
|
59
80
|
Writes the surface atlas's texel for a point of a view: the normal in the view's space, where x and y lie across and up the picture and z points at the viewer, the point's depth from the view's front, 0, to its back, 1, and its coverage. `out` takes the four bytes, and is returned, so a bake writes one buffer without allocating.
|
|
60
81
|
|
|
61
82
|
## `encodeOctahedral`
|
|
@@ -64,6 +85,8 @@ Writes the surface atlas's texel for a point of a view: the normal in the view's
|
|
|
64
85
|
function encodeOctahedral(direction: Direction, out: OctahedralUv = [0, 0]): OctahedralUv
|
|
65
86
|
```
|
|
66
87
|
|
|
88
|
+
Import from `@null3d/impostors`.
|
|
89
|
+
|
|
67
90
|
Folds a direction onto the octahedron's two coordinates, each from -1 to 1. The front half of the sphere, z from 0 up, fills the square's middle diamond, and the back half fills its four corners, so a grid of cells covers the whole sphere. The back pole, (0, 0, -1), lands on the corner (1, 1).
|
|
68
91
|
|
|
69
92
|
## `farCellGroups`
|
|
@@ -72,12 +95,16 @@ Folds a direction onto the octahedron's two coordinates, each from -1 to 1. The
|
|
|
72
95
|
function farCellGroups(centers: readonly (readonly [number, number, number])[], cellSize: number): number[][]
|
|
73
96
|
```
|
|
74
97
|
|
|
98
|
+
Import from `@null3d/impostors`.
|
|
99
|
+
|
|
75
100
|
Groups copies by the grid cell of their centers: the cell a center falls in is its position divided by `cellSize` and rounded down, along each axis. Merge each group into one mesh, so a large world draws a few meshes instead of one per copy. Centers that share a cell, in the order they were given, come back as one list.
|
|
76
101
|
|
|
77
102
|
## `FarPart`
|
|
78
103
|
|
|
79
104
|
Interface `FarPart`.
|
|
80
105
|
|
|
106
|
+
Import from `@null3d/impostors`.
|
|
107
|
+
|
|
81
108
|
One copy of a mesh in a merge: its arrays, and the transform that places it. The transform is a column-major 4 by 4 matrix, as `mat4` writes; without one the copy stays where its arrays are.
|
|
82
109
|
|
|
83
110
|
| Member | Description |
|
|
@@ -91,26 +118,123 @@ One copy of a mesh in a merge: its arrays, and the transform that places it. The
|
|
|
91
118
|
function frameDirection(frame: number, atlas: OctahedralAtlas, out: [number, number, number] = [0, 0, 0]): Direction
|
|
92
119
|
```
|
|
93
120
|
|
|
121
|
+
Import from `@null3d/impostors`.
|
|
122
|
+
|
|
94
123
|
The direction that the view of a cell was drawn from: the center of the octahedron's cell, as a unit direction. `impostorFrame` of the result gives `frame` again.
|
|
95
124
|
|
|
125
|
+
## `HAND_OVER_GROUPS`
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
const HAND_OVER_GROUPS: 4
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Import from `@null3d/impostors`.
|
|
132
|
+
|
|
133
|
+
The groups that a plant's trees hand over in, and how far either side of the plant's switch distance the groups' switches spread, as a share of it. The groups are what keeps one frame from taking every tree's mesh at once: a tree's own swap is as it was, but the trees around it swap a little before or after it, so a view loses one group's cards a frame instead of all of them.
|
|
134
|
+
|
|
135
|
+
## `HAND_OVER_SPREAD`
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
const HAND_OVER_SPREAD: 0.06
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Import from `@null3d/impostors`.
|
|
142
|
+
|
|
143
|
+
The share of the hand-over distance that the groups' switches spread either side of it, so the first group swaps a little early and the last a little late and the change is spread over a short stretch of travel rather than landing in one frame.
|
|
144
|
+
|
|
145
|
+
## `handOverCards`
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
function handOverCards(cards: InstanceBatch, earliestSwitch: number): void
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Import from `@null3d/impostors`.
|
|
152
|
+
|
|
153
|
+
Starts a batch of cards early enough that they stand at full coverage before the earliest mesh group that hands over to them begins to thin. Write the cards' turns and sizes before this call.
|
|
154
|
+
|
|
155
|
+
## `handOverMeshes`
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
function handOverMeshes(meshes: InstanceBatch, switchDistance: number, start = 0): void
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Import from `@null3d/impostors`.
|
|
162
|
+
|
|
163
|
+
Draws a group of near meshes from `start` up to its switch distance, where the engine dithers the range's far edge out.
|
|
164
|
+
|
|
165
|
+
## `handOverSwitches`
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
function handOverSwitches(switchDistance: number, count = HAND_OVER_GROUPS, spread = HAND_OVER_SPREAD): number[]
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Import from `@null3d/impostors`.
|
|
172
|
+
|
|
173
|
+
The switch distances of `count` groups, spread evenly either side of `switchDistance`: the first group hands over earliest and the last latest, and their mean is the switch distance itself. A group draws its meshes up to its own distance, so a camera crossing the plant's hand-over meets one group's switch after another.
|
|
174
|
+
|
|
96
175
|
## `handOverToCards`
|
|
97
176
|
|
|
98
177
|
```ts
|
|
99
178
|
function handOverToCards(meshes: InstanceBatch, cards: InstanceBatch, switchDistance: number, start = 0): void
|
|
100
179
|
```
|
|
101
180
|
|
|
102
|
-
|
|
181
|
+
Import from `@null3d/impostors`.
|
|
182
|
+
|
|
183
|
+
Hands one group of near meshes over to its far cards. The meshes draw up to `switchDistance`, and the cards start early enough that their own dithered edge ends before the meshes' edge begins to thin. So each pixel that a mesh drops shows its card at full coverage, and the background never shows through. Write the cards' turns and sizes before this call, and call it at setup.
|
|
184
|
+
|
|
185
|
+
A plant that hands over in groups calls `handOverCards` once with the earliest group's switch, so the cards stand behind every group, and `handOverMeshes` once for each group's own distance.
|
|
186
|
+
|
|
187
|
+
| Parameter | Description |
|
|
188
|
+
| --- | --- |
|
|
189
|
+
| `meshes` | The batch of near meshes, whose rows stand at the same places as the cards' rows. |
|
|
190
|
+
| `cards` | The card batch, such as `ImpostorBatch.batch`. |
|
|
191
|
+
| `switchDistance` | The distance from the camera at which these trees hand over, in meters. |
|
|
192
|
+
| `start` | The distance from which the meshes draw, in meters: 0 for a batch that draws from the camera out, or the start of a coarser level's own band. |
|
|
193
|
+
|
|
194
|
+
## `IMPOSTOR_FILE_FORMAT`
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
const IMPOSTOR_FILE_FORMAT: 'null3d-impostor'
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Import from `@null3d/impostors`.
|
|
201
|
+
|
|
202
|
+
The `format` field of an impostor atlas file.
|
|
203
|
+
|
|
204
|
+
## `ImpostorAtlasFile`
|
|
205
|
+
|
|
206
|
+
Interface `ImpostorAtlasFile`.
|
|
207
|
+
|
|
208
|
+
Import from `@null3d/impostors`.
|
|
209
|
+
|
|
210
|
+
What an impostor atlas file holds: the bake's grid and figures, and the names of its two images.
|
|
211
|
+
|
|
212
|
+
| Member | Description |
|
|
213
|
+
| --- | --- |
|
|
214
|
+
| `readonly format: typeof IMPOSTOR_FILE_FORMAT` | Always `"null3d-impostor"`. |
|
|
215
|
+
| `readonly version: number` | The format's version: 1. |
|
|
216
|
+
| `readonly atlas: OctahedralAtlas` | The cells across and down. |
|
|
217
|
+
| `readonly texels: number` | The texels on each side of a cell. |
|
|
218
|
+
| `readonly color: string` | The color atlas's PNG file, next to this file: sRGB color, with the coverage in alpha. |
|
|
219
|
+
| `readonly surface: string` | The surface atlas's PNG file, next to this file: linear normals, depth and coverage. |
|
|
220
|
+
| `readonly size: readonly [number, number]` | The card's width and height at scale 1, as the bake's `size`. |
|
|
221
|
+
| `readonly room: number` | How much taller a view's picture is than the card's height, as the bake's `room`. |
|
|
222
|
+
| `readonly depth: number` | The object's depth along a view, in world units, as the bake's `depth`. |
|
|
223
|
+
| `readonly min: readonly [number, number, number]` | The object's bounds in its own frame: the smallest corner. |
|
|
224
|
+
| `readonly max: readonly [number, number, number]` | The object's bounds in its own frame: the largest corner. |
|
|
103
225
|
|
|
104
226
|
## `ImpostorBake`
|
|
105
227
|
|
|
106
228
|
Interface `ImpostorBake`.
|
|
107
229
|
|
|
108
|
-
|
|
230
|
+
Import from `@null3d/impostors`.
|
|
231
|
+
|
|
232
|
+
The two atlases that a bake writes: the color in sRGB, with the coverage in alpha, and the surface in linear color, as `createImpostors` takes them.
|
|
109
233
|
|
|
110
234
|
| Member | Description |
|
|
111
235
|
| --- | --- |
|
|
112
236
|
| `readonly atlas: OctahedralAtlas` | The grid that the bake drew. |
|
|
113
|
-
| `readonly color: { width: number; height: number; data: Uint8Array; }` | The
|
|
237
|
+
| `readonly color: { width: number; height: number; data: Uint8Array; }` | The color atlas: its texels, and their grid. |
|
|
114
238
|
| `readonly surface: { width: number; height: number; data: Uint8Array; }` | The surface atlas: its texels, and their grid. |
|
|
115
239
|
| `readonly size: readonly [number, number]` | The world size of one card's quad at scale 1: the width that holds the object's widest horizontal reach, and its height. The card stands on the object's lowest point. |
|
|
116
240
|
| `readonly room: number` | How many times taller a view's picture is than `size`'s height, which holds the object from every view: `createImpostors` takes it as `room`. |
|
|
@@ -120,6 +244,8 @@ The two atlases that a bake writes: the colour in sRGB, with the coverage in alp
|
|
|
120
244
|
|
|
121
245
|
Interface `ImpostorBakeMap`.
|
|
122
246
|
|
|
247
|
+
Import from `@null3d/impostors`.
|
|
248
|
+
|
|
123
249
|
A map that a bake samples: its pixels, four bytes a texel in the first row first, and the cell that a part draws.
|
|
124
250
|
|
|
125
251
|
| Member | Description |
|
|
@@ -136,6 +262,8 @@ A map that a bake samples: its pixels, four bytes a texel in the first row first
|
|
|
136
262
|
|
|
137
263
|
Interface `ImpostorBakeOptions`.
|
|
138
264
|
|
|
265
|
+
Import from `@null3d/impostors`.
|
|
266
|
+
|
|
139
267
|
What `bakeImpostorAtlas` takes: the grid, its cells' size, and the object.
|
|
140
268
|
|
|
141
269
|
| Member | Description |
|
|
@@ -150,18 +278,20 @@ What `bakeImpostorAtlas` takes: the grid, its cells' size, and the object.
|
|
|
150
278
|
|
|
151
279
|
Interface `ImpostorBakePart`.
|
|
152
280
|
|
|
153
|
-
|
|
281
|
+
Import from `@null3d/impostors`.
|
|
282
|
+
|
|
283
|
+
One part that a bake draws: its mesh arrays and what colors its surface.
|
|
154
284
|
|
|
155
285
|
| Member | Description |
|
|
156
286
|
| --- | --- |
|
|
157
287
|
| `readonly positions: ArrayLike<number>` | The vertices' positions, three numbers each, in the object's frame. |
|
|
158
288
|
| `readonly normals?: ArrayLike<number>` | The vertices' normals, three numbers each. They are made where the part leaves them out. |
|
|
159
289
|
| `readonly uvs?: ArrayLike<number>` | The vertices' texture coordinates, two numbers each, where a map is drawn. |
|
|
160
|
-
| `readonly colors?: ArrayLike<number>` | The vertices'
|
|
290
|
+
| `readonly colors?: ArrayLike<number>` | The vertices' colors, three or four numbers each, linear. A fourth number is the vertex's coverage. |
|
|
161
291
|
| `readonly indices: ArrayLike<number>` | The triangles' vertices, three each. |
|
|
162
|
-
| `readonly color?: ImpostorBakeMap` | The
|
|
292
|
+
| `readonly color?: ImpostorBakeMap` | The color map, in sRGB, that the part samples. Its alpha is not the coverage. |
|
|
163
293
|
| `readonly coverage?: ImpostorBakeMap` | The coverage map, linear: its blue holds the coverage. |
|
|
164
|
-
| `readonly tint?: readonly [number, number, number]` | A linear
|
|
294
|
+
| `readonly tint?: readonly [number, number, number]` | A linear color that multiplies the part's own color. The default is white. |
|
|
165
295
|
| `readonly alphaCutoff?: number` | The coverage under which nothing draws. The default is 0.5. |
|
|
166
296
|
| `readonly doubleSided?: boolean` | True to draw both sides of the part's triangles and light the back ones. |
|
|
167
297
|
|
|
@@ -169,6 +299,8 @@ One part that a bake draws: its mesh arrays and what colours its surface.
|
|
|
169
299
|
|
|
170
300
|
Class `ImpostorBatch`.
|
|
171
301
|
|
|
302
|
+
Import from `@null3d/impostors`.
|
|
303
|
+
|
|
172
304
|
A batch of impostor cards, which `createImpostors` makes. The cards need no per-frame work: the material reads the eye from the frame's camera and picks each card's views itself. Write the cards' positions, sizes, turns or colors through `batch`, then call `markDirty` for those cards.
|
|
173
305
|
|
|
174
306
|
| Member | Description |
|
|
@@ -183,6 +315,8 @@ A batch of impostor cards, which `createImpostors` makes. The cards need no per-
|
|
|
183
315
|
|
|
184
316
|
Interface `ImpostorContext`.
|
|
185
317
|
|
|
318
|
+
Import from `@null3d/impostors`.
|
|
319
|
+
|
|
186
320
|
What `createImpostors` needs of the sketch: the scene, and the factories it draws with.
|
|
187
321
|
|
|
188
322
|
| Member | Description |
|
|
@@ -197,17 +331,21 @@ What `createImpostors` needs of the sketch: the scene, and the factories it draw
|
|
|
197
331
|
function impostorFrame(direction: Direction, atlas: OctahedralAtlas): number
|
|
198
332
|
```
|
|
199
333
|
|
|
334
|
+
Import from `@null3d/impostors`.
|
|
335
|
+
|
|
200
336
|
The cell of an atlas that shows a view from `direction`, as a frame counted from the atlas's top left, along each row and then down. A view was drawn from the direction a cell's center names, so a bake that walks `frameDirection` over every frame and this agree on every cell. A direction of length 0 shows the middle cell.
|
|
201
337
|
|
|
202
338
|
## `ImpostorOptions`
|
|
203
339
|
|
|
204
340
|
Interface `ImpostorOptions`.
|
|
205
341
|
|
|
342
|
+
Import from `@null3d/impostors`.
|
|
343
|
+
|
|
206
344
|
Options of `createImpostors`: the atlases, the cards and their look.
|
|
207
345
|
|
|
208
346
|
| Member | Description |
|
|
209
347
|
| --- | --- |
|
|
210
|
-
| `readonly color: Texture` | The
|
|
348
|
+
| `readonly color: Texture` | The color of every view, in sRGB: one cell per view, in the cells of `atlas`. |
|
|
211
349
|
| `readonly surface: Texture` | The surface of every view, in the same cells as `color`: red and green hold the octahedral code of the normal in the object's frame, blue its depth from the view's front to its back, and alpha its coverage. `bakeImpostorAtlas` writes one. |
|
|
212
350
|
| `readonly atlas: OctahedralAtlas` | The cells of the atlases: the frames across and down. |
|
|
213
351
|
| `readonly positions: ArrayLike<number>` | The cards: three numbers each, x, y and z, in world units. Each stands on its position, like a tree on the ground. Their count is the batch's size. |
|
|
@@ -225,13 +363,60 @@ Options of `createImpostors`: the atlases, the cards and their look.
|
|
|
225
363
|
| `readonly receiveShadows?: boolean` | True makes the shadows of other objects fall on the cards. The default is false. |
|
|
226
364
|
| `readonly castsStill?: boolean` | True keeps the cards' casters in place while the sun stands still, so a far shadow cascade stays cached. The default is true, which suits a card that turns to the eye of each pass. A scene that turns a card whose batch casts from frame to frame moves its caster while the light stands still, and the far cascades then keep a stale shadow: pass false for such a scene. |
|
|
227
365
|
|
|
366
|
+
## `LoadedImpostorAtlas`
|
|
367
|
+
|
|
368
|
+
Interface `LoadedImpostorAtlas`.
|
|
369
|
+
|
|
370
|
+
Import from `@null3d/impostors`.
|
|
371
|
+
|
|
372
|
+
A baked atlas that `loadImpostorAtlas` loaded: the fields that `createImpostors` takes from a bake, so a sketch spreads it into the options.
|
|
373
|
+
|
|
374
|
+
| Member | Description |
|
|
375
|
+
| --- | --- |
|
|
376
|
+
| `readonly color: Texture` | The color atlas, in sRGB, with no mipmaps. |
|
|
377
|
+
| `readonly surface: Texture` | The surface atlas, linear, with no mipmaps. |
|
|
378
|
+
| `readonly atlas: OctahedralAtlas` | The cells across and down. |
|
|
379
|
+
| `readonly size: readonly [number, number]` | The card's width and height at scale 1. |
|
|
380
|
+
| `readonly room: number` | How much taller a view's picture is than the card's height. |
|
|
381
|
+
| `readonly depth: number` | The object's depth along a view, in world units. |
|
|
382
|
+
|
|
383
|
+
## `loadImpostorAtlas`
|
|
384
|
+
|
|
385
|
+
```ts
|
|
386
|
+
function loadImpostorAtlas(assets: Pick<Assets, 'loadJson' | 'loadTexture'>, url: string | URL): Promise<LoadedImpostorAtlas>
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
Import from `@null3d/impostors`.
|
|
390
|
+
|
|
391
|
+
Loads an impostor atlas file that `bunx @null3d/cli assets impostor` wrote, with its two images.
|
|
392
|
+
|
|
393
|
+
The images load from the JSON file's folder. The result holds the fields that `createImpostors` takes from a bake:
|
|
394
|
+
|
|
395
|
+
```ts
|
|
396
|
+
const pine = await loadImpostorAtlas(assets, 'pine-impostor.json');
|
|
397
|
+
const trees = createImpostors({ scene, materials, geometry }, { ...pine, positions, alphaMode: 'mask' });
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
| Parameter | Description |
|
|
401
|
+
| --- | --- |
|
|
402
|
+
| `assets` | The sketch's asset loader. |
|
|
403
|
+
| `url` | The JSON file's address. |
|
|
404
|
+
|
|
405
|
+
Returns: The two atlases and the bake's figures.
|
|
406
|
+
|
|
228
407
|
## `mergeFarGeometry`
|
|
229
408
|
|
|
230
409
|
```ts
|
|
231
410
|
function mergeFarGeometry(parts: readonly FarPart[]): MeshArrays
|
|
232
411
|
```
|
|
233
412
|
|
|
234
|
-
|
|
413
|
+
Import from `@null3d/impostors`.
|
|
414
|
+
|
|
415
|
+
Merges copies of a mesh into the arrays of one mesh, moving each copy by its own transform. The result holds every vertex and triangle of every copy, with each copy's indices moved to point at its own vertices. Give it to `geometry.fromArrays`.
|
|
416
|
+
|
|
417
|
+
Every copy must carry the same attributes, and each attribute must hold the same numbers per vertex in every copy. An attribute that any copy lacks is left out of the result. Positions are always carried, and indices are made for a copy that has none.
|
|
418
|
+
|
|
419
|
+
A copy's normals turn by the inverse transpose of its transform's upper left 3 by 3, as normals turn, so a stretched copy keeps its shading. Its tangents turn by the upper left 3 by 3 itself. A mirrored copy, whose transform has a negative determinant, gets its triangles' winding reversed and its tangents' fourth number negated, so its front faces stay outward and its normal map keeps its sense. Throws a RangeError for arrays that do not fit together.
|
|
235
420
|
|
|
236
421
|
## `nearestFrame`
|
|
237
422
|
|
|
@@ -239,6 +424,8 @@ Merges copies of a mesh into the arrays of one mesh, moving each copy by its own
|
|
|
239
424
|
function nearestFrame(direction: Direction, directions: readonly Direction[]): number
|
|
240
425
|
```
|
|
241
426
|
|
|
427
|
+
Import from `@null3d/impostors`.
|
|
428
|
+
|
|
242
429
|
The view of a list of directions that faces the camera most: the one whose direction has the largest dot product with `direction`. Use it when a bake holds views that are not an octahedral grid, such as 12 views a tool picked. It returns -1 for an empty list.
|
|
243
430
|
|
|
244
431
|
## `octahedralAtlas`
|
|
@@ -247,12 +434,16 @@ The view of a list of directions that faces the camera most: the one whose direc
|
|
|
247
434
|
function octahedralAtlas(views: number): OctahedralAtlas
|
|
248
435
|
```
|
|
249
436
|
|
|
437
|
+
Import from `@null3d/impostors`.
|
|
438
|
+
|
|
250
439
|
The squarest grid of cells that holds at least `views` views, as `{ columns, rows }`. The grid can hold more cells than `views`, and every cell shows a direction. Give the result to a bake, which draws a view in each cell, and to `createImpostors`, which shows them.
|
|
251
440
|
|
|
252
441
|
## `OctahedralAtlas`
|
|
253
442
|
|
|
254
443
|
Interface `OctahedralAtlas`.
|
|
255
444
|
|
|
445
|
+
Import from `@null3d/impostors`.
|
|
446
|
+
|
|
256
447
|
The cells of an impostor atlas: `columns` across and `rows` down, as a sprite atlas.
|
|
257
448
|
|
|
258
449
|
| Member | Description |
|
|
@@ -266,6 +457,8 @@ The cells of an impostor atlas: `columns` across and `rows` down, as a sprite at
|
|
|
266
457
|
function octahedralCells(atlas: OctahedralAtlas): number
|
|
267
458
|
```
|
|
268
459
|
|
|
460
|
+
Import from `@null3d/impostors`.
|
|
461
|
+
|
|
269
462
|
The number of cells of an octahedral atlas: `columns` times `rows`. A bake draws a view in each of them, because each shows a direction.
|
|
270
463
|
|
|
271
464
|
## `OctahedralUv`
|
|
@@ -274,4 +467,6 @@ The number of cells of an octahedral atlas: `columns` times `rows`. A bake draws
|
|
|
274
467
|
type OctahedralUv = [number, number];
|
|
275
468
|
```
|
|
276
469
|
|
|
470
|
+
Import from `@null3d/impostors`.
|
|
471
|
+
|
|
277
472
|
Two octahedral coordinates, each from -1 to 1.
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: api/reference/input
|
|
3
3
|
title: "Input: API reference"
|
|
4
|
-
|
|
5
|
-
since: "0.1"
|
|
4
|
+
generated: true
|
|
6
5
|
summary: "Every export of the Input API, from the engine's doc comments."
|
|
7
6
|
---
|
|
8
7
|
|
|
@@ -53,7 +52,7 @@ The main pointer: the mouse, a pen, or the first finger that touches the canvas.
|
|
|
53
52
|
| `readonly dy: number` | Movement down since the previous frame, in CSS pixels. |
|
|
54
53
|
| `readonly dragDx: number` | The part of `dx` made while a button was held: a drag. Movement before a press or after a release in the same frame does not count. |
|
|
55
54
|
| `readonly dragDy: number` | The part of `dy` made while a button was held: a drag. |
|
|
56
|
-
| `readonly wheel: number` | The wheel's scroll since the previous frame, in pixels: positive where a page would scroll down. A wheel that scrolls by lines counts 16 pixels a line, and one that scrolls by pages counts 100 a page
|
|
55
|
+
| `readonly wheel: number` | The wheel's scroll since the previous frame, in pixels: positive where a page would scroll down. A wheel that scrolls by lines counts 16 pixels a line, and one that scrolls by pages counts 100 a page. Scroll that follows a release of the pointer waits for the next frame, so a frame's scroll never comes after the end of its drag. |
|
|
57
56
|
| `readonly pinch: number` | The part of `wheel` that came from a pinch on a trackpad: positive as the fingers close. Browsers send a pinch as wheel scroll that holds the Control key's flag while no Control key is down. |
|
|
58
57
|
| `readonly isTouch: boolean` | True when the pointer is a finger on a touch screen. |
|
|
59
58
|
| `readonly locked: boolean` | True while the canvas holds the pointer lock, which `engine.requestPointerLock()` asks for on the page. The browser then hides the pointer and keeps it still: `x` and `y` stay where the lock began, `dx` and `dy` give the mouse's movement, and objects take no pointer events. |
|
|
@@ -108,8 +107,8 @@ A pointer event on an object, which the handlers of `object.on` take. The engine
|
|
|
108
107
|
| `readonly point: Vec3Like` | Where the ray hits `object`, in world space. |
|
|
109
108
|
| `readonly normal: Vec3Like` | The unit normal of the hit triangle in world space, on the side that faces the camera. A hit on a sprite or a point faces the camera; on a line, it points back along the ray. |
|
|
110
109
|
| `readonly distance: number` | The distance from the ray's origin to the hit, in meters. |
|
|
111
|
-
| `readonly triangle: number` | The index of the hit triangle in its mesh,
|
|
112
|
-
| `readonly uv: Vec2Like` | Where on the surface the ray hit, as the first texture coordinates of the hit triangle blended across its three corners
|
|
110
|
+
| `readonly triangle: number` | The index of the hit triangle in its mesh, or -1 for a sprite, a point or a line. |
|
|
111
|
+
| `readonly uv: Vec2Like` | Where on the surface the ray hit, as the first texture coordinates of the hit triangle blended across its three corners. Read `hasUv` first: the numbers mean nothing when it is false. An in-world screen turns a click into a texel of its image with these, without working out where the surface lies in space. |
|
|
113
112
|
| `readonly hasUv: boolean` | True when the hit triangle's mesh has a first texture coordinate set, so `uv` holds where on the surface the ray hit. False for a hit on a sprite, a point or a line, and for a mesh with no such coordinates. |
|
|
114
113
|
| `readonly ray: Ray` | The ray from the camera through the pointer, from the frame that was on screen at the event. |
|
|
115
114
|
| `readonly x: number` | The pointer's distance from the canvas's left edge in CSS pixels. |
|