@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,130 @@
|
|
|
1
|
+
// The engine's rule for a mesh's levels of detail, as a sketch reads it: the distance at which one
|
|
2
|
+
// of a part's levels switches in, the distances at which a view measures a part's bounds, and the
|
|
3
|
+
// level that a distance picks. The core picks the level of every source that a frame draws by this
|
|
4
|
+
// rule (`crates/null3d-core/src/levels.rs`), so a scene that budgets its triangles asks the same
|
|
5
|
+
// rule instead of copying it. A copy is a shadow of the core and drifts from it as soon as the
|
|
6
|
+
// core's figures change.
|
|
7
|
+
//
|
|
8
|
+
// A level's switch measure is its error, a hand-set distance, or the share of the render's height
|
|
9
|
+
// that the bounds cover. An error is the largest distance between the level's surface and the base
|
|
10
|
+
// mesh's, in the units of the base mesh's positions. The switch distance follows:
|
|
11
|
+
//
|
|
12
|
+
// ```text
|
|
13
|
+
// error: error × scale × factor / bias
|
|
14
|
+
// distance: distance × scale / bias
|
|
15
|
+
// coverage: radius × P[1][1] / (coverage × bias)
|
|
16
|
+
// ```
|
|
17
|
+
//
|
|
18
|
+
// `scale` is the largest axis scale of the source's world matrix and `factor` is the render height
|
|
19
|
+
// in pixels times the projection's `P[1][1]`, over twice the threshold in pixels. A level given by
|
|
20
|
+
// its error is compared with a distance halfway into the bounds, so a large mesh keeps its fine
|
|
21
|
+
// levels until its near side shows them; a level given by a distance or by a coverage, and a
|
|
22
|
+
// distance band, compare the distance to the bounds' nearest point.
|
|
23
|
+
/**
|
|
24
|
+
* The smallest distance that the rule measures, in meters: a camera inside the bounds reads it.
|
|
25
|
+
*
|
|
26
|
+
* @category api/geometry
|
|
27
|
+
*/
|
|
28
|
+
export const LEAST_LEVEL_DISTANCE = 1e-3;
|
|
29
|
+
/** The share of the bounds' radius that an error's distance takes off the distance to the center. */
|
|
30
|
+
const ERROR_RADIUS_SHARE = 0.5;
|
|
31
|
+
/** The multiple of the distance to the nearest point that caps an error's distance. */
|
|
32
|
+
const ERROR_NEAREST_SHARE = 2;
|
|
33
|
+
/** The projection's `P[1][1]` for a perspective view of `fov` degrees, which a coverage reads. */
|
|
34
|
+
function projection(fov) {
|
|
35
|
+
return Math.abs(1 / Math.tan((fov * Math.PI) / 360));
|
|
36
|
+
}
|
|
37
|
+
/** The factor that turns a level's error into a switch distance: height × `P[1][1]` / (2 × threshold). */
|
|
38
|
+
function factor(view) {
|
|
39
|
+
const threshold = view.threshold ?? 1;
|
|
40
|
+
return threshold > 0 && view.height > 0
|
|
41
|
+
? (view.height * projection(view.fov)) / (2 * threshold)
|
|
42
|
+
: 0;
|
|
43
|
+
}
|
|
44
|
+
/** The source's threshold bias, and 1 for a bias that is not above 0. */
|
|
45
|
+
function bias(view) {
|
|
46
|
+
const value = view.bias ?? 1;
|
|
47
|
+
return value > 0 ? value : 1;
|
|
48
|
+
}
|
|
49
|
+
/** The distance at which a level switches in, given the view's factor and bias. */
|
|
50
|
+
function switchDistance(view, levelFactor, level, scale, radius) {
|
|
51
|
+
if ('error' in level)
|
|
52
|
+
return (level.error * scale * levelFactor) / bias(view);
|
|
53
|
+
if ('distance' in level)
|
|
54
|
+
return (level.distance * scale) / bias(view);
|
|
55
|
+
const p11 = projection(view.fov);
|
|
56
|
+
return level.coverage > 0 && p11 > 0
|
|
57
|
+
? (radius * p11) / (level.coverage * bias(view))
|
|
58
|
+
: Number.POSITIVE_INFINITY;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The distance at which one of a part's levels switches in.
|
|
62
|
+
*
|
|
63
|
+
* An error switches where it covers the view's threshold in pixels; a distance at its own figure,
|
|
64
|
+
* scaled by the source; and a coverage where the bounds' radius covers that share of the render
|
|
65
|
+
* height. A bias above 1 divides every result, so the level switches nearer.
|
|
66
|
+
*
|
|
67
|
+
* @param view The view that measures the level.
|
|
68
|
+
* @param level The level's switch measure.
|
|
69
|
+
* @param scale The largest axis scale of the source's world matrix.
|
|
70
|
+
* @param radius The radius of the source's world bounds, in meters, which a coverage reads.
|
|
71
|
+
* @returns The distance in meters at which the level draws, or `Infinity` for a coverage that is
|
|
72
|
+
* not above 0.
|
|
73
|
+
* @category api/geometry
|
|
74
|
+
*/
|
|
75
|
+
export function levelSwitchDistance(view, level, scale, radius = 0) {
|
|
76
|
+
return switchDistance(view, factor(view), level, scale, radius);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Both distances that a view's rule compares for a source's bounds. An error measures to a point
|
|
80
|
+
* halfway into the sphere, capped at twice the distance to its nearest point, so a camera beside a
|
|
81
|
+
* large mesh measures the surface below it. A distance or a coverage, and a distance band, measure
|
|
82
|
+
* to the nearest point. Both are at least `LEAST_LEVEL_DISTANCE`. An orthographic view compares an
|
|
83
|
+
* error at a distance of 1, since its pixels do not shrink with distance, and keeps the nearest
|
|
84
|
+
* point for the other measures.
|
|
85
|
+
*
|
|
86
|
+
* @param view The view that measures the source.
|
|
87
|
+
* @param bounds The source's bounds, with the center relative to the camera.
|
|
88
|
+
* @returns The two distances, in meters.
|
|
89
|
+
* @category api/geometry
|
|
90
|
+
*/
|
|
91
|
+
export function levelDistances(view, bounds) {
|
|
92
|
+
const [x, y, z] = bounds.centre;
|
|
93
|
+
const length = Math.hypot(x, y, z);
|
|
94
|
+
const nearest = (radius) => Math.max(length - radius, LEAST_LEVEL_DISTANCE);
|
|
95
|
+
const camera = nearest(bounds.radius);
|
|
96
|
+
const error = view.orthographic
|
|
97
|
+
? 1
|
|
98
|
+
: Math.min(nearest(ERROR_RADIUS_SHARE * bounds.radius), ERROR_NEAREST_SHARE * nearest(bounds.radius));
|
|
99
|
+
return { camera, error };
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The level of detail that a source draws: 0 for the base mesh, 1 for the first lower level, and so
|
|
103
|
+
* on, as `setLevels` takes them. The level is the last one whose switch distance lies under the
|
|
104
|
+
* distance, which is how the core's culling picks every source. This gives the level alone, not
|
|
105
|
+
* whether the source draws at all: a bound that covers fewer pixels than the threshold is hidden,
|
|
106
|
+
* and a draw range hides a source outside it.
|
|
107
|
+
*
|
|
108
|
+
* @param view The view that measures the levels.
|
|
109
|
+
* @param levels The lower levels, from the finest to the coarsest.
|
|
110
|
+
* @param scale The largest axis scale of the source's world matrix.
|
|
111
|
+
* @param radius The radius of the source's world bounds, in meters, which a coverage reads.
|
|
112
|
+
* @param distance A distance, which both measures read as a camera does, or the two distances that
|
|
113
|
+
* `levelDistances` gives.
|
|
114
|
+
* @returns The level's index among the base mesh and `levels`.
|
|
115
|
+
* @category api/geometry
|
|
116
|
+
*/
|
|
117
|
+
export function levelAt(view, levels, scale, radius, distance) {
|
|
118
|
+
const levelFactor = factor(view);
|
|
119
|
+
if (!(levelFactor > 0) || levels.length === 0)
|
|
120
|
+
return 0;
|
|
121
|
+
const at = typeof distance === 'number' ? { camera: distance, error: distance } : distance;
|
|
122
|
+
let level = 0;
|
|
123
|
+
for (const measure of levels) {
|
|
124
|
+
const compare = 'error' in measure ? at.error : at.camera;
|
|
125
|
+
if (!(switchDistance(view, levelFactor, measure, scale, radius) < compare))
|
|
126
|
+
break;
|
|
127
|
+
level++;
|
|
128
|
+
}
|
|
129
|
+
return level;
|
|
130
|
+
}
|
package/lib/scene/lines.d.ts
CHANGED
|
@@ -3,17 +3,16 @@ import type { ObjectEventHandler, ObjectEventType, PointerRows } from './pointer
|
|
|
3
3
|
import type { Blending, Geometry, MaterialFeatures, MaterialOptions, Materials, MeshGeometry, StandardValues } from './resources.js';
|
|
4
4
|
import type { Vec3 } from './scene.js';
|
|
5
5
|
/**
|
|
6
|
-
* Which points each segment joins. With `segments`, each pair of points makes a segment
|
|
7
|
-
*
|
|
8
|
-
* `loop`, the last point also joins the first, like `LineLoop`.
|
|
6
|
+
* Which points each segment joins. With `segments`, each pair of points makes a segment. With
|
|
7
|
+
* `strip`, every point joins the next. With `loop`, the last point also joins the first.
|
|
9
8
|
*
|
|
10
9
|
* @category api/lines
|
|
11
10
|
*/
|
|
12
11
|
export type LineMode = 'segments' | 'strip' | 'loop';
|
|
13
12
|
/**
|
|
14
13
|
* The values of a line batch's material, which `lines.material.set` changes at any time. The dash
|
|
15
|
-
* values act on dashed lines,
|
|
16
|
-
*
|
|
14
|
+
* values act on dashed lines. The metalness, roughness and emissive values act on lit lines, as a
|
|
15
|
+
* standard material takes them.
|
|
17
16
|
*
|
|
18
17
|
* @category api/lines
|
|
19
18
|
*/
|
|
@@ -51,22 +50,19 @@ export interface LineOptions extends LineValues, Pick<MaterialFeatures, 'fog' |
|
|
|
51
50
|
colors?: ArrayLike<number>;
|
|
52
51
|
/** Which points each segment joins. The default is `strip`. */
|
|
53
52
|
mode?: LineMode;
|
|
54
|
-
/**
|
|
55
|
-
* The width of the lines: CSS pixels, or world units with `worldUnits`. The default is 1, as
|
|
56
|
-
* three.js's `linewidth`.
|
|
57
|
-
*/
|
|
53
|
+
/** The width of the lines: CSS pixels, or world units with `worldUnits`. The default is 1. */
|
|
58
54
|
width?: number;
|
|
59
55
|
/**
|
|
60
|
-
* True gives the width in world units, so far lines look thinner
|
|
61
|
-
*
|
|
56
|
+
* True gives the width in world units, so far lines look thinner. False gives it in CSS pixels,
|
|
57
|
+
* so every line keeps its width on screen. The default is false.
|
|
62
58
|
*/
|
|
63
59
|
worldUnits?: boolean;
|
|
64
60
|
/** Draws the lines as dashes, which `dashSize`, `gapSize` and the other dash values shape. */
|
|
65
61
|
dashed?: boolean;
|
|
66
62
|
/**
|
|
67
63
|
* Lights the lines as a standard material lights a surface that faces the camera: the sun, the
|
|
68
|
-
* point and spot lights and the ambient light shade them. False draws the color as it is,
|
|
69
|
-
*
|
|
64
|
+
* point and spot lights and the ambient light shade them. False draws the color as it is,
|
|
65
|
+
* whatever the lights. The default is false.
|
|
70
66
|
*/
|
|
71
67
|
lit?: boolean;
|
|
72
68
|
/** Every point updates and uploads every frame; a static batch updates points marked dirty only. */
|
|
@@ -79,7 +75,7 @@ export interface LineOptions extends LineValues, Pick<MaterialFeatures, 'fog' |
|
|
|
79
75
|
* the world's origin.
|
|
80
76
|
*/
|
|
81
77
|
origin?: Vec3;
|
|
82
|
-
/** How the lines use their opacity. The default is `opaque
|
|
78
|
+
/** How the lines use their opacity. The default is `opaque`. */
|
|
83
79
|
alphaMode?: 'opaque' | 'blend';
|
|
84
80
|
}
|
|
85
81
|
/** What a line batch's segment mesh and material are made with: the engine's objects. */
|
|
@@ -134,9 +130,9 @@ export interface LineBatchRows extends PointerRows {
|
|
|
134
130
|
}
|
|
135
131
|
/**
|
|
136
132
|
* Lines of any width: segments between points, each drawn as a quad with round ends that faces the
|
|
137
|
-
* camera
|
|
138
|
-
*
|
|
139
|
-
*
|
|
133
|
+
* camera. Write points straight into the typed arrays, as for an instance batch. A dynamic batch
|
|
134
|
+
* updates every segment every frame, and a static batch updates the segments of the points you
|
|
135
|
+
* mark dirty.
|
|
140
136
|
*
|
|
141
137
|
* @category api/lines
|
|
142
138
|
*/
|
package/lib/scene/lines.js
CHANGED
|
@@ -136,9 +136,9 @@ export function lineParts({ geometry, materials }, core, mesh, options, checks,
|
|
|
136
136
|
const NO_POINTS = { positions: new Float32Array(0), colors: new Float32Array(0) };
|
|
137
137
|
/**
|
|
138
138
|
* Lines of any width: segments between points, each drawn as a quad with round ends that faces the
|
|
139
|
-
* camera
|
|
140
|
-
*
|
|
141
|
-
*
|
|
139
|
+
* camera. Write points straight into the typed arrays, as for an instance batch. A dynamic batch
|
|
140
|
+
* updates every segment every frame, and a static batch updates the segments of the points you
|
|
141
|
+
* mark dirty.
|
|
142
142
|
*
|
|
143
143
|
* @category api/lines
|
|
144
144
|
*/
|
package/lib/scene/lut.d.ts
CHANGED
|
@@ -30,8 +30,7 @@ export interface LutData {
|
|
|
30
30
|
/**
|
|
31
31
|
* A color grading table, which `assets.loadLut` loads from a file and `assets.lutFromData` makes
|
|
32
32
|
* from numbers. It is a 3D texture that maps each color of the picture to its graded color. Give
|
|
33
|
-
* it to `post.set({ lut })`, which applies it to every pixel after the tone mapping
|
|
34
|
-
* `LUTPass` does.
|
|
33
|
+
* it to `post.set({ lut })`, which applies it to every pixel after the tone mapping.
|
|
35
34
|
*
|
|
36
35
|
* @category api/assets
|
|
37
36
|
*/
|
package/lib/scene/lut.js
CHANGED
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* A color grading table, which `assets.loadLut` loads from a file and `assets.lutFromData` makes
|
|
6
6
|
* from numbers. It is a 3D texture that maps each color of the picture to its graded color. Give
|
|
7
|
-
* it to `post.set({ lut })`, which applies it to every pixel after the tone mapping
|
|
8
|
-
* `LUTPass` does.
|
|
7
|
+
* it to `post.set({ lut })`, which applies it to every pixel after the tone mapping.
|
|
9
8
|
*
|
|
10
9
|
* @category api/assets
|
|
11
10
|
*/
|
package/lib/scene/particles.d.ts
CHANGED
|
@@ -198,8 +198,10 @@ export interface ParticleBufferOptions extends ParticleValues {
|
|
|
198
198
|
/**
|
|
199
199
|
* Where an emitter's particles are born, in its own space, and which way they set off. A `point`
|
|
200
200
|
* emits at the emitter, along `direction`. A `sphere` emits inside a ball of `radius`, or on its
|
|
201
|
-
* surface with `surface`, and sends particles outward.
|
|
202
|
-
*
|
|
201
|
+
* surface with `surface`, and sends particles outward.
|
|
202
|
+
*
|
|
203
|
+
* A `cone` emits on a disc of `radius` across the emitter's +y axis. It sends particles up within
|
|
204
|
+
* `angle` radians of that axis. A `box` emits
|
|
203
205
|
* inside a box of `size`, centered on the emitter, along `direction`. A `disc` emits on a disc of
|
|
204
206
|
* `radius` across the +y axis, along `direction`.
|
|
205
207
|
*
|
|
@@ -294,7 +296,9 @@ export interface ParticleEmitterOptions {
|
|
|
294
296
|
* particles add-on's emitters write records into it. Write a particle's record once, when it is
|
|
295
297
|
* born, with `write`, or write a frame's births in one call with `writeRecords`. The GPU moves it
|
|
296
298
|
* and changes its look as it ages, as the buffer's values say. It stops drawing the particle at
|
|
297
|
-
* the end of its lifetime.
|
|
299
|
+
* the end of its lifetime.
|
|
300
|
+
*
|
|
301
|
+
* Once per frame, write the buffer's time and the records the GPU reads
|
|
298
302
|
* into `frame`, and call `commit`. Every call takes typed arrays and whole numbers, so a frame's
|
|
299
303
|
* calls allocate nothing.
|
|
300
304
|
*
|
package/lib/scene/particles.js
CHANGED
|
@@ -202,7 +202,9 @@ const NO_FLOAT64 = new Float64Array(0);
|
|
|
202
202
|
* particles add-on's emitters write records into it. Write a particle's record once, when it is
|
|
203
203
|
* born, with `write`, or write a frame's births in one call with `writeRecords`. The GPU moves it
|
|
204
204
|
* and changes its look as it ages, as the buffer's values say. It stops drawing the particle at
|
|
205
|
-
* the end of its lifetime.
|
|
205
|
+
* the end of its lifetime.
|
|
206
|
+
*
|
|
207
|
+
* Once per frame, write the buffer's time and the records the GPU reads
|
|
206
208
|
* into `frame`, and call `commit`. Every call takes typed arrays and whole numbers, so a frame's
|
|
207
209
|
* calls allocate nothing.
|
|
208
210
|
*
|
package/lib/scene/picks.d.ts
CHANGED
|
@@ -14,8 +14,8 @@ export interface PickHit {
|
|
|
14
14
|
instance: number;
|
|
15
15
|
/**
|
|
16
16
|
* Where on the surface the pixel landed, as the first texture coordinates of the hit triangle
|
|
17
|
-
* blended across its three corners
|
|
18
|
-
*
|
|
17
|
+
* blended across its three corners. Read `hasUv` first: the numbers mean nothing when it is
|
|
18
|
+
* false.
|
|
19
19
|
*/
|
|
20
20
|
uv?: Vec2Like;
|
|
21
21
|
/**
|
|
@@ -40,16 +40,13 @@ export interface ObjectPointerEvent {
|
|
|
40
40
|
readonly normal: Vec3Like;
|
|
41
41
|
/** The distance from the ray's origin to the hit, in meters. */
|
|
42
42
|
readonly distance: number;
|
|
43
|
-
/**
|
|
44
|
-
* The index of the hit triangle in its mesh, as three.js's `faceIndex`, or -1 for a sprite, a
|
|
45
|
-
* point or a line.
|
|
46
|
-
*/
|
|
43
|
+
/** The index of the hit triangle in its mesh, or -1 for a sprite, a point or a line. */
|
|
47
44
|
readonly triangle: number;
|
|
48
45
|
/**
|
|
49
46
|
* Where on the surface the ray hit, as the first texture coordinates of the hit triangle
|
|
50
|
-
* blended across its three corners
|
|
51
|
-
*
|
|
52
|
-
*
|
|
47
|
+
* blended across its three corners. Read `hasUv` first: the numbers mean nothing when it is
|
|
48
|
+
* false. An in-world screen turns a click into a texel of its image with these, without working
|
|
49
|
+
* out where the surface lies in space.
|
|
53
50
|
*/
|
|
54
51
|
readonly uv: Vec2Like;
|
|
55
52
|
/**
|
package/lib/scene/post.d.ts
CHANGED
|
@@ -13,11 +13,13 @@ import { ShaderTemplates } from './shader-templates.js';
|
|
|
13
13
|
import type { UniformValues } from './wgsl-uniforms.js';
|
|
14
14
|
export type { GradingSettings, SplitToningSettings, WhiteBalanceSettings, } from './grading.js';
|
|
15
15
|
/**
|
|
16
|
-
* How the engine maps the scene's high dynamic range color to the screen.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
16
|
+
* How the engine maps the scene's high dynamic range color to the screen. The `'agx'` curve is
|
|
17
|
+
* AgX, the curve of Blender and Filament. The `'agx-punchy'` curve is AgX with Filament's punchy
|
|
18
|
+
* look, which adds contrast and color. The `'neutral'` curve is Khronos PBR Neutral, which keeps
|
|
19
|
+
* base colors as they are until they near white. The `'aces'` curve is a fit of the ACES filmic
|
|
20
|
+
* curve, which first scales the color by 1 / 0.6 and shifts the hues of bright colors.
|
|
21
|
+
*
|
|
22
|
+
* The value `'none'` clips the exposed color at 1.
|
|
21
23
|
*
|
|
22
24
|
* @category api/post
|
|
23
25
|
*/
|
|
@@ -39,9 +41,9 @@ export type ToneCurve = CompiledWgsl | `${string}toneCurve${string}`;
|
|
|
39
41
|
export declare function exposureOfEv100(ev100: number): number;
|
|
40
42
|
/**
|
|
41
43
|
* How bloom's glow meets the scene's color. The `'mix'` blend moves each pixel's color toward the
|
|
42
|
-
* glow by the intensity, which keeps the image's total light. The `'add'` blend adds the glow,
|
|
43
|
-
*
|
|
44
|
-
*
|
|
44
|
+
* glow by the intensity, which keeps the image's total light. The `'add'` blend adds the glow, so
|
|
45
|
+
* the image gains light. The `'screen'` blend screens it, so the glow adds less where the scene is
|
|
46
|
+
* already bright.
|
|
45
47
|
*
|
|
46
48
|
* @category api/post
|
|
47
49
|
*/
|
|
@@ -82,7 +84,7 @@ export interface BloomSettings {
|
|
|
82
84
|
weights?: readonly number[];
|
|
83
85
|
}
|
|
84
86
|
/**
|
|
85
|
-
* Ambient occlusion's settings,
|
|
87
|
+
* Ambient occlusion's settings, for ground-truth ambient occlusion (GTAO). A setting that a call
|
|
86
88
|
* leaves out keeps its value.
|
|
87
89
|
*
|
|
88
90
|
* @category api/post
|
|
@@ -90,7 +92,7 @@ export interface BloomSettings {
|
|
|
90
92
|
export interface AoSettings {
|
|
91
93
|
/**
|
|
92
94
|
* How far from a surface the search for what hides it reaches, in world units: 0 or more, and
|
|
93
|
-
* 0.25 by default
|
|
95
|
+
* 0.25 by default.
|
|
94
96
|
*/
|
|
95
97
|
radius?: number;
|
|
96
98
|
/**
|
|
@@ -105,8 +107,7 @@ export interface AoSettings {
|
|
|
105
107
|
*/
|
|
106
108
|
distanceExponent?: number;
|
|
107
109
|
/**
|
|
108
|
-
* From 0 to 1: how much less the farther steps of the search count. It is 1 by default
|
|
109
|
-
* `GTAOPass`'s `distanceFallOff`.
|
|
110
|
+
* From 0 to 1: how much less the farther steps of the search count. It is 1 by default.
|
|
110
111
|
*/
|
|
111
112
|
distanceFalloff?: number;
|
|
112
113
|
/** The power that the occlusion is raised to: 0 or more, and 1 by default. Above 1 it darkens. */
|
|
@@ -117,33 +118,31 @@ export interface AoSettings {
|
|
|
117
118
|
*/
|
|
118
119
|
samples?: number;
|
|
119
120
|
/**
|
|
120
|
-
* From 0 to 1: how much of the occlusion reaches the ambient light. It is 1 by default
|
|
121
|
-
* `GTAOPass`'s `blendIntensity`.
|
|
121
|
+
* From 0 to 1: how much of the occlusion reaches the ambient light. It is 1 by default.
|
|
122
122
|
*/
|
|
123
123
|
intensity?: number;
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
|
-
* Screen-space reflections' settings
|
|
127
|
-
* call leaves out keeps its value.
|
|
126
|
+
* Screen-space reflections' settings. A setting that a call leaves out keeps its value.
|
|
128
127
|
*
|
|
129
128
|
* @category api/post
|
|
130
129
|
*/
|
|
131
130
|
export interface SsrSettings {
|
|
132
131
|
/**
|
|
133
132
|
* From 0 to 1: how much of the environment's reflection the screen's reflection replaces where
|
|
134
|
-
* a ray hits, and 1 by default
|
|
135
|
-
*
|
|
133
|
+
* a ray hits, and 1 by default. The material's Fresnel term, metalness and specular values
|
|
134
|
+
* still weigh the reflection.
|
|
136
135
|
*/
|
|
137
136
|
intensity?: number;
|
|
138
137
|
/**
|
|
139
|
-
* How far a reflected ray travels, in world units: above 0, and 100 by default
|
|
140
|
-
*
|
|
138
|
+
* How far a reflected ray travels, in world units: above 0, and 100 by default. Reflections
|
|
139
|
+
* fade out over the last fifth of it.
|
|
141
140
|
*/
|
|
142
141
|
maxDistance?: number;
|
|
143
142
|
/**
|
|
144
|
-
* How far behind a surface on the screen a ray may pass and still hit it, in world units
|
|
145
|
-
* more, and 0.5 by default
|
|
146
|
-
*
|
|
143
|
+
* How far behind a surface on the screen a ray may pass and still hit it, in world units. It is
|
|
144
|
+
* 0 or more, and 0.5 by default. Thin objects need a small value, or objects behind them
|
|
145
|
+
* reflect as if they were solid.
|
|
147
146
|
*/
|
|
148
147
|
thickness?: number;
|
|
149
148
|
/**
|
|
@@ -316,23 +315,22 @@ export interface PostSettings {
|
|
|
316
315
|
/**
|
|
317
316
|
* How the engine maps high dynamic range color to the screen: a built-in curve's name, or a
|
|
318
317
|
* custom tone curve's WGSL. The default is `'agx-punchy'`, which keeps the hues of bright colors
|
|
319
|
-
* on their way to white and keeps the picture's contrast.
|
|
320
|
-
*
|
|
321
|
-
* color, as bloom does; on a device without an HDR target the built-in curve stays.
|
|
318
|
+
* on their way to white and keeps the picture's contrast. A custom curve needs HDR color, as
|
|
319
|
+
* bloom does; on a device without an HDR target the built-in curve stays.
|
|
322
320
|
*/
|
|
323
321
|
toneMapping?: ToneMapping | ToneCurve;
|
|
324
322
|
/**
|
|
325
|
-
* Scales the scene's color before the tone mapping,
|
|
326
|
-
*
|
|
327
|
-
*
|
|
323
|
+
* Scales the scene's color before the tone mapping: 2 is one stop brighter, and 0.5 one stop
|
|
324
|
+
* darker. It is 0 or more, and 1 by default. With `ev100`, it scales the camera's exposure, as
|
|
325
|
+
* exposure compensation does.
|
|
328
326
|
*/
|
|
329
327
|
exposure?: number;
|
|
330
328
|
/**
|
|
331
329
|
* The camera's exposure value at ISO 100, for lights in real units: 15 suits a sunny day lit by
|
|
332
330
|
* a sun of 100,000 lux, 12 an overcast day, and 7 a lit room. It scales the scene's color by
|
|
333
331
|
* 1 / (1.2 × 2^ev100), as Filament and Bevy do, so each step up is one stop darker. It is a
|
|
334
|
-
* number from -20 to 30,
|
|
335
|
-
*
|
|
332
|
+
* number from -20 to 30. The default, `false`, turns it off, for scenes whose lights have small
|
|
333
|
+
* intensities, such as a sun of 3.
|
|
336
334
|
*/
|
|
337
335
|
ev100?: number | false;
|
|
338
336
|
/**
|
|
@@ -343,21 +341,20 @@ export interface PostSettings {
|
|
|
343
341
|
bloom?: BloomSettings | false;
|
|
344
342
|
/**
|
|
345
343
|
* Ambient occlusion: darkens the ambient light where nearby surfaces hide a surface from the
|
|
346
|
-
* sky,
|
|
347
|
-
*
|
|
348
|
-
* and `false` turns it off. It is off by default, and draws only where the
|
|
349
|
-
* `aoScale` is above 0.
|
|
344
|
+
* sky, found with ground-truth ambient occlusion (GTAO). It darkens only the light that comes
|
|
345
|
+
* from all around, so direct light keeps its strength. Settings turn it on, `{}` with the
|
|
346
|
+
* values it had, and `false` turns it off. It is off by default, and draws only where the
|
|
347
|
+
* quality setting `aoScale` is above 0.
|
|
350
348
|
*/
|
|
351
349
|
ao?: AoSettings | false;
|
|
352
350
|
/**
|
|
353
351
|
* A color grading table from `assets.loadLut` or `assets.lutFromData`, which maps each pixel's
|
|
354
|
-
* color after the tone mapping
|
|
355
|
-
* by default.
|
|
352
|
+
* color after the tone mapping. `false` turns it off. It is off by default.
|
|
356
353
|
*/
|
|
357
354
|
lut?: Lut | false;
|
|
358
355
|
/**
|
|
359
|
-
* The share of the table's color in each pixel, from 0 for none to 1 for all of it
|
|
360
|
-
*
|
|
356
|
+
* The share of the table's color in each pixel, from 0 for none to 1 for all of it. It is 1 by
|
|
357
|
+
* default.
|
|
361
358
|
*/
|
|
362
359
|
lutIntensity?: number;
|
|
363
360
|
/**
|
|
@@ -380,10 +377,9 @@ export interface PostSettings {
|
|
|
380
377
|
outline?: OutlineSettings | false;
|
|
381
378
|
/**
|
|
382
379
|
* Depth of field: blurs what lies in front of and behind the focus distance, as a camera lens
|
|
383
|
-
* does
|
|
384
|
-
*
|
|
385
|
-
*
|
|
386
|
-
* `dofSamples` is above 0.
|
|
380
|
+
* does. The near and far fields blur apart. It runs after the custom effects and before bloom.
|
|
381
|
+
* Settings turn it on, `{}` with the values it had, and `false` turns it off. It is off by
|
|
382
|
+
* default, and draws only where the quality setting `dofSamples` is above 0.
|
|
387
383
|
*/
|
|
388
384
|
dof?: DofSettings | false;
|
|
389
385
|
/**
|
package/lib/scene/post.js
CHANGED
|
@@ -15,6 +15,7 @@ import { EngineError } from '../errors/engine-error.js';
|
|
|
15
15
|
import { reasonOf } from '../errors/message.js';
|
|
16
16
|
import * as C from '../generated/core.js';
|
|
17
17
|
import { hexValue, invalidColor } from '../math/hex.js';
|
|
18
|
+
import { importOnce } from '../shared/import-once.js';
|
|
18
19
|
import { writeLinearColor } from './color.js';
|
|
19
20
|
import { EffectChain } from './effects.js';
|
|
20
21
|
import { Lut } from './lut.js';
|
|
@@ -911,13 +912,15 @@ function checkGrading(grading) {
|
|
|
911
912
|
checkRange('grading.splitToning.balance', split.balance, -1, 1);
|
|
912
913
|
checkRange('grading.splitToning.strength', split.strength, 0, 1);
|
|
913
914
|
}
|
|
915
|
+
/** The full-screen feature adapter's module, shared by every call that waits for it. */
|
|
916
|
+
const featureEffectCode = importOnce(() => import('./feature-effects.js'));
|
|
914
917
|
/**
|
|
915
918
|
* The full-screen feature adapter, which loads at the first call that places a feature, so a page
|
|
916
919
|
* that places none downloads none of it. Throws E1406 when its code does not download.
|
|
917
920
|
*/
|
|
918
921
|
async function loadFeatureEffects(call) {
|
|
919
922
|
try {
|
|
920
|
-
return await
|
|
923
|
+
return await featureEffectCode();
|
|
921
924
|
}
|
|
922
925
|
catch (error) {
|
|
923
926
|
throw new EngineError('E1406', `the feature effect code did not download for ${call}(): ${reasonOf(error)}.`);
|
package/lib/scene/prefab.d.ts
CHANGED
|
@@ -90,14 +90,13 @@ export declare class Prefab {
|
|
|
90
90
|
readonly textures: readonly Texture[];
|
|
91
91
|
private destroyed;
|
|
92
92
|
/**
|
|
93
|
-
* Destroys the model
|
|
94
|
-
* texture
|
|
95
|
-
*
|
|
96
|
-
* the
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* the model throw E1101.
|
|
93
|
+
* Destroys the model. It frees the GPU memory and the engine data of every mesh, material and
|
|
94
|
+
* texture that the load made, and of its skeleton and animation clips. Destroy the copies that
|
|
95
|
+
* `scene.instantiate` and `scene.createInstances` made first, and the objects that use one of
|
|
96
|
+
* its meshes or materials, in the same frame or before. Throws E1111 while one still does, and
|
|
97
|
+
* E1101 for a model that is destroyed already. Materials of your own that map one of the
|
|
98
|
+
* model's textures draw with their colors alone afterwards. Later calls that pass the model
|
|
99
|
+
* throw E1101.
|
|
101
100
|
*/
|
|
102
101
|
destroy(): void;
|
|
103
102
|
/** The names of the model's clips, which a copy's animator plays. */
|
package/lib/scene/prefab.js
CHANGED
|
@@ -67,14 +67,13 @@ export class Prefab {
|
|
|
67
67
|
this.properties = properties;
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
|
-
* Destroys the model
|
|
71
|
-
* texture
|
|
72
|
-
*
|
|
73
|
-
* the
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* the model throw E1101.
|
|
70
|
+
* Destroys the model. It frees the GPU memory and the engine data of every mesh, material and
|
|
71
|
+
* texture that the load made, and of its skeleton and animation clips. Destroy the copies that
|
|
72
|
+
* `scene.instantiate` and `scene.createInstances` made first, and the objects that use one of
|
|
73
|
+
* its meshes or materials, in the same frame or before. Throws E1111 while one still does, and
|
|
74
|
+
* E1101 for a model that is destroyed already. Materials of your own that map one of the
|
|
75
|
+
* model's textures draw with their colors alone afterwards. Later calls that pass the model
|
|
76
|
+
* throw E1101.
|
|
78
77
|
*/
|
|
79
78
|
destroy() {
|
|
80
79
|
const call = 'prefab.destroy';
|
|
@@ -144,7 +144,7 @@ export declare class PropertyAnimation {
|
|
|
144
144
|
get loop(): boolean;
|
|
145
145
|
/** The rate of the animation's time: 1 plays it as made, and a negative rate plays it backward. */
|
|
146
146
|
get speed(): number;
|
|
147
|
-
/** Sets the animation's time in seconds
|
|
147
|
+
/** Sets the animation's time in seconds. */
|
|
148
148
|
setTime(seconds: number): void;
|
|
149
149
|
/** Starts or stops the time, without changing the value that the target holds. */
|
|
150
150
|
setPaused(paused: boolean): void;
|
|
@@ -220,7 +220,7 @@ export class PropertyAnimation {
|
|
|
220
220
|
get speed() {
|
|
221
221
|
return this.rate;
|
|
222
222
|
}
|
|
223
|
-
/** Sets the animation's time in seconds
|
|
223
|
+
/** Sets the animation's time in seconds. */
|
|
224
224
|
setTime(seconds) {
|
|
225
225
|
this.seconds = seconds;
|
|
226
226
|
}
|
package/lib/scene/queries.d.ts
CHANGED
|
@@ -12,8 +12,7 @@ import type { PointBatch, SpriteBatch } from './sprites.js';
|
|
|
12
12
|
export interface QueryOptions {
|
|
13
13
|
/**
|
|
14
14
|
* The layers to test, as a 32-bit mask like `Object3D.setLayers` takes. A query tests an object
|
|
15
|
-
* when their masks share a layer. The default is layer 0 alone, as for a camera
|
|
16
|
-
* three.js's `Raycaster`.
|
|
15
|
+
* when their masks share a layer. The default is layer 0 alone, as for a camera.
|
|
17
16
|
*/
|
|
18
17
|
layers?: number;
|
|
19
18
|
}
|
|
@@ -27,14 +26,12 @@ export interface RaycastOptions extends QueryOptions {
|
|
|
27
26
|
maxDistance?: number;
|
|
28
27
|
/**
|
|
29
28
|
* When set, a ray hits a point that it passes within this many meters of, whatever the point's
|
|
30
|
-
* size
|
|
31
|
-
* square that a point draws.
|
|
29
|
+
* size. By default a ray hits the square that a point draws.
|
|
32
30
|
*/
|
|
33
31
|
pointThreshold?: number;
|
|
34
32
|
/**
|
|
35
33
|
* When set, a ray hits a line that it passes within this many meters of, whatever the line's
|
|
36
|
-
* width
|
|
37
|
-
* within half its width.
|
|
34
|
+
* width. By default a ray hits a line within half its width.
|
|
38
35
|
*/
|
|
39
36
|
lineThreshold?: number;
|
|
40
37
|
}
|
|
@@ -74,16 +71,13 @@ export interface RaycastHit extends OverlapHit {
|
|
|
74
71
|
normal: Vec3Like;
|
|
75
72
|
/** The distance from the ray's origin to the hit, in meters. */
|
|
76
73
|
distance: number;
|
|
77
|
-
/**
|
|
78
|
-
* The index of the hit triangle in its mesh, as three.js's `faceIndex`, or -1 for a sprite, a
|
|
79
|
-
* point or a line.
|
|
80
|
-
*/
|
|
74
|
+
/** The index of the hit triangle in its mesh, or -1 for a sprite, a point or a line. */
|
|
81
75
|
triangle: number;
|
|
82
76
|
/**
|
|
83
77
|
* Where on the surface the ray hit, as the first texture coordinates of the hit triangle
|
|
84
|
-
* blended across its three corners
|
|
85
|
-
*
|
|
86
|
-
*
|
|
78
|
+
* blended across its three corners. Give the hit object an array of two numbers, as it has
|
|
79
|
+
* arrays for `point` and `normal`, and every raycast fills it. Read `hasUv` first: the numbers
|
|
80
|
+
* mean nothing when it is false.
|
|
87
81
|
*/
|
|
88
82
|
uv?: Vec2Like;
|
|
89
83
|
/**
|