@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
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: api/reference/sound
|
|
3
|
+
title: "Sound (@null3d/sound): API reference"
|
|
4
|
+
generated: true
|
|
5
|
+
summary: "Every export of the Sound (@null3d/sound) API, from the engine's doc comments."
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Sound (@null3d/sound): API reference
|
|
9
|
+
|
|
10
|
+
> [Sound (@null3d/sound)](../sound.md) explains these exports. The engine's doc comments make this page.
|
|
11
|
+
|
|
12
|
+
## `connectSound`
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
function connectSound(engine: Engine, options: PageSoundOptions = {}): PageSound
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Import from `@null3d/sound/page`.
|
|
19
|
+
|
|
20
|
+
Connects the page to the sketch's sounds, which `createSound` makes in the sketch. Call it once, after `createEngine` resolves. Nothing plays until `start` runs in answer to a click, a tap or a key, or the user's first input with `startOnInput`.
|
|
21
|
+
|
|
22
|
+
## `createSound`
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
function createSound(ctx: SketchContext, options: SoundOptions): Sound
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Import from `@null3d/sound`.
|
|
29
|
+
|
|
30
|
+
Makes the sketch's sounds. Call it in the sketch's setup, and call `update` once a frame in `onLateUpdate`. The sounds play on the page once the page's half, `connectSound` from `@null3d/sound/page`, has started the audio. A sketch may make its sounds at any time; a sound made before the page connects plays once it does.
|
|
31
|
+
|
|
32
|
+
## `NAMESPACE`
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
const NAMESPACE: AddonNamespace
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Import from `@null3d/sound`.
|
|
39
|
+
|
|
40
|
+
The add-on's names, claimed once as the sketch loads: its name, its package and its error codes.
|
|
41
|
+
|
|
42
|
+
## `PageSound`
|
|
43
|
+
|
|
44
|
+
Interface `PageSound`.
|
|
45
|
+
|
|
46
|
+
Import from `@null3d/sound/page`.
|
|
47
|
+
|
|
48
|
+
The page's half of the sound, as `connectSound` makes it.
|
|
49
|
+
|
|
50
|
+
| Member | Description |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| `readonly state: SoundState` | Where the sound stands now. |
|
|
53
|
+
| `readonly muted: boolean` | True while the page's sound is muted. |
|
|
54
|
+
| `start(): Promise<void>` | Starts the audio. Call it in the handler of a click, a tap or a key, since browsers start a page's audio only in answer to the user. Resolves once the audio runs, with the sounds' files still loading; each sound fades in as its file arrives. |
|
|
55
|
+
| `setMuted(muted: boolean): void` | Mutes or unmutes every sound. |
|
|
56
|
+
| `onState(handler: (state: SoundState) => void): () => void` | Calls `handler` each time the state changes. Returns a function that removes the handler. |
|
|
57
|
+
| `stop(): void` | Stops the audio for good and closes the link to the sketch. The engine's stop does the same. |
|
|
58
|
+
|
|
59
|
+
## `PageSoundOptions`
|
|
60
|
+
|
|
61
|
+
Interface `PageSoundOptions`.
|
|
62
|
+
|
|
63
|
+
Import from `@null3d/sound/page`.
|
|
64
|
+
|
|
65
|
+
Options for `connectSound`.
|
|
66
|
+
|
|
67
|
+
| Member | Description |
|
|
68
|
+
| --- | --- |
|
|
69
|
+
| `startOnInput?: boolean` | Starts the sound on the user's first click, tap or key on the page, other than Escape. Browsers let a page start its audio only in answer to such an input. The default is false: the page calls `start` from its own control, such as a sound button. |
|
|
70
|
+
| `muted?: boolean` | Starts muted. The default is false. |
|
|
71
|
+
|
|
72
|
+
## `Sound`
|
|
73
|
+
|
|
74
|
+
Interface `Sound`.
|
|
75
|
+
|
|
76
|
+
Import from `@null3d/sound`.
|
|
77
|
+
|
|
78
|
+
The sketch's sounds, as `createSound` makes them.
|
|
79
|
+
|
|
80
|
+
| Member | Description |
|
|
81
|
+
| --- | --- |
|
|
82
|
+
| `readonly connected: boolean` | True once the page's half has opened its link to the sketch. |
|
|
83
|
+
| `loop(options: SoundLoopOptions): SoundLoop` | Makes a sound that plays its file over and over. |
|
|
84
|
+
| `group(options: SoundGroupOptions): SoundGroup` | Makes a group of sounds that play one file, of which the loudest few sound at once. |
|
|
85
|
+
| `shot(options: SoundShotOptions): SoundShot` | Makes a sound that plays its file once for each call of its `play`. |
|
|
86
|
+
| `setVolume(volume: number): void` | Sets the volume of every sound, from 0 to 1. |
|
|
87
|
+
| `update(): void` | Reads the listener's place and turn and counts the frame. Call it once a frame, in `onLateUpdate`, after the camera has moved. A sketch that stops calling it fades every sound out, as a paused engine does. |
|
|
88
|
+
| `destroy(): void` | Stops every sound and closes the link to the page. |
|
|
89
|
+
|
|
90
|
+
## `SoundGroup`
|
|
91
|
+
|
|
92
|
+
Interface `SoundGroup`.
|
|
93
|
+
|
|
94
|
+
Import from `@null3d/sound`.
|
|
95
|
+
|
|
96
|
+
Many sounds that play one file, such as the engines of the cars in a street, as `sound.group` makes it. Its arrays are views of the table, which a sketch may also write in bulk. They belong to the group until `destroy`: after it, the group's emitters may serve another sound, so a sketch drops the arrays with the group.
|
|
97
|
+
|
|
98
|
+
| Member | Description |
|
|
99
|
+
| --- | --- |
|
|
100
|
+
| `readonly count: number` | The members of the group. |
|
|
101
|
+
| `readonly positions: Float32Array` | Each member's place in the world, three numbers each. |
|
|
102
|
+
| `readonly levels: Float32Array` | Each member's level, from 0. |
|
|
103
|
+
| `readonly rates: Float32Array` | Each member's playback rate. |
|
|
104
|
+
| `readonly tones: Float32Array` | Each member's tone, from 0 to 1. |
|
|
105
|
+
| `setPosition(index: number, x: number, y: number, z: number): void` | Moves member `index` to a place in the world. |
|
|
106
|
+
| `setLevel(index: number, level: number): void` | Sets member `index`'s level. |
|
|
107
|
+
| `setRate(index: number, rate: number): void` | Sets member `index`'s playback rate. |
|
|
108
|
+
| `setTone(index: number, tone: number): void` | Sets member `index`'s tone. |
|
|
109
|
+
| `destroy(): void` | Stops every member, with a short fade, and frees the group's emitters and voices. |
|
|
110
|
+
|
|
111
|
+
## `SoundGroupOptions`
|
|
112
|
+
|
|
113
|
+
Interface `SoundGroupOptions`, which extends `SoundPlacement`.
|
|
114
|
+
|
|
115
|
+
Import from `@null3d/sound`.
|
|
116
|
+
|
|
117
|
+
Options for `sound.group`.
|
|
118
|
+
|
|
119
|
+
| Member | Description |
|
|
120
|
+
| --- | --- |
|
|
121
|
+
| `file: string \| URL` | The audio file that every member plays, as `SoundLoopOptions.file` takes it. |
|
|
122
|
+
| `count: number` | The members of the group, each with its own place, level, rate and tone. |
|
|
123
|
+
| `voices: number` | The members that sound at once: the loudest where the listener stands. |
|
|
124
|
+
|
|
125
|
+
## `SoundListener`
|
|
126
|
+
|
|
127
|
+
Interface `SoundListener`.
|
|
128
|
+
|
|
129
|
+
Import from `@null3d/sound`.
|
|
130
|
+
|
|
131
|
+
The object that hears the sounds, usually the active camera. The add-on reads its place and turn in the world once a frame. A camera looks down its own -Z axis, and so does the listener.
|
|
132
|
+
|
|
133
|
+
| Member | Description |
|
|
134
|
+
| --- | --- |
|
|
135
|
+
| `getWorldPosition(out: Vec3Like): void` | Writes the object's place in the world into `out`. |
|
|
136
|
+
| `getWorldQuaternion(out: QuatLike): void` | Writes the object's turn in the world, as a quaternion, into `out`. |
|
|
137
|
+
|
|
138
|
+
## `SoundLoop`
|
|
139
|
+
|
|
140
|
+
Interface `SoundLoop`.
|
|
141
|
+
|
|
142
|
+
Import from `@null3d/sound`.
|
|
143
|
+
|
|
144
|
+
A sound that plays its file over and over, as `sound.loop` makes it.
|
|
145
|
+
|
|
146
|
+
| Member | Description |
|
|
147
|
+
| --- | --- |
|
|
148
|
+
| `setLevel(level: number): void` | Sets the level, from 0. A level of 0 silences the sound. |
|
|
149
|
+
| `setRate(rate: number): void` | Sets the playback rate, where 1 is the file's own speed and pitch. |
|
|
150
|
+
| `setTone(tone: number): void` | Sets the tone, from 0 (muffled) to 1 (the file's own brightness). |
|
|
151
|
+
| `setPosition(x: number, y: number, z: number): void` | Moves the sound to a place in the world. A bed that plays in both ears ignores its place. |
|
|
152
|
+
| `destroy(): void` | Stops the sound, with a short fade, and frees its emitter and its voice. Its setters then do nothing. |
|
|
153
|
+
|
|
154
|
+
## `SoundLoopOptions`
|
|
155
|
+
|
|
156
|
+
Interface `SoundLoopOptions`, which extends `SoundPlacement`.
|
|
157
|
+
|
|
158
|
+
Import from `@null3d/sound`.
|
|
159
|
+
|
|
160
|
+
Options for `sound.loop`.
|
|
161
|
+
|
|
162
|
+
| Member | Description |
|
|
163
|
+
| --- | --- |
|
|
164
|
+
| `file: string \| URL` | The audio file's address. A relative address resolves against the page's address, as the engine's loaders do. `new URL('./file.mp3', import.meta.url)` names a file beside the sketch. |
|
|
165
|
+
| `positional?: boolean` | True for a sound that comes from a place, which `setPosition` moves. False for a bed that plays in both ears alike, such as wind or rain. The default is true. |
|
|
166
|
+
| `level?: number` | The first level, from 0. The default is 1. |
|
|
167
|
+
| `rate?: number` | The first playback rate, where 1 is the file's own speed and pitch. The default is 1. |
|
|
168
|
+
| `tone?: number` | The first tone, from 0 (muffled) to 1 (the file's own brightness). The default is 1. |
|
|
169
|
+
| `position?: readonly [number, number, number]` | The first place in the world. The default is the origin. |
|
|
170
|
+
|
|
171
|
+
## `SoundOptions`
|
|
172
|
+
|
|
173
|
+
Interface `SoundOptions`.
|
|
174
|
+
|
|
175
|
+
Import from `@null3d/sound`.
|
|
176
|
+
|
|
177
|
+
Options for `createSound`.
|
|
178
|
+
|
|
179
|
+
| Member | Description |
|
|
180
|
+
| --- | --- |
|
|
181
|
+
| `listener: SoundListener` | The object that hears the sounds, usually the active camera. |
|
|
182
|
+
| `capacity?: number` | The emitters that the sketch's sounds hold together: one for each loop, one for each member of a group, and one for each voice of a shot. The default is 256 and the most is 4,096. |
|
|
183
|
+
| `volume?: number` | The volume of every sound, from 0 to 1. The default is 1. |
|
|
184
|
+
|
|
185
|
+
## `SoundPlacement`
|
|
186
|
+
|
|
187
|
+
Interface `SoundPlacement`.
|
|
188
|
+
|
|
189
|
+
Import from `@null3d/sound`.
|
|
190
|
+
|
|
191
|
+
How a sound falls off with distance. A sound with neither distance keeps the level that the sketch gives it wherever the listener stands.
|
|
192
|
+
|
|
193
|
+
| Member | Description |
|
|
194
|
+
| --- | --- |
|
|
195
|
+
| `near?: number` | The distance within which the sound is at its full level. Beyond it the level falls as the distance grows: at twice this distance it is half. Leave it out for a sound whose level the sketch sets itself. |
|
|
196
|
+
| `far?: number` | The distance at which the sound has faded out. Leave it out for no such distance. |
|
|
197
|
+
| `muffle?: boolean` | Whether the sound loses its highs as it nears its far distance, as distant sounds do. The default is true for a sound with a far distance. |
|
|
198
|
+
|
|
199
|
+
## `SoundShot`
|
|
200
|
+
|
|
201
|
+
Interface `SoundShot`.
|
|
202
|
+
|
|
203
|
+
Import from `@null3d/sound`.
|
|
204
|
+
|
|
205
|
+
A sound that plays its file once for each call, such as thunder or a door, as `sound.shot` makes it.
|
|
206
|
+
|
|
207
|
+
| Member | Description |
|
|
208
|
+
| --- | --- |
|
|
209
|
+
| `play(x: number, y: number, z: number, level?: number, rate?: number): void` | Plays the file once at a place in the world, at a level and a playback rate. A shot that plays in both ears ignores the place. |
|
|
210
|
+
| `destroy(): void` | Stops every play and frees the shot's emitters and voices. |
|
|
211
|
+
|
|
212
|
+
## `SoundShotOptions`
|
|
213
|
+
|
|
214
|
+
Interface `SoundShotOptions`, which extends `SoundPlacement`.
|
|
215
|
+
|
|
216
|
+
Import from `@null3d/sound`.
|
|
217
|
+
|
|
218
|
+
Options for `sound.shot`.
|
|
219
|
+
|
|
220
|
+
| Member | Description |
|
|
221
|
+
| --- | --- |
|
|
222
|
+
| `file: string \| URL` | The audio file that each play starts, as `SoundLoopOptions.file` takes it. |
|
|
223
|
+
| `voices?: number` | The plays that sound at once. A play past this count stops the oldest. The default is 2. |
|
|
224
|
+
| `positional?: boolean` | True for a shot that comes from a place. The default is true. |
|
|
225
|
+
|
|
226
|
+
## `SoundState`
|
|
227
|
+
|
|
228
|
+
```ts
|
|
229
|
+
type SoundState = 'off' | 'starting' | 'on' | 'paused' | 'interrupted' | 'stopped';
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Import from `@null3d/sound/page`.
|
|
233
|
+
|
|
234
|
+
Where the page's sound stands: not started, starting, playing, paused while the engine is paused or the page is hidden, interrupted while the browser holds the audio, as an iPhone does during a call, or stopped for good. An interrupted sound resumes at the user's next input, or when the page shows again.
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: api/reference/splats
|
|
3
3
|
title: "Gaussian splats (@null3d/splats): API reference"
|
|
4
|
-
|
|
5
|
-
since: "0.3"
|
|
4
|
+
generated: true
|
|
6
5
|
summary: "Every export of the Gaussian splats (@null3d/splats) API, from the engine's doc comments."
|
|
7
6
|
---
|
|
8
7
|
|
|
@@ -16,12 +15,16 @@ summary: "Every export of the Gaussian splats (@null3d/splats) API, from the eng
|
|
|
16
15
|
function checkSplats(data: SplatData, what: string): SplatData
|
|
17
16
|
```
|
|
18
17
|
|
|
18
|
+
Import from `@null3d/splats`.
|
|
19
|
+
|
|
19
20
|
Checks that a cloud's arrays hold what its count says, and throws when they do not.
|
|
20
21
|
|
|
21
22
|
## `ChunkOptions`
|
|
22
23
|
|
|
23
24
|
Interface `ChunkOptions`.
|
|
24
25
|
|
|
26
|
+
Import from `@null3d/splats`.
|
|
27
|
+
|
|
25
28
|
How a cloud is cut, and what the caller sees as it is.
|
|
26
29
|
|
|
27
30
|
| Member | Description |
|
|
@@ -36,6 +39,8 @@ How a cloud is cut, and what the caller sees as it is.
|
|
|
36
39
|
function chunkSplats(data: SplatData, options: ChunkOptions = {}): Promise<SplatChunks>
|
|
37
40
|
```
|
|
38
41
|
|
|
42
|
+
Import from `@null3d/splats`.
|
|
43
|
+
|
|
39
44
|
Cuts a cloud into chunks of nearby splats, each ordered so that its first splats cover the most surface. `yieldTo` runs between chunks, and `onChunk` sees each chunk as it is ready: a draw that takes them one by one appears coarse to fine, and a large cloud never holds up a frame.
|
|
40
45
|
|
|
41
46
|
## `colorOfSh`
|
|
@@ -44,6 +49,8 @@ Cuts a cloud into chunks of nearby splats, each ordered so that its first splats
|
|
|
44
49
|
function colorOfSh(dc: readonly [number, number, number], encoded = true, out = new Float32Array(3)): Float32Array
|
|
45
50
|
```
|
|
46
51
|
|
|
52
|
+
Import from `@null3d/splats`.
|
|
53
|
+
|
|
47
54
|
The linear RGB of a first-band spherical-harmonic coefficient, from its three channels. `encoded` says that the reconstructed value is an sRGB display value, which this decodes; leave it out for a value that is already linear.
|
|
48
55
|
|
|
49
56
|
## `createSplats`
|
|
@@ -52,7 +59,13 @@ The linear RGB of a first-band spherical-harmonic coefficient, from its three ch
|
|
|
52
59
|
function createSplats(ctx: SketchContext, options: SplatsOptions): Promise<Splats>
|
|
53
60
|
```
|
|
54
61
|
|
|
55
|
-
|
|
62
|
+
Import from `@null3d/splats`.
|
|
63
|
+
|
|
64
|
+
Draws a cloud of Gaussian splats in a sketch. The cloud comes from an SPZ file, from a splat stream index, or from the data of another reader. A glTF model that carries `KHR_gaussian_splatting` loads through `assets.loadGltf`, because the add-on's module registers the reader as it loads. A cloud draws with detail levels, a budget that follows the quality preset and the GPU path, and a soft mix with the scene's opaque meshes.
|
|
65
|
+
|
|
66
|
+
A splat stream starts drawing before its whole cloud has downloaded: give the address of its index, and the add-on fetches the chunks that the view needs as it needs them. Each chunk of the cloud is an SPZ file, and the index names them.
|
|
67
|
+
|
|
68
|
+
Call `splats.update(eye)` once in each frame, with the camera's position from `getPosition`, and free the cloud with `splats.destroy()`.
|
|
56
69
|
|
|
57
70
|
## `decodeSpz`
|
|
58
71
|
|
|
@@ -60,6 +73,8 @@ Draws a cloud of Gaussian splats in a sketch. The cloud comes from an SPZ file,
|
|
|
60
73
|
function decodeSpz(file: Uint8Array | ArrayBuffer): Promise<SplatData>
|
|
61
74
|
```
|
|
62
75
|
|
|
76
|
+
Import from `@null3d/splats`.
|
|
77
|
+
|
|
63
78
|
Reads an SPZ file into a cloud of splats. `file` holds the file's bytes as the browser delivers them. Throws when the file is not an SPZ file this reader knows, when its sizes do not fit, and when a zstd stream needs a browser without the zstd decompressor.
|
|
64
79
|
|
|
65
80
|
## `encodeSpz`
|
|
@@ -68,6 +83,8 @@ Reads an SPZ file into a cloud of splats. `file` holds the file's bytes as the b
|
|
|
68
83
|
function encodeSpz(data: SplatData): Promise<Uint8Array>
|
|
69
84
|
```
|
|
70
85
|
|
|
86
|
+
Import from `@null3d/splats`.
|
|
87
|
+
|
|
71
88
|
Writes a cloud as a version 3 SPZ file, gzipped as the readers of the format expect. A stream writer cuts a cloud with `chunkSplats` and writes each chunk with this call, then names the files in a stream index. Throws E2101 for a cloud whose arrays do not fit its count.
|
|
72
89
|
|
|
73
90
|
## `parseStreamIndex`
|
|
@@ -76,6 +93,8 @@ Writes a cloud as a version 3 SPZ file, gzipped as the readers of the format exp
|
|
|
76
93
|
function parseStreamIndex(text: string, base: string | URL | undefined, what = 'the splat stream index'): SplatStream
|
|
77
94
|
```
|
|
78
95
|
|
|
96
|
+
Import from `@null3d/splats`.
|
|
97
|
+
|
|
79
98
|
Reads a stream index. `base` resolves each chunk's address, which a relative one needs. Throws E2112 for a text that is not a stream index of this version, and for a cloud whose chunks do not hold the number of splats that it names.
|
|
80
99
|
|
|
81
100
|
## `SPLAT_EXTENSION`
|
|
@@ -84,12 +103,16 @@ Reads a stream index. `base` resolves each chunk's address, which a relative one
|
|
|
84
103
|
const SPLAT_EXTENSION: 'KHR_gaussian_splatting'
|
|
85
104
|
```
|
|
86
105
|
|
|
106
|
+
Import from `@null3d/splats`.
|
|
107
|
+
|
|
87
108
|
The glTF extension that a splat file carries, which this handler reads.
|
|
88
109
|
|
|
89
110
|
## `SplatChunk`
|
|
90
111
|
|
|
91
112
|
Interface `SplatChunk`.
|
|
92
113
|
|
|
114
|
+
Import from `@null3d/splats`.
|
|
115
|
+
|
|
93
116
|
One chunk of a cloud, with its splats in the order that a coarser level keeps.
|
|
94
117
|
|
|
95
118
|
| Member | Description |
|
|
@@ -107,6 +130,8 @@ One chunk of a cloud, with its splats in the order that a coarser level keeps.
|
|
|
107
130
|
|
|
108
131
|
Interface `SplatChunks`.
|
|
109
132
|
|
|
133
|
+
Import from `@null3d/splats`.
|
|
134
|
+
|
|
110
135
|
A cloud cut into chunks, and the splits that its levels take.
|
|
111
136
|
|
|
112
137
|
| Member | Description |
|
|
@@ -118,6 +143,8 @@ A cloud cut into chunks, and the splits that its levels take.
|
|
|
118
143
|
|
|
119
144
|
Interface `SplatData`.
|
|
120
145
|
|
|
146
|
+
Import from `@null3d/splats`.
|
|
147
|
+
|
|
121
148
|
One cloud of Gaussian splats, ready to draw.
|
|
122
149
|
|
|
123
150
|
| Member | Description |
|
|
@@ -132,6 +159,8 @@ One cloud of Gaussian splats, ready to draw.
|
|
|
132
159
|
|
|
133
160
|
Interface `Splats`.
|
|
134
161
|
|
|
162
|
+
Import from `@null3d/splats`.
|
|
163
|
+
|
|
135
164
|
A cloud of Gaussian splats that a scene draws, with its levels and its budget.
|
|
136
165
|
|
|
137
166
|
| Member | Description |
|
|
@@ -155,6 +184,8 @@ A cloud of Gaussian splats that a scene draws, with its levels and its budget.
|
|
|
155
184
|
|
|
156
185
|
Interface `SplatsDraw`.
|
|
157
186
|
|
|
187
|
+
Import from `@null3d/splats`.
|
|
188
|
+
|
|
158
189
|
The draw that a cloud fills: the instance batch whose rows are the splats that draw. Write the rows, mark them, and set the number that draw. The draw's material is the add-on's shader.
|
|
159
190
|
|
|
160
191
|
| Member | Description |
|
|
@@ -168,6 +199,8 @@ The draw that a cloud fills: the instance batch whose rows are the splats that d
|
|
|
168
199
|
|
|
169
200
|
Interface `SplatsOptions`.
|
|
170
201
|
|
|
202
|
+
Import from `@null3d/splats`.
|
|
203
|
+
|
|
171
204
|
Options of `createSplats`. Give the cloud itself, or the address of a splat file or a stream index.
|
|
172
205
|
|
|
173
206
|
| Member | Description |
|
|
@@ -183,6 +216,8 @@ Options of `createSplats`. Give the cloud itself, or the address of a splat file
|
|
|
183
216
|
|
|
184
217
|
Interface `SplatStream`.
|
|
185
218
|
|
|
219
|
+
Import from `@null3d/splats`.
|
|
220
|
+
|
|
186
221
|
A splat stream's index: the cloud's count and the chunks that it is cut into.
|
|
187
222
|
|
|
188
223
|
| Member | Description |
|
|
@@ -195,6 +230,8 @@ A splat stream's index: the cloud's count and the chunks that it is cut into.
|
|
|
195
230
|
|
|
196
231
|
Interface `StreamChunk`.
|
|
197
232
|
|
|
233
|
+
Import from `@null3d/splats`.
|
|
234
|
+
|
|
198
235
|
One chunk of a splat stream: where its file lies, how many splats it holds, and the bounds that the selection needs before it loads.
|
|
199
236
|
|
|
200
237
|
| Member | Description |
|
|
@@ -211,4 +248,6 @@ One chunk of a splat stream: where its file lies, how many splats it holds, and
|
|
|
211
248
|
type Yielder = () => Promise<void>;
|
|
212
249
|
```
|
|
213
250
|
|
|
251
|
+
Import from `@null3d/splats`.
|
|
252
|
+
|
|
214
253
|
Hands the thread back between chunks, so a large cloud never holds up a frame.
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: api/reference/sprites
|
|
3
3
|
title: "Sprites: API reference"
|
|
4
|
-
|
|
5
|
-
since: "0.2"
|
|
4
|
+
generated: true
|
|
6
5
|
summary: "Every export of the Sprites API, from the engine's doc comments."
|
|
7
6
|
---
|
|
8
7
|
|
|
@@ -34,7 +33,7 @@ Many sprites: quads that face the camera, each with its own position, size, rota
|
|
|
34
33
|
| `dropViews(): void` | Forgets the row arrays, which the next read makes again. |
|
|
35
34
|
| `readonly positions: Float32Array` | Positions in the world, 3 floats per sprite. A new sprite is at the origin. |
|
|
36
35
|
| `readonly sizes: Float32Array` | Width and height, 2 floats per sprite: world units, or CSS pixels without size attenuation. A new sprite is 1 by 1. A negative size mirrors the sprite. |
|
|
37
|
-
| `readonly rotations: Float32Array` | The turn of each sprite on the screen, in radians, counterclockwise, 1 float per sprite
|
|
36
|
+
| `readonly rotations: Float32Array` | The turn of each sprite on the screen, in radians, counterclockwise, 1 float per sprite. A new sprite has 0. |
|
|
38
37
|
| `readonly colors: Float32Array` | Linear RGBA colors, 4 floats per sprite, which multiply the material's color and map. A new sprite is white. Components from 0 to 1024 draw, and alpha from 0 to 1. |
|
|
39
38
|
| `readonly frames: Uint32Array` | The frame of the atlas that each sprite shows, 1 per sprite. Frame 0 is the top left. A frame past the last one counts again from the first. |
|
|
40
39
|
| `setActiveCount(count: number): void` | Draws only the first `count` sprites. |
|
|
@@ -46,21 +45,21 @@ Many sprites: quads that face the camera, each with its own position, size, rota
|
|
|
46
45
|
|
|
47
46
|
## `SpriteOptions`
|
|
48
47
|
|
|
49
|
-
Interface `SpriteOptions`, which extends `SpriteValues`, `Omit
|
|
48
|
+
Interface `SpriteOptions`, which extends `SpriteValues`, `Omit<MaterialFeatures, 'doubleSided' | 'vertexColors' | 'forceSinglePass'>`.
|
|
50
49
|
|
|
51
|
-
Options of `scene.createSprites`. The look of the sprites takes the options of an unlit material, but sprites blend by default
|
|
50
|
+
Options of `scene.createSprites`. The look of the sprites takes the options of an unlit material, but sprites blend by default.
|
|
52
51
|
|
|
53
52
|
| Member | Description |
|
|
54
53
|
| --- | --- |
|
|
55
54
|
| `count: number` | The number of sprites: the batch's capacity, which never changes. |
|
|
56
55
|
| `map?: Texture` | A color map, in sRGB, whose color multiplies `color` and each sprite's color. With `atlas`, each sprite shows one frame of it. It is fixed when the batch is created. |
|
|
57
56
|
| `atlas?: SpriteAtlas` | Splits `map` into a grid of frames, which each sprite picks from with its `frames` row. |
|
|
58
|
-
| `sizeAttenuation?: boolean` | True gives sizes in world units, so far sprites look smaller
|
|
59
|
-
| `center?: readonly [number, number]` | The point of each sprite that sits at its position, as a fraction of its width and height from its bottom left corner
|
|
57
|
+
| `sizeAttenuation?: boolean` | True gives sizes in world units, so far sprites look smaller. False gives sizes in CSS pixels, so every sprite keeps its size on screen. The default is true. |
|
|
58
|
+
| `center?: readonly [number, number]` | The point of each sprite that sits at its position, as a fraction of its width and height from its bottom left corner. The sprite turns about it. The default, `[0.5, 0.5]`, is the middle; `[0.5, 0]` stands a sprite on its position. |
|
|
60
59
|
| `dynamic?: boolean` | Every sprite updates and uploads every frame; a static batch updates rows marked dirty only. |
|
|
61
60
|
| `layers?: number` | The layers every sprite is on, as a 32-bit mask. The default, 1, is layer 0. |
|
|
62
61
|
| `origin?: Vec3` | The point that every sprite's position is relative to, as an instance batch's `origin`. The default is (0, 0, 0). Sprites near it keep the precision of 32-bit floats at any distance from the world's origin. |
|
|
63
|
-
| `alphaMode?: MaterialFeatures['alphaMode']` | How the sprites use their alpha. The default is `blend
|
|
62
|
+
| `alphaMode?: MaterialFeatures['alphaMode']` | How the sprites use their alpha. The default is `blend`. |
|
|
64
63
|
|
|
65
64
|
## `SpriteValues`
|
|
66
65
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: api/reference/tasks
|
|
3
3
|
title: "Tasks on the job workers: API reference"
|
|
4
|
-
|
|
5
|
-
since: "0.3"
|
|
4
|
+
generated: true
|
|
6
5
|
summary: "Every export of the Tasks on the job workers API, from the engine's doc comments."
|
|
7
6
|
---
|
|
8
7
|
|
|
@@ -16,7 +15,21 @@ summary: "Every export of the Tasks on the job workers API, from the engine's do
|
|
|
16
15
|
function runTask<T>(task: Task, input: unknown, transfer: Transferable[] = NO_TRANSFER): Promise<T>
|
|
17
16
|
```
|
|
18
17
|
|
|
19
|
-
Runs a task in a job worker, beside the frames, and resolves with its output.
|
|
18
|
+
Runs a task in a job worker, beside the frames, and resolves with its output.
|
|
19
|
+
|
|
20
|
+
The task's module is imported once in each worker that runs it, so a module keeps its state between tasks, and each of its WebAssembly files compiles once per page. A module exports `run`, which gets the task's input and a function that returns each compiled module by the name that the task gives it.
|
|
21
|
+
|
|
22
|
+
The task runs in a job worker, never in the thread that ran the sketch. A job worker leaves the job system only between the chunks of a frame, so a frame never waits for a task, and with two or more job workers one stays for the frames.
|
|
23
|
+
|
|
24
|
+
The engine resolves the promise between two frames, so code in its `then` runs before the next frame's `onUpdate`, and that frame draws what the task wrote. Tasks run at the same time in different job workers, so their answers come in no fixed order. Await one task's answer before you queue the next when the order matters.
|
|
25
|
+
|
|
26
|
+
A `SharedArrayBuffer` in the input reaches the worker shared rather than copied, and the task writes into it. While the task runs, order the writes that both threads read with `Atomics`. Once the promise resolves, the worker has stopped writing, and the thread that ran the task reads the buffer as it stands. Such a buffer suits data too large to copy, such as the depths and order of many instances sorted in every frame.
|
|
27
|
+
|
|
28
|
+
The engine asks the page for job workers with the first task, and sends no task to one that did not start. Where no job worker takes the tasks, the engine starts a task worker for them, as on a page without worker threads.
|
|
29
|
+
|
|
30
|
+
The promise rejects with a `TaskFailure` when the task's module or WebAssembly fails to start, when its `run` throws, or when the engine stops before the answer arrives. A WebAssembly file that does not download or compile rejects with the engine's error.
|
|
31
|
+
|
|
32
|
+
Call it from the code that runs the sketch: the setup function or a callback. A task's input and output must pass to another worker: numbers, strings, plain objects and arrays, typed arrays, `ArrayBuffer`s, `SharedArrayBuffer`s and the objects that the transfer list names.
|
|
20
33
|
|
|
21
34
|
## `Task`
|
|
22
35
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: api/reference/terrain
|
|
3
3
|
title: "Terrain (@null3d/terrain): API reference"
|
|
4
|
-
|
|
5
|
-
since: "0.2"
|
|
4
|
+
generated: true
|
|
6
5
|
summary: "Every export of the Terrain (@null3d/terrain) API, from the engine's doc comments."
|
|
7
6
|
---
|
|
8
7
|
|
|
@@ -16,6 +15,8 @@ summary: "Every export of the Terrain (@null3d/terrain) API, from the engine's d
|
|
|
16
15
|
function createHeightfield(options: HeightfieldOptions): Heightfield
|
|
17
16
|
```
|
|
18
17
|
|
|
18
|
+
Import from `@null3d/terrain`.
|
|
19
|
+
|
|
19
20
|
Makes a height field. See `Heightfield`.
|
|
20
21
|
|
|
21
22
|
## `createTerrain`
|
|
@@ -24,12 +25,16 @@ Makes a height field. See `Heightfield`.
|
|
|
24
25
|
function createTerrain(context: SketchContext, options: TerrainOptions): Terrain
|
|
25
26
|
```
|
|
26
27
|
|
|
28
|
+
Import from `@null3d/terrain`.
|
|
29
|
+
|
|
27
30
|
Makes a terrain: a height field drawn as a quadtree of blocks with a splat-mapped surface. Call `terrain.update(eye)` with the camera's world position when it moves, and read `heightAt` and `normalAt` to place what stands on the ground. `terrain.destroy()` frees it.
|
|
28
31
|
|
|
29
32
|
## `Heightfield`
|
|
30
33
|
|
|
31
34
|
Class `Heightfield`.
|
|
32
35
|
|
|
36
|
+
Import from `@null3d/terrain`.
|
|
37
|
+
|
|
33
38
|
The height field that a terrain builds every block from: the height of a square piece of ground, sampled once and read back with bilinear interpolation.
|
|
34
39
|
|
|
35
40
|
| Member | Description |
|
|
@@ -49,6 +54,8 @@ The height field that a terrain builds every block from: the height of a square
|
|
|
49
54
|
|
|
50
55
|
Interface `HeightfieldOptions`.
|
|
51
56
|
|
|
57
|
+
Import from `@null3d/terrain`.
|
|
58
|
+
|
|
52
59
|
Options for `createHeightfield`.
|
|
53
60
|
|
|
54
61
|
| Member | Description |
|
|
@@ -63,12 +70,16 @@ Options for `createHeightfield`.
|
|
|
63
70
|
type SplatFunction = (x: number, z: number, out: number[]) => void;
|
|
64
71
|
```
|
|
65
72
|
|
|
73
|
+
Import from `@null3d/terrain`.
|
|
74
|
+
|
|
66
75
|
A weight of each layer at a point, written into `out` as red, green, blue and alpha.
|
|
67
76
|
|
|
68
77
|
## `Terrain`
|
|
69
78
|
|
|
70
79
|
Class `Terrain`.
|
|
71
80
|
|
|
81
|
+
Import from `@null3d/terrain`.
|
|
82
|
+
|
|
72
83
|
A ground drawn as a quadtree of blocks. `createTerrain` makes one.
|
|
73
84
|
|
|
74
85
|
| Member | Description |
|
|
@@ -81,6 +92,7 @@ A ground drawn as a quadtree of blocks. `createTerrain` makes one.
|
|
|
81
92
|
| `heightAt(x: number, z: number): number` | The height of the ground at a point, in meters, with bilinear interpolation between the samples of the height field. Allocates nothing. |
|
|
82
93
|
| `normalAt(x: number, z: number, out: number[] \| Float32Array): void` | The unit normal of the ground at a point, written into `out` as x, y and z, for placing an object that stands on the ground. Allocates nothing. |
|
|
83
94
|
| `update(eye: Vec3Like): void` | Picks the blocks to draw for a camera whose world position `eye` holds, as x, y and z. The ground picks again when the camera crosses a cell of the finest level, rises by one such cell, or draws through a different field of view or buffer height, so a still camera costs no work. The selection and the block build run in the add-on's WebAssembly module on the engine's job workers, so this call only asks for them. A new selection builds at most `blocksPerUpdate` blocks in one task, the first selection builds every block it needs, and the ground draws the selection it had until the new one is built. A block that the new selection needs takes the mesh of one that it left out. Call it in `onUpdate` with the camera's own position, in an array you keep: an array crosses the call as it is, where two fractions make the browser box each of them into an object. |
|
|
95
|
+
| `setTint(tint: readonly [number, number, number]): void` | Multiplies every layer's color, so a scene darkens its open ground with the hour: white leaves the ground as its maps give it. It sets the material's own color, which every block shares, so a value that holds still costs nothing. |
|
|
84
96
|
| `setMorph(enabled: boolean): void` | Turns the block morph on or off, from the next frame. The ground reads the selection's scale again with the last view, so a page that compares the look or measures the cost needs no new selection. |
|
|
85
97
|
| `setVisible(visible: boolean): void` | Shows or hides the whole ground, for a camera high above it. |
|
|
86
98
|
| `destroy(): void` | Destroys the ground: every block's object and mesh, and the material's own textures. |
|
|
@@ -89,6 +101,8 @@ A ground drawn as a quadtree of blocks. `createTerrain` makes one.
|
|
|
89
101
|
|
|
90
102
|
Interface `TerrainLayer`.
|
|
91
103
|
|
|
104
|
+
Import from `@null3d/terrain`.
|
|
105
|
+
|
|
92
106
|
One layer of the ground's surface: a tiled color map, and how rough it is.
|
|
93
107
|
|
|
94
108
|
| Member | Description |
|
|
@@ -103,6 +117,8 @@ One layer of the ground's surface: a tiled color map, and how rough it is.
|
|
|
103
117
|
|
|
104
118
|
Interface `TerrainOptions`.
|
|
105
119
|
|
|
120
|
+
Import from `@null3d/terrain`.
|
|
121
|
+
|
|
106
122
|
What `createTerrain` needs and what the ground may change.
|
|
107
123
|
|
|
108
124
|
| Member | Description |
|
|
@@ -119,10 +135,10 @@ What `createTerrain` needs and what the ground may change.
|
|
|
119
135
|
| `error?: number` | The screen error, in pixels, above which a block splits into four. The default is 35 times the quality preset's `lodThreshold`, so the ground draws with that preset's detail: Low picks coarser blocks. 0 keeps the finest level everywhere. |
|
|
120
136
|
| `bakedNormals?: boolean` | True lights every pixel from a normal map baked over the ground, which shows relief that a coarse block's vertices cannot. The default is true; false lights from the mesh's own normals. |
|
|
121
137
|
| `steepFaces?: boolean` | True maps the third layer, the rock, from the sides on a steep face, where a map laid from above stretches into streaks. It costs two more samples of that map. The default is false. |
|
|
122
|
-
| `skirt?: number` | How far the skirt around each block hangs down, in meters. The default is four of the block's cells, which closes the seam against a
|
|
138
|
+
| `skirt?: number` | How far the skirt around each block hangs down, in meters. The default is four of the block's cells, which closes the seam against a neighbor up to a level or two coarser. |
|
|
123
139
|
| `morph?: boolean` | True moves each block toward its parent block's surface as the camera pulls away, so a block that hands over to a coarser one does not pop. The default is true. False switches each block at once and keeps the block's vertices as they are. |
|
|
124
140
|
| `metalness?: number` | How much the ground acts like a metal, from 0 to 1. The default is 0. |
|
|
125
|
-
| `castShadows?: boolean` | True makes the ground cast the
|
|
141
|
+
| `castShadows?: boolean` | True makes the ground cast the shadows of the lights that cast them. The default is true. |
|
|
126
142
|
| `receiveShadows?: boolean` | True makes shadows fall on the ground. The default is true. |
|
|
127
143
|
| `maxBlocks?: number` | The most meshes the ground holds, from 16 up: a block that a selection leaves out gives up its mesh to the next block that needs one, so the ground stops building meshes once it holds this many. Its meshes wait for a block again until the count passes this figure. The default is 512. |
|
|
128
144
|
| `blocksPerUpdate?: number` | The most new blocks that one task builds, from 1 up. A camera that crosses into a new cell may need tens of blocks, and building them all at once would stall the frame. The ground draws its last complete selection until the new one is built. The first selection builds every block that it needs, over a few tasks, since there is no ground to draw before it. The default is 16. |
|
|
@@ -131,6 +147,8 @@ What `createTerrain` needs and what the ground may change.
|
|
|
131
147
|
|
|
132
148
|
Interface `TerrainTextureOptions`.
|
|
133
149
|
|
|
150
|
+
Import from `@null3d/terrain`.
|
|
151
|
+
|
|
134
152
|
How to make the layer maps.
|
|
135
153
|
|
|
136
154
|
| Member | Description |
|
|
@@ -144,12 +162,16 @@ How to make the layer maps.
|
|
|
144
162
|
function terrainTextures(textures: SketchContext['textures'], options: TerrainTextureOptions = {}): TerrainTextures
|
|
145
163
|
```
|
|
146
164
|
|
|
147
|
-
|
|
165
|
+
Import from `@null3d/terrain`.
|
|
166
|
+
|
|
167
|
+
Makes the four layer maps in code. Each is `size` texels across and repeats; the noise tiles, so the maps do too, and the same seed gives the same maps on every run. Each map keeps a height in its alpha channel, so a layer that reads its height from there pushes its clumps and stones through a neighbor at a boundary.
|
|
148
168
|
|
|
149
169
|
## `TerrainTextures`
|
|
150
170
|
|
|
151
171
|
Interface `TerrainTextures`.
|
|
152
172
|
|
|
173
|
+
Import from `@null3d/terrain`.
|
|
174
|
+
|
|
153
175
|
The four layer maps, ready for `TerrainLayer.map`.
|
|
154
176
|
|
|
155
177
|
| Member | Description |
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: api/reference/textures
|
|
3
3
|
title: "Textures: API reference"
|
|
4
|
-
|
|
5
|
-
since: "0.1"
|
|
4
|
+
generated: true
|
|
6
5
|
summary: "Every export of the Textures API, from the engine's doc comments."
|
|
7
6
|
---
|
|
8
7
|
|
|
@@ -122,11 +121,11 @@ How a texture stores and samples its texels. Every call that makes a texture tak
|
|
|
122
121
|
| Member | Description |
|
|
123
122
|
| --- | --- |
|
|
124
123
|
| `colorSpace?: TextureColorSpace` | `srgb` for color maps, such as a base color, and `linear` for data maps, such as normal, roughness, metalness and occlusion maps. The default is `srgb` for images and `linear` for data. |
|
|
125
|
-
| `wrap?: TextureWrap \| readonly [TextureWrap, TextureWrap]` | Along u, then v, or one value for both. The default is `clamp
|
|
124
|
+
| `wrap?: TextureWrap \| readonly [TextureWrap, TextureWrap]` | Along u, then v, or one value for both. The default is `clamp`. |
|
|
126
125
|
| `filter?: TextureFilter` | The filter of magnified and minified texels and between mip levels. The default is `linear`. |
|
|
127
126
|
| `mipmaps?: boolean` | True to make mip levels on the GPU after each upload, so the texture does not shimmer where it covers few pixels. The default is true for images and false for data. `rgba16float` textures have no mip levels. |
|
|
128
127
|
| `anisotropy?: number` | Samples along the direction of steepest change, a whole number from 1 to 16, which keeps a texture sharp on a surface seen at a slant. The quality preset caps it, and a `nearest` filter turns it off. The default is 1, which is off. |
|
|
129
|
-
| `uvSet?: 0 \| 1` | The set of texture coordinates that materials read the texture at: 0 for the first, 1 for the second
|
|
128
|
+
| `uvSet?: 0 \| 1` | The set of texture coordinates that materials read the texture at: 0 for the first, 1 for the second. The default is 0. |
|
|
130
129
|
|
|
131
130
|
## `Textures`
|
|
132
131
|
|
|
@@ -136,8 +135,8 @@ Makes textures from decoded images and from data, and reads what the GPU holds.
|
|
|
136
135
|
|
|
137
136
|
| Member | Description |
|
|
138
137
|
| --- | --- |
|
|
139
|
-
| `fromPass(pass: RenderPass): Texture` | The texture that a render pass draws into, which materials and sprites take as a map
|
|
140
|
-
| `fromImageBitmap(image: ImageBitmap, options: TextureOptions = {}): Texture` | A texture from a decoded image. The image's first row goes to v = 0, the bottom of a plane. Decode images with `imageOrientation: 'flipY'`, as `assets.loadImageBitmap` does by default, so that they stand upright
|
|
138
|
+
| `fromPass(pass: RenderPass): Texture` | The texture that a render pass draws into, which materials and sprites take as a map. It holds linear color, after the exposure and before the tone curve: high dynamic range color where the device draws it. The image stands upright on a plane, with v = 0 at its bottom row. A reflection pass's texture on the HDR WebGPU path is the one exception: its rows start at the top, so read it with `reflection_uv`. It samples as no texture until the pass first draws, and keeps the last image while the pass is switched off. `render.removePass` destroys it. Throws E1101 for a pass that was removed. |
|
|
139
|
+
| `fromImageBitmap(image: ImageBitmap, options: TextureOptions = {}): Texture` | A texture from a decoded image. The image's first row goes to v = 0, the bottom of a plane. Decode images with `imageOrientation: 'flipY'`, as `assets.loadImageBitmap` does by default, so that they stand upright on a plane. The image moves to the thread that draws, so this thread can use it no more. Throws E1208 for an image without pixels, one larger than `maxSize`, and options the engine does not know. |
|
|
141
140
|
| `fromCanvas(canvas: OffscreenCanvas \| HTMLCanvasElement, options: CanvasTextureOptions = {}): Texture` | A texture that follows a canvas, such as the `OffscreenCanvas` that the sketch draws a score, a map or a video frame on. The canvas's last row goes to v = 0, the bottom of a plane, so the canvas stands upright on a plane as on a page. Its texels upload as any image's do. `texture.refresh` then gives the texture the canvas's new pixels, and only those of the rectangle that changed. Throws E1208 for a canvas without a 2D context, or with no pixels. Call `getContext('2d', { willReadFrequently: true })` on the canvas, so the browser keeps its pixels where the engine reads them. |
|
|
142
141
|
| `fromVideo(name: string, options: TextureOptions = {}): Texture` | A texture that follows a video on the page, which `engine.registerVideo` registered under `name`. The page sends the image of each frame that the video presents, and the texture uploads the newest one in its turn, within the frame's upload budget. A paused video presents no frames, so its texture costs nothing then. The image stands upright on a plane, with v = 0 at its bottom row, as an image that `textures.fromImageBitmap` takes, and the first frame gives the texture its size. Until a frame is on the GPU, materials draw with their colors alone. Call this once for each video, and `texture.destroy` to stop the page's frames. Throws E1208 for a name that is not a string with at least one character, or that another texture follows. |
|
|
143
142
|
| `fromData(texture: TextureData): Texture` | A texture from data: four numbers per texel, in rows from the bottom up, layer after layer. A texture of several layers is a texture array of its own. Throws E1208 when the data does not fit the size and format, and for options the engine does not know. |
|