@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,475 @@
|
|
|
1
|
+
// The in-page inspector: a panel docked at the left edge of the page, in a development build. It
|
|
2
|
+
// lists the scene as a tree, selects an object and outlines it in the view, edits its transform, its
|
|
3
|
+
// material and its visibility, and shows the engine's frame figures. It reads and writes the live
|
|
4
|
+
// scene through the page's inspection bridge (`engine.inspect`), so each change is applied between
|
|
5
|
+
// frames. The page loads this module on first use, when the `?inspect` switch asks for it.
|
|
6
|
+
/** The most rows that the tree draws at once, so a scene of many thousands stays responsive. */
|
|
7
|
+
const MAX_ROWS = 2000;
|
|
8
|
+
/** How long the search waits for the next key before it lists the scene again. */
|
|
9
|
+
const SEARCH_DELAY_MS = 150;
|
|
10
|
+
/** How often the panel reads the frame figures. */
|
|
11
|
+
const STATS_MS = 1000;
|
|
12
|
+
const CSS = `
|
|
13
|
+
:host { all: initial; }
|
|
14
|
+
.panel {
|
|
15
|
+
--ok: #3ddc97; --amber: #f2b453; --line: rgba(255, 255, 255, 0.08);
|
|
16
|
+
--line-soft: rgba(255, 255, 255, 0.045);
|
|
17
|
+
--text: #e9eef7; --dim: #98a3b6; --faint: #7a8699;
|
|
18
|
+
position: fixed; left: 0; top: 0; bottom: 0; z-index: 2147483646;
|
|
19
|
+
width: 320px; max-width: 82vw;
|
|
20
|
+
display: flex; flex-direction: column;
|
|
21
|
+
background: linear-gradient(180deg, rgba(20, 25, 33, 0.97), rgba(13, 17, 23, 0.98));
|
|
22
|
+
border-right: 1px solid rgba(255, 255, 255, 0.1);
|
|
23
|
+
box-shadow: 12px 0 30px rgba(0, 0, 0, 0.4);
|
|
24
|
+
color: var(--text);
|
|
25
|
+
font: 12px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
|
26
|
+
font-variant-numeric: tabular-nums;
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
}
|
|
29
|
+
.head { display: flex; align-items: baseline; gap: 8px; padding: 12px 14px 10px; border-bottom: 1px solid var(--line); }
|
|
30
|
+
.head .title { font-weight: 600; font-size: 14px; letter-spacing: 0.01em; }
|
|
31
|
+
.head .meta { margin-left: auto; color: var(--faint); font-size: 10px; }
|
|
32
|
+
.head button {
|
|
33
|
+
border: 0; background: none; color: var(--faint); font: inherit; font-size: 16px;
|
|
34
|
+
cursor: pointer; padding: 0 2px; line-height: 1;
|
|
35
|
+
}
|
|
36
|
+
.head button:hover { color: var(--text); }
|
|
37
|
+
.find { padding: 10px 12px 6px; }
|
|
38
|
+
.find input, .field input {
|
|
39
|
+
box-sizing: border-box; width: 100%;
|
|
40
|
+
border: 1px solid var(--line); border-radius: 6px; background: #11161f;
|
|
41
|
+
color: var(--text); font: inherit; padding: 4px 7px; outline: none;
|
|
42
|
+
}
|
|
43
|
+
.find input:focus, .field input:focus { border-color: rgba(242, 180, 83, 0.55); }
|
|
44
|
+
.tree { flex: 1 1 26%; min-height: 70px; overflow: auto; padding: 2px 8px 8px; }
|
|
45
|
+
.row { display: flex; align-items: center; gap: 5px; padding: 2px 5px; border-radius: 5px; cursor: pointer; color: var(--dim); }
|
|
46
|
+
.row:hover { background: rgba(255, 255, 255, 0.04); }
|
|
47
|
+
.row.sel { background: rgba(242, 180, 83, 0.14); color: var(--text); }
|
|
48
|
+
.row .tw { width: 10px; flex: none; text-align: center; color: var(--faint); }
|
|
49
|
+
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
50
|
+
.row .kind { margin-left: auto; font-size: 9px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--faint); flex: none; }
|
|
51
|
+
.truncated { color: var(--faint); padding: 6px 8px; font-size: 10.5px; }
|
|
52
|
+
.detail { border-top: 1px solid var(--line); padding: 9px 12px 10px; overflow: auto; flex: 1 1 auto; min-height: 0; }
|
|
53
|
+
.detail .empty { color: var(--faint); }
|
|
54
|
+
.detail .title { font-weight: 600; font-size: 12.5px; }
|
|
55
|
+
.detail .meta { color: var(--faint); font-size: 9.5px; margin-left: 6px; }
|
|
56
|
+
.group { margin-top: 8px; }
|
|
57
|
+
.group .label { font-size: 8.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin-bottom: 3px; }
|
|
58
|
+
.triple { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
|
|
59
|
+
.triple input { text-align: right; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10.5px; padding: 3px 5px; }
|
|
60
|
+
.check { display: flex; align-items: center; gap: 6px; color: var(--dim); }
|
|
61
|
+
.check input { width: 14px; height: 14px; accent-color: #3ddc97; }
|
|
62
|
+
.material { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
|
|
63
|
+
.mat-row { display: flex; align-items: center; gap: 7px; color: var(--dim); }
|
|
64
|
+
.mat-row .name { width: 74px; flex: none; }
|
|
65
|
+
.mat-row input[type="color"] { width: 26px; height: 20px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: #11161f; }
|
|
66
|
+
.mat-row input[type="range"] { flex: 1; min-width: 0; accent-color: #a98bfa; }
|
|
67
|
+
.mat-row input[type="number"] { width: 48px; text-align: right; font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; padding: 2px 4px; }
|
|
68
|
+
.figures { border-top: 1px solid var(--line); padding: 8px 12px 11px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
|
|
69
|
+
.fig { background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line-soft); border-radius: 6px; padding: 4px 6px; min-width: 0; }
|
|
70
|
+
.fig .k { font-size: 8px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
|
|
71
|
+
.fig .v { font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
72
|
+
.fig .v small { font-size: 8px; font-weight: 500; color: var(--dim); }
|
|
73
|
+
.error { color: #ff8074; padding: 0 12px 8px; font-size: 10.5px; }
|
|
74
|
+
.hint { color: var(--faint); font-size: 10px; padding: 0 12px 8px; }
|
|
75
|
+
`;
|
|
76
|
+
/** The panel's element, which a page finds by this attribute. */
|
|
77
|
+
export const INSPECTOR_ATTRIBUTE = 'data-null3d-inspector';
|
|
78
|
+
/** Makes an element with a class and, where given, text. */
|
|
79
|
+
function el(tag, className, text) {
|
|
80
|
+
const node = document.createElement(tag);
|
|
81
|
+
if (className !== undefined)
|
|
82
|
+
node.className = className;
|
|
83
|
+
if (text !== undefined)
|
|
84
|
+
node.textContent = text;
|
|
85
|
+
return node;
|
|
86
|
+
}
|
|
87
|
+
/** Throws the bridge's error as an Error with its text, whatever it was. */
|
|
88
|
+
function asError(error) {
|
|
89
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
90
|
+
}
|
|
91
|
+
/** Puts the panel's style sheet in its shadow root, passing a Content Security Policy without 'unsafe-inline'. */
|
|
92
|
+
function installStyles(root) {
|
|
93
|
+
try {
|
|
94
|
+
const sheet = new CSSStyleSheet();
|
|
95
|
+
sheet.replaceSync(CSS);
|
|
96
|
+
root.adoptedStyleSheets = [sheet];
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
const style = document.createElement('style');
|
|
100
|
+
style.textContent = CSS;
|
|
101
|
+
root.append(style);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** Turns a quaternion (x, y, z, w) into X, then Y, then Z Euler angles in radians, as the engine's setRotationEuler takes. */
|
|
105
|
+
function quaternionToEuler(q) {
|
|
106
|
+
const x = q[0];
|
|
107
|
+
const y = q[1];
|
|
108
|
+
const z = q[2];
|
|
109
|
+
const w = q[3];
|
|
110
|
+
const ex = Math.atan2(2 * (w * x + y * z), 1 - 2 * (x * x + y * y));
|
|
111
|
+
const sy = 2 * (w * y - z * x);
|
|
112
|
+
const ey = Math.asin(Math.min(1, Math.max(-1, sy)));
|
|
113
|
+
const ez = Math.atan2(2 * (w * z + x * y), 1 - 2 * (y * y + z * z));
|
|
114
|
+
return [ex, ey, ez];
|
|
115
|
+
}
|
|
116
|
+
/** The panel of the in-page inspector. */
|
|
117
|
+
export class Inspector {
|
|
118
|
+
bridge;
|
|
119
|
+
host;
|
|
120
|
+
tree = el('div', 'tree');
|
|
121
|
+
detail = el('div', 'detail');
|
|
122
|
+
figures = el('div', 'figures');
|
|
123
|
+
count = el('span', 'meta', '');
|
|
124
|
+
search = el('input');
|
|
125
|
+
error = el('div', 'error');
|
|
126
|
+
treeRows = [];
|
|
127
|
+
collapsed = new Set();
|
|
128
|
+
selected;
|
|
129
|
+
summaries = new Map();
|
|
130
|
+
statsTimer;
|
|
131
|
+
searchTimer;
|
|
132
|
+
selectToken = 0;
|
|
133
|
+
listToken = 0;
|
|
134
|
+
statsBusy = false;
|
|
135
|
+
removed = false;
|
|
136
|
+
constructor(bridge) {
|
|
137
|
+
this.bridge = bridge;
|
|
138
|
+
this.host = document.createElement('div');
|
|
139
|
+
this.host.setAttribute(INSPECTOR_ATTRIBUTE, '');
|
|
140
|
+
const root = this.host.attachShadow({ mode: 'open' });
|
|
141
|
+
installStyles(root);
|
|
142
|
+
const panel = el('div', 'panel');
|
|
143
|
+
const head = el('div', 'head');
|
|
144
|
+
head.append(el('span', 'title', 'Scene'), this.count);
|
|
145
|
+
const close = el('button', '', '×');
|
|
146
|
+
close.type = 'button';
|
|
147
|
+
close.setAttribute('aria-label', 'Close the inspector');
|
|
148
|
+
close.addEventListener('click', () => this.remove());
|
|
149
|
+
const refresh = el('button', '', '↻');
|
|
150
|
+
refresh.type = 'button';
|
|
151
|
+
refresh.title = 'List the scene again';
|
|
152
|
+
refresh.setAttribute('aria-label', 'List the scene again');
|
|
153
|
+
refresh.addEventListener('click', () => void this.list());
|
|
154
|
+
head.append(refresh, close);
|
|
155
|
+
this.search.type = 'search';
|
|
156
|
+
this.search.placeholder = 'Find an object';
|
|
157
|
+
this.search.setAttribute('aria-label', 'Find an object by name');
|
|
158
|
+
this.search.addEventListener('input', () => this.scheduleSearch());
|
|
159
|
+
const find = el('div', 'find');
|
|
160
|
+
find.append(this.search);
|
|
161
|
+
this.detail.append(el('div', 'empty', 'Select an object to edit it.'));
|
|
162
|
+
const hint = el('div', 'hint', '?inspect · development build');
|
|
163
|
+
panel.append(head, find, this.tree, this.detail, this.figures, this.error, hint);
|
|
164
|
+
root.append(panel);
|
|
165
|
+
panel.addEventListener('keydown', (event) => {
|
|
166
|
+
if (event.key === 'Escape')
|
|
167
|
+
this.remove();
|
|
168
|
+
});
|
|
169
|
+
document.body.append(this.host);
|
|
170
|
+
void this.list();
|
|
171
|
+
this.refreshStats();
|
|
172
|
+
this.statsTimer = setInterval(() => this.refreshStats(), STATS_MS);
|
|
173
|
+
}
|
|
174
|
+
/** Takes the panel off the page and clears the selection's outline. */
|
|
175
|
+
remove() {
|
|
176
|
+
if (this.removed)
|
|
177
|
+
return;
|
|
178
|
+
this.removed = true;
|
|
179
|
+
if (this.statsTimer !== undefined)
|
|
180
|
+
clearInterval(this.statsTimer);
|
|
181
|
+
if (this.searchTimer !== undefined)
|
|
182
|
+
clearTimeout(this.searchTimer);
|
|
183
|
+
this.host.remove();
|
|
184
|
+
void this.bridge.inspect('highlight', {}).catch(() => { });
|
|
185
|
+
}
|
|
186
|
+
/** Lists the scene again after the search settles. */
|
|
187
|
+
scheduleSearch() {
|
|
188
|
+
if (this.searchTimer !== undefined)
|
|
189
|
+
clearTimeout(this.searchTimer);
|
|
190
|
+
this.searchTimer = setTimeout(() => {
|
|
191
|
+
this.searchTimer = undefined;
|
|
192
|
+
void this.list();
|
|
193
|
+
}, SEARCH_DELAY_MS);
|
|
194
|
+
}
|
|
195
|
+
/** Lists the scene, or the objects that the search names, and draws the tree. */
|
|
196
|
+
async list() {
|
|
197
|
+
const token = ++this.listToken;
|
|
198
|
+
try {
|
|
199
|
+
const answer = (await this.bridge.inspect('objects', {
|
|
200
|
+
filter: this.search.value.trim() || undefined,
|
|
201
|
+
}));
|
|
202
|
+
if (token !== this.listToken || this.removed)
|
|
203
|
+
return;
|
|
204
|
+
this.showError(undefined);
|
|
205
|
+
this.summaries = new Map(answer.objects.map((object) => [object.slot, object]));
|
|
206
|
+
this.count.textContent = `${answer.count} object${answer.count === 1 ? '' : 's'}`;
|
|
207
|
+
this.drawTree(answer);
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
if (token === this.listToken)
|
|
211
|
+
this.showError(asError(error).message);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/** Draws the tree from a listing, parents before their children, with the rows nested. */
|
|
215
|
+
drawTree(listing) {
|
|
216
|
+
this.tree.replaceChildren();
|
|
217
|
+
this.treeRows.length = 0;
|
|
218
|
+
const children = new Map();
|
|
219
|
+
for (const object of listing.objects) {
|
|
220
|
+
const parent = object.parent !== null && this.summaries.has(object.parent) ? object.parent : null;
|
|
221
|
+
const list = children.get(parent);
|
|
222
|
+
if (list === undefined)
|
|
223
|
+
children.set(parent, [object]);
|
|
224
|
+
else
|
|
225
|
+
list.push(object);
|
|
226
|
+
}
|
|
227
|
+
let rows = 0;
|
|
228
|
+
const append = (parent, depth) => {
|
|
229
|
+
const list = children.get(parent);
|
|
230
|
+
if (list === undefined)
|
|
231
|
+
return;
|
|
232
|
+
for (const object of list) {
|
|
233
|
+
if (rows >= MAX_ROWS)
|
|
234
|
+
return;
|
|
235
|
+
const row = el('div', 'row');
|
|
236
|
+
row.style.paddingLeft = `${5 + depth * 12}px`;
|
|
237
|
+
row.dataset.slot = String(object.slot);
|
|
238
|
+
const hasChildren = object.children > 0 && children.has(object.slot);
|
|
239
|
+
const twist = el('span', 'tw', hasChildren ? (this.collapsed.has(object.slot) ? '▸' : '▾') : '·');
|
|
240
|
+
twist.addEventListener('click', (event) => {
|
|
241
|
+
event.stopPropagation();
|
|
242
|
+
if (this.collapsed.has(object.slot))
|
|
243
|
+
this.collapsed.delete(object.slot);
|
|
244
|
+
else
|
|
245
|
+
this.collapsed.add(object.slot);
|
|
246
|
+
this.drawTree(listing);
|
|
247
|
+
});
|
|
248
|
+
row.append(twist, el('span', 'name', object.name || '(unnamed)'), el('span', 'kind', object.kind));
|
|
249
|
+
row.addEventListener('click', () => void this.select(object.slot));
|
|
250
|
+
if (object.slot === this.selected)
|
|
251
|
+
row.classList.add('sel');
|
|
252
|
+
row.setAttribute('role', 'treeitem');
|
|
253
|
+
this.tree.append(row);
|
|
254
|
+
this.treeRows.push(row);
|
|
255
|
+
rows++;
|
|
256
|
+
if (hasChildren && !this.collapsed.has(object.slot))
|
|
257
|
+
append(object.slot, depth + 1);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
append(null, 0);
|
|
261
|
+
if (listing.truncated || listing.count > rows)
|
|
262
|
+
this.tree.append(el('div', 'truncated', `Showing the first ${rows} of ${listing.count}. Search to narrow the list.`));
|
|
263
|
+
}
|
|
264
|
+
/** Selects `slot`, outlines it and shows its fields. */
|
|
265
|
+
async select(slot) {
|
|
266
|
+
const token = ++this.selectToken;
|
|
267
|
+
this.selected = slot;
|
|
268
|
+
for (const row of this.treeRows) {
|
|
269
|
+
row.classList.toggle('sel', row.dataset.slot === String(slot));
|
|
270
|
+
}
|
|
271
|
+
try {
|
|
272
|
+
const detail = (await this.bridge.inspect('object', { selector: slot }));
|
|
273
|
+
if (token !== this.selectToken || this.removed)
|
|
274
|
+
return;
|
|
275
|
+
this.showError(undefined);
|
|
276
|
+
this.drawDetail(detail);
|
|
277
|
+
await this.bridge.inspect('highlight', { selector: slot });
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
if (token === this.selectToken)
|
|
281
|
+
this.showError(asError(error).message);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/** Shows an object's title, transform, flags and material. */
|
|
285
|
+
drawDetail(detail) {
|
|
286
|
+
const title = el('div');
|
|
287
|
+
title.append(el('span', 'title', detail.name || '(unnamed)'), el('span', 'meta', `#${detail.slot} · ${detail.kind}`));
|
|
288
|
+
const position = this.vectorGroup('Position · m', detail.position, 0.1, (values) => this.change({ selector: detail.slot, position: values }));
|
|
289
|
+
const euler = quaternionToEuler(detail.rotation).map((radians) => Number(((radians * 180) / Math.PI).toFixed(2)));
|
|
290
|
+
const rotation = this.vectorGroup('Rotation · °', euler, 1, (values) => this.change({
|
|
291
|
+
selector: detail.slot,
|
|
292
|
+
rotationEuler: values.map((degrees) => (degrees * Math.PI) / 180),
|
|
293
|
+
}));
|
|
294
|
+
const scale = this.vectorGroup('Scale', detail.scale, 0.01, (values) => this.change({ selector: detail.slot, scale: values }));
|
|
295
|
+
const visible = this.checkField('Visible', detail.visible, (on) => this.change({ selector: detail.slot, visible: on }));
|
|
296
|
+
const dynamic = this.checkField('Dynamic', detail.dynamic, (on) => this.change({ selector: detail.slot, dynamic: on }));
|
|
297
|
+
this.detail.replaceChildren(title, position, rotation, scale, visible, dynamic);
|
|
298
|
+
if (detail.kind === 'mesh' && detail.materialValues !== undefined)
|
|
299
|
+
this.detail.append(this.materialSection(detail));
|
|
300
|
+
}
|
|
301
|
+
/** A labelled row of three number fields that reports all three when one changes. */
|
|
302
|
+
vectorGroup(label, values, step, change) {
|
|
303
|
+
const group = el('div', 'group');
|
|
304
|
+
group.append(el('div', 'label', label));
|
|
305
|
+
const triple = el('div', 'triple');
|
|
306
|
+
const inputs = [];
|
|
307
|
+
for (let k = 0; k < 3; k++) {
|
|
308
|
+
const input = el('input');
|
|
309
|
+
input.type = 'number';
|
|
310
|
+
input.step = String(step);
|
|
311
|
+
input.value = String(Number(values[k].toFixed(3)));
|
|
312
|
+
input.setAttribute('aria-label', `${label.split(' · ')[0]} ${['X', 'Y', 'Z'][k]}`);
|
|
313
|
+
input.addEventListener('change', () => {
|
|
314
|
+
const numbers = inputs.map((field) => Number(field.value));
|
|
315
|
+
if (numbers.every(Number.isFinite))
|
|
316
|
+
change(numbers);
|
|
317
|
+
});
|
|
318
|
+
inputs.push(input);
|
|
319
|
+
triple.append(input);
|
|
320
|
+
}
|
|
321
|
+
group.append(triple);
|
|
322
|
+
return group;
|
|
323
|
+
}
|
|
324
|
+
/** A labelled checkbox. */
|
|
325
|
+
checkField(label, checked, change) {
|
|
326
|
+
const group = el('div', 'group');
|
|
327
|
+
const row = el('label', 'check');
|
|
328
|
+
const input = el('input');
|
|
329
|
+
input.type = 'checkbox';
|
|
330
|
+
input.checked = checked;
|
|
331
|
+
input.addEventListener('change', () => change(input.checked));
|
|
332
|
+
row.append(input, document.createTextNode(label));
|
|
333
|
+
group.append(row);
|
|
334
|
+
return group;
|
|
335
|
+
}
|
|
336
|
+
/** The base color and the three values that the inspector edits most. */
|
|
337
|
+
materialSection(detail) {
|
|
338
|
+
const values = detail.materialValues ?? {};
|
|
339
|
+
const section = el('div', 'material');
|
|
340
|
+
const color = el('input');
|
|
341
|
+
color.type = 'color';
|
|
342
|
+
color.value = typeof values.color === 'string' ? values.color : '#ffffff';
|
|
343
|
+
color.addEventListener('change', () => this.changeMaterial(detail.slot, { color: color.value }));
|
|
344
|
+
section.append(this.materialRow('Base color', color));
|
|
345
|
+
for (const [key, name] of [
|
|
346
|
+
['roughness', 'Roughness'],
|
|
347
|
+
['metalness', 'Metalness'],
|
|
348
|
+
['opacity', 'Opacity'],
|
|
349
|
+
]) {
|
|
350
|
+
const value = typeof values[key] === 'number' ? values[key] : 1;
|
|
351
|
+
const range = el('input');
|
|
352
|
+
range.type = 'range';
|
|
353
|
+
range.min = '0';
|
|
354
|
+
range.max = '1';
|
|
355
|
+
range.step = '0.01';
|
|
356
|
+
range.value = String(value);
|
|
357
|
+
const number = el('input');
|
|
358
|
+
number.type = 'number';
|
|
359
|
+
number.min = '0';
|
|
360
|
+
number.max = '1';
|
|
361
|
+
number.step = '0.01';
|
|
362
|
+
number.value = String(value);
|
|
363
|
+
const apply = (next) => {
|
|
364
|
+
range.value = String(next);
|
|
365
|
+
number.value = String(next);
|
|
366
|
+
this.changeMaterial(detail.slot, { [key]: next });
|
|
367
|
+
};
|
|
368
|
+
range.addEventListener('change', () => apply(Number(range.value)));
|
|
369
|
+
number.addEventListener('change', () => {
|
|
370
|
+
const next = Number(number.value);
|
|
371
|
+
if (Number.isFinite(next))
|
|
372
|
+
apply(next);
|
|
373
|
+
});
|
|
374
|
+
const row = el('div', 'mat-row');
|
|
375
|
+
row.append(el('span', 'name', name), range, number);
|
|
376
|
+
section.append(row);
|
|
377
|
+
}
|
|
378
|
+
return section;
|
|
379
|
+
}
|
|
380
|
+
/** One row of the material section. */
|
|
381
|
+
materialRow(name, control) {
|
|
382
|
+
const row = el('div', 'mat-row');
|
|
383
|
+
row.append(el('span', 'name', name), control);
|
|
384
|
+
return row;
|
|
385
|
+
}
|
|
386
|
+
/** Applies a change to the selected object and shows what the scene now holds. */
|
|
387
|
+
async change(args) {
|
|
388
|
+
const token = this.selectToken;
|
|
389
|
+
try {
|
|
390
|
+
const detail = (await this.bridge.inspect('setObject', args));
|
|
391
|
+
if (token !== this.selectToken || this.removed)
|
|
392
|
+
return;
|
|
393
|
+
this.showError(undefined);
|
|
394
|
+
this.drawDetail(detail);
|
|
395
|
+
}
|
|
396
|
+
catch (error) {
|
|
397
|
+
this.showError(asError(error).message);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
/** Applies a material change and shows the object's new state. */
|
|
401
|
+
async changeMaterial(slot, values) {
|
|
402
|
+
const token = this.selectToken;
|
|
403
|
+
try {
|
|
404
|
+
const detail = (await this.bridge.inspect('setMaterial', {
|
|
405
|
+
selector: slot,
|
|
406
|
+
values,
|
|
407
|
+
}));
|
|
408
|
+
if (token !== this.selectToken || this.removed)
|
|
409
|
+
return;
|
|
410
|
+
this.showError(undefined);
|
|
411
|
+
this.drawDetail(detail);
|
|
412
|
+
}
|
|
413
|
+
catch (error) {
|
|
414
|
+
this.showError(asError(error).message);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
/** Reads the frame figures and shows them. */
|
|
418
|
+
async refreshStats() {
|
|
419
|
+
if (this.removed || this.statsBusy)
|
|
420
|
+
return;
|
|
421
|
+
this.statsBusy = true;
|
|
422
|
+
try {
|
|
423
|
+
const stats = (await this.bridge.inspect('stats'));
|
|
424
|
+
if (this.removed)
|
|
425
|
+
return;
|
|
426
|
+
const figures = [
|
|
427
|
+
['FPS', stats.frames > 0 ? stats.presentedFps.toFixed(0) : '—'],
|
|
428
|
+
['CPU', stats.frames > 0 ? `${stats.cpuMs.toFixed(1)} ms` : '—'],
|
|
429
|
+
['GPU', stats.gpuMs === null || stats.frames === 0 ? '—' : `${stats.gpuMs.toFixed(1)} ms`],
|
|
430
|
+
['Draws', String(stats.drawCalls)],
|
|
431
|
+
['Triangles', count(stats.triangles)],
|
|
432
|
+
['Objects', String(stats.objects)],
|
|
433
|
+
['Uploads', bytes(stats.uploadBytes)],
|
|
434
|
+
['Preset', stats.preset],
|
|
435
|
+
['Tier', stats.tier],
|
|
436
|
+
];
|
|
437
|
+
const grid = this.figures;
|
|
438
|
+
grid.replaceChildren(...figures.map(([key, value]) => {
|
|
439
|
+
const fig = el('div', 'fig');
|
|
440
|
+
fig.append(el('div', 'k', key), el('div', 'v', value));
|
|
441
|
+
return fig;
|
|
442
|
+
}));
|
|
443
|
+
}
|
|
444
|
+
catch {
|
|
445
|
+
// The figures are a convenience; a stopped engine leaves the last ones drawn.
|
|
446
|
+
}
|
|
447
|
+
finally {
|
|
448
|
+
this.statsBusy = false;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
/** Shows an error under the detail, or clears it. */
|
|
452
|
+
showError(message) {
|
|
453
|
+
this.error.textContent = message ?? '';
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
/** Counts a large number with one decimal and its scale, such as "1.2 M". */
|
|
457
|
+
function count(value) {
|
|
458
|
+
if (value >= 1_000_000)
|
|
459
|
+
return `${(value / 1_000_000).toFixed(1)} M`;
|
|
460
|
+
if (value >= 1_000)
|
|
461
|
+
return `${(value / 1_000).toFixed(1)} k`;
|
|
462
|
+
return String(Math.round(value));
|
|
463
|
+
}
|
|
464
|
+
/** Reads bytes as a short figure, such as "412 kB". */
|
|
465
|
+
function bytes(value) {
|
|
466
|
+
if (value >= 1024 * 1024)
|
|
467
|
+
return `${(value / (1024 * 1024)).toFixed(1)} MB`;
|
|
468
|
+
if (value >= 1024)
|
|
469
|
+
return `${Math.round(value / 1024)} kB`;
|
|
470
|
+
return `${Math.round(value)} B`;
|
|
471
|
+
}
|
|
472
|
+
/** Opens the inspector panel on the page, and returns it. */
|
|
473
|
+
export function openInspector(bridge) {
|
|
474
|
+
return new Inspector(bridge);
|
|
475
|
+
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type StatsFigures, type StatsThread } from './stats-text.js';
|
|
2
2
|
/** The card's width in CSS pixels, which every tab shares. Its height follows the tab it shows. */
|
|
3
3
|
export declare const STATS_PANEL_WIDTH = 360;
|
|
4
|
+
/** The space between the canvas's edges and the panel's header and card, in CSS pixels. */
|
|
5
|
+
export declare const PANEL_EDGE = 12;
|
|
6
|
+
/** The space between the header and the card, in CSS pixels. */
|
|
7
|
+
export declare const PANEL_GAP = 8;
|
|
4
8
|
/** The card's tabs, in reading order. */
|
|
5
9
|
export declare const STATS_TABS: readonly ["frame", "memory", "steps", "systems"];
|
|
6
10
|
export type StatsTab = (typeof STATS_TABS)[number];
|
|
@@ -80,6 +84,8 @@ export declare class StatsCard {
|
|
|
80
84
|
private readonly mode;
|
|
81
85
|
private readonly tabButtons;
|
|
82
86
|
private readonly panes;
|
|
87
|
+
/** The element that holds the tabs' figures, which scrolls when the card's height stops it. */
|
|
88
|
+
readonly scroller: HTMLElement;
|
|
83
89
|
private readonly selection;
|
|
84
90
|
private readonly both;
|
|
85
91
|
private readonly sketch;
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
// looks, so a new design changes this file alone.
|
|
4
4
|
//
|
|
5
5
|
// The header is a dark pill: a ring gauge of the frame rate as a share of the target, the frame
|
|
6
|
-
// rate, and a chevron
|
|
7
|
-
//
|
|
8
|
-
//
|
|
6
|
+
// rate, and a chevron that points the way the card opens. Under it, or above it at the canvas's
|
|
7
|
+
// bottom corner, a card of 360 pixels wide holds four tabs. Its height follows the tab that shows,
|
|
8
|
+
// so a short tab leaves no empty card, up to the room on screen, past which the tab's figures
|
|
9
|
+
// scroll. The header of the card keeps the target and its interval in view on every tab. One tab shows at a
|
|
9
10
|
// time: Frame holds the work bars and the geometry figures, Memory the parts of the memory bar,
|
|
10
11
|
// Steps the add-ons and the GPU's timed passes, and Systems the memory register.
|
|
11
12
|
//
|
|
@@ -38,6 +39,10 @@ const MONO = "ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospac
|
|
|
38
39
|
const SHOWN_STEP_MS = 0.005;
|
|
39
40
|
/** The card's width in CSS pixels, which every tab shares. Its height follows the tab it shows. */
|
|
40
41
|
export const STATS_PANEL_WIDTH = 360;
|
|
42
|
+
/** The space between the canvas's edges and the panel's header and card, in CSS pixels. */
|
|
43
|
+
export const PANEL_EDGE = 12;
|
|
44
|
+
/** The space between the header and the card, in CSS pixels. */
|
|
45
|
+
export const PANEL_GAP = 8;
|
|
41
46
|
/** The card's tabs, in reading order. */
|
|
42
47
|
export const STATS_TABS = ['frame', 'memory', 'steps', 'systems'];
|
|
43
48
|
/** Each tab's label. */
|
|
@@ -94,8 +99,8 @@ const CSS = `
|
|
|
94
99
|
display: flex;
|
|
95
100
|
flex-direction: column;
|
|
96
101
|
align-items: flex-end;
|
|
97
|
-
gap:
|
|
98
|
-
padding:
|
|
102
|
+
gap: ${PANEL_GAP}px;
|
|
103
|
+
padding: ${PANEL_EDGE}px;
|
|
99
104
|
font: 12px/1.35 ${FONT};
|
|
100
105
|
font-variant-numeric: tabular-nums;
|
|
101
106
|
letter-spacing: normal;
|
|
@@ -105,6 +110,8 @@ const CSS = `
|
|
|
105
110
|
pointer-events: none;
|
|
106
111
|
}
|
|
107
112
|
[hidden] { display: none !important; }
|
|
113
|
+
.panel[data-corner='bottom-right'] { flex-direction: column-reverse; }
|
|
114
|
+
.panel[data-home-bar] { padding-bottom: calc(${PANEL_EDGE}px + env(safe-area-inset-bottom, 0px)); }
|
|
108
115
|
button {
|
|
109
116
|
margin: 0;
|
|
110
117
|
font: inherit;
|
|
@@ -137,11 +144,14 @@ button {
|
|
|
137
144
|
.ring[data-level='bad'] .arc { stroke: var(--bad); }
|
|
138
145
|
.fps { font-family: ${MONO}; letter-spacing: -0.02em; }
|
|
139
146
|
.chevron { width: 10px; height: 10px; flex: none; color: var(--amber); transition: transform 0.18s ease; }
|
|
140
|
-
.header[aria-expanded='true'] .chevron
|
|
147
|
+
.header[aria-expanded='true'] .chevron,
|
|
148
|
+
[data-corner='bottom-right'] .header[aria-expanded='false'] .chevron { transform: rotate(180deg); }
|
|
149
|
+
[data-corner='bottom-right'] .header[aria-expanded='true'] .chevron { transform: none; }
|
|
141
150
|
.card {
|
|
142
151
|
display: flex;
|
|
143
152
|
flex-direction: column;
|
|
144
153
|
width: min(${STATS_PANEL_WIDTH}px, 92vw);
|
|
154
|
+
max-height: var(--room, none);
|
|
145
155
|
box-sizing: border-box;
|
|
146
156
|
border: 1px solid rgba(255, 255, 255, 0.09);
|
|
147
157
|
border-radius: 14px;
|
|
@@ -236,7 +246,16 @@ button {
|
|
|
236
246
|
.tabs button:hover { color: var(--dim); }
|
|
237
247
|
.tabs button[aria-selected='true'] { color: var(--text); box-shadow: inset 0 -2px 0 var(--amber); }
|
|
238
248
|
.tabs button:focus-visible { outline: 1px solid var(--amber); outline-offset: -3px; border-radius: 4px; }
|
|
239
|
-
.
|
|
249
|
+
.panel[data-home-bar] .card { max-height: calc(var(--room, 100vh) - env(safe-area-inset-bottom, 0px)); }
|
|
250
|
+
.panes {
|
|
251
|
+
display: flex;
|
|
252
|
+
flex: 1;
|
|
253
|
+
align-items: flex-start;
|
|
254
|
+
min-height: 0;
|
|
255
|
+
overflow-y: auto;
|
|
256
|
+
overscroll-behavior: contain;
|
|
257
|
+
}
|
|
258
|
+
.panes[data-scrolls] { pointer-events: auto; }
|
|
240
259
|
.pane { flex: 1; flex-direction: column; min-height: 0; padding: 12px; overflow: hidden; }
|
|
241
260
|
.pane:not([hidden]) { display: flex; }
|
|
242
261
|
.block { display: flex; flex: none; flex-direction: column; }
|
|
@@ -982,6 +1001,8 @@ export class StatsCard {
|
|
|
982
1001
|
mode;
|
|
983
1002
|
tabButtons = [];
|
|
984
1003
|
panes = new Map();
|
|
1004
|
+
/** The element that holds the tabs' figures, which scrolls when the card's height stops it. */
|
|
1005
|
+
scroller;
|
|
985
1006
|
selection = new TabSelection();
|
|
986
1007
|
both;
|
|
987
1008
|
sketch;
|
|
@@ -1043,6 +1064,7 @@ export class StatsCard {
|
|
|
1043
1064
|
this.tabButtons.push(button);
|
|
1044
1065
|
}
|
|
1045
1066
|
const panes = element('div', 'panes', card);
|
|
1067
|
+
this.scroller = panes;
|
|
1046
1068
|
for (const tab of STATS_TABS) {
|
|
1047
1069
|
const pane = element('section', 'pane', panes);
|
|
1048
1070
|
pane.id = `pane-${tab}`;
|
package/lib/debug/overlay.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
// The stats overlay that `debug.stats`, `engine.stats` and the `stats` option show: a panel over
|
|
2
|
-
// the top-right corner of the canvas, which the page updates from the metrics buffer
|
|
3
|
-
// second. The page owns the overlay's element, and the engine's threads write the
|
|
4
|
-
// as they always do. The panel's header is a button with the frame rate, which
|
|
5
|
-
// tabbed card of the other figures
|
|
6
|
-
// frame's work and counts, the parts of memory, the add-ons and GPU steps, or the
|
|
7
|
-
// The figures are judged against the engine's target frame rate
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
2
|
+
// the top-right or bottom-right corner of the canvas, which the page updates from the metrics buffer
|
|
3
|
+
// a few times a second. The page owns the overlay's element, and the engine's threads write the
|
|
4
|
+
// figures it reads as they always do. The panel's header is a button with the frame rate, which
|
|
5
|
+
// shows and hides a tabbed card of the other figures beside it. The card's four tabs show one group
|
|
6
|
+
// at a time: the frame's work and counts, the parts of memory, the add-ons and GPU steps, or the
|
|
7
|
+
// memory register. The figures are judged against the engine's target frame rate
|
|
8
|
+
// (frame-target.ts). While the card shows, the engine samples the costly figures: GPU time, the
|
|
9
|
+
// counts of the draws that the GPU culls, and the memory figures that the engine's threads publish.
|
|
10
|
+
// Collapsed to its header, the overlay turns that sampling off and formats none of the card's
|
|
11
|
+
// figures. The page adds what only it can measure, where the browser offers it: its JavaScript heap
|
|
12
|
+
// and the whole page's memory. Only the header button, the card's two symbols, its tabs and figures
|
|
13
|
+
// that scroll take the pointer, so drags on the rest of the panel still reach the canvas.
|
|
13
14
|
// stats-panel.ts holds the panel on the page, which a three.js page shows too, and overlay-look.ts
|
|
14
15
|
// holds its look.
|
|
15
16
|
import { MEMORY_AREA_COUNT, MEMORY_AREA_NAMES } from '../shared/memory-area.js';
|
|
@@ -135,6 +136,7 @@ export class StatsOverlay {
|
|
|
135
136
|
this.sample(true);
|
|
136
137
|
this.panel = new StatsPanel(setup.canvas, {
|
|
137
138
|
collapsed,
|
|
139
|
+
corner: options.corner,
|
|
138
140
|
onToggle: (closed) => {
|
|
139
141
|
this.sample(!closed);
|
|
140
142
|
if (!closed)
|
|
@@ -149,6 +151,8 @@ export class StatsOverlay {
|
|
|
149
151
|
configure(options) {
|
|
150
152
|
if (options.collapsed !== undefined)
|
|
151
153
|
this.panel.setCollapsed(options.collapsed);
|
|
154
|
+
if (options.corner !== undefined)
|
|
155
|
+
this.panel.setCorner(options.corner);
|
|
152
156
|
}
|
|
153
157
|
remove() {
|
|
154
158
|
clearInterval(this.timer);
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The corner of the canvas that the stats overlay's header button sits in. At the top right the
|
|
3
|
+
* card opens under the button, and at the bottom right it opens above it.
|
|
4
|
+
*
|
|
5
|
+
* @category api/debug
|
|
6
|
+
*/
|
|
7
|
+
export type StatsCorner = 'top-right' | 'bottom-right';
|
|
1
8
|
/**
|
|
2
9
|
* Options for the stats overlay, which `debug.stats`, `engine.stats` and the `stats` option of
|
|
3
10
|
* `createEngine` take in place of `true`. A field that a call leaves out keeps its last value.
|
|
@@ -10,6 +17,12 @@ export interface StatsOverlayOptions {
|
|
|
10
17
|
* Space key on it shows and hides the other figures. The default is false: every figure shows.
|
|
11
18
|
*/
|
|
12
19
|
collapsed?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The corner of the canvas that the header button sits in. The default is `'top-right'`. At
|
|
22
|
+
* `'bottom-right'` the button sits at the bottom of the part of the canvas on screen, clear of a
|
|
23
|
+
* phone's home bar, and the card opens above it.
|
|
24
|
+
*/
|
|
25
|
+
corner?: StatsCorner;
|
|
13
26
|
}
|
|
14
27
|
/** What `debug.stats`, `engine.stats` and the `stats` option ask: hide, show, or show with options. */
|
|
15
28
|
export type StatsRequest = boolean | StatsOverlayOptions;
|