@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,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Touch zones (ws/input-4): screen regions that turn thumbs into a stick, buttons or swipes and
|
|
3
|
+
* feed actions through an `Input`. A pointer that goes down inside a zone is claimed through the
|
|
4
|
+
* input's pointer dispatcher, so gestures and the router never see it (two thumbs never pinch);
|
|
5
|
+
* each zone tracks at most one pointer. Zone rects are in CSS px of the pointer target, computed
|
|
6
|
+
* from its size when a pointer lands, so they follow resizes.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const zones = createTouchZones(input, {
|
|
10
|
+
* zones: {
|
|
11
|
+
* move: { kind: 'stick', rect: (w, h) => ({ x: 0, y: h / 2, w: w / 2, h: h / 2 }) },
|
|
12
|
+
* act: { kind: 'buttons', rect: (w, h) => ({ x: w / 2, y: h / 2, w: w / 2, h: h / 2 }),
|
|
13
|
+
* buttons: { jump: (w, h) => ({ x: w - 120, y: h - 120, w: 100, h: 100 }) } },
|
|
14
|
+
* },
|
|
15
|
+
* bindings: {
|
|
16
|
+
* moveLeft: { zone: 'move', axis: 'x', dir: -1 },
|
|
17
|
+
* moveRight: { zone: 'move', axis: 'x', dir: 1 },
|
|
18
|
+
* jump: { zone: 'act', button: 'jump' },
|
|
19
|
+
* },
|
|
20
|
+
* });
|
|
21
|
+
* // every tick, after input.update():
|
|
22
|
+
* zones.zones.move.vector; // [x, y] -1..1
|
|
23
|
+
* input.axis('moveLeft', 'moveRight'); // the same x through the actions
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* Recordings capture zone thumbs through the input's existing pointer feed (the primary pointer
|
|
27
|
+
* only; see the README), so no new record kind is needed.
|
|
28
|
+
*/
|
|
29
|
+
import type { Input } from './input.js';
|
|
30
|
+
import { type PointerRecordDevice } from './pointer-dispatch.js';
|
|
31
|
+
/** A zone or button rect in CSS px of the pointer target, origin top-left. */
|
|
32
|
+
export interface ZoneRect {
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
w: number;
|
|
36
|
+
h: number;
|
|
37
|
+
}
|
|
38
|
+
/** `(targetWidth, targetHeight) => rect`, called when a pointer lands. */
|
|
39
|
+
export type ZoneRectFn = (w: number, h: number) => ZoneRect;
|
|
40
|
+
export type TouchZoneKind = 'stick' | 'buttons' | 'swipe';
|
|
41
|
+
export interface StickZoneOptions {
|
|
42
|
+
kind: 'stick';
|
|
43
|
+
rect: ZoneRectFn;
|
|
44
|
+
/** Vector magnitude below which the stick reads 0 (rescaled above it). Default 0.12. */
|
|
45
|
+
deadZone?: number;
|
|
46
|
+
/** CSS px of travel for a full deflection. Default 64. */
|
|
47
|
+
radius?: number;
|
|
48
|
+
/** Where the stick's origin is: the down point (default) or the zone's centre. */
|
|
49
|
+
anchor?: 'down' | 'center';
|
|
50
|
+
}
|
|
51
|
+
export interface ButtonsZoneOptions {
|
|
52
|
+
kind: 'buttons';
|
|
53
|
+
rect: ZoneRectFn;
|
|
54
|
+
/** Sub-rects by name; a pointer landing in one presses it (and holds it until it lifts). */
|
|
55
|
+
buttons: Record<string, ZoneRectFn>;
|
|
56
|
+
}
|
|
57
|
+
export interface SwipeZoneOptions {
|
|
58
|
+
kind: 'swipe';
|
|
59
|
+
rect: ZoneRectFn;
|
|
60
|
+
/** CSS px of travel that makes a swipe. Default 24. */
|
|
61
|
+
threshold?: number;
|
|
62
|
+
}
|
|
63
|
+
export type TouchZoneOptions = StickZoneOptions | ButtonsZoneOptions | SwipeZoneOptions;
|
|
64
|
+
export type SwipeDirection = 'left' | 'right' | 'up' | 'down';
|
|
65
|
+
/** A `stick` zone's reading. */
|
|
66
|
+
export interface StickZone {
|
|
67
|
+
readonly kind: 'stick';
|
|
68
|
+
/** True while a pointer is down in the zone. */
|
|
69
|
+
readonly active: boolean;
|
|
70
|
+
/** The deflection, -1..1 each (y down). One array, updated in place. */
|
|
71
|
+
readonly vector: readonly [number, number];
|
|
72
|
+
/** Shorthands for `vector[0]` / `vector[1]`. */
|
|
73
|
+
readonly x: number;
|
|
74
|
+
readonly y: number;
|
|
75
|
+
/** The stick's origin in target px (NaN while inactive). */
|
|
76
|
+
readonly originX: number;
|
|
77
|
+
readonly originY: number;
|
|
78
|
+
}
|
|
79
|
+
/** A `buttons` zone's reading. */
|
|
80
|
+
export interface ButtonsZone {
|
|
81
|
+
readonly kind: 'buttons';
|
|
82
|
+
readonly active: boolean;
|
|
83
|
+
/** True on the tick a pointer landed on the button. */
|
|
84
|
+
pressed(name: string): boolean;
|
|
85
|
+
/** True while a pointer that landed on the button is down. */
|
|
86
|
+
held(name: string): boolean;
|
|
87
|
+
/** The button held now, or `null`. */
|
|
88
|
+
readonly down: string | null;
|
|
89
|
+
}
|
|
90
|
+
/** A `swipe` zone's reading. */
|
|
91
|
+
export interface SwipeZone {
|
|
92
|
+
readonly kind: 'swipe';
|
|
93
|
+
readonly active: boolean;
|
|
94
|
+
/** The direction swiped this tick, once per gesture, else `null`. */
|
|
95
|
+
readonly swipe: SwipeDirection | null;
|
|
96
|
+
}
|
|
97
|
+
export type TouchZoneReading<O extends TouchZoneOptions> = O extends StickZoneOptions ? StickZone : O extends ButtonsZoneOptions ? ButtonsZone : SwipeZone;
|
|
98
|
+
/**
|
|
99
|
+
* How an action reads a zone. `Z` is the zone names (ws/api-core: `createTouchZones` checks
|
|
100
|
+
* `zone` against its `zones`); default any string.
|
|
101
|
+
*/
|
|
102
|
+
export type TouchZoneBinding<Z extends string = string> =
|
|
103
|
+
/** A stick axis in one direction: 0..1 of the deflection along it. */
|
|
104
|
+
{
|
|
105
|
+
zone: Z;
|
|
106
|
+
axis: 'x' | 'y';
|
|
107
|
+
dir: 1 | -1;
|
|
108
|
+
}
|
|
109
|
+
/** A button: 1 while held, with a fresh press each landing. */
|
|
110
|
+
| {
|
|
111
|
+
zone: Z;
|
|
112
|
+
button: string;
|
|
113
|
+
}
|
|
114
|
+
/** A swipe: 1 on the tick it is recognised. */
|
|
115
|
+
| {
|
|
116
|
+
zone: Z;
|
|
117
|
+
swipe: SwipeDirection;
|
|
118
|
+
};
|
|
119
|
+
export interface TouchZonesOptions<Z extends Record<string, TouchZoneOptions>, A extends string = string> {
|
|
120
|
+
zones: Z;
|
|
121
|
+
/**
|
|
122
|
+
* Actions fed through `input` from the zones. Typed (ws/api-core): the actions are the
|
|
123
|
+
* input's, the `zone`s are names in `zones`.
|
|
124
|
+
*/
|
|
125
|
+
bindings?: Partial<Record<A, TouchZoneBinding<keyof Z & string> | readonly TouchZoneBinding<keyof Z & string>[]>>;
|
|
126
|
+
/** Pointer devices the zones take. Default `['touch']`. */
|
|
127
|
+
devices?: readonly PointerRecordDevice[];
|
|
128
|
+
}
|
|
129
|
+
export interface TouchZones<Z extends Record<string, TouchZoneOptions>> {
|
|
130
|
+
readonly zones: {
|
|
131
|
+
readonly [K in keyof Z]: TouchZoneReading<Z[K]>;
|
|
132
|
+
};
|
|
133
|
+
/** False stops the zones taking pointers (held ones are dropped). */
|
|
134
|
+
enabled: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Advance the per-tick edges (`pressed`, `swipe`). The linked `input.update()` calls this
|
|
137
|
+
* through its action source; do not call it yourself while the zones are linked.
|
|
138
|
+
*/
|
|
139
|
+
update(): void;
|
|
140
|
+
/** Join the input's dispatcher (done on creation and on every `input.attach`). */
|
|
141
|
+
attach(): void;
|
|
142
|
+
/** Leave the dispatcher and drop every pointer. */
|
|
143
|
+
detach(): void;
|
|
144
|
+
/** Detach and unlink from the input (actions and attach events). */
|
|
145
|
+
destroy(): void;
|
|
146
|
+
}
|
|
147
|
+
export declare function createTouchZones<Z extends Record<string, TouchZoneOptions>, A extends string = string>(input: Input<A>, opts: TouchZonesOptions<Z, NoInfer<A>>): TouchZones<Z>;
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { POINTER_PRIORITY, } from './pointer-dispatch.js';
|
|
2
|
+
const DEFAULT_DEAD_ZONE = 0.12;
|
|
3
|
+
const DEFAULT_RADIUS = 64;
|
|
4
|
+
const DEFAULT_SWIPE_PX = 24;
|
|
5
|
+
const inRect = (r, x, y) => x >= r.x && x < r.x + r.w && y >= r.y && y < r.y + r.h;
|
|
6
|
+
export function createTouchZones(input, opts) {
|
|
7
|
+
const devices = opts.devices ?? ['touch'];
|
|
8
|
+
const states = [];
|
|
9
|
+
const byName = new Map();
|
|
10
|
+
const readings = {};
|
|
11
|
+
for (const name of Object.keys(opts.zones)) {
|
|
12
|
+
const z = opts.zones[name];
|
|
13
|
+
const st = {
|
|
14
|
+
name,
|
|
15
|
+
opts: z,
|
|
16
|
+
pointer: -1,
|
|
17
|
+
left: 0,
|
|
18
|
+
top: 0,
|
|
19
|
+
width: 0,
|
|
20
|
+
height: 0,
|
|
21
|
+
rect: { x: 0, y: 0, w: 0, h: 0 },
|
|
22
|
+
vector: [0, 0],
|
|
23
|
+
originX: Number.NaN,
|
|
24
|
+
originY: Number.NaN,
|
|
25
|
+
down: null,
|
|
26
|
+
pendingPress: null,
|
|
27
|
+
pressedNow: null,
|
|
28
|
+
downX: 0,
|
|
29
|
+
downY: 0,
|
|
30
|
+
swiped: false,
|
|
31
|
+
pendingSwipe: null,
|
|
32
|
+
swipeNow: null,
|
|
33
|
+
};
|
|
34
|
+
states.push(st);
|
|
35
|
+
byName.set(name, st);
|
|
36
|
+
readings[name] = makeReading(st);
|
|
37
|
+
}
|
|
38
|
+
const bindings = new Map();
|
|
39
|
+
if (opts.bindings) {
|
|
40
|
+
for (const action of Object.keys(opts.bindings)) {
|
|
41
|
+
const b = opts.bindings[action];
|
|
42
|
+
bindings.set(action, Array.isArray(b) ? b : [b]);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
let dispatcher = null;
|
|
46
|
+
let enabled = true;
|
|
47
|
+
const drop = (st) => {
|
|
48
|
+
if (st.pointer >= 0)
|
|
49
|
+
dispatcher?.release(st.pointer);
|
|
50
|
+
st.pointer = -1;
|
|
51
|
+
st.vector[0] = 0;
|
|
52
|
+
st.vector[1] = 0;
|
|
53
|
+
st.originX = Number.NaN;
|
|
54
|
+
st.originY = Number.NaN;
|
|
55
|
+
st.down = null;
|
|
56
|
+
st.swiped = false;
|
|
57
|
+
};
|
|
58
|
+
const holder = (id) => {
|
|
59
|
+
for (let i = 0; i < states.length; i++)
|
|
60
|
+
if (states[i].pointer === id)
|
|
61
|
+
return states[i];
|
|
62
|
+
return null;
|
|
63
|
+
};
|
|
64
|
+
const consumer = {
|
|
65
|
+
pointerDown: (p) => {
|
|
66
|
+
if (!enabled || !dispatcher || devices.indexOf(p.device) < 0)
|
|
67
|
+
return;
|
|
68
|
+
const b = dispatcher.bounds();
|
|
69
|
+
const x = p.clientX - b.left;
|
|
70
|
+
const y = p.clientY - b.top;
|
|
71
|
+
for (let i = 0; i < states.length; i++) {
|
|
72
|
+
const st = states[i];
|
|
73
|
+
if (st.pointer >= 0)
|
|
74
|
+
continue;
|
|
75
|
+
const r = st.opts.rect(b.width, b.height);
|
|
76
|
+
if (!inRect(r, x, y))
|
|
77
|
+
continue;
|
|
78
|
+
if (!dispatcher.claim(p.id, consumer))
|
|
79
|
+
return;
|
|
80
|
+
st.pointer = p.id;
|
|
81
|
+
st.left = b.left;
|
|
82
|
+
st.top = b.top;
|
|
83
|
+
st.width = b.width;
|
|
84
|
+
st.height = b.height;
|
|
85
|
+
st.rect = r;
|
|
86
|
+
const o = st.opts;
|
|
87
|
+
if (o.kind === 'stick') {
|
|
88
|
+
if (o.anchor === 'center') {
|
|
89
|
+
st.originX = r.x + r.w / 2;
|
|
90
|
+
st.originY = r.y + r.h / 2;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
st.originX = x;
|
|
94
|
+
st.originY = y;
|
|
95
|
+
}
|
|
96
|
+
stickMove(st, o, x, y);
|
|
97
|
+
}
|
|
98
|
+
else if (o.kind === 'buttons') {
|
|
99
|
+
for (const name of Object.keys(o.buttons)) {
|
|
100
|
+
if (inRect(o.buttons[name](b.width, b.height), x, y)) {
|
|
101
|
+
st.down = name;
|
|
102
|
+
st.pendingPress = name;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
st.downX = x;
|
|
109
|
+
st.downY = y;
|
|
110
|
+
st.swiped = false;
|
|
111
|
+
}
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
pointerMove: (p) => {
|
|
116
|
+
const st = holder(p.id);
|
|
117
|
+
if (!st)
|
|
118
|
+
return;
|
|
119
|
+
const x = p.clientX - st.left;
|
|
120
|
+
const y = p.clientY - st.top;
|
|
121
|
+
const o = st.opts;
|
|
122
|
+
if (o.kind === 'stick')
|
|
123
|
+
stickMove(st, o, x, y);
|
|
124
|
+
else if (o.kind === 'swipe' && !st.swiped) {
|
|
125
|
+
const dx = x - st.downX;
|
|
126
|
+
const dy = y - st.downY;
|
|
127
|
+
const threshold = o.threshold ?? DEFAULT_SWIPE_PX;
|
|
128
|
+
if (dx * dx + dy * dy >= threshold * threshold) {
|
|
129
|
+
st.swiped = true;
|
|
130
|
+
st.pendingSwipe =
|
|
131
|
+
Math.abs(dx) >= Math.abs(dy) ? (dx > 0 ? 'right' : 'left') : dy > 0 ? 'down' : 'up';
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
pointerUp: (p) => {
|
|
136
|
+
const st = holder(p.id);
|
|
137
|
+
if (st)
|
|
138
|
+
drop(st);
|
|
139
|
+
},
|
|
140
|
+
pointerCancel: (p) => {
|
|
141
|
+
const st = holder(p.id);
|
|
142
|
+
if (st)
|
|
143
|
+
drop(st);
|
|
144
|
+
},
|
|
145
|
+
cancelAll: () => {
|
|
146
|
+
for (let i = 0; i < states.length; i++)
|
|
147
|
+
drop(states[i]);
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
const update = () => {
|
|
151
|
+
for (let i = 0; i < states.length; i++) {
|
|
152
|
+
const st = states[i];
|
|
153
|
+
st.pressedNow = st.pendingPress;
|
|
154
|
+
st.pendingPress = null;
|
|
155
|
+
st.swipeNow = st.pendingSwipe;
|
|
156
|
+
st.pendingSwipe = null;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const bindingValue = (b) => {
|
|
160
|
+
const st = byName.get(b.zone);
|
|
161
|
+
if (!st)
|
|
162
|
+
return 0;
|
|
163
|
+
if ('axis' in b) {
|
|
164
|
+
const v = st.vector[b.axis === 'x' ? 0 : 1] * b.dir;
|
|
165
|
+
return Math.max(0, v);
|
|
166
|
+
}
|
|
167
|
+
if ('button' in b)
|
|
168
|
+
return st.down === b.button ? 1 : 0;
|
|
169
|
+
return st.swipeNow === b.swipe ? 1 : 0;
|
|
170
|
+
};
|
|
171
|
+
const source = {
|
|
172
|
+
update,
|
|
173
|
+
value: (action) => {
|
|
174
|
+
const list = bindings.get(action);
|
|
175
|
+
if (!list)
|
|
176
|
+
return 0;
|
|
177
|
+
let v = 0;
|
|
178
|
+
for (let i = 0; i < list.length; i++) {
|
|
179
|
+
const x = bindingValue(list[i]);
|
|
180
|
+
if (x > v)
|
|
181
|
+
v = x;
|
|
182
|
+
}
|
|
183
|
+
return v;
|
|
184
|
+
},
|
|
185
|
+
fresh: (action) => {
|
|
186
|
+
const list = bindings.get(action);
|
|
187
|
+
if (!list)
|
|
188
|
+
return false;
|
|
189
|
+
for (let i = 0; i < list.length; i++) {
|
|
190
|
+
const b = list[i];
|
|
191
|
+
if ('button' in b && byName.get(b.zone)?.pressedNow === b.button)
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
return false;
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
let removeConsumer = null;
|
|
198
|
+
const detach = () => {
|
|
199
|
+
consumer.cancelAll();
|
|
200
|
+
removeConsumer?.();
|
|
201
|
+
removeConsumer = null;
|
|
202
|
+
dispatcher = null;
|
|
203
|
+
};
|
|
204
|
+
const attach = () => {
|
|
205
|
+
detach();
|
|
206
|
+
const d = input.dispatcher;
|
|
207
|
+
if (!d)
|
|
208
|
+
return;
|
|
209
|
+
dispatcher = d;
|
|
210
|
+
removeConsumer = d.add(consumer, POINTER_PRIORITY.zones);
|
|
211
|
+
};
|
|
212
|
+
const removeSource = input.addActionSource(source);
|
|
213
|
+
const offAttach = input.on('attach', attach);
|
|
214
|
+
const offDetach = input.on('detach', detach);
|
|
215
|
+
attach();
|
|
216
|
+
return {
|
|
217
|
+
zones: readings,
|
|
218
|
+
get enabled() {
|
|
219
|
+
return enabled;
|
|
220
|
+
},
|
|
221
|
+
set enabled(v) {
|
|
222
|
+
enabled = v;
|
|
223
|
+
if (!v)
|
|
224
|
+
consumer.cancelAll();
|
|
225
|
+
},
|
|
226
|
+
update,
|
|
227
|
+
attach,
|
|
228
|
+
detach,
|
|
229
|
+
destroy() {
|
|
230
|
+
detach();
|
|
231
|
+
removeSource();
|
|
232
|
+
offAttach();
|
|
233
|
+
offDetach();
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function stickMove(st, o, x, y) {
|
|
238
|
+
const radius = o.radius ?? DEFAULT_RADIUS;
|
|
239
|
+
const dead = o.deadZone ?? DEFAULT_DEAD_ZONE;
|
|
240
|
+
let vx = (x - st.originX) / radius;
|
|
241
|
+
let vy = (y - st.originY) / radius;
|
|
242
|
+
const m = Math.sqrt(vx * vx + vy * vy);
|
|
243
|
+
if (m <= dead) {
|
|
244
|
+
vx = 0;
|
|
245
|
+
vy = 0;
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
const scaled = Math.min(1, (m - dead) / (1 - dead));
|
|
249
|
+
vx = (vx / m) * scaled;
|
|
250
|
+
vy = (vy / m) * scaled;
|
|
251
|
+
}
|
|
252
|
+
st.vector[0] = vx;
|
|
253
|
+
st.vector[1] = vy;
|
|
254
|
+
}
|
|
255
|
+
function makeReading(st) {
|
|
256
|
+
const kind = st.opts.kind;
|
|
257
|
+
if (kind === 'stick') {
|
|
258
|
+
return {
|
|
259
|
+
kind,
|
|
260
|
+
get active() {
|
|
261
|
+
return st.pointer >= 0;
|
|
262
|
+
},
|
|
263
|
+
vector: st.vector,
|
|
264
|
+
get x() {
|
|
265
|
+
return st.vector[0];
|
|
266
|
+
},
|
|
267
|
+
get y() {
|
|
268
|
+
return st.vector[1];
|
|
269
|
+
},
|
|
270
|
+
get originX() {
|
|
271
|
+
return st.originX;
|
|
272
|
+
},
|
|
273
|
+
get originY() {
|
|
274
|
+
return st.originY;
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
if (kind === 'buttons') {
|
|
279
|
+
return {
|
|
280
|
+
kind,
|
|
281
|
+
get active() {
|
|
282
|
+
return st.pointer >= 0;
|
|
283
|
+
},
|
|
284
|
+
pressed: (name) => st.pressedNow === name,
|
|
285
|
+
held: (name) => st.down === name,
|
|
286
|
+
get down() {
|
|
287
|
+
return st.down;
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
return {
|
|
292
|
+
kind,
|
|
293
|
+
get active() {
|
|
294
|
+
return st.pointer >= 0;
|
|
295
|
+
},
|
|
296
|
+
get swipe() {
|
|
297
|
+
return st.swipeNow;
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a binding turns its raw input into an action (ws/input-3). `'press'` (the default) is
|
|
3
|
+
* active while the input is down. `'hold'` becomes active once the input has stayed down for
|
|
4
|
+
* `holdMs` (400) and stays active until it lifts; `ActionState.holdProgress` runs 0..1 meanwhile.
|
|
5
|
+
* `'doubleTap'` is active for one tick when the input goes down a second time within
|
|
6
|
+
* `doubleTapMs` (300) of the previous down. Times are measured in ticks of `Input.update()`
|
|
7
|
+
* (`InputOptions.tickMs`, default 1000/60), so a recording replays identically.
|
|
8
|
+
*/
|
|
9
|
+
export type Trigger = 'press' | 'hold' | 'doubleTap';
|
|
10
|
+
/** The trigger fields every `Binding` may carry. */
|
|
11
|
+
export interface TriggerOptions {
|
|
12
|
+
trigger?: Trigger;
|
|
13
|
+
/** Ms down before a `'hold'` fires. Default 400. */
|
|
14
|
+
holdMs?: number;
|
|
15
|
+
/** Most ms between the two downs of a `'doubleTap'`. Default 300. */
|
|
16
|
+
doubleTapMs?: number;
|
|
17
|
+
}
|
|
18
|
+
/** The input half of a `Binding`, without its trigger fields. */
|
|
19
|
+
export type BindingSource =
|
|
20
|
+
/** `KeyboardEvent.code` (layout-independent), e.g. `'KeyZ'`, `'Space'`, `'ArrowLeft'`, `'Escape'`. */
|
|
21
|
+
{
|
|
22
|
+
key: string;
|
|
23
|
+
}
|
|
24
|
+
/** `PointerEvent.button`: 0 primary (also touch/pen contact), 1 middle, 2 secondary. */
|
|
25
|
+
| {
|
|
26
|
+
mouse: number;
|
|
27
|
+
}
|
|
28
|
+
/** Wheel scrolled this tick. `1` = deltaY > 0 (down / towards the user), `-1` = up. */
|
|
29
|
+
| {
|
|
30
|
+
wheel: 1 | -1;
|
|
31
|
+
}
|
|
32
|
+
/** Standard-mapping gamepad button index (0 = A/Cross, 9 = Start …). `pad` omitted = any pad. */
|
|
33
|
+
| {
|
|
34
|
+
padButton: number;
|
|
35
|
+
pad?: number;
|
|
36
|
+
threshold?: number;
|
|
37
|
+
}
|
|
38
|
+
/** Gamepad axis past `threshold` (default 0.5) in direction `dir`. Value is analog 0..1. */
|
|
39
|
+
| {
|
|
40
|
+
padAxis: number;
|
|
41
|
+
dir: 1 | -1;
|
|
42
|
+
pad?: number;
|
|
43
|
+
threshold?: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A gesture from the `Gestures` linked with `Input.setGestures`. `tap` and `doubleTap` press
|
|
47
|
+
* for one tick; `longPress` holds until its pointer lifts; `pan`, `drag` and `pinch` hold
|
|
48
|
+
* from their start until they end. Reads inactive when no gestures are linked.
|
|
49
|
+
*/
|
|
50
|
+
| {
|
|
51
|
+
gesture: GestureKind;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A button of any pointer the linked `PointerRouter` routes (`Input.setPointers`): `select` is
|
|
55
|
+
* mouse button 0, a touch or pen contact, the pad cursor's press button and an XR trigger or
|
|
56
|
+
* pinch; `secondary` is mouse button 2, the pad cursor's second button and an XR squeeze.
|
|
57
|
+
* Pressed when one goes down; held while any is down. Inactive with no router linked.
|
|
58
|
+
*/
|
|
59
|
+
| {
|
|
60
|
+
pointer: PointerButton;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* An XR controller or hand button from an XR `PointerSource` (`hand` omitted = either hand).
|
|
64
|
+
* `createGame({ xr })` adds an `XrPointerSource` to `ctx.pointers` for the session; with no XR
|
|
65
|
+
* source on the router this reads inactive.
|
|
66
|
+
*/
|
|
67
|
+
| {
|
|
68
|
+
xr: XrButton;
|
|
69
|
+
hand?: Hand;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A chord (ws/input-3): active while every member binding is down, in any order; `pressed`
|
|
73
|
+
* fires once when the last one lands. Members are plain bindings (their own triggers are
|
|
74
|
+
* ignored); the members may also drive actions of their own.
|
|
75
|
+
*/
|
|
76
|
+
| {
|
|
77
|
+
chord: readonly Binding[];
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* A physical input that can drive an action, with optional trigger fields (`trigger`, `holdMs`,
|
|
81
|
+
* `doubleTapMs`). The engine ships no default bindings; the game supplies them.
|
|
82
|
+
*/
|
|
83
|
+
export type Binding = BindingSource & TriggerOptions;
|
|
84
|
+
/** Pointer buttons a `{ pointer }` binding can name. */
|
|
85
|
+
export type PointerButton = 'select' | 'secondary';
|
|
86
|
+
/** XR buttons a `{ xr }` binding can name: controller trigger, grip squeeze, hand pinch. */
|
|
87
|
+
export type XrButton = 'trigger' | 'squeeze' | 'pinch';
|
|
88
|
+
/** Which hand an XR pointer is in. */
|
|
89
|
+
export type Hand = 'left' | 'right';
|
|
90
|
+
/** The gestures `Gestures` recognises (and a `{ gesture }` binding can name). */
|
|
91
|
+
export type GestureKind = 'tap' | 'doubleTap' | 'longPress' | 'pan' | 'drag' | 'pinch';
|
|
92
|
+
export type Bindings<A extends string> = {
|
|
93
|
+
readonly [K in A]: readonly Binding[];
|
|
94
|
+
};
|
|
95
|
+
/** The device that last produced input (`Input.lastDevice`); `'xr'` once an XR button fires. */
|
|
96
|
+
export type InputDevice = 'keyboard' | 'mouse' | 'touch' | 'pen' | 'gamepad' | 'xr';
|
|
97
|
+
/** The `Gamepad.vibrationActuator` shape `Input.rumble` drives. */
|
|
98
|
+
export interface GamepadActuatorLike {
|
|
99
|
+
readonly type?: string;
|
|
100
|
+
playEffect(type: string, params: {
|
|
101
|
+
duration: number;
|
|
102
|
+
startDelay?: number;
|
|
103
|
+
strongMagnitude?: number;
|
|
104
|
+
weakMagnitude?: number;
|
|
105
|
+
}): Promise<unknown> | unknown;
|
|
106
|
+
}
|
|
107
|
+
/** Minimal shape of a `Gamepad` (lets tests feed plain objects). */
|
|
108
|
+
export interface GamepadLike {
|
|
109
|
+
readonly connected?: boolean;
|
|
110
|
+
readonly buttons: readonly {
|
|
111
|
+
readonly pressed: boolean;
|
|
112
|
+
readonly value: number;
|
|
113
|
+
}[];
|
|
114
|
+
readonly axes: readonly number[];
|
|
115
|
+
/** `Gamepad.id`, used to guess the button layout for prompt glyphs. */
|
|
116
|
+
readonly id?: string;
|
|
117
|
+
/** `Gamepad.vibrationActuator`, when the pad can rumble. */
|
|
118
|
+
readonly vibrationActuator?: GamepadActuatorLike | null;
|
|
119
|
+
}
|
|
120
|
+
/** Maps a client-space point (CSS px, `clientX/Y`) into game space, or `null` if outside it. */
|
|
121
|
+
export type PointerTransform = (clientX: number, clientY: number) => {
|
|
122
|
+
x: number;
|
|
123
|
+
y: number;
|
|
124
|
+
} | null;
|
|
125
|
+
export interface PointerState {
|
|
126
|
+
/** Position in game space (after the transform). Holds the last inside position when outside. */
|
|
127
|
+
x: number;
|
|
128
|
+
y: number;
|
|
129
|
+
/** Movement since the previous `update()`, game space. */
|
|
130
|
+
dx: number;
|
|
131
|
+
dy: number;
|
|
132
|
+
/** True when the last known position mapped inside the game rect. */
|
|
133
|
+
inside: boolean;
|
|
134
|
+
/** Primary button / contact currently down. */
|
|
135
|
+
down: boolean;
|
|
136
|
+
/** Wheel accumulated since the previous `update()` (pixels, normalised). */
|
|
137
|
+
wheelX: number;
|
|
138
|
+
wheelY: number;
|
|
139
|
+
/** Device of the most recent pointer event. */
|
|
140
|
+
type: 'mouse' | 'touch' | 'pen';
|
|
141
|
+
}
|
|
142
|
+
export interface ActionState {
|
|
143
|
+
/** True on the first tick the action became active. */
|
|
144
|
+
pressed: boolean;
|
|
145
|
+
/** True while active (also for a tap that started and ended between two ticks). */
|
|
146
|
+
held: boolean;
|
|
147
|
+
/** True on the first tick after the action stopped being active. */
|
|
148
|
+
released: boolean;
|
|
149
|
+
/** Analog value 0..1 (digital inputs give 0 or 1). */
|
|
150
|
+
value: number;
|
|
151
|
+
/** Consecutive ticks held (0 when not held). */
|
|
152
|
+
heldTicks: number;
|
|
153
|
+
/**
|
|
154
|
+
* For `'hold'` bindings: how far the longest press in progress is towards `holdMs`, 0..1 (1
|
|
155
|
+
* once the hold fired, 0 while nothing is down or the action has no hold binding).
|
|
156
|
+
*/
|
|
157
|
+
holdProgress: number;
|
|
158
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/// <reference path="../platform/xr-types.d.ts" preserve="true" />
|
|
2
|
+
/**
|
|
3
|
+
* XR controllers and hands as pointers (ws/xr; ARCHITECTURE "Input"). `XrPointerSource` is a
|
|
4
|
+
* `PointerSource` the router polls like any other: each `XRInputSource` of the session becomes
|
|
5
|
+
* one `PointerSample` whose ray is the source's target ray in the reference space (`x`, `y`
|
|
6
|
+
* NaN: there is no screen), with `xr.trigger` and `xr.squeeze` from the `xr-standard` gamepad
|
|
7
|
+
* (buttons 0 and 1) or, without a gamepad, from the session's select and squeeze events, and
|
|
8
|
+
* `xr.pinch` from the hand's index-finger tip and thumb tip when the Hand Input module reports
|
|
9
|
+
* joints. `select = trigger || pinch`, `secondary = squeeze`, `hand` is the handedness. Nothing in
|
|
10
|
+
* the router changes; `{ xr: 'trigger' | 'squeeze' | 'pinch', hand? }` bindings read these.
|
|
11
|
+
*
|
|
12
|
+
* Poses are only readable inside an `XRFrame`, so the source takes a getter for the frame that is
|
|
13
|
+
* running (`() => xrHost.frame`); polled outside one it reports no pointers.
|
|
14
|
+
*/
|
|
15
|
+
import { type PointerSample, type PointerSource } from './pointer-sources.js';
|
|
16
|
+
import type { RayCamera } from './rays.js';
|
|
17
|
+
export interface XrPointerSourceOptions {
|
|
18
|
+
/** Index tip to thumb tip distance (metres) at or under which a pinch starts. Default 0.02. */
|
|
19
|
+
pinchStart?: number;
|
|
20
|
+
/** Distance over which a pinch ends (hysteresis). Default 0.035. */
|
|
21
|
+
pinchEnd?: number;
|
|
22
|
+
}
|
|
23
|
+
export declare class XrPointerSource implements PointerSource {
|
|
24
|
+
readonly session: XRSession;
|
|
25
|
+
readonly referenceSpace: XRReferenceSpace;
|
|
26
|
+
/** The `XRFrame` running now, or null between frames (`() => xrHost.frame`). */
|
|
27
|
+
private readonly frame;
|
|
28
|
+
private readonly samples;
|
|
29
|
+
private readonly pressed;
|
|
30
|
+
private readonly pinching;
|
|
31
|
+
private readonly out;
|
|
32
|
+
private readonly pinchStart;
|
|
33
|
+
private readonly pinchEnd;
|
|
34
|
+
private nextKey;
|
|
35
|
+
private listening;
|
|
36
|
+
constructor(session: XRSession, referenceSpace: XRReferenceSpace,
|
|
37
|
+
/** The `XRFrame` running now, or null between frames (`() => xrHost.frame`). */
|
|
38
|
+
frame: () => XRFrame | null, opts?: XrPointerSourceOptions);
|
|
39
|
+
/** Listens to the session's select and squeeze events (the router calls this; idempotent). */
|
|
40
|
+
attach(): void;
|
|
41
|
+
/** Stops listening and forgets every pointer. */
|
|
42
|
+
detach(): void;
|
|
43
|
+
poll(_camera: RayCamera | null): readonly PointerSample[];
|
|
44
|
+
/** Index tip to thumb tip under `pinchStart` starts a pinch; over `pinchEnd` ends it. */
|
|
45
|
+
private pinch;
|
|
46
|
+
private state;
|
|
47
|
+
private readonly onSelectStart;
|
|
48
|
+
private readonly onSelectEnd;
|
|
49
|
+
private readonly onSqueezeStart;
|
|
50
|
+
private readonly onSqueezeEnd;
|
|
51
|
+
/** A removed source's pointer ends (its key stops appearing) and its state is dropped. */
|
|
52
|
+
private readonly onSourcesChange;
|
|
53
|
+
}
|