@thunderclap-engine/engine 0.0.0-stage → 1.1.0
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/CHANGELOG.md +390 -0
- package/LICENSE +21 -0
- package/README.md +333 -2
- package/dist/analytics/analytics.d.ts +80 -0
- package/dist/analytics/analytics.js +129 -0
- package/dist/analytics/index.d.ts +1 -0
- package/dist/analytics/index.js +1 -0
- package/dist/anim/aim.d.ts +43 -0
- package/dist/anim/aim.js +157 -0
- package/dist/anim/clip.d.ts +98 -0
- package/dist/anim/clip.js +282 -0
- package/dist/anim/compress.d.ts +65 -0
- package/dist/anim/compress.js +339 -0
- package/dist/anim/foot-ik.d.ts +74 -0
- package/dist/anim/foot-ik.js +241 -0
- package/dist/anim/graph.d.ts +153 -0
- package/dist/anim/graph.js +532 -0
- package/dist/anim/ik.d.ts +105 -0
- package/dist/anim/ik.js +435 -0
- package/dist/anim/index.d.ts +36 -0
- package/dist/anim/index.js +21 -0
- package/dist/anim/match.d.ts +66 -0
- package/dist/anim/match.js +153 -0
- package/dist/anim/mixer.d.ts +113 -0
- package/dist/anim/mixer.js +314 -0
- package/dist/anim/morph.d.ts +41 -0
- package/dist/anim/morph.js +94 -0
- package/dist/anim/pose.d.ts +74 -0
- package/dist/anim/pose.js +254 -0
- package/dist/anim/quat.d.ts +44 -0
- package/dist/anim/quat.js +187 -0
- package/dist/anim/retarget.d.ts +97 -0
- package/dist/anim/retarget.js +366 -0
- package/dist/anim/root-motion.d.ts +44 -0
- package/dist/anim/root-motion.js +224 -0
- package/dist/anim/skin-pose.d.ts +39 -0
- package/dist/anim/skin-pose.js +53 -0
- package/dist/anim/socket.d.ts +47 -0
- package/dist/anim/socket.js +84 -0
- package/dist/anim/spring-chain.d.ts +73 -0
- package/dist/anim/spring-chain.js +294 -0
- package/dist/assets/atlas.d.ts +90 -0
- package/dist/assets/atlas.js +212 -0
- package/dist/assets/baked.d.ts +33 -0
- package/dist/assets/baked.js +38 -0
- package/dist/assets/bundle.d.ts +88 -0
- package/dist/assets/bundle.js +464 -0
- package/dist/assets/cache.d.ts +56 -0
- package/dist/assets/cache.js +123 -0
- package/dist/assets/gltf-load.d.ts +252 -0
- package/dist/assets/gltf-load.js +661 -0
- package/dist/assets/gltf-skin.d.ts +36 -0
- package/dist/assets/gltf-skin.js +109 -0
- package/dist/assets/gltf.d.ts +706 -0
- package/dist/assets/gltf.js +1376 -0
- package/dist/assets/index.d.ts +20 -0
- package/dist/assets/index.js +10 -0
- package/dist/assets/ktx2.d.ts +71 -0
- package/dist/assets/ktx2.js +213 -0
- package/dist/assets/manifest.d.ts +79 -0
- package/dist/assets/manifest.js +7 -0
- package/dist/assets/meshopt.d.ts +23 -0
- package/dist/assets/meshopt.js +403 -0
- package/dist/audio/audio.d.ts +733 -0
- package/dist/audio/audio.js +2013 -0
- package/dist/audio/dsp.d.ts +61 -0
- package/dist/audio/dsp.js +159 -0
- package/dist/audio/duck.d.ts +44 -0
- package/dist/audio/duck.js +101 -0
- package/dist/audio/envelope.d.ts +53 -0
- package/dist/audio/envelope.js +106 -0
- package/dist/audio/index.d.ts +13 -0
- package/dist/audio/index.js +14 -0
- package/dist/audio/music.d.ts +113 -0
- package/dist/audio/music.js +548 -0
- package/dist/audio/occlusion.d.ts +55 -0
- package/dist/audio/occlusion.js +61 -0
- package/dist/audio/persist.d.ts +23 -0
- package/dist/audio/persist.js +27 -0
- package/dist/audio/recipes.d.ts +55 -0
- package/dist/audio/recipes.js +227 -0
- package/dist/audio/send.d.ts +41 -0
- package/dist/audio/send.js +118 -0
- package/dist/audio/sprites.d.ts +59 -0
- package/dist/audio/sprites.js +43 -0
- package/dist/audio/synth.d.ts +103 -0
- package/dist/audio/synth.js +197 -0
- package/dist/audio/variations.d.ts +25 -0
- package/dist/audio/variations.js +55 -0
- package/dist/audio/zones.d.ts +100 -0
- package/dist/audio/zones.js +167 -0
- package/dist/core/detached-surface.d.ts +44 -0
- package/dist/core/detached-surface.js +104 -0
- package/dist/core/events.d.ts +24 -0
- package/dist/core/events.js +43 -0
- package/dist/core/game.d.ts +409 -0
- package/dist/core/game.js +530 -0
- package/dist/core/hash.d.ts +24 -0
- package/dist/core/hash.js +49 -0
- package/dist/core/index.d.ts +17 -0
- package/dist/core/index.js +9 -0
- package/dist/core/loop.d.ts +113 -0
- package/dist/core/loop.js +185 -0
- package/dist/core/math.d.ts +58 -0
- package/dist/core/math.js +210 -0
- package/dist/core/noise.d.ts +40 -0
- package/dist/core/noise.js +247 -0
- package/dist/core/pool.d.ts +42 -0
- package/dist/core/pool.js +85 -0
- package/dist/core/random.d.ts +61 -0
- package/dist/core/random.js +199 -0
- package/dist/core/scene.d.ts +79 -0
- package/dist/core/scene.js +195 -0
- package/dist/core/timer.d.ts +66 -0
- package/dist/core/timer.js +286 -0
- package/dist/fx/billboard-wgsl.d.ts +29 -0
- package/dist/fx/billboard-wgsl.js +158 -0
- package/dist/fx/billboard.d.ts +249 -0
- package/dist/fx/billboard.js +702 -0
- package/dist/fx/debug-draw.d.ts +127 -0
- package/dist/fx/debug-draw.js +523 -0
- package/dist/fx/debug-wgsl.d.ts +7 -0
- package/dist/fx/debug-wgsl.js +32 -0
- package/dist/fx/decals-wgsl.d.ts +15 -0
- package/dist/fx/decals-wgsl.js +173 -0
- package/dist/fx/decals.d.ts +216 -0
- package/dist/fx/decals.js +607 -0
- package/dist/fx/effect.d.ts +129 -0
- package/dist/fx/effect.js +349 -0
- package/dist/fx/effects/hit-spark.json +48 -0
- package/dist/fx/effects/index.d.ts +8 -0
- package/dist/fx/effects/index.js +9 -0
- package/dist/fx/effects/magic-aura.json +47 -0
- package/dist/fx/effects/smoke-puff.json +34 -0
- package/dist/fx/emit-surface.d.ts +40 -0
- package/dist/fx/emit-surface.js +124 -0
- package/dist/fx/flicker.d.ts +30 -0
- package/dist/fx/flicker.js +42 -0
- package/dist/fx/index.d.ts +31 -0
- package/dist/fx/index.js +20 -0
- package/dist/fx/particles-wgsl.d.ts +57 -0
- package/dist/fx/particles-wgsl.js +828 -0
- package/dist/fx/particles.d.ts +566 -0
- package/dist/fx/particles.js +1533 -0
- package/dist/fx/random.d.ts +15 -0
- package/dist/fx/random.js +20 -0
- package/dist/fx/sky-wgsl.d.ts +23 -0
- package/dist/fx/sky-wgsl.js +127 -0
- package/dist/fx/sky.d.ts +96 -0
- package/dist/fx/sky.js +175 -0
- package/dist/fx/text-atlas.d.ts +143 -0
- package/dist/fx/text-atlas.js +327 -0
- package/dist/fx/trail-wgsl.d.ts +11 -0
- package/dist/fx/trail-wgsl.js +42 -0
- package/dist/fx/trail.d.ts +194 -0
- package/dist/fx/trail.js +555 -0
- package/dist/fx/water-wgsl.d.ts +34 -0
- package/dist/fx/water-wgsl.js +197 -0
- package/dist/fx/water.d.ts +176 -0
- package/dist/fx/water.js +371 -0
- package/dist/geom/collide/bvh.d.ts +151 -0
- package/dist/geom/collide/bvh.js +493 -0
- package/dist/geom/collide/debug.d.ts +14 -0
- package/dist/geom/collide/debug.js +74 -0
- package/dist/geom/collide/grid.d.ts +26 -0
- package/dist/geom/collide/grid.js +91 -0
- package/dist/geom/collide/index.d.ts +8 -0
- package/dist/geom/collide/index.js +8 -0
- package/dist/geom/collide/queries.d.ts +70 -0
- package/dist/geom/collide/queries.js +583 -0
- package/dist/geom/collide/serialize.d.ts +14 -0
- package/dist/geom/collide/serialize.js +145 -0
- package/dist/geom/collide/shapes.d.ts +161 -0
- package/dist/geom/collide/shapes.js +686 -0
- package/dist/geom/collide/slide.d.ts +66 -0
- package/dist/geom/collide/slide.js +375 -0
- package/dist/geom/collide/tile-slide.d.ts +88 -0
- package/dist/geom/collide/tile-slide.js +255 -0
- package/dist/geom/geometry.d.ts +95 -0
- package/dist/geom/geometry.js +322 -0
- package/dist/geom/heightfield.d.ts +72 -0
- package/dist/geom/heightfield.js +295 -0
- package/dist/geom/hull.d.ts +27 -0
- package/dist/geom/hull.js +279 -0
- package/dist/geom/index.d.ts +35 -0
- package/dist/geom/index.js +23 -0
- package/dist/geom/iso.d.ts +74 -0
- package/dist/geom/iso.js +89 -0
- package/dist/geom/lod.d.ts +29 -0
- package/dist/geom/lod.js +27 -0
- package/dist/geom/ops.d.ts +47 -0
- package/dist/geom/ops.js +285 -0
- package/dist/geom/primitives.d.ts +97 -0
- package/dist/geom/primitives.js +359 -0
- package/dist/geom/shapes.d.ts +43 -0
- package/dist/geom/shapes.js +88 -0
- package/dist/geom/simplify.d.ts +38 -0
- package/dist/geom/simplify.js +519 -0
- package/dist/geom/split.d.ts +37 -0
- package/dist/geom/split.js +413 -0
- package/dist/geom/sweep.d.ts +83 -0
- package/dist/geom/sweep.js +534 -0
- package/dist/geom/tangents.d.ts +16 -0
- package/dist/geom/tangents.js +124 -0
- package/dist/geom/triangulate.d.ts +19 -0
- package/dist/geom/triangulate.js +147 -0
- package/dist/host/default.d.ts +10 -0
- package/dist/host/default.js +10 -0
- package/dist/host/index.d.ts +4 -0
- package/dist/host/index.js +3 -0
- package/dist/host/types.d.ts +144 -0
- package/dist/host/types.js +1 -0
- package/dist/host/web-links.d.ts +38 -0
- package/dist/host/web-links.js +110 -0
- package/dist/host/web.d.ts +30 -0
- package/dist/host/web.js +216 -0
- package/dist/host/xr.d.ts +24 -0
- package/dist/host/xr.js +59 -0
- package/dist/i18n/i18n.d.ts +59 -0
- package/dist/i18n/i18n.js +241 -0
- package/dist/i18n/index.d.ts +3 -0
- package/dist/i18n/index.js +3 -0
- package/dist/i18n/message.d.ts +72 -0
- package/dist/i18n/message.js +369 -0
- package/dist/i18n/negotiate.d.ts +17 -0
- package/dist/i18n/negotiate.js +58 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1 -0
- package/dist/input/bindings.d.ts +31 -0
- package/dist/input/bindings.js +141 -0
- package/dist/input/clock.d.ts +44 -0
- package/dist/input/clock.js +49 -0
- package/dist/input/follow.d.ts +133 -0
- package/dist/input/follow.js +218 -0
- package/dist/input/gestures.d.ts +281 -0
- package/dist/input/gestures.js +662 -0
- package/dist/input/glyphs.d.ts +35 -0
- package/dist/input/glyphs.js +216 -0
- package/dist/input/gyro.d.ts +85 -0
- package/dist/input/gyro.js +140 -0
- package/dist/input/index.d.ts +19 -0
- package/dist/input/index.js +16 -0
- package/dist/input/input.d.ts +543 -0
- package/dist/input/input.js +1492 -0
- package/dist/input/look.d.ts +327 -0
- package/dist/input/look.js +681 -0
- package/dist/input/magnify.d.ts +177 -0
- package/dist/input/magnify.js +131 -0
- package/dist/input/pointer-dispatch.d.ts +138 -0
- package/dist/input/pointer-dispatch.js +180 -0
- package/dist/input/pointer-router.d.ts +204 -0
- package/dist/input/pointer-router.js +533 -0
- package/dist/input/pointer-sources.d.ts +164 -0
- package/dist/input/pointer-sources.js +306 -0
- package/dist/input/rays.d.ts +138 -0
- package/dist/input/rays.js +615 -0
- package/dist/input/record.d.ts +209 -0
- package/dist/input/record.js +601 -0
- package/dist/input/touch-zones.d.ts +147 -0
- package/dist/input/touch-zones.js +300 -0
- package/dist/input/types.d.ts +158 -0
- package/dist/input/types.js +1 -0
- package/dist/input/xr-source.d.ts +53 -0
- package/dist/input/xr-source.js +164 -0
- package/dist/nav/astar.d.ts +45 -0
- package/dist/nav/astar.js +182 -0
- package/dist/nav/corridor.d.ts +40 -0
- package/dist/nav/corridor.js +95 -0
- package/dist/nav/crowd.d.ts +94 -0
- package/dist/nav/crowd.js +624 -0
- package/dist/nav/flow.d.ts +61 -0
- package/dist/nav/flow.js +193 -0
- package/dist/nav/grid.d.ts +108 -0
- package/dist/nav/grid.js +210 -0
- package/dist/nav/heap.d.ts +22 -0
- package/dist/nav/heap.js +92 -0
- package/dist/nav/index.d.ts +37 -0
- package/dist/nav/index.js +19 -0
- package/dist/nav/mesh/areas.d.ts +44 -0
- package/dist/nav/mesh/areas.js +98 -0
- package/dist/nav/mesh/bake-options.d.ts +33 -0
- package/dist/nav/mesh/bake-options.js +76 -0
- package/dist/nav/mesh/contour.d.ts +22 -0
- package/dist/nav/mesh/contour.js +323 -0
- package/dist/nav/mesh/flow3.d.ts +35 -0
- package/dist/nav/mesh/flow3.js +229 -0
- package/dist/nav/mesh/links.d.ts +38 -0
- package/dist/nav/mesh/links.js +72 -0
- package/dist/nav/mesh/mesh-path.d.ts +152 -0
- package/dist/nav/mesh/mesh-path.js +643 -0
- package/dist/nav/mesh/mesh-reach.d.ts +78 -0
- package/dist/nav/mesh/mesh-reach.js +450 -0
- package/dist/nav/mesh/navmesh.d.ts +117 -0
- package/dist/nav/mesh/navmesh.js +647 -0
- package/dist/nav/mesh/polymesh.d.ts +24 -0
- package/dist/nav/mesh/polymesh.js +384 -0
- package/dist/nav/mesh/regions.d.ts +12 -0
- package/dist/nav/mesh/regions.js +367 -0
- package/dist/nav/mesh/serialize.d.ts +13 -0
- package/dist/nav/mesh/serialize.js +197 -0
- package/dist/nav/mesh/voxelize.d.ts +111 -0
- package/dist/nav/mesh/voxelize.js +552 -0
- package/dist/nav/obstacles.d.ts +75 -0
- package/dist/nav/obstacles.js +294 -0
- package/dist/nav/path.d.ts +59 -0
- package/dist/nav/path.js +177 -0
- package/dist/nav/query-queue.d.ts +46 -0
- package/dist/nav/query-queue.js +308 -0
- package/dist/nav/reach.d.ts +53 -0
- package/dist/nav/reach.js +148 -0
- package/dist/nav/steer.d.ts +36 -0
- package/dist/nav/steer.js +78 -0
- package/dist/platform/boot.d.ts +28 -0
- package/dist/platform/boot.js +43 -0
- package/dist/platform/device-mode.d.ts +40 -0
- package/dist/platform/device-mode.js +104 -0
- package/dist/platform/device.d.ts +31 -0
- package/dist/platform/device.js +91 -0
- package/dist/platform/environment.d.ts +42 -0
- package/dist/platform/environment.js +82 -0
- package/dist/platform/gpu.d.ts +40 -0
- package/dist/platform/gpu.js +57 -0
- package/dist/platform/index.d.ts +18 -0
- package/dist/platform/index.js +10 -0
- package/dist/platform/letterbox.d.ts +43 -0
- package/dist/platform/letterbox.js +57 -0
- package/dist/platform/links.d.ts +20 -0
- package/dist/platform/links.js +43 -0
- package/dist/platform/screens.d.ts +36 -0
- package/dist/platform/screens.js +138 -0
- package/dist/platform/surface.d.ts +72 -0
- package/dist/platform/surface.js +157 -0
- package/dist/platform/xr-fake.d.ts +168 -0
- package/dist/platform/xr-fake.js +434 -0
- package/dist/platform/xr-surface.d.ts +120 -0
- package/dist/platform/xr-surface.js +214 -0
- package/dist/platform/xr-types.d.ts +262 -0
- package/dist/post/ao.d.ts +12 -0
- package/dist/post/ao.js +136 -0
- package/dist/post/blend.d.ts +27 -0
- package/dist/post/blend.js +129 -0
- package/dist/post/depth-pass.d.ts +43 -0
- package/dist/post/depth-pass.js +118 -0
- package/dist/post/dof.d.ts +1 -0
- package/dist/post/dof.js +66 -0
- package/dist/post/exposure.d.ts +80 -0
- package/dist/post/exposure.js +322 -0
- package/dist/post/index.d.ts +12 -0
- package/dist/post/index.js +11 -0
- package/dist/post/lens-dirt.d.ts +13 -0
- package/dist/post/lens-dirt.js +91 -0
- package/dist/post/lut.d.ts +19 -0
- package/dist/post/lut.js +50 -0
- package/dist/post/motion-blur.d.ts +9 -0
- package/dist/post/motion-blur.js +78 -0
- package/dist/post/post-stack.d.ts +302 -0
- package/dist/post/post-stack.js +1137 -0
- package/dist/post/settings.d.ts +485 -0
- package/dist/post/settings.js +416 -0
- package/dist/post/shaders.d.ts +25 -0
- package/dist/post/shaders.js +410 -0
- package/dist/post/ssr.d.ts +16 -0
- package/dist/post/ssr.js +155 -0
- package/dist/post/taa.d.ts +74 -0
- package/dist/post/taa.js +235 -0
- package/dist/post/white-balance.d.ts +25 -0
- package/dist/post/white-balance.js +98 -0
- package/dist/render/bindings.d.ts +98 -0
- package/dist/render/bindings.js +281 -0
- package/dist/render/blend.d.ts +13 -0
- package/dist/render/blend.js +26 -0
- package/dist/render/camera-2d.d.ts +72 -0
- package/dist/render/camera-2d.js +92 -0
- package/dist/render/camera.d.ts +302 -0
- package/dist/render/camera.js +671 -0
- package/dist/render/color.d.ts +16 -0
- package/dist/render/color.js +41 -0
- package/dist/render/compressed.d.ts +104 -0
- package/dist/render/compressed.js +248 -0
- package/dist/render/diagnostics.d.ts +15 -0
- package/dist/render/diagnostics.js +43 -0
- package/dist/render/dynamic-resolution.d.ts +70 -0
- package/dist/render/dynamic-resolution.js +126 -0
- package/dist/render/fake-gpu.d.ts +204 -0
- package/dist/render/fake-gpu.js +426 -0
- package/dist/render/flipbook.d.ts +56 -0
- package/dist/render/flipbook.js +87 -0
- package/dist/render/frame.d.ts +278 -0
- package/dist/render/frame.js +174 -0
- package/dist/render/fullscreen.d.ts +54 -0
- package/dist/render/fullscreen.js +91 -0
- package/dist/render/gpu-timer.d.ts +73 -0
- package/dist/render/gpu-timer.js +186 -0
- package/dist/render/index.d.ts +53 -0
- package/dist/render/index.js +29 -0
- package/dist/render/instance-list.d.ts +185 -0
- package/dist/render/instance-list.js +547 -0
- package/dist/render/lights.d.ts +181 -0
- package/dist/render/lights.js +233 -0
- package/dist/render/lod.d.ts +54 -0
- package/dist/render/lod.js +52 -0
- package/dist/render/material.d.ts +165 -0
- package/dist/render/material.js +292 -0
- package/dist/render/mesh.d.ts +284 -0
- package/dist/render/mesh.js +472 -0
- package/dist/render/mipmap.d.ts +16 -0
- package/dist/render/mipmap.js +121 -0
- package/dist/render/parallax.d.ts +50 -0
- package/dist/render/parallax.js +47 -0
- package/dist/render/pbr-wgsl.d.ts +31 -0
- package/dist/render/pbr-wgsl.js +119 -0
- package/dist/render/ping-pong.d.ts +42 -0
- package/dist/render/ping-pong.js +74 -0
- package/dist/render/renderer.d.ts +741 -0
- package/dist/render/renderer.js +2486 -0
- package/dist/render/scene-pipelines.d.ts +44 -0
- package/dist/render/scene-pipelines.js +92 -0
- package/dist/render/scene-target.d.ts +170 -0
- package/dist/render/scene-target.js +450 -0
- package/dist/render/shadow.d.ts +74 -0
- package/dist/render/shadow.js +208 -0
- package/dist/render/skin.d.ts +112 -0
- package/dist/render/skin.js +240 -0
- package/dist/render/snapshot.d.ts +36 -0
- package/dist/render/snapshot.js +34 -0
- package/dist/render/standard.d.ts +162 -0
- package/dist/render/standard.js +263 -0
- package/dist/render/texture.d.ts +142 -0
- package/dist/render/texture.js +228 -0
- package/dist/render/tile-layer.d.ts +110 -0
- package/dist/render/tile-layer.js +304 -0
- package/dist/render/transform.d.ts +115 -0
- package/dist/render/transform.js +318 -0
- package/dist/render/wgsl.d.ts +131 -0
- package/dist/render/wgsl.js +528 -0
- package/dist/save/codec.d.ts +49 -0
- package/dist/save/codec.js +169 -0
- package/dist/save/index.d.ts +8 -0
- package/dist/save/index.js +8 -0
- package/dist/save/journal.d.ts +24 -0
- package/dist/save/journal.js +102 -0
- package/dist/save/migrate.d.ts +15 -0
- package/dist/save/migrate.js +37 -0
- package/dist/save/schema.d.ts +72 -0
- package/dist/save/schema.js +154 -0
- package/dist/save/settings.d.ts +28 -0
- package/dist/save/settings.js +59 -0
- package/dist/save/slots.d.ts +56 -0
- package/dist/save/slots.js +200 -0
- package/dist/save/storage.d.ts +35 -0
- package/dist/save/storage.js +62 -0
- package/dist/save/store.d.ts +114 -0
- package/dist/save/store.js +269 -0
- package/dist/testing/fake-host.d.ts +103 -0
- package/dist/testing/fake-host.js +163 -0
- package/dist/testing/fixed-clock.d.ts +25 -0
- package/dist/testing/fixed-clock.js +30 -0
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.js +5 -0
- package/dist/testing/test-game.d.ts +76 -0
- package/dist/testing/test-game.js +92 -0
- package/dist/tween/ease.d.ts +77 -0
- package/dist/tween/ease.js +192 -0
- package/dist/tween/index.d.ts +8 -0
- package/dist/tween/index.js +7 -0
- package/dist/tween/timeline.d.ts +78 -0
- package/dist/tween/timeline.js +269 -0
- package/dist/tween/tween.d.ts +168 -0
- package/dist/tween/tween.js +320 -0
- package/dist/ui/anchor.d.ts +206 -0
- package/dist/ui/anchor.js +307 -0
- package/dist/ui/caption.d.ts +122 -0
- package/dist/ui/caption.js +286 -0
- package/dist/ui/cursor.d.ts +105 -0
- package/dist/ui/cursor.js +261 -0
- package/dist/ui/dom.d.ts +30 -0
- package/dist/ui/dom.js +92 -0
- package/dist/ui/floats.d.ts +86 -0
- package/dist/ui/floats.js +260 -0
- package/dist/ui/hud.d.ts +198 -0
- package/dist/ui/hud.js +431 -0
- package/dist/ui/index.d.ts +37 -0
- package/dist/ui/index.js +34 -0
- package/dist/ui/inventory-card.d.ts +52 -0
- package/dist/ui/inventory-card.js +173 -0
- package/dist/ui/inventory-context.d.ts +29 -0
- package/dist/ui/inventory-context.js +125 -0
- package/dist/ui/inventory-drag.d.ts +63 -0
- package/dist/ui/inventory-drag.js +394 -0
- package/dist/ui/inventory-grid.d.ts +66 -0
- package/dist/ui/inventory-grid.js +625 -0
- package/dist/ui/inventory-radial.d.ts +39 -0
- package/dist/ui/inventory-radial.js +168 -0
- package/dist/ui/inventory.d.ts +128 -0
- package/dist/ui/inventory.js +154 -0
- package/dist/ui/layout.d.ts +356 -0
- package/dist/ui/layout.js +856 -0
- package/dist/ui/link.d.ts +64 -0
- package/dist/ui/link.js +155 -0
- package/dist/ui/loading.d.ts +40 -0
- package/dist/ui/loading.js +157 -0
- package/dist/ui/loupe.d.ts +74 -0
- package/dist/ui/loupe.js +164 -0
- package/dist/ui/menu-nav.d.ts +33 -0
- package/dist/ui/menu-nav.js +28 -0
- package/dist/ui/minimap-canvas.d.ts +145 -0
- package/dist/ui/minimap-canvas.js +460 -0
- package/dist/ui/notify.d.ts +40 -0
- package/dist/ui/notify.js +141 -0
- package/dist/ui/orb.d.ts +53 -0
- package/dist/ui/orb.js +304 -0
- package/dist/ui/overlay.d.ts +213 -0
- package/dist/ui/overlay.js +394 -0
- package/dist/ui/padnav.d.ts +53 -0
- package/dist/ui/padnav.js +146 -0
- package/dist/ui/perf.d.ts +130 -0
- package/dist/ui/perf.js +329 -0
- package/dist/ui/rotate-card.d.ts +54 -0
- package/dist/ui/rotate-card.js +97 -0
- package/dist/ui/stack.d.ts +128 -0
- package/dist/ui/stack.js +312 -0
- package/dist/ui/styles.d.ts +13 -0
- package/dist/ui/styles.js +200 -0
- package/dist/ui/text-scale.d.ts +67 -0
- package/dist/ui/text-scale.js +102 -0
- package/dist/ui/theme.d.ts +70 -0
- package/dist/ui/theme.js +98 -0
- package/dist/ui/toast.d.ts +23 -0
- package/dist/ui/toast.js +46 -0
- package/dist/ui/tooltip.d.ts +89 -0
- package/dist/ui/tooltip.js +333 -0
- package/dist/ui/widgets-2.d.ts +134 -0
- package/dist/ui/widgets-2.js +399 -0
- package/dist/ui/widgets-3.d.ts +91 -0
- package/dist/ui/widgets-3.js +212 -0
- package/dist/ui/widgets.d.ts +34 -0
- package/dist/ui/widgets.js +50 -0
- package/dist/ui/world-panel/index.d.ts +5 -0
- package/dist/ui/world-panel/index.js +5 -0
- package/dist/ui/world-panel/layout.d.ts +38 -0
- package/dist/ui/world-panel/layout.js +68 -0
- package/dist/ui/world-panel/paint.d.ts +96 -0
- package/dist/ui/world-panel/paint.js +136 -0
- package/dist/ui/world-panel/panel.d.ts +235 -0
- package/dist/ui/world-panel/panel.js +762 -0
- package/dist/ui/world-panel/wgsl.d.ts +10 -0
- package/dist/ui/world-panel/wgsl.js +52 -0
- package/dist/ui/world-panel/widgets.d.ts +207 -0
- package/dist/ui/world-panel/widgets.js +569 -0
- package/dist/voxel/chunks.d.ts +77 -0
- package/dist/voxel/chunks.js +149 -0
- package/dist/voxel/grid.d.ts +84 -0
- package/dist/voxel/grid.js +223 -0
- package/dist/voxel/index.d.ts +22 -0
- package/dist/voxel/index.js +7 -0
- package/dist/voxel/mesher-worker.d.ts +14 -0
- package/dist/voxel/mesher-worker.js +47 -0
- package/dist/voxel/mesher.d.ts +73 -0
- package/dist/voxel/mesher.js +306 -0
- package/dist/voxel/ray.d.ts +32 -0
- package/dist/voxel/ray.js +73 -0
- package/dist/voxel/wgsl.d.ts +16 -0
- package/dist/voxel/wgsl.js +28 -0
- package/dist/voxel/worker-client.d.ts +79 -0
- package/dist/voxel/worker-client.js +122 -0
- package/package.json +177 -3
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
import type { Gestures } from './gestures.js';
|
|
2
|
+
import { type Glyph, type PadLayout } from './glyphs.js';
|
|
3
|
+
import type { Look } from './look.js';
|
|
4
|
+
import { type PointerDispatcher, type PointerRecord } from './pointer-dispatch.js';
|
|
5
|
+
import type { PointerRouter } from './pointer-router.js';
|
|
6
|
+
import type { InputPlayback, InputRecorder } from './record.js';
|
|
7
|
+
import type { ActionState, Binding, Bindings, GamepadLike, InputDevice, PointerState, PointerTransform } from './types.js';
|
|
8
|
+
export interface InputOptions {
|
|
9
|
+
/** Gamepad source. Default: `navigator.getGamepads()` (guarded). */
|
|
10
|
+
getGamepads?: () => readonly (GamepadLike | null)[];
|
|
11
|
+
/**
|
|
12
|
+
* While this returns true (e.g. a modal UI panel is open) every action reads inactive and no
|
|
13
|
+
* keys are `preventDefault`ed. Raw state keeps tracking so nothing sticks on unblock.
|
|
14
|
+
*/
|
|
15
|
+
blocked?: () => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Key codes that still register while a button, link or other non-text control has focus
|
|
18
|
+
* (e.g. HUD shortcuts after clicking a HUD button). They never register in text entry and
|
|
19
|
+
* are not preventDefaulted on interactive targets. See `setGlobalKeys`.
|
|
20
|
+
*/
|
|
21
|
+
globalKeys?: Iterable<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Key codes that still register while a plain button or link has focus (`isButtonTarget`),
|
|
24
|
+
* but not on form controls that use them (sliders, checkboxes, selects, text). For keys
|
|
25
|
+
* like Escape and the arrows: a clicked button shouldn't swallow "back" or navigation.
|
|
26
|
+
* Like global keys they are not preventDefaulted there. See `setButtonKeys`.
|
|
27
|
+
*/
|
|
28
|
+
buttonKeys?: Iterable<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Queue repeat taps: when a key or mouse button goes down again before the tick that saw
|
|
31
|
+
* its first press, each extra tap fires `pressed` on a following tick instead of merging
|
|
32
|
+
* into one. Default true; pass false for the old one-press-per-tick behaviour.
|
|
33
|
+
*/
|
|
34
|
+
queueTaps?: boolean;
|
|
35
|
+
/** Gestures to link (see `Input.setGestures`). */
|
|
36
|
+
gestures?: Gestures;
|
|
37
|
+
/** Pointer router to link (see `Input.setPointers`). */
|
|
38
|
+
pointers?: PointerRouter<any>;
|
|
39
|
+
/** Look controls to link (see `Input.setLook`). */
|
|
40
|
+
look?: Look;
|
|
41
|
+
/**
|
|
42
|
+
* Ms per `update()` tick, the clock `'hold'` and `'doubleTap'` triggers and `listen` timeouts
|
|
43
|
+
* count in (ws/input-3). Default 1000/60. Pass the game's fixed step so `holdMs` means ms.
|
|
44
|
+
*/
|
|
45
|
+
tickMs?: number;
|
|
46
|
+
/** Pad button naming for `glyphFor`; default guessed from the first connected pad's `id`. */
|
|
47
|
+
padLayout?: PadLayout;
|
|
48
|
+
}
|
|
49
|
+
/** `Input` events (`Input.on`). */
|
|
50
|
+
export interface InputEvents {
|
|
51
|
+
/** `lastDevice` changed. */
|
|
52
|
+
device: InputDevice;
|
|
53
|
+
/** `rumble` was issued (whether or not a pad could play it). */
|
|
54
|
+
rumble: RumbleOptions;
|
|
55
|
+
/** `attach` built its pointer dispatcher (touch zones and other consumers join here). */
|
|
56
|
+
attach: PointerDispatcher;
|
|
57
|
+
/** `detach` is about to destroy the dispatcher. */
|
|
58
|
+
detach: PointerDispatcher;
|
|
59
|
+
/** The top action context changed (`pushContext`, `popContext`): its name, `null` for none. */
|
|
60
|
+
context: string | null;
|
|
61
|
+
/**
|
|
62
|
+
* A playback replayed an overlay control's activation (`replayControl`, the recording's `ui`
|
|
63
|
+
* lane; ws/input-12): its stable id. `createGame` activates the overlay control with that id
|
|
64
|
+
* (`Overlay.activate`). A live `control(id)` does not emit it: the control's handler ran.
|
|
65
|
+
*/
|
|
66
|
+
control: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* What a pushed action context lets through for the actions it does not bind (ws/input-5):
|
|
70
|
+
* `'unbound'` falls through to the context below, `'none'` silences them, `'all'` falls through
|
|
71
|
+
* and also adds the context below's bindings to the ones it does bind.
|
|
72
|
+
*/
|
|
73
|
+
export type ContextPass = 'none' | 'unbound' | 'all';
|
|
74
|
+
/** `Input.pushContext` options. */
|
|
75
|
+
export interface ContextOptions<A extends string> {
|
|
76
|
+
/**
|
|
77
|
+
* The context's own bindings. Default none. An action the base map lacks is added
|
|
78
|
+
* (ws/api-core): it reads inactive below this context and after it pops, never throws.
|
|
79
|
+
*/
|
|
80
|
+
bindings?: Partial<Bindings<A>>;
|
|
81
|
+
/** What happens to the actions it does not bind. Default `'unbound'`. */
|
|
82
|
+
pass?: ContextPass;
|
|
83
|
+
}
|
|
84
|
+
/** How `shapeStick` and `Input.stick` treat the deadzone (ws/input-5). */
|
|
85
|
+
export type StickShape = 'radial' | 'axial' | 'scaledRadial';
|
|
86
|
+
/** `shapeStick` / `Input.stick` options. */
|
|
87
|
+
export interface StickOptions {
|
|
88
|
+
/** Below this length (each axis for `'axial'`) the stick reads 0. 0..1, default 0.15. */
|
|
89
|
+
deadzone?: number;
|
|
90
|
+
/**
|
|
91
|
+
* `'scaledRadial'` (default): a radial deadzone, the rest rescaled so its edge is 0 and full
|
|
92
|
+
* deflection 1 (continuous). `'radial'`: a radial deadzone, the rest passed through as is.
|
|
93
|
+
* `'axial'`: each axis has its own deadzone, passed through (cardinal snapping).
|
|
94
|
+
*/
|
|
95
|
+
shape?: StickShape;
|
|
96
|
+
/** Exponent on the shaped length (each axis for `'axial'`): 2 is finer near the centre. Default 1. */
|
|
97
|
+
curve?: number;
|
|
98
|
+
/** Clamp the length to 1 (diagonal keys read 1, not √2). Default true. */
|
|
99
|
+
clamp?: boolean;
|
|
100
|
+
}
|
|
101
|
+
/** The phase of a pointer the feed saw (`InputFeedHook.pointer`, the recording's `ptr` lane). */
|
|
102
|
+
export type InputPointerPhase = 'down' | 'move' | 'up' | 'cancel' | 'leave';
|
|
103
|
+
/**
|
|
104
|
+
* Shape a stick (x, y) through a deadzone into `out` and return it (ws/input-5). Pure and
|
|
105
|
+
* allocation-free; `Input.stick` reads four actions through it and `Look` reads the pad sticks
|
|
106
|
+
* and the touch stick through it. See `StickOptions` for the shapes.
|
|
107
|
+
*/
|
|
108
|
+
export declare function shapeStick(x: number, y: number, out: [number, number], opts?: StickOptions): [number, number];
|
|
109
|
+
/**
|
|
110
|
+
* Something that feeds action values from outside the bindings (ws/input-4): touch zones. The
|
|
111
|
+
* input calls `update()` every tick before evaluating actions, then `value(action)` per action
|
|
112
|
+
* (0..1, folded in like a `press` binding) and `fresh(action)` for a new press while already
|
|
113
|
+
* active (a repeated button tap).
|
|
114
|
+
*/
|
|
115
|
+
export interface ActionSource {
|
|
116
|
+
update?(): void;
|
|
117
|
+
value(action: string): number;
|
|
118
|
+
fresh?(action: string): boolean;
|
|
119
|
+
}
|
|
120
|
+
/** `Input.rumble` parameters: magnitudes 0..1, duration in ms. */
|
|
121
|
+
export interface RumbleOptions {
|
|
122
|
+
/** Low-frequency motor, 0..1. Default 1. */
|
|
123
|
+
strong?: number;
|
|
124
|
+
/** High-frequency motor, 0..1. Default 1. */
|
|
125
|
+
weak?: number;
|
|
126
|
+
/** Duration in ms. Default 100. */
|
|
127
|
+
ms?: number;
|
|
128
|
+
/** Pad index; default the first connected pad that can rumble. */
|
|
129
|
+
pad?: number;
|
|
130
|
+
}
|
|
131
|
+
/** `Input.listen` options. */
|
|
132
|
+
export interface ListenOptions {
|
|
133
|
+
/** Give up (resolve `null`) after this many ms of ticks. Default: never. */
|
|
134
|
+
timeoutMs?: number;
|
|
135
|
+
}
|
|
136
|
+
/** Default `holdMs` for `trigger: 'hold'`. */
|
|
137
|
+
export declare const DEFAULT_HOLD_MS = 400;
|
|
138
|
+
/** Default `doubleTapMs` for `trigger: 'doubleTap'`. */
|
|
139
|
+
export declare const DEFAULT_DOUBLE_TAP_MS = 300;
|
|
140
|
+
/**
|
|
141
|
+
* Sees every low-level feed call and the pads `update()` reads, in call order. `input/record.ts`
|
|
142
|
+
* builds the two implementations (`createInputRecorder`, `createInputPlayback`); `Input.onFeed`
|
|
143
|
+
* installs one. Nothing here changes how `Input` evaluates bindings.
|
|
144
|
+
*/
|
|
145
|
+
export interface InputFeedHook {
|
|
146
|
+
keyDown(code: string): void;
|
|
147
|
+
keyUp(code: string): void;
|
|
148
|
+
buttonDown(button: number): void;
|
|
149
|
+
buttonUp(button: number): void;
|
|
150
|
+
wheel(dx: number, dy: number): void;
|
|
151
|
+
pointerAt(clientX: number, clientY: number, type: PointerState['type']): void;
|
|
152
|
+
releaseAll(): void;
|
|
153
|
+
/** Called once per `update()` with the pads `getGamepads` returned; what it returns is used. */
|
|
154
|
+
gamepads(pads: readonly (GamepadLike | null)[]): readonly (GamepadLike | null)[];
|
|
155
|
+
/**
|
|
156
|
+
* Replace this tick's pads before anything reads them (ws/input-9): called once per `update()`,
|
|
157
|
+
* before gestures and a linked look advance, with the pads `getGamepads` returned. A playback
|
|
158
|
+
* returns its recorded snapshot here, so the linked look turns from the recorded sticks too.
|
|
159
|
+
* `gamepads` then sees what this returned.
|
|
160
|
+
*/
|
|
161
|
+
padSource?(pads: readonly (GamepadLike | null)[]): readonly (GamepadLike | null)[];
|
|
162
|
+
/** Sees every `rumble` call (ws/input-3), after defaults are applied. */
|
|
163
|
+
rumble?(strong: number, weak: number, ms: number, pad: number | undefined): void;
|
|
164
|
+
/**
|
|
165
|
+
* Sees every pointer the attached dispatcher delivers, claimed or not, primary or not
|
|
166
|
+
* (ws/input-5): the recorder's `ptr` lane. The record is reused; copy what you keep.
|
|
167
|
+
*/
|
|
168
|
+
pointer?(phase: InputPointerPhase, p: Readonly<PointerRecord>): void;
|
|
169
|
+
/** The dispatcher dropped every pointer (window blur, hidden tab). */
|
|
170
|
+
cancelPointers?(): void;
|
|
171
|
+
/** `pushContext` (`pushed` true) or a context's removal (false). */
|
|
172
|
+
context?(name: string, pushed: boolean): void;
|
|
173
|
+
/** `consume(action)` was called. */
|
|
174
|
+
consume?(action: string): void;
|
|
175
|
+
/** `control(id)` was called: an overlay control with that stable id fired (ws/input-12). */
|
|
176
|
+
control?(id: string): void;
|
|
177
|
+
}
|
|
178
|
+
export interface AttachOptions {
|
|
179
|
+
/** Element that receives pointer/wheel input (the canvas, or the element wrapping it). */
|
|
180
|
+
pointerTarget: HTMLElement;
|
|
181
|
+
/** Where keyboard events are read. Default: the pointer target's window. */
|
|
182
|
+
keyTarget?: Window | HTMLElement;
|
|
183
|
+
/** Set `touch-action: none` on the pointer target so touch drags don't scroll/zoom. Default true. */
|
|
184
|
+
disableTouchScroll?: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Let a pointer claimed through the dispatcher (an orbit drag, a touch-zone thumb) still hover
|
|
187
|
+
* the linked router (`hit`/`hitEnd`, no select). Default false: a claimed pointer is hidden
|
|
188
|
+
* from the router until it is released.
|
|
189
|
+
*/
|
|
190
|
+
hoverWhileClaimed?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* The element whose box pointer positions are measured against (ws/core-8;
|
|
193
|
+
* `PointerDispatcherOptions.bounds`). Default the pointer target. `createGame`'s replay sink
|
|
194
|
+
* passes the canvas, so a recorded touch stick or touch zone replays at its recorded place.
|
|
195
|
+
*/
|
|
196
|
+
bounds?: Element;
|
|
197
|
+
}
|
|
198
|
+
/** True for elements where keys type text (text inputs, textareas, selects, contenteditable). */
|
|
199
|
+
export declare function isTextEntryTarget(target: EventTarget | null): boolean;
|
|
200
|
+
/**
|
|
201
|
+
* True for plain activatable controls (buttons, links, `summary`, button-type inputs,
|
|
202
|
+
* `role=button|link|menuitem`) whose own keys are only Enter and Space.
|
|
203
|
+
*/
|
|
204
|
+
export declare function isButtonTarget(target: EventTarget | null): boolean;
|
|
205
|
+
/** True for elements that own their keyboard input (text fields, buttons, links, …). */
|
|
206
|
+
export declare function isInteractiveTarget(target: EventTarget | null): boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Action-mapped input. Feed it raw events (via `attach` or the low-level methods), call
|
|
209
|
+
* `update()` once per simulation tick, then query actions.
|
|
210
|
+
*
|
|
211
|
+
* ```ts
|
|
212
|
+
* const input = new Input({ confirm: [{ key: 'Enter' }, { key: 'Space' }, { padButton: 0 }],
|
|
213
|
+
* cancel: [{ key: 'Escape' }, { padButton: 1 }] });
|
|
214
|
+
* input.attach({ pointerTarget: canvas });
|
|
215
|
+
* input.setPointerTransform(platform.clientToLogical);
|
|
216
|
+
* // each tick:
|
|
217
|
+
* input.update();
|
|
218
|
+
* if (input.pressed('confirm')) …
|
|
219
|
+
* ```
|
|
220
|
+
*
|
|
221
|
+
* `A` is the full action union. The base map may leave some out (ws/input-12): an action only a
|
|
222
|
+
* pushed context binds (`new Input<'jump' | 'back'>({ jump }, …)`, then
|
|
223
|
+
* `pushContext('menu', { bindings: { back } })`) is typed everywhere and reads inactive until a
|
|
224
|
+
* context binds it. `bindings()` lists the actions bound so far.
|
|
225
|
+
*/
|
|
226
|
+
export declare class Input<A extends string> {
|
|
227
|
+
readonly pointer: PointerState;
|
|
228
|
+
blocked: () => boolean;
|
|
229
|
+
/** Pad button naming for `glyphFor` (`InputOptions.padLayout`); `null` guesses from the pad's `id`. */
|
|
230
|
+
padLayout: PadLayout | null;
|
|
231
|
+
/** Ms per tick (`InputOptions.tickMs`). */
|
|
232
|
+
readonly tickMs: number;
|
|
233
|
+
/** The recorder capturing this input's feed (`createInputRecorder`), until `stop()`. */
|
|
234
|
+
recorder: InputRecorder | null;
|
|
235
|
+
/** The playback feeding this input (`createInputPlayback`), until `detach()`. */
|
|
236
|
+
playback: InputPlayback | null;
|
|
237
|
+
/** Feed hooks in install order (`onFeed`). Read-only for callers. */
|
|
238
|
+
private readonly feedHooks;
|
|
239
|
+
/** The base bindings (below every context). */
|
|
240
|
+
private map;
|
|
241
|
+
/** The bindings in force: `map` with the context stack resolved over it (`map` when empty). */
|
|
242
|
+
private active;
|
|
243
|
+
/** Pushed contexts, bottom first. */
|
|
244
|
+
private readonly stack;
|
|
245
|
+
/** Actions a context added that the base map lacks (`pushContext`); bound to nothing below it. */
|
|
246
|
+
private extraActions;
|
|
247
|
+
/** `stack`'s names, bottom first (the `contexts` getter). */
|
|
248
|
+
private contextNames;
|
|
249
|
+
/** The latest press per action (`buffered`, `consume`). */
|
|
250
|
+
private readonly presses;
|
|
251
|
+
/** True while `replayPointer` dispatches: the feed consumer then leaves the raw state alone. */
|
|
252
|
+
private injecting;
|
|
253
|
+
private readonly states;
|
|
254
|
+
private readonly triggers;
|
|
255
|
+
private readonly events;
|
|
256
|
+
private deviceValue;
|
|
257
|
+
/** Ticks since construction (the trigger clock). */
|
|
258
|
+
private tick;
|
|
259
|
+
private listenState;
|
|
260
|
+
/** Last client-space pointer position fed through `pointerAt` (the orbit drag's coordinates). */
|
|
261
|
+
private clientX;
|
|
262
|
+
private clientY;
|
|
263
|
+
private readonly claimFn;
|
|
264
|
+
private readonly getGamepads;
|
|
265
|
+
private transform;
|
|
266
|
+
private readonly keysDown;
|
|
267
|
+
private readonly keysTapped;
|
|
268
|
+
private readonly buttonsDown;
|
|
269
|
+
private readonly buttonsTapped;
|
|
270
|
+
/** Extra taps queued per key/button (see `InputOptions.queueTaps`). */
|
|
271
|
+
private readonly keyRepeats;
|
|
272
|
+
private readonly buttonRepeats;
|
|
273
|
+
private readonly queueTaps;
|
|
274
|
+
private globalKeys;
|
|
275
|
+
private buttonKeys;
|
|
276
|
+
private wheelAccX;
|
|
277
|
+
private wheelAccY;
|
|
278
|
+
private prevX;
|
|
279
|
+
private prevY;
|
|
280
|
+
private boundKeys;
|
|
281
|
+
private boundMouse;
|
|
282
|
+
private boundWheel;
|
|
283
|
+
private pads;
|
|
284
|
+
/** `this.pads`, bound once, for a linked look (`Look.padsFromInput`). */
|
|
285
|
+
private readonly readTickPads;
|
|
286
|
+
/** Keys and mouse buttons that were down or tapped on the last tick. */
|
|
287
|
+
private readonly prevKeys;
|
|
288
|
+
private readonly prevButtons;
|
|
289
|
+
private detachFn;
|
|
290
|
+
private linkedGestures;
|
|
291
|
+
private linkedPointers;
|
|
292
|
+
private linkedLook;
|
|
293
|
+
private attached;
|
|
294
|
+
private dispatcherValue;
|
|
295
|
+
private readonly updatedFns;
|
|
296
|
+
private readonly actionSources;
|
|
297
|
+
private readonly actionReader;
|
|
298
|
+
constructor(bindings: Partial<Bindings<A>>, opts?: InputOptions);
|
|
299
|
+
/**
|
|
300
|
+
* Device that produced the most recent input (updated on real events: keys, pointer events,
|
|
301
|
+
* pad activity, XR button presses). Useful for showing the right button prompts; `on('device')`
|
|
302
|
+
* fires when it changes.
|
|
303
|
+
*/
|
|
304
|
+
get lastDevice(): InputDevice;
|
|
305
|
+
set lastDevice(device: InputDevice);
|
|
306
|
+
/** Subscribe to an `InputEvents` event; returns the unsubscriber. */
|
|
307
|
+
on<K extends keyof InputEvents>(type: K, fn: (payload: InputEvents[K]) => void): () => void;
|
|
308
|
+
/**
|
|
309
|
+
* Link gestures (or unlink with `null`). Linked gestures share this input's `blocked()` and
|
|
310
|
+
* pointer transform, attach to the same pointer target, and advance in `update()` before the
|
|
311
|
+
* actions are read, so `{ gesture }` bindings work. Don't call `gestures.update()` yourself.
|
|
312
|
+
*/
|
|
313
|
+
setGestures(gestures: Gestures | null): void;
|
|
314
|
+
/** The linked gestures (`setGestures`), or `null`. */
|
|
315
|
+
get gestures(): Gestures | null;
|
|
316
|
+
/**
|
|
317
|
+
* Link a pointer router (or unlink with `null`). A linked router shares this input's
|
|
318
|
+
* `blocked()`, pointer transform (client → camera screen units) and gestures (the magnify aim),
|
|
319
|
+
* attaches to the same pointer target, and is polled in `update()` before the actions are
|
|
320
|
+
* read, so `{ pointer }` and `{ xr }` bindings work; after them its `select` and `secondary`
|
|
321
|
+
* events follow the actions named by `selectAction` / `secondaryAction` when bound. Don't call
|
|
322
|
+
* `router.update()` yourself.
|
|
323
|
+
*/
|
|
324
|
+
setPointers<T>(router: PointerRouter<T> | null): void;
|
|
325
|
+
/** The linked pointer router (`setPointers`), or `null`. */
|
|
326
|
+
get pointers(): PointerRouter<unknown> | null;
|
|
327
|
+
/**
|
|
328
|
+
* Link look controls (or unlink with `null`). Linked, they share this input's `blocked()`, read
|
|
329
|
+
* their move keys from its raw key state, attach to the same pointer target and advance in
|
|
330
|
+
* `update()`, so `look.look` and `look.move` are this tick's. Don't call `look.update()` yourself.
|
|
331
|
+
*/
|
|
332
|
+
setLook(look: Look | null): void;
|
|
333
|
+
/**
|
|
334
|
+
* The pointer dispatcher `attach` built (one DOM listener set shared by the feed, gestures,
|
|
335
|
+
* look, router and touch zones), or `null` while detached.
|
|
336
|
+
*/
|
|
337
|
+
get dispatcher(): PointerDispatcher | null;
|
|
338
|
+
/**
|
|
339
|
+
* Run `fn` at the end of every `update()`, after gestures, look, router and triggers have
|
|
340
|
+
* advanced (same tick, registration order): the place to poll a world panel or read
|
|
341
|
+
* `pressed()` for the frame. Returns the remover.
|
|
342
|
+
*/
|
|
343
|
+
onUpdated(fn: () => void): () => void;
|
|
344
|
+
/** Add an `ActionSource` (touch zones). Returns the remover. */
|
|
345
|
+
addActionSource(src: ActionSource): () => void;
|
|
346
|
+
/** `value(positive) - value(negative)`, -1..1: a move axis from two actions. */
|
|
347
|
+
axis(negative: A, positive: A): number;
|
|
348
|
+
/**
|
|
349
|
+
* Gives the linked gestures the look's pointer claim (an orbit drag is never a pan) when the
|
|
350
|
+
* gestures have no claim of their own; takes it back when the look unlinks.
|
|
351
|
+
*/
|
|
352
|
+
private wireClaim;
|
|
353
|
+
/** The linked look controls (`setLook`), or `null`. */
|
|
354
|
+
get look(): Look | null;
|
|
355
|
+
/**
|
|
356
|
+
* Replace the base bindings (below every pushed context). Action states and the input buffer
|
|
357
|
+
* reset (use `rebind` to change one action and keep the rest). The map may leave out actions
|
|
358
|
+
* of `A` (ws/input-12): a pushed context binds those.
|
|
359
|
+
*/
|
|
360
|
+
setBindings(bindings: Partial<Bindings<A>>): void;
|
|
361
|
+
/**
|
|
362
|
+
* Replace one action's bindings, keeping every other action's state (ws/input-3). Rebinding
|
|
363
|
+
* while an input is held is safe: the old action sees `released` next tick, and a new binding
|
|
364
|
+
* whose input is already down reads inactive until it lifts and goes down again.
|
|
365
|
+
*
|
|
366
|
+
* With contexts pushed (ws/input-5) it writes into the top context (the action becomes one that
|
|
367
|
+
* context binds); `context` names another pushed context instead, `null` the base map.
|
|
368
|
+
*/
|
|
369
|
+
rebind(action: A, list: readonly Binding[], context?: string | null): void;
|
|
370
|
+
/**
|
|
371
|
+
* The bindings in force (what `serializeBindings` saves): the base map with the pushed
|
|
372
|
+
* contexts resolved over it. `context` reads one context's own bindings over the ones below
|
|
373
|
+
* it as if it were on top (`null`: the base map).
|
|
374
|
+
*/
|
|
375
|
+
bindings(context?: string | null): Bindings<A>;
|
|
376
|
+
/**
|
|
377
|
+
* Push an action context (ws/input-5): a menu, gameplay, a vehicle, each with its own bindings.
|
|
378
|
+
* The top context's bindings win; `pass` says what happens to the actions it does not bind
|
|
379
|
+
* (default `'unbound'`: they fall through). Pushing a name already on the stack moves it to the
|
|
380
|
+
* top with the new options. Every action whose bindings in force change resets its hold
|
|
381
|
+
* progress, tap counts and buffered press, and a binding whose input is already down reads
|
|
382
|
+
* inactive until it lifts, so a held key never fires across the change. Returns the remover
|
|
383
|
+
* (it removes this push only).
|
|
384
|
+
*/
|
|
385
|
+
pushContext(name: string, opts?: ContextOptions<A>): () => void;
|
|
386
|
+
/** Remove the topmost context named `name`. Returns false when none is pushed. */
|
|
387
|
+
popContext(name: string): boolean;
|
|
388
|
+
/** The top context's name, `null` with none pushed. */
|
|
389
|
+
get context(): string | null;
|
|
390
|
+
/** The pushed context names, bottom first. One array, rebuilt when the stack changes. */
|
|
391
|
+
get contexts(): readonly string[];
|
|
392
|
+
/** Shorthand for `on('context', fn)`: the top context changed. Returns the remover. */
|
|
393
|
+
onContextChange(fn: (name: string | null) => void): () => void;
|
|
394
|
+
private removeContextAt;
|
|
395
|
+
private contextIndex;
|
|
396
|
+
/** The context `rebind` writes to: `undefined` the top one (or none), `null` none, else by name. */
|
|
397
|
+
private contextEntry;
|
|
398
|
+
/** Give a context's actions the base map lacks a state (bound to nothing below the context). */
|
|
399
|
+
private addContextActions;
|
|
400
|
+
/** The bindings in force with contexts `0..top` on the stack (all of them by default). */
|
|
401
|
+
private resolveContexts;
|
|
402
|
+
private resolveAction;
|
|
403
|
+
/**
|
|
404
|
+
* Recompute the bindings in force; every action whose list changed (element by element), and
|
|
405
|
+
* `force` too, gets fresh trigger state, latched where its input is down, and loses its
|
|
406
|
+
* buffered press.
|
|
407
|
+
*/
|
|
408
|
+
private applyActive;
|
|
409
|
+
/**
|
|
410
|
+
* True if `action` went `pressed` within the last `windowMs` (counted in ticks:
|
|
411
|
+
* `ceil(windowMs / tickMs)`, this tick included) and that press was not `consume`d
|
|
412
|
+
* (ws/input-5). A press a few frames early still lands: `if (input.buffered('jump', 100) &&
|
|
413
|
+
* grounded) { input.consume('jump'); jump(); }`. Deterministic under replay.
|
|
414
|
+
*/
|
|
415
|
+
buffered(action: A, windowMs: number): boolean;
|
|
416
|
+
/**
|
|
417
|
+
* Mark `action`'s latest press used: `buffered` no longer returns it and `pressed` reads false
|
|
418
|
+
* for the rest of this tick. Returns whether there was an unused press. Feed hooks see it, so a
|
|
419
|
+
* recording carries it.
|
|
420
|
+
*/
|
|
421
|
+
consume(action: A): boolean;
|
|
422
|
+
/**
|
|
423
|
+
* Read four actions as a stick into `out` (`[x, y]`, the caller's; returned) through
|
|
424
|
+
* `shapeStick` (ws/input-5): x is `value(posX) - value(negX)`, y `value(posY) - value(negY)`.
|
|
425
|
+
* Keys, pad axes (bind them with `threshold: 0` for an analog read) and touch-zone sticks all
|
|
426
|
+
* go through it; diagonal keys read length 1. Allocation-free.
|
|
427
|
+
*/
|
|
428
|
+
stick(negX: A, posX: A, negY: A, posY: A, out: [number, number], opts?: StickOptions): [number, number];
|
|
429
|
+
/**
|
|
430
|
+
* The aim angle of a stick read (`Math.atan2(y, x)`, radians), `null` when it is at rest
|
|
431
|
+
* (inside the deadzone). Pass the array `stick` filled.
|
|
432
|
+
*/
|
|
433
|
+
stickAngle(out: readonly [number, number]): number | null;
|
|
434
|
+
private rebuildBound;
|
|
435
|
+
private noteBound;
|
|
436
|
+
/**
|
|
437
|
+
* Resolve with the next input the player presses (ws/input-3): a key as `{ key }`, a mouse
|
|
438
|
+
* or pen button as `{ mouse }`, a pad button that was up when the listen began as
|
|
439
|
+
* `{ padButton }`, an XR button as `{ xr }`. Escape, a `timeoutMs` elapsing or a newer
|
|
440
|
+
* `listen` resolve `null`. The captured input is swallowed (no action sees it). Keys typed
|
|
441
|
+
* into text fields never reach `Input`, so they are not captured either. The caller rebinds:
|
|
442
|
+
* `const b = await input.listen('jump'); if (b) input.rebind('jump', [b]);`.
|
|
443
|
+
*/
|
|
444
|
+
listen(action: A, opts?: ListenOptions): Promise<Binding | null>;
|
|
445
|
+
/** The action a `listen` is waiting for, or `null`. */
|
|
446
|
+
get listening(): A | null;
|
|
447
|
+
private settleListen;
|
|
448
|
+
/** Replace the global keys (see `InputOptions.globalKeys`). */
|
|
449
|
+
setGlobalKeys(codes: Iterable<string>): void;
|
|
450
|
+
/** Replace the button keys (see `InputOptions.buttonKeys`). */
|
|
451
|
+
setButtonKeys(codes: Iterable<string>): void;
|
|
452
|
+
/**
|
|
453
|
+
* The prompt glyph for `action` on `device` (default `lastDevice`): the first binding that
|
|
454
|
+
* device produces, else the action's first binding; `null` for an unbound action. Pad labels
|
|
455
|
+
* follow `padLayout`, guessed from the first connected pad's `id` when unset. Reads the
|
|
456
|
+
* bindings in force, so the top context's (ws/input-5).
|
|
457
|
+
*/
|
|
458
|
+
glyphFor(action: A, device?: InputDevice): Glyph | null;
|
|
459
|
+
private firstPad;
|
|
460
|
+
/** True when `pad` (or any connected pad) has a vibration actuator `rumble` can drive. */
|
|
461
|
+
rumbleSupported(pad?: number): boolean;
|
|
462
|
+
private actuatorPad;
|
|
463
|
+
/**
|
|
464
|
+
* Play a dual-rumble effect on `pad` (default: the first connected pad that can). Returns
|
|
465
|
+
* true when an actuator took it; a no-op (false) otherwise, so games call it freely. Feed hooks
|
|
466
|
+
* see every call, so a recording carries the rumbles for playback to assert.
|
|
467
|
+
*/
|
|
468
|
+
rumble(opts?: RumbleOptions): boolean;
|
|
469
|
+
/**
|
|
470
|
+
* Install a feed hook: it sees every `keyDown`, `keyUp`, `buttonDown`, `buttonUp`, `wheel`,
|
|
471
|
+
* `pointerAt` and `releaseAll` call (DOM or direct) and the pads read in `update()`, and may
|
|
472
|
+
* substitute those pads. Returns the uninstaller. Used by `createInputRecorder` and
|
|
473
|
+
* `createInputPlayback`; hooks never change how bindings are evaluated.
|
|
474
|
+
*/
|
|
475
|
+
onFeed(hook: InputFeedHook): () => void;
|
|
476
|
+
/** Install the client → game-space mapping (platform owns letterboxing). `null` = identity relative to the target. */
|
|
477
|
+
setPointerTransform(fn: PointerTransform | null): void;
|
|
478
|
+
pressed(action: A): boolean;
|
|
479
|
+
held(action: A): boolean;
|
|
480
|
+
released(action: A): boolean;
|
|
481
|
+
value(action: A): number;
|
|
482
|
+
state(action: A): Readonly<ActionState>;
|
|
483
|
+
/** True if any bound action was pressed this tick. */
|
|
484
|
+
anyPressed(): boolean;
|
|
485
|
+
/** Raw key state by `KeyboardEvent.code`, ignoring bindings and blocking. */
|
|
486
|
+
keyHeld(code: string): boolean;
|
|
487
|
+
/** Advance one tick: poll gamepads, compute edges, clear per-tick accumulators. */
|
|
488
|
+
update(): void;
|
|
489
|
+
/** A pending `listen`: pad buttons newly down, XR presses, the timeout. Keys and mouse come via the feed. */
|
|
490
|
+
private pollListen;
|
|
491
|
+
private readonly evalOut;
|
|
492
|
+
/**
|
|
493
|
+
* Fold a list of bindings into one value: the largest raw value after each binding's trigger
|
|
494
|
+
* (`press` passes it through, `hold` gates it on `holdMs` of ticks down, `doubleTap` passes a
|
|
495
|
+
* second down edge within `doubleTapMs`). `fresh` marks a new press while already active,
|
|
496
|
+
* `hold` the furthest hold progress, `pad` that a pad produced the value.
|
|
497
|
+
*/
|
|
498
|
+
private evaluate;
|
|
499
|
+
/** One binding's raw value before its trigger; sets `evalOut.fresh`/`pad` as a side effect. */
|
|
500
|
+
private rawValue;
|
|
501
|
+
private padValue;
|
|
502
|
+
keyDown(code: string): void;
|
|
503
|
+
keyUp(code: string): void;
|
|
504
|
+
buttonDown(button: number): void;
|
|
505
|
+
buttonUp(button: number): void;
|
|
506
|
+
wheel(dx: number, dy: number): void;
|
|
507
|
+
/** Set the pointer position from client coordinates (runs the transform). */
|
|
508
|
+
pointerAt(clientX: number, clientY: number, type?: PointerState['type']): void;
|
|
509
|
+
/** Release every key and button (focus loss, tab hidden). */
|
|
510
|
+
releaseAll(): void;
|
|
511
|
+
/**
|
|
512
|
+
* An overlay control fired (ws/input-12): a button the player clicked, tapped or activated
|
|
513
|
+
* with Enter or the pad, named by its stable id (`controlId` in ui). Feed hooks see it, so a
|
|
514
|
+
* recording carries it in its `ui` lane on the tick it happened; nothing else changes. The
|
|
515
|
+
* control's own handler has already run. `createGame` calls it for every overlay control.
|
|
516
|
+
*/
|
|
517
|
+
control(id: string): void;
|
|
518
|
+
/**
|
|
519
|
+
* Replay an overlay control's activation (ws/input-12): emits `'control'` with `id`, whose
|
|
520
|
+
* listener (`createGame`: `Overlay.activate`) fires the control. `createInputPlayback` calls it
|
|
521
|
+
* for the recording's `ui` lane, before that tick's `update()`, so the handler runs on the
|
|
522
|
+
* tick it ran live. Feed hooks do not see it.
|
|
523
|
+
*/
|
|
524
|
+
replayControl(id: string): void;
|
|
525
|
+
/**
|
|
526
|
+
* Listen to the DOM. Keyboard: only bound keys are `preventDefault`ed, and never when a
|
|
527
|
+
* modifier (Ctrl/Meta/Alt) is held, the target is a text field/button/link, input is
|
|
528
|
+
* blocked, or the document lacks focus. That keeps browser shortcuts working and avoids
|
|
529
|
+
* scrolling hijacks inside the itch.io iframe.
|
|
530
|
+
*/
|
|
531
|
+
attach(opts: AttachOptions): void;
|
|
532
|
+
/**
|
|
533
|
+
* Dispatch a recorded pointer event on the attached pointer target (ws/input-5), so every
|
|
534
|
+
* dispatcher consumer (gestures, look, touch zones, the router) sees it as it saw the original;
|
|
535
|
+
* the feed's own key/button/pointer state is left to the playback's `b` and `p` lanes.
|
|
536
|
+
* `createInputPlayback` calls it for the recording's `ptr` lane. `age` (ws/input-7) is how
|
|
537
|
+
* many ms ago the event happened on the consumers' clocks (`PointerRecord.age`; negative is
|
|
538
|
+
* ahead); omitted, it happened now. Returns false (and does nothing) while detached or
|
|
539
|
+
* without `PointerEvent`.
|
|
540
|
+
*/
|
|
541
|
+
replayPointer(phase: InputPointerPhase, id: number, device: 'mouse' | 'touch' | 'pen', clientX: number, clientY: number, button: number, primary: boolean, age?: number): boolean;
|
|
542
|
+
detach(): void;
|
|
543
|
+
}
|