@null3d/engine 0.0.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +109 -0
- package/THIRD-PARTY-NOTICES.txt +0 -1
- package/dist/wasm/single/null3d.js +25 -10
- package/dist/wasm/single/null3d_bg.wasm +0 -0
- package/dist/wasm/threaded/null3d.js +25 -10
- package/dist/wasm/threaded/null3d_bg.wasm +0 -0
- package/docs/api/animation.md +114 -86
- package/docs/api/assets.md +135 -49
- package/docs/api/cameras.md +45 -12
- package/docs/api/controls.md +88 -62
- package/docs/api/debug.md +116 -41
- package/docs/api/engine.md +117 -35
- package/docs/api/feature-draws.md +23 -17
- package/docs/api/feature-effects.md +11 -11
- package/docs/api/feature-instances.md +70 -19
- package/docs/api/features.md +77 -47
- package/docs/api/geometry.md +132 -82
- package/docs/api/grass.md +55 -13
- package/docs/api/impostors.md +175 -22
- package/docs/api/input.md +24 -18
- package/docs/api/lights.md +78 -51
- package/docs/api/lines.md +41 -33
- package/docs/api/materials.md +248 -121
- package/docs/api/math.md +12 -13
- package/docs/api/objects.md +47 -22
- package/docs/api/page.md +58 -7
- package/docs/api/particles.md +33 -20
- package/docs/api/points.md +19 -31
- package/docs/api/post.md +75 -42
- package/docs/api/quality.md +42 -17
- package/docs/api/raycast.md +65 -51
- package/docs/api/reference/animation.md +10 -11
- package/docs/api/reference/assets.md +25 -22
- package/docs/api/reference/cameras.md +8 -4
- package/docs/api/reference/controls.md +134 -25
- package/docs/api/reference/debug.md +81 -14
- package/docs/api/reference/engine.md +58 -17
- package/docs/api/reference/feature-draws.md +3 -4
- package/docs/api/reference/feature-effects.md +2 -3
- package/docs/api/reference/feature-instances.md +5 -4
- package/docs/api/reference/features.md +7 -4
- package/docs/api/reference/geometry.md +287 -97
- package/docs/api/reference/grass.md +63 -3
- package/docs/api/reference/impostors.md +208 -13
- package/docs/api/reference/input.md +4 -5
- package/docs/api/reference/lights.md +13 -12
- package/docs/api/reference/lines.md +10 -11
- package/docs/api/reference/materials.md +54 -53
- package/docs/api/reference/math.md +35 -24
- package/docs/api/reference/objects.md +11 -12
- package/docs/api/reference/particles.md +31 -6
- package/docs/api/reference/points.md +6 -7
- package/docs/api/reference/post.md +21 -20
- package/docs/api/reference/quality.md +8 -5
- package/docs/api/reference/raycast.md +7 -8
- package/docs/api/reference/render.md +5 -4
- package/docs/api/reference/scene.md +52 -30
- package/docs/api/reference/sketch.md +15 -11
- package/docs/api/reference/sound.md +234 -0
- package/docs/api/reference/splats.md +42 -3
- package/docs/api/reference/sprites.md +7 -8
- package/docs/api/reference/tasks.md +16 -3
- package/docs/api/reference/terrain.md +27 -5
- package/docs/api/reference/textures.md +5 -6
- package/docs/api/reference/three-compat.md +18 -7
- package/docs/api/reference/time.md +1 -2
- package/docs/api/reference/ui.md +12 -9
- package/docs/api/reference/vertex-draws.md +5 -6
- package/docs/api/reference/water.md +153 -9
- package/docs/api/reference/wind.md +17 -4
- package/docs/api/render.md +73 -29
- package/docs/api/scene.md +164 -60
- package/docs/api/sketch.md +102 -15
- package/docs/api/sound.md +205 -0
- package/docs/api/splats.md +46 -12
- package/docs/api/sprites.md +10 -24
- package/docs/api/tasks.md +33 -24
- package/docs/api/terrain.md +42 -22
- package/docs/api/textures.md +68 -19
- package/docs/api/three-compat.md +15 -7
- package/docs/api/time.md +3 -5
- package/docs/api/ui.md +19 -23
- package/docs/api/vertex-draws.md +13 -12
- package/docs/api/water.md +262 -35
- package/docs/api/wind.md +63 -17
- package/docs/cli/null3d.md +177 -27
- package/docs/concepts/architecture.md +73 -27
- package/docs/concepts/assets.md +57 -33
- package/docs/concepts/backends.md +69 -27
- package/docs/concepts/color-management.md +54 -36
- package/docs/concepts/culling.md +68 -47
- package/docs/concepts/handles.md +14 -5
- package/docs/concepts/instances.md +74 -25
- package/docs/concepts/large-worlds.md +18 -8
- package/docs/concepts/lighting.md +155 -87
- package/docs/concepts/lod.md +126 -44
- package/docs/concepts/materials.md +58 -27
- package/docs/concepts/particle-buffer.md +48 -35
- package/docs/concepts/post-processing.md +84 -43
- package/docs/concepts/quality-preset-tables.md +56 -52
- package/docs/concepts/quality-presets.md +164 -52
- package/docs/concepts/render-graph.md +69 -29
- package/docs/concepts/render-layers.md +11 -21
- package/docs/concepts/shadows.md +105 -52
- package/docs/concepts/static-dynamic.md +22 -7
- package/docs/cookbook/index.md +164 -120
- package/docs/data/threejs-mapping.json +362 -367
- package/docs/errors/E1101.md +23 -5
- package/docs/errors/E1102.md +11 -3
- package/docs/errors/E1103.md +11 -3
- package/docs/errors/E1104.md +11 -3
- package/docs/errors/E1105.md +13 -5
- package/docs/errors/E1106.md +11 -3
- package/docs/errors/E1107.md +15 -5
- package/docs/errors/E1108.md +11 -3
- package/docs/errors/E1109.md +32 -6
- package/docs/errors/E1110.md +23 -5
- package/docs/errors/E1111.md +11 -3
- package/docs/errors/E1112.md +11 -3
- package/docs/errors/E1203.md +12 -4
- package/docs/errors/E1204.md +11 -3
- package/docs/errors/E1205.md +11 -3
- package/docs/errors/E1206.md +28 -6
- package/docs/errors/E1207.md +11 -3
- package/docs/errors/E1208.md +12 -3
- package/docs/errors/E1209.md +11 -3
- package/docs/errors/E1213.md +27 -5
- package/docs/errors/E1214.md +14 -6
- package/docs/errors/E1215.md +31 -6
- package/docs/errors/E1216.md +31 -6
- package/docs/errors/E1217.md +29 -6
- package/docs/errors/E1218.md +22 -6
- package/docs/errors/E1219.md +11 -3
- package/docs/errors/E1220.md +24 -5
- package/docs/errors/E1221.md +24 -5
- package/docs/errors/E1222.md +11 -3
- package/docs/errors/E1223.md +39 -6
- package/docs/errors/E1224.md +11 -3
- package/docs/errors/E1225.md +11 -3
- package/docs/errors/E1301.md +11 -3
- package/docs/errors/E1302.md +11 -3
- package/docs/errors/E1303.md +11 -3
- package/docs/errors/E1304.md +11 -3
- package/docs/errors/E1305.md +13 -3
- package/docs/errors/E1306.md +11 -3
- package/docs/errors/E1307.md +40 -0
- package/docs/errors/E1401.md +11 -3
- package/docs/errors/E1402.md +13 -5
- package/docs/errors/E1403.md +11 -3
- package/docs/errors/E1404.md +13 -3
- package/docs/errors/E1405.md +15 -4
- package/docs/errors/E1406.md +31 -5
- package/docs/errors/E1407.md +11 -3
- package/docs/errors/E1408.md +11 -3
- package/docs/errors/E1409.md +11 -3
- package/docs/errors/E1410.md +13 -5
- package/docs/errors/E1411.md +11 -3
- package/docs/errors/E1412.md +29 -6
- package/docs/errors/E1413.md +11 -3
- package/docs/errors/E1414.md +11 -3
- package/docs/errors/E1415.md +11 -3
- package/docs/errors/E1416.md +27 -6
- package/docs/errors/E1417.md +11 -3
- package/docs/errors/E1418.md +12 -3
- package/docs/errors/E1419.md +13 -5
- package/docs/errors/E1420.md +14 -6
- package/docs/errors/E1421.md +11 -3
- package/docs/errors/E1422.md +12 -3
- package/docs/errors/E1423.md +12 -3
- package/docs/errors/E1424.md +24 -5
- package/docs/errors/E1425.md +11 -3
- package/docs/errors/E1426.md +11 -3
- package/docs/errors/E1430.md +11 -3
- package/docs/errors/E1431.md +11 -3
- package/docs/errors/E1432.md +11 -3
- package/docs/errors/E1433.md +11 -3
- package/docs/errors/E1434.md +15 -6
- package/docs/errors/E1435.md +11 -3
- package/docs/errors/E1436.md +11 -3
- package/docs/errors/E1437.md +14 -6
- package/docs/errors/E1501.md +41 -6
- package/docs/errors/E1502.md +13 -3
- package/docs/errors/E1503.md +11 -3
- package/docs/errors/E1504.md +11 -3
- package/docs/errors/E1505.md +23 -5
- package/docs/errors/E1506.md +11 -3
- package/docs/errors/index.md +54 -30
- package/docs/getting-started/cdn.md +32 -10
- package/docs/getting-started/first-scene.md +21 -13
- package/docs/getting-started/hosting.md +152 -63
- package/docs/getting-started/install.md +44 -28
- package/docs/getting-started/network-use.md +33 -15
- package/docs/getting-started/project-structure.md +33 -12
- package/docs/getting-started/third-party-notices.md +12 -14
- package/docs/guides/accessibility.md +5 -5
- package/docs/guides/add-ons.md +86 -15
- package/docs/guides/agents.md +16 -9
- package/docs/guides/assets-pipeline.md +259 -82
- package/docs/guides/audio.md +115 -128
- package/docs/guides/baked-light-data.md +44 -23
- package/docs/guides/car-paint.md +38 -32
- package/docs/guides/content-pages.md +63 -35
- package/docs/guides/custom-passes.md +65 -22
- package/docs/guides/custom-shaders.md +59 -39
- package/docs/guides/debugging.md +74 -10
- package/docs/guides/deploying.md +85 -6
- package/docs/guides/deterministic-simulation.md +24 -17
- package/docs/guides/first-use-shaders.md +83 -45
- package/docs/guides/lens-kit.md +29 -26
- package/docs/guides/loading-screens.md +132 -47
- package/docs/guides/multiple-views.md +63 -13
- package/docs/guides/performance.md +192 -38
- package/docs/guides/phones.md +78 -15
- package/docs/guides/physics.md +7 -11
- package/docs/guides/screens.md +47 -33
- package/docs/guides/start-time.md +363 -0
- package/docs/guides/testing.md +152 -95
- package/docs/guides/ui-overlays.md +19 -14
- package/docs/guides/video-textures.md +14 -13
- package/docs/images/api/animation/character.webp +0 -0
- package/docs/images/api/animation/look-at-ring.webp +0 -0
- package/docs/images/api/animation/morph-tulips.webp +0 -0
- package/docs/images/api/animation/skeleton-lines.webp +0 -0
- package/docs/images/api/controls/gizmo-handles.webp +0 -0
- package/docs/images/api/controls/walk-and-fly.webp +0 -0
- package/docs/images/api/debug/debug-shapes.webp +0 -0
- package/docs/images/api/debug/levels-view.webp +0 -0
- package/docs/images/api/engine/transparent-canvas.webp +0 -0
- package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
- package/docs/images/api/feature-instances/compute-instances.webp +0 -0
- package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
- package/docs/images/api/geometry/extra-shapes.webp +0 -0
- package/docs/images/api/geometry/generators.webp +0 -0
- package/docs/images/api/geometry/mesh-arrays.webp +0 -0
- package/docs/images/api/geometry/vertex-updates.webp +0 -0
- package/docs/images/api/grass/grass-grove.webp +0 -0
- package/docs/images/api/grass/grass-presets.webp +0 -0
- package/docs/images/api/grass/grass-shadow.webp +0 -0
- package/docs/images/api/impostors/impostor-handover.webp +0 -0
- package/docs/images/api/impostors/impostor-shadow.webp +0 -0
- package/docs/images/api/impostors/impostors-forest.webp +0 -0
- package/docs/images/api/lights/spot-cookies.webp +0 -0
- package/docs/images/api/lines/lines-lit.webp +0 -0
- package/docs/images/api/lines/lines-widths.webp +0 -0
- package/docs/images/api/materials/coat-and-sheen.webp +0 -0
- package/docs/images/api/materials/decals.webp +0 -0
- package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
- package/docs/images/api/materials/relief.webp +0 -0
- package/docs/images/api/materials/shader-inputs.webp +0 -0
- package/docs/images/api/materials/standard-grid.webp +0 -0
- package/docs/images/api/materials/subsurface.webp +0 -0
- package/docs/images/api/materials/translucency.webp +0 -0
- package/docs/images/api/objects/objects-turntable.webp +0 -0
- package/docs/images/api/particles/campfire.webp +0 -0
- package/docs/images/api/points/galaxy.webp +0 -0
- package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
- package/docs/images/api/render/fullscreen-glow.webp +0 -0
- package/docs/images/api/render/reflection-mirror.webp +0 -0
- package/docs/images/api/render/security-camera.webp +0 -0
- package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
- package/docs/images/api/sound/sound-demo.webp +0 -0
- package/docs/images/api/splats/splats-demo.webp +0 -0
- package/docs/images/api/sprites/sprites-lines.webp +0 -0
- package/docs/images/api/terrain/terrain-demo.webp +0 -0
- package/docs/images/api/textures/canvas-screen.webp +0 -0
- package/docs/images/api/textures/mipmaps.webp +0 -0
- package/docs/images/api/vertex-draws/rain.webp +0 -0
- package/docs/images/api/water/ocean.webp +0 -0
- package/docs/images/api/water/water-demo.webp +0 -0
- package/docs/images/api/water/water-rain.webp +0 -0
- package/docs/images/api/water/waterfall.webp +0 -0
- package/docs/images/concepts/assets/gltf-model.webp +0 -0
- package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
- package/docs/images/concepts/culling/far-from-origin.webp +0 -0
- package/docs/images/concepts/instances/instances.webp +0 -0
- package/docs/images/concepts/instances/per-row-colors.webp +0 -0
- package/docs/images/concepts/large-worlds/large-world.webp +0 -0
- package/docs/images/concepts/lighting/area-lights.webp +0 -0
- package/docs/images/concepts/lighting/atmosphere.webp +0 -0
- package/docs/images/concepts/lighting/environment.webp +0 -0
- package/docs/images/concepts/lighting/light-shafts.webp +0 -0
- package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
- package/docs/images/concepts/lod/forest.webp +0 -0
- package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
- package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
- package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
- package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
- package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
- package/docs/images/concepts/post-processing/sharpen.webp +0 -0
- package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
- package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
- package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
- package/docs/images/cookbook/index/picking.webp +0 -0
- package/docs/images/cookbook/index/time-of-day.webp +0 -0
- package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
- package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
- package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
- package/docs/images/guides/multiple-views/split-screen.webp +0 -0
- package/docs/images/guides/performance/overdraw-view.webp +0 -0
- package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
- package/docs/images/index/showcase-island.webp +0 -0
- package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
- package/docs/images/shaders/builtins/builtins.webp +0 -0
- package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
- package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
- package/docs/images/shots.json +2231 -0
- package/docs/index.md +18 -23
- package/docs/moves.json +1 -0
- package/docs/nav.json +300 -0
- package/docs/pages.md +230 -209
- package/docs/porting/react-three-fiber.md +225 -6
- package/docs/porting/threejs-loop-and-threads.md +217 -7
- package/docs/porting/threejs-mapping.md +1249 -233
- package/docs/porting/threejs-materials.md +218 -6
- package/docs/porting/threejs-overview.md +240 -7
- package/docs/porting/threejs-postprocessing.md +4 -8
- package/docs/porting/threejs-shaders.md +301 -6
- package/docs/porting/threejs-unsupported.md +83 -7
- package/docs/porting/verification.md +178 -6
- package/docs/shaders/builtins.md +15 -4
- package/docs/shaders/library.md +72 -45
- package/docs/shaders/surface-functions.md +59 -23
- package/docs/shaders/wgsl-rules.md +12 -5
- package/lib/debug/channel.d.ts +103 -0
- package/lib/debug/channel.js +269 -0
- package/lib/debug/debug.d.ts +11 -9
- package/lib/debug/draw.d.ts +11 -2
- package/lib/debug/draw.js +57 -6
- package/lib/debug/inspector.d.ts +60 -0
- package/lib/debug/inspector.js +475 -0
- package/lib/debug/overlay-look.d.ts +6 -0
- package/lib/debug/overlay-look.js +29 -7
- package/lib/debug/overlay.js +15 -11
- package/lib/debug/stats-options.d.ts +13 -0
- package/lib/debug/stats-panel.d.ts +22 -7
- package/lib/debug/stats-panel.js +80 -13
- package/lib/debug/stats.d.ts +2 -3
- package/lib/errors/codes.d.ts +17 -3
- package/lib/errors/codes.js +117 -105
- package/lib/errors/engine-error.js +25 -10
- package/lib/errors/fixes.d.ts +1 -0
- package/lib/errors/fixes.js +20 -19
- package/lib/generated/core.d.ts +1 -1
- package/lib/generated/core.js +1 -1
- package/lib/gpu/early-builds.d.ts +68 -0
- package/lib/gpu/early-builds.js +158 -0
- package/lib/gpu/pipeline-name.d.ts +6 -0
- package/lib/gpu/pipeline-name.js +23 -0
- package/lib/gpu/variants.d.ts +8 -2
- package/lib/gpu/variants.js +39 -7
- package/lib/gpu/webgl2/backend.d.ts +63 -2
- package/lib/gpu/webgl2/backend.js +226 -8
- package/lib/gpu/webgl2/programs.d.ts +18 -0
- package/lib/gpu/webgl2/programs.js +5 -2
- package/lib/gpu/webgpu/backend.d.ts +89 -2
- package/lib/gpu/webgpu/backend.js +255 -8
- package/lib/gpu/webgpu/pipelines.d.ts +13 -0
- package/lib/gpu/webgpu/pipelines.js +28 -14
- package/lib/index.d.ts +7 -5
- package/lib/index.js +3 -2
- package/lib/math/color.d.ts +5 -5
- package/lib/math/color.js +5 -5
- package/lib/math/mat4.d.ts +6 -12
- package/lib/math/mat4.js +6 -12
- package/lib/math/namespaces/quat.d.ts +3 -3
- package/lib/math/namespaces/quat.js +3 -3
- package/lib/math/quat.d.ts +8 -12
- package/lib/math/quat.js +8 -12
- package/lib/math/random.d.ts +2 -3
- package/lib/math/random.js +2 -3
- package/lib/math/types.d.ts +4 -4
- package/lib/math/vec3.d.ts +3 -6
- package/lib/math/vec3.js +3 -6
- package/lib/page/capabilities.d.ts +8 -8
- package/lib/page/capabilities.js +39 -25
- package/lib/page/check-store.d.ts +14 -2
- package/lib/page/check-store.js +34 -11
- package/lib/page/engine.d.ts +117 -31
- package/lib/page/engine.js +438 -99
- package/lib/page/first-frame.d.ts +16 -0
- package/lib/page/first-frame.js +35 -0
- package/lib/page/frame-stats.d.ts +34 -1
- package/lib/page/frame-stats.js +15 -0
- package/lib/page/label-loop.d.ts +7 -3
- package/lib/page/label-loop.js +26 -14
- package/lib/page/labels.d.ts +3 -3
- package/lib/page/pipeline-store.d.ts +25 -0
- package/lib/page/pipeline-store.js +84 -0
- package/lib/page/start-marker.d.ts +4 -1
- package/lib/page/start-marker.js +5 -2
- package/lib/page/stats-switch.js +2 -0
- package/lib/page/switches.d.ts +38 -6
- package/lib/page/switches.js +29 -5
- package/lib/quality/check.d.ts +24 -3
- package/lib/quality/check.js +21 -7
- package/lib/quality/chooser.d.ts +6 -0
- package/lib/quality/chooser.js +8 -0
- package/lib/quality/governor.d.ts +98 -6
- package/lib/quality/governor.js +250 -20
- package/lib/quality/preset-docs.d.ts +16 -1
- package/lib/quality/preset-docs.js +3 -0
- package/lib/quality/presets.d.ts +84 -7
- package/lib/quality/presets.js +94 -2
- package/lib/render/draw.d.ts +3 -2
- package/lib/render/draw.js +15 -5
- package/lib/render/load-draw.d.ts +7 -5
- package/lib/render/load-draw.js +7 -5
- package/lib/render/loss.d.ts +28 -10
- package/lib/render/loss.js +50 -22
- package/lib/render/recovery.d.ts +20 -0
- package/lib/render/recovery.js +44 -4
- package/lib/render/renderer.d.ts +85 -9
- package/lib/render/renderer.js +181 -42
- package/lib/render/scene-renderer.d.ts +19 -1
- package/lib/render/scene-renderer.js +25 -1
- package/lib/render/webgl2-renderers.js +8 -5
- package/lib/render/webgpu-renderers.js +5 -4
- package/lib/scene/animation.d.ts +28 -32
- package/lib/scene/animation.js +12 -15
- package/lib/scene/assets.d.ts +61 -86
- package/lib/scene/assets.js +103 -236
- package/lib/scene/background.d.ts +14 -18
- package/lib/scene/background.js +5 -2
- package/lib/scene/baked-light.d.ts +2 -2
- package/lib/scene/color.d.ts +3 -3
- package/lib/scene/downloads.d.ts +2 -0
- package/lib/scene/downloads.js +371 -0
- package/lib/scene/environment.d.ts +7 -7
- package/lib/scene/environment.js +1 -1
- package/lib/scene/fake-call-values.js +3 -3
- package/lib/scene/fog.d.ts +11 -4
- package/lib/scene/fog.js +8 -2
- package/lib/scene/frame-cameras.d.ts +35 -4
- package/lib/scene/frame-cameras.js +86 -10
- package/lib/scene/gltf.d.ts +33 -3
- package/lib/scene/gltf.js +78 -49
- package/lib/scene/grading.d.ts +2 -2
- package/lib/scene/grading.js +3 -3
- package/lib/scene/ktx2.d.ts +9 -1
- package/lib/scene/ktx2.js +3 -2
- package/lib/scene/level-rule.d.ts +121 -0
- package/lib/scene/level-rule.js +130 -0
- package/lib/scene/lines.d.ts +13 -17
- package/lib/scene/lines.js +3 -3
- package/lib/scene/lut.d.ts +1 -2
- package/lib/scene/lut.js +1 -2
- package/lib/scene/particles.d.ts +7 -3
- package/lib/scene/particles.js +3 -1
- package/lib/scene/picks.d.ts +2 -2
- package/lib/scene/pointer-events.d.ts +4 -7
- package/lib/scene/post.d.ts +39 -43
- package/lib/scene/post.js +4 -1
- package/lib/scene/prefab.d.ts +7 -8
- package/lib/scene/prefab.js +7 -8
- package/lib/scene/property-animation.d.ts +1 -1
- package/lib/scene/property-animation.js +1 -1
- package/lib/scene/queries.d.ts +7 -13
- package/lib/scene/resources.d.ts +238 -261
- package/lib/scene/resources.js +179 -81
- package/lib/scene/scene.d.ts +167 -120
- package/lib/scene/scene.js +243 -103
- package/lib/scene/serial-loads.d.ts +29 -0
- package/lib/scene/serial-loads.js +68 -0
- package/lib/scene/shader-preloads.d.ts +34 -0
- package/lib/scene/shader-preloads.js +38 -0
- package/lib/scene/sprites.d.ts +14 -17
- package/lib/scene/sprites.js +5 -6
- package/lib/scene/textures.d.ts +11 -12
- package/lib/scene/textures.js +9 -10
- package/lib/scene/time-of-day.d.ts +11 -7
- package/lib/scene/time-of-day.js +11 -8
- package/lib/scene/vertex-draws.d.ts +5 -4
- package/lib/scene/vertex-draws.js +7 -5
- package/lib/shader-artifact.json +1 -0
- package/lib/shared/core.d.ts +5 -0
- package/lib/shared/core.js +1 -0
- package/lib/shared/import-once.d.ts +6 -0
- package/lib/shared/import-once.js +19 -0
- package/lib/shared/labels.d.ts +5 -2
- package/lib/shared/labels.js +5 -2
- package/lib/shared/metrics.d.ts +38 -0
- package/lib/shared/metrics.js +62 -1
- package/lib/shared/permutation-words.d.ts +2 -0
- package/lib/shared/permutation-words.js +8 -0
- package/lib/shared/recording.d.ts +13 -5
- package/lib/shared/recording.js +31 -10
- package/lib/shared/run-task.js +7 -1
- package/lib/shared/sketch-data.d.ts +9 -0
- package/lib/shared/sketch-data.js +57 -0
- package/lib/shared/task-pending.d.ts +12 -0
- package/lib/shared/task-pending.js +61 -1
- package/lib/shared/tasks.js +79 -32
- package/lib/shared/version.d.ts +17 -1
- package/lib/shared/version.js +19 -1
- package/lib/shared/wasm.d.ts +12 -4
- package/lib/shared/wasm.js +50 -27
- package/lib/shared/worker-start.d.ts +7 -0
- package/lib/shared/worker-start.js +27 -0
- package/lib/sketch/define-sketch.d.ts +51 -7
- package/lib/sketch/define-sketch.js +2 -1
- package/lib/sketch/input.d.ts +2 -2
- package/lib/sketch/preset-check.d.ts +20 -6
- package/lib/sketch/preset-check.js +42 -17
- package/lib/sketch/quality.d.ts +69 -11
- package/lib/sketch/quality.js +54 -13
- package/lib/sketch/runner.d.ts +80 -9
- package/lib/sketch/runner.js +390 -52
- package/lib/sketch/ui.d.ts +5 -8
- package/lib/sketch/ui.js +4 -2
- package/lib/stats.d.ts +1 -0
- package/lib/workers/probe-worker.d.ts +5 -0
- package/lib/workers/probe-worker.js +13 -4
- package/lib/workers/protocol.d.ts +71 -13
- package/lib/workers/protocol.js +4 -0
- package/lib/workers/render-worker.js +29 -5
- package/lib/workers/sketch-worker.js +108 -16
- package/package.json +2 -2
package/lib/sketch/ui.d.ts
CHANGED
|
@@ -3,12 +3,9 @@ import type { Object3D } from '../scene/scene.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* How a label's element sits in the scene.
|
|
5
5
|
*
|
|
6
|
-
* - `'screen'` keeps the element flat on the screen at the label's place, always the same size
|
|
7
|
-
*
|
|
8
|
-
* - `'
|
|
9
|
-
* three.js's `CSS3DObject` does.
|
|
10
|
-
* - `'billboard'` makes the element a plane of the scene that always faces the camera, as
|
|
11
|
-
* three.js's `CSS3DSprite` does.
|
|
6
|
+
* - `'screen'` keeps the element flat on the screen at the label's place, always the same size.
|
|
7
|
+
* - `'world'` makes the element a plane of the scene: it turns and scales with the object.
|
|
8
|
+
* - `'billboard'` makes the element a plane of the scene that always faces the camera.
|
|
12
9
|
*
|
|
13
10
|
* @category api/ui
|
|
14
11
|
*/
|
|
@@ -27,8 +24,8 @@ export interface LabelOptions {
|
|
|
27
24
|
/** How the element sits in the scene. The default is `'screen'`. */
|
|
28
25
|
transform?: LabelTransform;
|
|
29
26
|
/**
|
|
30
|
-
* The element's turn in its own plane, in radians, for `'billboard'`. It turns the
|
|
31
|
-
*
|
|
27
|
+
* The element's turn in its own plane, in radians, for `'billboard'`. It turns the element's
|
|
28
|
+
* content counterclockwise, while the element keeps facing the camera.
|
|
32
29
|
*/
|
|
33
30
|
rotation?: number;
|
|
34
31
|
}
|
package/lib/sketch/ui.js
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
import { checkLive, checkVector, DEV } from '../errors/checks.js';
|
|
15
15
|
import { EngineError } from '../errors/engine-error.js';
|
|
16
16
|
import { FLAG_VISIBLE } from '../generated/core.js';
|
|
17
|
-
import { projectPoint, VIEW_CENTER_X, VIEW_CENTER_Y, VIEW_FAR, VIEW_FLOATS, VIEW_NEAR, VIEW_ORTHO, VIEW_SCALE_Y, } from '../scene/frame-cameras.js';
|
|
18
|
-
import { CAMERA_CENTER_X, CAMERA_CENTER_Y, CAMERA_HALF_HEIGHT, CAMERA_ORTHO, GENERATION_SHIFT, LABEL_DEPTH, LABEL_SHOWN, LABEL_STATE, LABEL_WORDS, LABEL_X, LABEL_Y, LABEL3D_MATRIX, LABEL3D_STATE, LABEL3D_WORDS, parityTable, parityTable3d, setParityCount, setParityCount3d, TABLE_3D, TABLE_SCREEN, } from '../shared/labels.js';
|
|
17
|
+
import { projectPoint, VIEW_CENTER_X, VIEW_CENTER_Y, VIEW_FAR, VIEW_FLOATS, VIEW_NEAR, VIEW_ORTHO, VIEW_SCALE_Y, VIEW_SHIFT_X, VIEW_SHIFT_Y, } from '../scene/frame-cameras.js';
|
|
18
|
+
import { CAMERA_CENTER_X, CAMERA_CENTER_Y, CAMERA_HALF_HEIGHT, CAMERA_ORTHO, CAMERA_SHIFT_X, CAMERA_SHIFT_Y, GENERATION_SHIFT, LABEL_DEPTH, LABEL_SHOWN, LABEL_STATE, LABEL_WORDS, LABEL_X, LABEL_Y, LABEL3D_MATRIX, LABEL3D_STATE, LABEL3D_WORDS, parityTable, parityTable3d, setParityCount, setParityCount3d, TABLE_3D, TABLE_SCREEN, } from '../shared/labels.js';
|
|
19
19
|
const GENERATIONS = 1 << 16;
|
|
20
20
|
/** The three transform modes, as the label's own tables number them. */
|
|
21
21
|
const SCREEN = 0;
|
|
@@ -375,6 +375,8 @@ function writeCamera(region, parity, view) {
|
|
|
375
375
|
record[CAMERA_ORTHO] = view[VIEW_ORTHO];
|
|
376
376
|
record[CAMERA_CENTER_X] = view[VIEW_CENTER_X];
|
|
377
377
|
record[CAMERA_CENTER_Y] = view[VIEW_CENTER_Y];
|
|
378
|
+
record[CAMERA_SHIFT_X] = view[VIEW_SHIFT_X];
|
|
379
|
+
record[CAMERA_SHIFT_Y] = view[VIEW_SHIFT_Y];
|
|
378
380
|
}
|
|
379
381
|
/** True when `object` and every ancestor it has are visible. */
|
|
380
382
|
function shownWithAncestors(object) {
|
package/lib/stats.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { MainThreadWindow, type MemoryMeasurement, measurePageMemory, type PageMemory, PageMemorySampler, pageHeapBytes, } from './debug/page-meters.js';
|
|
2
|
+
export type { StatsCorner } from './debug/stats-options.js';
|
|
2
3
|
export { type StatsFrameMode, StatsPanel, type StatsPanelFrame, type StatsPanelOptions, } from './debug/stats-panel.js';
|
|
3
4
|
export { type StatsFigures, type StatsGpuStep, type StatsMainThread, type StatsMemory, type StatsMemoryArea, type StatsThread, statsText, } from './debug/stats-text.js';
|
|
4
5
|
export { countPerSecond, type Percentiles, percentiles, ratePerSecond } from './shared/stats.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type DrawPathReason } from '../gpu/webgpu/draw-path-probe.js';
|
|
2
|
+
import type { PowerPreference } from '../page/capabilities.js';
|
|
2
3
|
/**
|
|
3
4
|
* What a dedicated worker can do, in `CapabilityReport.worker`. A render worker needs the frame
|
|
4
5
|
* timer and an offscreen canvas for its GPU path.
|
|
@@ -27,3 +28,7 @@ export interface WorkerProbe {
|
|
|
27
28
|
* for the script without a time limit, so a slow download never reads as a worker that cannot draw.
|
|
28
29
|
*/
|
|
29
30
|
export type ProbeMessage = 'loaded' | WorkerProbe;
|
|
31
|
+
/** What the page sends the probe worker: the power preference that picks the GPU to test. */
|
|
32
|
+
export interface ProbeRequest {
|
|
33
|
+
powerPreference?: PowerPreference;
|
|
34
|
+
}
|
|
@@ -6,7 +6,11 @@ import { messageOf } from '../errors/message.js';
|
|
|
6
6
|
import { probeDrawPath } from '../gpu/webgpu/draw-path-probe.js';
|
|
7
7
|
import { needsOwnArguments } from '../gpu/webgpu/indirect-arguments.js';
|
|
8
8
|
const post = (message) => postMessage(message);
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Tests the worker's GPU paths on the GPU that `powerPreference` picks, the one that the engine will
|
|
11
|
+
* draw with.
|
|
12
|
+
*/
|
|
13
|
+
async function probe(powerPreference) {
|
|
10
14
|
const result = {
|
|
11
15
|
requestAnimationFrame: typeof globalThis.requestAnimationFrame ===
|
|
12
16
|
'function',
|
|
@@ -15,8 +19,10 @@ async function probe() {
|
|
|
15
19
|
directDraws: false,
|
|
16
20
|
drawPath: 'no-probe',
|
|
17
21
|
};
|
|
22
|
+
// The adapter request runs while the WebGL2 test, which blocks this thread, does.
|
|
23
|
+
const adapterRequest = (async () => navigator.gpu?.requestAdapter({ featureLevel: 'compatibility', powerPreference }))();
|
|
18
24
|
try {
|
|
19
|
-
const gl = new OffscreenCanvas(1, 1).getContext('webgl2');
|
|
25
|
+
const gl = new OffscreenCanvas(1, 1).getContext('webgl2', { powerPreference });
|
|
20
26
|
result.offscreenWebGL2 = gl !== null;
|
|
21
27
|
// A browser holds only a few WebGL contexts at once, and frees this one when it collects it.
|
|
22
28
|
gl?.getExtension('WEBGL_lose_context')?.loseContext();
|
|
@@ -25,7 +31,7 @@ async function probe() {
|
|
|
25
31
|
result.offscreenWebGL2 = false;
|
|
26
32
|
}
|
|
27
33
|
try {
|
|
28
|
-
const adapter = await
|
|
34
|
+
const adapter = await adapterRequest;
|
|
29
35
|
if (adapter) {
|
|
30
36
|
const device = await adapter.requestDevice();
|
|
31
37
|
const context = new OffscreenCanvas(1, 1).getContext('webgpu');
|
|
@@ -46,4 +52,7 @@ async function probe() {
|
|
|
46
52
|
return result;
|
|
47
53
|
}
|
|
48
54
|
post('loaded');
|
|
49
|
-
|
|
55
|
+
self.onmessage = ({ data }) => {
|
|
56
|
+
self.onmessage = null;
|
|
57
|
+
probe(data.powerPreference).then(post);
|
|
58
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { InspectReply } from '../debug/channel.js';
|
|
1
2
|
import type { StatsRequest } from '../debug/stats-options.js';
|
|
2
3
|
import type { PowerPreference } from '../page/capabilities.js';
|
|
3
4
|
import type { EngineCapabilities } from '../page/engine.js';
|
|
@@ -5,7 +6,8 @@ import type { HoldScript, HoldScriptResult } from '../page/hold.js';
|
|
|
5
6
|
import type { CoreDevice } from '../page/limits.js';
|
|
6
7
|
import type { GlTimingMode } from '../page/switches.js';
|
|
7
8
|
import type { FramePacing } from '../render/loop.js';
|
|
8
|
-
import type {
|
|
9
|
+
import type { GpuErrorKind } from '../render/loss.js';
|
|
10
|
+
import type { DrawingPreload, Tier } from '../render/renderer.js';
|
|
9
11
|
import { type Build, type StartedCore } from '../shared/core.js';
|
|
10
12
|
import type { ReplayProgram, ReplayResult } from '../shared/recording.js';
|
|
11
13
|
import type { WAKE } from '../shared/wake.js';
|
|
@@ -65,12 +67,24 @@ export interface RendererSetup extends FramePacing {
|
|
|
65
67
|
* thread that draws loads the tier's shaders with the first generator that it runs.
|
|
66
68
|
*/
|
|
67
69
|
cloudSteps?: number;
|
|
70
|
+
/**
|
|
71
|
+
* The pipeline list of the first frame of the sketch's last start, whose pipelines the thread
|
|
72
|
+
* starts to build at once (`gpu/early-builds.ts`).
|
|
73
|
+
*/
|
|
74
|
+
earlyBuilds?: Uint32Array;
|
|
75
|
+
/**
|
|
76
|
+
* True when the page stores pipeline lists: the thread sends the list of its first frame's
|
|
77
|
+
* pipelines once that frame has drawn.
|
|
78
|
+
*/
|
|
79
|
+
keepBuilds?: boolean;
|
|
68
80
|
}
|
|
69
81
|
export type SketchWorkerInit = CoreHandoff & {
|
|
70
82
|
type: 'init';
|
|
71
83
|
sketchUrl: string;
|
|
72
84
|
/** The page's address, which the sketch's relative asset addresses resolve against. */
|
|
73
85
|
pageUrl: string;
|
|
86
|
+
/** The start data that the page passed, as JSON text, which the sketch reads as `ctx.data`. */
|
|
87
|
+
data?: string;
|
|
74
88
|
/**
|
|
75
89
|
* The key names, in the order of the numbers that the page gives keys in the input ring. The
|
|
76
90
|
* page hands them over, so the sketch worker's file needs no copy.
|
|
@@ -125,15 +139,20 @@ export type JobWorkerInit = CoreHandoff & {
|
|
|
125
139
|
};
|
|
126
140
|
/**
|
|
127
141
|
* A request any worker that owns a renderer takes: a capture, which it answers with the frame's
|
|
128
|
-
* pixels, or with a PNG file of the frame when `image` is true; a simulated loss;
|
|
129
|
-
*
|
|
130
|
-
*
|
|
142
|
+
* pixels, or with a PNG file of the frame when `image` is true; a simulated loss; the page's entry
|
|
143
|
+
* into the browser's back/forward cache, when `cached` is true, which gives the GPU back, and its
|
|
144
|
+
* return from it, which takes a new device; a stop, which it answers once it has destroyed its GPU
|
|
145
|
+
* objects and its device; or a park after the stop, which lets go of the engine's core and keeps
|
|
146
|
+
* the canvas for the next engine.
|
|
131
147
|
*/
|
|
132
148
|
export type RendererRequest = {
|
|
133
149
|
type: 'capture';
|
|
134
150
|
image?: boolean;
|
|
135
151
|
} | {
|
|
136
152
|
type: 'lose-gpu';
|
|
153
|
+
} | {
|
|
154
|
+
type: 'page-cache';
|
|
155
|
+
cached: boolean;
|
|
137
156
|
} | {
|
|
138
157
|
type: 'stop-drawing';
|
|
139
158
|
} | {
|
|
@@ -145,14 +164,12 @@ export type RendererRequest = {
|
|
|
145
164
|
};
|
|
146
165
|
/**
|
|
147
166
|
* Sent to the worker that draws as soon as the probe has chosen the GPU path, before the core
|
|
148
|
-
* arrives: start the downloads of that path's renderers
|
|
149
|
-
* and the
|
|
167
|
+
* arrives: start the downloads of that path's renderers, of the device's shaders and of the
|
|
168
|
+
* features that the start preloads, and on WebGPU the request for the device.
|
|
150
169
|
*/
|
|
151
|
-
export
|
|
170
|
+
export type ShaderPreload = DrawingPreload & {
|
|
152
171
|
type: 'load-shaders';
|
|
153
|
-
|
|
154
|
-
bits: number;
|
|
155
|
-
}
|
|
172
|
+
};
|
|
156
173
|
export type WorkerReply = {
|
|
157
174
|
type: 'ready';
|
|
158
175
|
role: 'sketch' | 'render' | 'job';
|
|
@@ -170,6 +187,14 @@ export type WorkerReply = {
|
|
|
170
187
|
type: 'recorded';
|
|
171
188
|
role: 'sketch' | 'render';
|
|
172
189
|
permutations: number[];
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* In a development build, a permutation word that the drawing thread's pipelines found for the
|
|
193
|
+
* first time, which the page hands to the dev server to compare with the project's shader list.
|
|
194
|
+
*/
|
|
195
|
+
| {
|
|
196
|
+
type: 'permutation';
|
|
197
|
+
word: number;
|
|
173
198
|
} | {
|
|
174
199
|
type: 'error';
|
|
175
200
|
role: 'sketch' | 'render' | 'job';
|
|
@@ -185,11 +210,14 @@ export type WorkerReply = {
|
|
|
185
210
|
index?: number;
|
|
186
211
|
message: string;
|
|
187
212
|
}
|
|
188
|
-
/**
|
|
213
|
+
/**
|
|
214
|
+
* The GPU of the thread that draws ran out of memory, rejected a command, or its driver could not
|
|
215
|
+
* build a pipeline of the scene's objects; the engine draws on.
|
|
216
|
+
*/
|
|
189
217
|
| {
|
|
190
218
|
type: 'gpu-error';
|
|
191
219
|
role: 'sketch' | 'render';
|
|
192
|
-
|
|
220
|
+
kind: GpuErrorKind;
|
|
193
221
|
message: string;
|
|
194
222
|
}
|
|
195
223
|
/** A job worker left the job system after the engine stopped, so it no longer blocks. */
|
|
@@ -212,6 +240,11 @@ export type WorkerReply = {
|
|
|
212
240
|
role: 'sketch' | 'render' | 'job';
|
|
213
241
|
step: string;
|
|
214
242
|
}
|
|
243
|
+
/** The pipeline list of the pipelines that the first frame built, which the page stores. */
|
|
244
|
+
| {
|
|
245
|
+
type: 'pipeline-list';
|
|
246
|
+
list: Uint32Array;
|
|
247
|
+
}
|
|
215
248
|
/** The browser took the GPU away from the worker that draws, which stopped drawing. */
|
|
216
249
|
| {
|
|
217
250
|
type: 'lost';
|
|
@@ -273,7 +306,12 @@ export type WorkerReply = {
|
|
|
273
306
|
| {
|
|
274
307
|
type: 'recording';
|
|
275
308
|
bytes: Uint8Array;
|
|
276
|
-
}
|
|
309
|
+
}
|
|
310
|
+
/** The answer to a development build's inspection call: its value, or why it failed. */
|
|
311
|
+
| ({
|
|
312
|
+
type: 'inspect-reply';
|
|
313
|
+
id: number;
|
|
314
|
+
} & InspectReply) | ({
|
|
277
315
|
type: 'captured';
|
|
278
316
|
} & CapturedFrame) | {
|
|
279
317
|
type: 'captured-image';
|
|
@@ -286,11 +324,29 @@ export type SketchWorkerMessage = SketchWorkerInit
|
|
|
286
324
|
/** Sent before the core in low-latency mode, where the sketch worker draws: load the renderer. */
|
|
287
325
|
| {
|
|
288
326
|
type: 'load-renderer';
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Sent as the worker starts, for a live sketch: import the sketch module at `url` now, while the
|
|
330
|
+
* core downloads, and start the files that its options list, whose addresses resolve against
|
|
331
|
+
* `pageUrl`. Hold mode, a replay and a recording send none, since their sketch module loads only
|
|
332
|
+
* after the runner has seeded the thread's random numbers.
|
|
333
|
+
*/
|
|
334
|
+
| {
|
|
335
|
+
type: 'load-sketch';
|
|
336
|
+
url: string;
|
|
337
|
+
pageUrl: string;
|
|
289
338
|
} | ShaderPreload | RendererRequest | {
|
|
290
339
|
type: 'post';
|
|
291
340
|
name: string;
|
|
292
341
|
data: unknown;
|
|
293
342
|
}
|
|
343
|
+
/** A development build's inspection call, which the worker answers with `inspect-reply`. */
|
|
344
|
+
| {
|
|
345
|
+
type: 'inspect';
|
|
346
|
+
id: number;
|
|
347
|
+
call: string;
|
|
348
|
+
args?: unknown;
|
|
349
|
+
}
|
|
294
350
|
/** Asks the sketch worker to save the recording of the session so far. */
|
|
295
351
|
| {
|
|
296
352
|
type: 'save-recording';
|
|
@@ -312,6 +368,8 @@ export type SketchWorkerMessage = SketchWorkerInit
|
|
|
312
368
|
| typeof WAKE;
|
|
313
369
|
/** Sends a reply from a worker to the page, moving the `transfer` objects instead of copying them. */
|
|
314
370
|
export declare function replyToPage(message: WorkerReply, transfer?: Transferable[]): void;
|
|
371
|
+
/** Sends the page the pipeline list of the first frame, which the page stores for the next start. */
|
|
372
|
+
export declare function sendPipelineList(list: Uint32Array): void;
|
|
315
373
|
/**
|
|
316
374
|
* Sends the page a captured frame, as pixels or as an image file, once `capture` resolves, or the
|
|
317
375
|
* reason it failed.
|
package/lib/workers/protocol.js
CHANGED
|
@@ -10,6 +10,10 @@ export function startWorkerCore(handoff, step) {
|
|
|
10
10
|
export function replyToPage(message, transfer = []) {
|
|
11
11
|
postMessage(message, { transfer });
|
|
12
12
|
}
|
|
13
|
+
/** Sends the page the pipeline list of the first frame, which the page stores for the next start. */
|
|
14
|
+
export function sendPipelineList(list) {
|
|
15
|
+
replyToPage({ type: 'pipeline-list', list }, [list.buffer]);
|
|
16
|
+
}
|
|
13
17
|
/**
|
|
14
18
|
* Sends the page a captured frame, as pixels or as an image file, once `capture` resolves, or the
|
|
15
19
|
* reason it failed.
|
|
@@ -3,26 +3,37 @@
|
|
|
3
3
|
// shared memory, so it runs no copy of the engine's core. The canvas cannot go back to the page once
|
|
4
4
|
// it is here, so when the engine stops, the worker keeps it: it frees its GPU device and lets go of
|
|
5
5
|
// the engine's memory, and the next engine on the same canvas starts it again with its own.
|
|
6
|
+
import { DEV } from '../errors/checks.js';
|
|
6
7
|
import { messageOf } from '../errors/message.js';
|
|
7
|
-
import { recordPermutations, stopRecordingPermutations } from '../gpu/variants.js';
|
|
8
|
-
import { captureFrame, captureImage,
|
|
8
|
+
import { recordPermutations, reportPermutations, stopRecordingPermutations } from '../gpu/variants.js';
|
|
9
|
+
import { captureFrame, captureImage, startDrawing, startEarly } from '../render/draw.js';
|
|
9
10
|
import { controlViews } from '../shared/control.js';
|
|
10
11
|
import { setWakeByMessage } from '../shared/wake.js';
|
|
11
12
|
import { DrawingHost } from './drawing-host.js';
|
|
12
|
-
import { replyToPage, replyWithCapture, startSteps, startWorker, } from './protocol.js';
|
|
13
|
+
import { replyToPage, replyWithCapture, sendPipelineList, startSteps, startWorker, } from './protocol.js';
|
|
13
14
|
let host = new DrawingHost();
|
|
14
15
|
let controlSlots;
|
|
15
16
|
/** The canvas that the first engine moved here, which every later engine draws on. */
|
|
16
17
|
let canvas;
|
|
17
18
|
/** The running engine's image port, which a park lets go of. */
|
|
18
19
|
let imagePort;
|
|
20
|
+
/** What the worker started for the next engine's renderer, until that engine's setup arrives. */
|
|
21
|
+
let early;
|
|
22
|
+
/** Destroys the device of an early start that no renderer took. */
|
|
23
|
+
function releaseEarly() {
|
|
24
|
+
early?.release();
|
|
25
|
+
early = undefined;
|
|
26
|
+
}
|
|
19
27
|
const step = startSteps('render');
|
|
20
28
|
startWorker('render', step, async (event) => {
|
|
21
29
|
const message = event.data;
|
|
22
30
|
if (message.type === 'load-shaders') {
|
|
23
|
-
|
|
31
|
+
releaseEarly();
|
|
32
|
+
early = startEarly(message);
|
|
24
33
|
}
|
|
25
34
|
else if (message.type === 'init') {
|
|
35
|
+
const started = early;
|
|
36
|
+
early = undefined;
|
|
26
37
|
try {
|
|
27
38
|
canvas = message.canvas ?? canvas;
|
|
28
39
|
if (!canvas)
|
|
@@ -31,6 +42,8 @@ startWorker('render', step, async (event) => {
|
|
|
31
42
|
// page stops it once the held frame has drawn them.
|
|
32
43
|
if (message.recordPermutations)
|
|
33
44
|
recordPermutations();
|
|
45
|
+
if (DEV)
|
|
46
|
+
reportPermutations((word) => replyToPage({ type: 'permutation', word }));
|
|
34
47
|
host = new DrawingHost();
|
|
35
48
|
imagePort = message.imagePort;
|
|
36
49
|
controlSlots = controlViews(message.control).slots;
|
|
@@ -38,10 +51,12 @@ startWorker('render', step, async (event) => {
|
|
|
38
51
|
const drawing = await host.start(startDrawing({
|
|
39
52
|
...message,
|
|
40
53
|
canvas,
|
|
54
|
+
early: started,
|
|
41
55
|
scene: message.memory && { memory: message.memory, control: message.control },
|
|
42
56
|
fail: (reason) => replyToPage({ type: 'lost', role: 'render', reason }),
|
|
43
57
|
fault: (error) => replyToPage({ type: 'fault', role: 'render', message: messageOf(error) }),
|
|
44
|
-
gpuError: (
|
|
58
|
+
gpuError: (kind, text) => replyToPage({ type: 'gpu-error', role: 'render', kind, message: text }),
|
|
59
|
+
listBuilds: message.keepBuilds ? sendPipelineList : undefined,
|
|
45
60
|
}));
|
|
46
61
|
if (!drawing)
|
|
47
62
|
return;
|
|
@@ -53,6 +68,7 @@ startWorker('render', step, async (event) => {
|
|
|
53
68
|
});
|
|
54
69
|
}
|
|
55
70
|
catch (e) {
|
|
71
|
+
started?.release();
|
|
56
72
|
await host.release();
|
|
57
73
|
replyToPage({
|
|
58
74
|
type: 'error',
|
|
@@ -71,10 +87,18 @@ startWorker('render', step, async (event) => {
|
|
|
71
87
|
else if (message.type === 'lose-gpu') {
|
|
72
88
|
host.drawing?.simulateLoss();
|
|
73
89
|
}
|
|
90
|
+
else if (message.type === 'page-cache') {
|
|
91
|
+
if (message.cached)
|
|
92
|
+
host.drawing?.enterPageCache();
|
|
93
|
+
else
|
|
94
|
+
await host.drawing?.leavePageCache();
|
|
95
|
+
}
|
|
74
96
|
else if (message.type === 'stop-drawing') {
|
|
97
|
+
releaseEarly();
|
|
75
98
|
await host.stop('render');
|
|
76
99
|
}
|
|
77
100
|
else if (message.type === 'park') {
|
|
101
|
+
releaseEarly();
|
|
78
102
|
imagePort?.close();
|
|
79
103
|
imagePort = undefined;
|
|
80
104
|
controlSlots = undefined;
|
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
// The sketch worker: runs the sketch's code and the engine core. In pipelined mode it computes frame
|
|
2
2
|
// N+1 while the render worker draws frame N, and waits for the render worker's signal without
|
|
3
3
|
// blocking, so its event loop stays alive for promises and messages. In low-latency mode it
|
|
4
|
-
// also owns the canvas and draws each frame itself; only then does it load the renderer.
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
4
|
+
// also owns the canvas and draws each frame itself; only then does it load the renderer. A live
|
|
5
|
+
// sketch's module loads as soon as the page names it, while the core downloads, so the module's own
|
|
6
|
+
// imports and its top-level code do not wait for the core. When the engine stops, the sketch's
|
|
7
|
+
// onDestroy runs here. A worker that drew keeps the canvas, which cannot go back to the page: it
|
|
8
|
+
// frees its GPU device and lets go of the engine's core, and the next engine on the same canvas
|
|
9
|
+
// starts it again.
|
|
8
10
|
import { DEV } from '../errors/checks.js';
|
|
9
11
|
import { messageOf } from '../errors/message.js';
|
|
10
|
-
import { recordPermutations, stopRecordingPermutations } from '../gpu/variants.js';
|
|
11
|
-
import { loadDrawModule,
|
|
12
|
+
import { recordPermutations, reportPermutations, stopRecordingPermutations } from '../gpu/variants.js';
|
|
13
|
+
import { loadDrawModule, preloadDrawing } from '../render/load-draw.js';
|
|
12
14
|
import { awaitLater } from '../shared/await-later.js';
|
|
13
15
|
import { controlViews } from '../shared/control.js';
|
|
14
16
|
import { drawingSenders, ImageTable } from '../shared/images.js';
|
|
15
17
|
import { clearJobTasks, jobAsker, setJobTasks } from '../shared/task-host.js';
|
|
16
|
-
import { onAddonChecked } from '../shared/version.js';
|
|
18
|
+
import { hearAddonsEarly, onAddonChecked } from '../shared/version.js';
|
|
17
19
|
import { setWakeByMessage, wakeWaiters } from '../shared/wake.js';
|
|
18
20
|
import { loadSketch } from '../sketch/define-sketch.js';
|
|
19
|
-
import { runPipelined, SketchRunner } from '../sketch/runner.js';
|
|
21
|
+
import { runPipelined, SketchRunner, startListedFiles } from '../sketch/runner.js';
|
|
20
22
|
import { DrawingHost } from './drawing-host.js';
|
|
21
|
-
import { replyToPage, replyWithCapture, startSteps, startWorker, startWorkerCore, } from './protocol.js';
|
|
23
|
+
import { replyToPage, replyWithCapture, sendPipelineList, startSteps, startWorker, startWorkerCore, } from './protocol.js';
|
|
22
24
|
let runner;
|
|
23
25
|
/** The renderer, which this worker loads only in low-latency mode, where it draws. */
|
|
24
26
|
let drawLoad;
|
|
25
27
|
let draw;
|
|
28
|
+
/** What the worker started for its renderer in low-latency mode, until the renderer takes it. */
|
|
29
|
+
let early;
|
|
26
30
|
let host = new DrawingHost();
|
|
27
31
|
let controlSlots;
|
|
28
32
|
/** The canvas that the first engine moved here in low-latency mode, which later engines draw on. */
|
|
@@ -30,6 +34,13 @@ let canvas;
|
|
|
30
34
|
let core;
|
|
31
35
|
/** The job workers' task ports that this worker's on-demand loader uses while the engine runs. */
|
|
32
36
|
let jobTaskHost;
|
|
37
|
+
/**
|
|
38
|
+
* The import of a live sketch's module that started before the core arrived, with its address, and
|
|
39
|
+
* the downloads of the files that its options list.
|
|
40
|
+
*/
|
|
41
|
+
let earlySketch;
|
|
42
|
+
/** In a development build, the add-ons that the sketch's module loaded before the runner existed. */
|
|
43
|
+
let earlyAddons;
|
|
33
44
|
const step = startSteps('sketch');
|
|
34
45
|
startWorker('sketch', step, async (event) => {
|
|
35
46
|
const message = event.data;
|
|
@@ -43,9 +54,35 @@ startWorker('sketch', step, async (event) => {
|
|
|
43
54
|
}
|
|
44
55
|
else if (message.type === 'load-shaders') {
|
|
45
56
|
drawLoad ??= loadDrawModule();
|
|
46
|
-
|
|
57
|
+
releaseEarly();
|
|
58
|
+
early = preloadDrawing(drawLoad, message);
|
|
59
|
+
}
|
|
60
|
+
else if (message.type === 'load-sketch') {
|
|
61
|
+
// A development build hears each add-on that the module loads from before its import begins,
|
|
62
|
+
// and hands them to the runner once it exists.
|
|
63
|
+
if (DEV) {
|
|
64
|
+
endEarlyAddons();
|
|
65
|
+
earlyAddons = hearAddonsEarly();
|
|
66
|
+
}
|
|
67
|
+
earlySketch = {
|
|
68
|
+
url: message.url,
|
|
69
|
+
sketch: awaitLater(loadSketch(message.url, { step })),
|
|
70
|
+
listed: {},
|
|
71
|
+
};
|
|
72
|
+
step('sketch import started');
|
|
73
|
+
// The files that the sketch lists start downloading as soon as its module has loaded.
|
|
74
|
+
const { sketch, listed } = earlySketch;
|
|
75
|
+
sketch.then((loaded) => startListedFiles(listed, loaded, message.pageUrl), () => { });
|
|
47
76
|
}
|
|
48
77
|
else if (message.type === 'init') {
|
|
78
|
+
// Only a live start takes the module that loaded early: hold mode, a replay and a recording
|
|
79
|
+
// load it once the runner has seeded the thread's random numbers.
|
|
80
|
+
const live = message.hold === undefined && message.replay === undefined && !message.record;
|
|
81
|
+
const taken = live && earlySketch?.url === message.sketchUrl ? earlySketch : undefined;
|
|
82
|
+
const loadedSketch = taken?.sketch;
|
|
83
|
+
earlySketch = undefined;
|
|
84
|
+
if (DEV && !loadedSketch)
|
|
85
|
+
endEarlyAddons();
|
|
49
86
|
try {
|
|
50
87
|
// The renderer loads while the core and the sketch start, if the page did not ask for it
|
|
51
88
|
// sooner.
|
|
@@ -89,6 +126,7 @@ startWorker('sketch', step, async (event) => {
|
|
|
89
126
|
...senders,
|
|
90
127
|
pageUrl: message.pageUrl,
|
|
91
128
|
sketchUrl: message.sketchUrl,
|
|
129
|
+
data: message.data,
|
|
92
130
|
maxTargetFps: message.maxTargetFps,
|
|
93
131
|
threads: message.threads,
|
|
94
132
|
twoStepProbe: message.twoStepProbe,
|
|
@@ -96,13 +134,24 @@ startWorker('sketch', step, async (event) => {
|
|
|
96
134
|
wantJobs,
|
|
97
135
|
sendLabelSlot: (id, table, slot, generation) => replyToPage({ type: 'label', id, table, slot, generation }),
|
|
98
136
|
reportSketchError: (message) => replyToPage({ type: 'sketch-error', message }),
|
|
99
|
-
|
|
100
|
-
|
|
137
|
+
listed: taken?.listed,
|
|
138
|
+
// What the sketch's module loaded before the runner existed, then each later load.
|
|
139
|
+
...(DEV && {
|
|
140
|
+
hearAddons: (heard) => {
|
|
141
|
+
const before = earlyAddons;
|
|
142
|
+
earlyAddons = undefined;
|
|
143
|
+
return before?.hand(heard) ?? onAddonChecked(heard);
|
|
144
|
+
},
|
|
145
|
+
}),
|
|
101
146
|
}, message.hold, message.holdScript, message.replay, message.record, message.debugView);
|
|
147
|
+
// A runner that hears no add-ons leaves the early hearing to end here.
|
|
148
|
+
if (DEV)
|
|
149
|
+
endEarlyAddons();
|
|
102
150
|
step('engine created');
|
|
103
|
-
// The sketch downloads while the renderer starts
|
|
104
|
-
// so a warm-up in the setup has a renderer to build its
|
|
105
|
-
|
|
151
|
+
// The sketch downloads while the renderer starts, unless it loaded while the core did. The
|
|
152
|
+
// renderer starts before the setup, so a warm-up in the setup has a renderer to build its
|
|
153
|
+
// pipelines.
|
|
154
|
+
const sketch = loadedSketch ?? awaitLater(loadSketch(message.sketchUrl, { step }));
|
|
106
155
|
/** The GPU path that this worker draws with, in low-latency mode. */
|
|
107
156
|
let tier;
|
|
108
157
|
if (message.renderer && drawModule) {
|
|
@@ -111,9 +160,14 @@ startWorker('sketch', step, async (event) => {
|
|
|
111
160
|
// pipelines ask for. The page stops it once the held frame has drawn them.
|
|
112
161
|
if (message.renderer.recordPermutations)
|
|
113
162
|
recordPermutations();
|
|
163
|
+
if (DEV)
|
|
164
|
+
reportPermutations((word) => replyToPage({ type: 'permutation', word }));
|
|
114
165
|
step('renderer loaded');
|
|
166
|
+
const started = early;
|
|
167
|
+
early = undefined;
|
|
115
168
|
const drawing = await host.start(draw.startDrawing({
|
|
116
169
|
...message.renderer,
|
|
170
|
+
early: await started,
|
|
117
171
|
canvas: canvas,
|
|
118
172
|
metrics: message.metrics,
|
|
119
173
|
device: message.device,
|
|
@@ -123,7 +177,8 @@ startWorker('sketch', step, async (event) => {
|
|
|
123
177
|
imageTable,
|
|
124
178
|
fail: (reason) => replyToPage({ type: 'lost', role: 'sketch', reason }),
|
|
125
179
|
fault,
|
|
126
|
-
gpuError: (
|
|
180
|
+
gpuError: (kind, text) => replyToPage({ type: 'gpu-error', role: 'sketch', kind, message: text }),
|
|
181
|
+
listBuilds: message.renderer.keepBuilds ? sendPipelineList : undefined,
|
|
127
182
|
}));
|
|
128
183
|
if (!drawing)
|
|
129
184
|
return;
|
|
@@ -155,6 +210,9 @@ startWorker('sketch', step, async (event) => {
|
|
|
155
210
|
});
|
|
156
211
|
}
|
|
157
212
|
catch (e) {
|
|
213
|
+
if (DEV)
|
|
214
|
+
endEarlyAddons();
|
|
215
|
+
releaseEarly();
|
|
158
216
|
await host.release();
|
|
159
217
|
replyToPage({
|
|
160
218
|
type: 'error',
|
|
@@ -177,6 +235,22 @@ startWorker('sketch', step, async (event) => {
|
|
|
177
235
|
else if (message.type === 'post') {
|
|
178
236
|
runner?.receive(message.name, message.data);
|
|
179
237
|
}
|
|
238
|
+
else if (message.type === 'inspect') {
|
|
239
|
+
// The inspection channel is a development build's: a release build answers that it has none.
|
|
240
|
+
try {
|
|
241
|
+
if (!DEV || runner?.inspect === undefined)
|
|
242
|
+
throw new Error('The inspector needs a development build. Run the Vite dev server, not a production build.');
|
|
243
|
+
replyToPage({
|
|
244
|
+
type: 'inspect-reply',
|
|
245
|
+
id: message.id,
|
|
246
|
+
ok: true,
|
|
247
|
+
result: await runner.inspect(message.call, message.args),
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
catch (e) {
|
|
251
|
+
replyToPage({ type: 'inspect-reply', id: message.id, ok: false, error: messageOf(e) });
|
|
252
|
+
}
|
|
253
|
+
}
|
|
180
254
|
else if (message.type === 'capture' && draw && host.drawing && controlSlots) {
|
|
181
255
|
const capture = message.image ? draw.captureImage : draw.captureFrame;
|
|
182
256
|
await replyWithCapture(capture(host.drawing, controlSlots));
|
|
@@ -187,12 +261,20 @@ startWorker('sketch', step, async (event) => {
|
|
|
187
261
|
else if (message.type === 'lose-gpu') {
|
|
188
262
|
host.drawing?.simulateLoss();
|
|
189
263
|
}
|
|
264
|
+
else if (message.type === 'page-cache') {
|
|
265
|
+
if (message.cached)
|
|
266
|
+
host.drawing?.enterPageCache();
|
|
267
|
+
else
|
|
268
|
+
await host.drawing?.leavePageCache();
|
|
269
|
+
}
|
|
190
270
|
else if (message.type === 'stop-drawing') {
|
|
271
|
+
releaseEarly();
|
|
191
272
|
runner?.dispose();
|
|
192
273
|
runner = undefined;
|
|
193
274
|
await host.stop('sketch');
|
|
194
275
|
}
|
|
195
276
|
else if (message.type === 'park') {
|
|
277
|
+
releaseEarly();
|
|
196
278
|
controlSlots = undefined;
|
|
197
279
|
clearJobTasks(jobTaskHost);
|
|
198
280
|
jobTaskHost = undefined;
|
|
@@ -200,6 +282,16 @@ startWorker('sketch', step, async (event) => {
|
|
|
200
282
|
core = undefined;
|
|
201
283
|
}
|
|
202
284
|
});
|
|
285
|
+
/** Ends a development build's hearing of add-ons for a runner that did not exist yet. */
|
|
286
|
+
function endEarlyAddons() {
|
|
287
|
+
earlyAddons?.stop();
|
|
288
|
+
earlyAddons = undefined;
|
|
289
|
+
}
|
|
290
|
+
/** Destroys the device of an early start that no renderer took. */
|
|
291
|
+
function releaseEarly() {
|
|
292
|
+
void early?.then((start) => start?.release());
|
|
293
|
+
early = undefined;
|
|
294
|
+
}
|
|
203
295
|
/** Tells the page that the sketch's frame loop, or the drawing in low-latency mode, failed. */
|
|
204
296
|
function fault(error) {
|
|
205
297
|
replyToPage({ type: 'fault', role: 'sketch', message: messageOf(error) });
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@null3d/engine",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The null3D engine, a browser 3D engine for
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "The null3D engine, a high-performance browser 3D engine for agents, faster than three.js, with wide device compatibility: the TypeScript API, the page shim, the worker entry points, both WebAssembly builds and the docs.",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"author": "Ramesh Nair (https://hiddentao.com)",
|
|
7
7
|
"homepage": "https://github.com/null3d-engine/null3d#readme",
|