@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,216 @@
|
|
|
1
|
+
/** The pad layout for a `Gamepad.id` (vendor words and USB vendor ids), `'generic'` when unknown. */
|
|
2
|
+
export function guessPadLayout(id) {
|
|
3
|
+
if (!id)
|
|
4
|
+
return 'generic';
|
|
5
|
+
const s = id.toLowerCase();
|
|
6
|
+
if (/xbox|xinput|microsoft|045e/.test(s))
|
|
7
|
+
return 'xbox';
|
|
8
|
+
if (/playstation|dualshock|dualsense|sony|wireless controller|054c/.test(s))
|
|
9
|
+
return 'playstation';
|
|
10
|
+
if (/nintendo|switch|joy-con|pro controller|057e/.test(s))
|
|
11
|
+
return 'nintendo';
|
|
12
|
+
return 'generic';
|
|
13
|
+
}
|
|
14
|
+
const PAD_BUTTONS = {
|
|
15
|
+
xbox: [
|
|
16
|
+
'A',
|
|
17
|
+
'B',
|
|
18
|
+
'X',
|
|
19
|
+
'Y',
|
|
20
|
+
'LB',
|
|
21
|
+
'RB',
|
|
22
|
+
'LT',
|
|
23
|
+
'RT',
|
|
24
|
+
'View',
|
|
25
|
+
'Menu',
|
|
26
|
+
'LS',
|
|
27
|
+
'RS',
|
|
28
|
+
'↑',
|
|
29
|
+
'↓',
|
|
30
|
+
'←',
|
|
31
|
+
'→',
|
|
32
|
+
'Xbox',
|
|
33
|
+
],
|
|
34
|
+
playstation: [
|
|
35
|
+
'Cross',
|
|
36
|
+
'Circle',
|
|
37
|
+
'Square',
|
|
38
|
+
'Triangle',
|
|
39
|
+
'L1',
|
|
40
|
+
'R1',
|
|
41
|
+
'L2',
|
|
42
|
+
'R2',
|
|
43
|
+
'Share',
|
|
44
|
+
'Options',
|
|
45
|
+
'L3',
|
|
46
|
+
'R3',
|
|
47
|
+
'↑',
|
|
48
|
+
'↓',
|
|
49
|
+
'←',
|
|
50
|
+
'→',
|
|
51
|
+
'PS',
|
|
52
|
+
],
|
|
53
|
+
nintendo: [
|
|
54
|
+
'B',
|
|
55
|
+
'A',
|
|
56
|
+
'Y',
|
|
57
|
+
'X',
|
|
58
|
+
'L',
|
|
59
|
+
'R',
|
|
60
|
+
'ZL',
|
|
61
|
+
'ZR',
|
|
62
|
+
'-',
|
|
63
|
+
'+',
|
|
64
|
+
'LS',
|
|
65
|
+
'RS',
|
|
66
|
+
'↑',
|
|
67
|
+
'↓',
|
|
68
|
+
'←',
|
|
69
|
+
'→',
|
|
70
|
+
'Home',
|
|
71
|
+
],
|
|
72
|
+
generic: [],
|
|
73
|
+
};
|
|
74
|
+
/** Standard-mapping pad button `index` in `layout` (`'Button 7'` past the table or for `'generic'`). */
|
|
75
|
+
export function padButtonLabel(index, layout = 'generic') {
|
|
76
|
+
return PAD_BUTTONS[layout][index] ?? `Button ${index}`;
|
|
77
|
+
}
|
|
78
|
+
const AXES = ['LS', 'LS', 'RS', 'RS'];
|
|
79
|
+
/** Standard-mapping pad axis `axis` pushed in `dir`: `'LS →'`, `'RS ↑'`, or `'Axis 4 +'` past the sticks. */
|
|
80
|
+
export function padAxisLabel(axis, dir) {
|
|
81
|
+
const stick = AXES[axis];
|
|
82
|
+
if (!stick)
|
|
83
|
+
return `Axis ${axis} ${dir > 0 ? '+' : '-'}`;
|
|
84
|
+
const vertical = axis % 2 === 1;
|
|
85
|
+
const arrow = vertical ? (dir > 0 ? '↓' : '↑') : dir > 0 ? '→' : '←';
|
|
86
|
+
return `${stick} ${arrow}`;
|
|
87
|
+
}
|
|
88
|
+
const KEY_LABELS = {
|
|
89
|
+
Space: 'Space',
|
|
90
|
+
Enter: 'Enter',
|
|
91
|
+
NumpadEnter: 'Enter',
|
|
92
|
+
Escape: 'Esc',
|
|
93
|
+
Tab: 'Tab',
|
|
94
|
+
Backspace: 'Backspace',
|
|
95
|
+
Delete: 'Del',
|
|
96
|
+
Insert: 'Ins',
|
|
97
|
+
Home: 'Home',
|
|
98
|
+
End: 'End',
|
|
99
|
+
PageUp: 'PgUp',
|
|
100
|
+
PageDown: 'PgDn',
|
|
101
|
+
CapsLock: 'Caps',
|
|
102
|
+
ArrowUp: '↑',
|
|
103
|
+
ArrowDown: '↓',
|
|
104
|
+
ArrowLeft: '←',
|
|
105
|
+
ArrowRight: '→',
|
|
106
|
+
ShiftLeft: 'Shift',
|
|
107
|
+
ShiftRight: 'Shift',
|
|
108
|
+
ControlLeft: 'Ctrl',
|
|
109
|
+
ControlRight: 'Ctrl',
|
|
110
|
+
AltLeft: 'Alt',
|
|
111
|
+
AltRight: 'Alt',
|
|
112
|
+
MetaLeft: 'Meta',
|
|
113
|
+
MetaRight: 'Meta',
|
|
114
|
+
ContextMenu: 'Menu',
|
|
115
|
+
Minus: '-',
|
|
116
|
+
Equal: '=',
|
|
117
|
+
BracketLeft: '[',
|
|
118
|
+
BracketRight: ']',
|
|
119
|
+
Backslash: '\\',
|
|
120
|
+
Semicolon: ';',
|
|
121
|
+
Quote: "'",
|
|
122
|
+
Backquote: '`',
|
|
123
|
+
Comma: ',',
|
|
124
|
+
Period: '.',
|
|
125
|
+
Slash: '/',
|
|
126
|
+
NumpadAdd: 'Num +',
|
|
127
|
+
NumpadSubtract: 'Num -',
|
|
128
|
+
NumpadMultiply: 'Num *',
|
|
129
|
+
NumpadDivide: 'Num /',
|
|
130
|
+
NumpadDecimal: 'Num .',
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Display text for a `KeyboardEvent.code`: `'KeyA'` → `'A'`, `'Digit1'` → `'1'`, `'Numpad1'` →
|
|
134
|
+
* `'Num 1'`, `'F5'` → `'F5'`, arrows as arrows, modifiers without their side; unknown codes are
|
|
135
|
+
* split at their capitals (`'AudioVolumeUp'` → `'Audio Volume Up'`).
|
|
136
|
+
*/
|
|
137
|
+
export function keyLabel(code) {
|
|
138
|
+
const known = KEY_LABELS[code];
|
|
139
|
+
if (known)
|
|
140
|
+
return known;
|
|
141
|
+
if (code.startsWith('Key') && code.length === 4)
|
|
142
|
+
return code.slice(3);
|
|
143
|
+
if (code.startsWith('Digit') && code.length === 6)
|
|
144
|
+
return code.slice(5);
|
|
145
|
+
if (code.startsWith('Numpad') && code.length === 7)
|
|
146
|
+
return `Num ${code.slice(6)}`;
|
|
147
|
+
if (/^F\d{1,2}$/.test(code))
|
|
148
|
+
return code;
|
|
149
|
+
return code.replace(/([a-z])([A-Z])/g, '$1 $2');
|
|
150
|
+
}
|
|
151
|
+
const POINTER_LABELS = { select: 'Select', secondary: 'Secondary' };
|
|
152
|
+
const XR_LABELS = {
|
|
153
|
+
trigger: 'Trigger',
|
|
154
|
+
squeeze: 'Squeeze',
|
|
155
|
+
pinch: 'Pinch',
|
|
156
|
+
};
|
|
157
|
+
const GESTURE_LABELS = {
|
|
158
|
+
tap: 'Tap',
|
|
159
|
+
doubleTap: 'Double tap',
|
|
160
|
+
longPress: 'Hold',
|
|
161
|
+
pan: 'Drag',
|
|
162
|
+
drag: 'Drag',
|
|
163
|
+
pinch: 'Pinch',
|
|
164
|
+
};
|
|
165
|
+
const MOUSE_LABELS = ['Left click', 'Middle click', 'Right click', 'Back', 'Forward'];
|
|
166
|
+
/**
|
|
167
|
+
* The glyph for one binding. A chord joins its members with ` + ` and takes the first member's
|
|
168
|
+
* kind; `trigger: 'hold'` prefixes `Hold `, `'doubleTap'` prefixes `Double-tap `.
|
|
169
|
+
*/
|
|
170
|
+
export function glyphForBinding(b, layout = 'generic') {
|
|
171
|
+
const g = sourceGlyph(b, layout);
|
|
172
|
+
if (b.trigger === 'hold')
|
|
173
|
+
g.label = `Hold ${g.label}`;
|
|
174
|
+
else if (b.trigger === 'doubleTap')
|
|
175
|
+
g.label = `Double-tap ${g.label}`;
|
|
176
|
+
return g;
|
|
177
|
+
}
|
|
178
|
+
function sourceGlyph(b, layout) {
|
|
179
|
+
if ('key' in b)
|
|
180
|
+
return { kind: 'key', label: keyLabel(b.key) };
|
|
181
|
+
if ('mouse' in b)
|
|
182
|
+
return { kind: 'pointer', label: MOUSE_LABELS[b.mouse] ?? `Mouse ${b.mouse}` };
|
|
183
|
+
if ('wheel' in b)
|
|
184
|
+
return { kind: 'pointer', label: b.wheel < 0 ? 'Wheel up' : 'Wheel down' };
|
|
185
|
+
if ('padButton' in b)
|
|
186
|
+
return { kind: 'button', label: padButtonLabel(b.padButton, layout) };
|
|
187
|
+
if ('padAxis' in b)
|
|
188
|
+
return { kind: 'axis', label: padAxisLabel(b.padAxis, b.dir) };
|
|
189
|
+
if ('gesture' in b)
|
|
190
|
+
return { kind: 'gesture', label: GESTURE_LABELS[b.gesture] ?? b.gesture };
|
|
191
|
+
if ('pointer' in b)
|
|
192
|
+
return { kind: 'pointer', label: POINTER_LABELS[b.pointer] };
|
|
193
|
+
if ('xr' in b)
|
|
194
|
+
return { kind: 'xr', label: XR_LABELS[b.xr] };
|
|
195
|
+
const parts = b.chord.map((m) => glyphForBinding(m, layout));
|
|
196
|
+
const first = parts[0];
|
|
197
|
+
return { kind: first?.kind ?? 'key', label: parts.map((p) => p.label).join(' + ') };
|
|
198
|
+
}
|
|
199
|
+
/** True when `b` is what `device` produces, so its glyph is the one to show for that device. */
|
|
200
|
+
export function bindingMatchesDevice(b, device) {
|
|
201
|
+
if ('chord' in b)
|
|
202
|
+
return b.chord.some((m) => bindingMatchesDevice(m, device));
|
|
203
|
+
switch (device) {
|
|
204
|
+
case 'keyboard':
|
|
205
|
+
return 'key' in b;
|
|
206
|
+
case 'mouse':
|
|
207
|
+
case 'pen':
|
|
208
|
+
return 'mouse' in b || 'wheel' in b || 'pointer' in b;
|
|
209
|
+
case 'touch':
|
|
210
|
+
return 'gesture' in b || 'pointer' in b || 'mouse' in b;
|
|
211
|
+
case 'gamepad':
|
|
212
|
+
return 'padButton' in b || 'padAxis' in b;
|
|
213
|
+
case 'xr':
|
|
214
|
+
return 'xr' in b || 'pointer' in b;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gyro aim (ws/input-5): the device's rotation rate (`devicemotion`'s `rotationRate`) turned into
|
|
3
|
+
* a look delta, so a phone aims by turning it. Feature-detected; `Look` adds it to the pointer
|
|
4
|
+
* and stick delta each tick when given one (`LookOptions.gyro`). iOS asks the player first:
|
|
5
|
+
* call `requestPermission()` from a tap.
|
|
6
|
+
*/
|
|
7
|
+
/** `GyroSource.requestPermission` result; `'prompt'` is `permission` before it is asked. */
|
|
8
|
+
export type GyroPermission = 'granted' | 'denied' | 'unavailable';
|
|
9
|
+
/** The slice of `DeviceMotionEvent` the source reads. */
|
|
10
|
+
export interface GyroMotionEvent {
|
|
11
|
+
/** Degrees per second about the device's z (`alpha`), x (`beta`) and y (`gamma`) axes. */
|
|
12
|
+
rotationRate?: {
|
|
13
|
+
alpha?: number | null;
|
|
14
|
+
beta?: number | null;
|
|
15
|
+
gamma?: number | null;
|
|
16
|
+
} | null;
|
|
17
|
+
/** Ms between events, as the browser reports it. */
|
|
18
|
+
interval?: number;
|
|
19
|
+
timeStamp?: number;
|
|
20
|
+
}
|
|
21
|
+
/** Where the source listens (tests and the harness pass a fake). Default: the page's window. */
|
|
22
|
+
export interface GyroEnv {
|
|
23
|
+
/** Fires `devicemotion`. `null`: no API. */
|
|
24
|
+
target: {
|
|
25
|
+
addEventListener(type: 'devicemotion', fn: (e: GyroMotionEvent) => void): void;
|
|
26
|
+
removeEventListener(type: 'devicemotion', fn: (e: GyroMotionEvent) => void): void;
|
|
27
|
+
} | null;
|
|
28
|
+
/** `DeviceMotionEvent.requestPermission` where the platform has it (iOS 13+). */
|
|
29
|
+
requestPermission?: () => Promise<string>;
|
|
30
|
+
/** Screen rotation in degrees (`screen.orientation.angle`): 0, 90, 180 or 270. */
|
|
31
|
+
screenAngle?: () => number;
|
|
32
|
+
}
|
|
33
|
+
export interface GyroSourceOptions {
|
|
34
|
+
/** Look radians per radian the device turns. Default 1. */
|
|
35
|
+
sensitivity?: number;
|
|
36
|
+
/** Flip the pitch (the gyro's own; `Look.invertY` does not apply to it). Default false. */
|
|
37
|
+
invertY?: boolean;
|
|
38
|
+
/** 0..1 low-pass on each tick's delta: 0 none, 0.5 halves a jolt. Default 0. */
|
|
39
|
+
smoothing?: number;
|
|
40
|
+
/** The event source. Default the page's `window` and `DeviceMotionEvent`. */
|
|
41
|
+
env?: GyroEnv;
|
|
42
|
+
}
|
|
43
|
+
export interface GyroSource {
|
|
44
|
+
/** While false the rotation is dropped and `take` reads zero. Default true. */
|
|
45
|
+
enabled: boolean;
|
|
46
|
+
sensitivity: number;
|
|
47
|
+
invertY: boolean;
|
|
48
|
+
smoothing: number;
|
|
49
|
+
/** True when the platform has the motion API at all. */
|
|
50
|
+
readonly available: boolean;
|
|
51
|
+
/** True once a motion event with a rotation rate arrived (desktops have the API, no sensor). */
|
|
52
|
+
readonly receiving: boolean;
|
|
53
|
+
/** `'prompt'` until `requestPermission` settles. */
|
|
54
|
+
readonly permission: GyroPermission | 'prompt';
|
|
55
|
+
/**
|
|
56
|
+
* Ask for the sensor: `'unavailable'` without the API, the player's answer where the platform
|
|
57
|
+
* asks (iOS; call it from a tap), `'granted'` where it does not. Never rejects.
|
|
58
|
+
*/
|
|
59
|
+
requestPermission(): Promise<GyroPermission>;
|
|
60
|
+
/**
|
|
61
|
+
* The turn since the last `take`, radians (`dx` > 0 turns right, `dy` > 0 looks up, as
|
|
62
|
+
* `Look.look`), smoothed; resets the accumulator. Writes `out` and returns it. `Look` calls it.
|
|
63
|
+
*/
|
|
64
|
+
take(out: {
|
|
65
|
+
dx: number;
|
|
66
|
+
dy: number;
|
|
67
|
+
}): {
|
|
68
|
+
dx: number;
|
|
69
|
+
dy: number;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Add a rotation rate (degrees per second about the device's z, x and y axes, as
|
|
73
|
+
* `rotationRate.alpha/beta/gamma`) held for `ms`. The event listener calls it; tests and the
|
|
74
|
+
* harness feed it directly.
|
|
75
|
+
*/
|
|
76
|
+
feed(alpha: number, beta: number, gamma: number, ms: number): void;
|
|
77
|
+
/** Stop listening. */
|
|
78
|
+
dispose(): void;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Build a gyro source. It listens at once (where the platform needs permission, events start
|
|
82
|
+
* after `requestPermission` is granted). Rotation about the screen's vertical axis yaws, about
|
|
83
|
+
* its horizontal axis pitches, following `screen.orientation.angle`.
|
|
84
|
+
*/
|
|
85
|
+
export declare function createGyroSource(opts?: GyroSourceOptions): GyroSource;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gyro aim (ws/input-5): the device's rotation rate (`devicemotion`'s `rotationRate`) turned into
|
|
3
|
+
* a look delta, so a phone aims by turning it. Feature-detected; `Look` adds it to the pointer
|
|
4
|
+
* and stick delta each tick when given one (`LookOptions.gyro`). iOS asks the player first:
|
|
5
|
+
* call `requestPermission()` from a tap.
|
|
6
|
+
*/
|
|
7
|
+
/** Longest gap one event integrates over, ms (a stalled sensor must not jump the view). */
|
|
8
|
+
const MAX_EVENT_MS = 100;
|
|
9
|
+
const DEG = Math.PI / 180;
|
|
10
|
+
function defaultEnv() {
|
|
11
|
+
if (typeof window === 'undefined' || typeof DeviceMotionEvent === 'undefined') {
|
|
12
|
+
return { target: null };
|
|
13
|
+
}
|
|
14
|
+
const ctor = DeviceMotionEvent;
|
|
15
|
+
return {
|
|
16
|
+
target: window,
|
|
17
|
+
requestPermission: typeof ctor.requestPermission === 'function' ? () => ctor.requestPermission() : undefined,
|
|
18
|
+
screenAngle: () => (typeof screen !== 'undefined' && screen.orientation?.angle) ||
|
|
19
|
+
// Old iOS Safari.
|
|
20
|
+
Number(window.orientation ?? 0),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Build a gyro source. It listens at once (where the platform needs permission, events start
|
|
25
|
+
* after `requestPermission` is granted). Rotation about the screen's vertical axis yaws, about
|
|
26
|
+
* its horizontal axis pitches, following `screen.orientation.angle`.
|
|
27
|
+
*/
|
|
28
|
+
export function createGyroSource(opts = {}) {
|
|
29
|
+
const env = opts.env ?? defaultEnv();
|
|
30
|
+
const target = env.target;
|
|
31
|
+
let yaw = 0;
|
|
32
|
+
let pitch = 0;
|
|
33
|
+
let sx = 0;
|
|
34
|
+
let sy = 0;
|
|
35
|
+
let lastStamp = Number.NaN;
|
|
36
|
+
let receiving = false;
|
|
37
|
+
let permission = target ? 'prompt' : 'unavailable';
|
|
38
|
+
const onMotion = (e) => {
|
|
39
|
+
const r = e.rotationRate;
|
|
40
|
+
if (!r)
|
|
41
|
+
return;
|
|
42
|
+
receiving = true;
|
|
43
|
+
let ms;
|
|
44
|
+
const stamp = e.timeStamp;
|
|
45
|
+
if (stamp !== undefined && !Number.isNaN(lastStamp))
|
|
46
|
+
ms = stamp - lastStamp;
|
|
47
|
+
else {
|
|
48
|
+
// Some browsers have reported `interval` in seconds.
|
|
49
|
+
const iv = e.interval ?? 16;
|
|
50
|
+
ms = iv > 0 && iv < 1 ? iv * 1000 : iv;
|
|
51
|
+
}
|
|
52
|
+
if (stamp !== undefined)
|
|
53
|
+
lastStamp = stamp;
|
|
54
|
+
src.feed(r.alpha ?? 0, r.beta ?? 0, r.gamma ?? 0, ms);
|
|
55
|
+
};
|
|
56
|
+
const src = {
|
|
57
|
+
enabled: true,
|
|
58
|
+
sensitivity: opts.sensitivity ?? 1,
|
|
59
|
+
invertY: opts.invertY ?? false,
|
|
60
|
+
smoothing: opts.smoothing ?? 0,
|
|
61
|
+
get available() {
|
|
62
|
+
return target !== null;
|
|
63
|
+
},
|
|
64
|
+
get receiving() {
|
|
65
|
+
return receiving;
|
|
66
|
+
},
|
|
67
|
+
get permission() {
|
|
68
|
+
return permission;
|
|
69
|
+
},
|
|
70
|
+
async requestPermission() {
|
|
71
|
+
if (!target) {
|
|
72
|
+
permission = 'unavailable';
|
|
73
|
+
return permission;
|
|
74
|
+
}
|
|
75
|
+
if (!env.requestPermission) {
|
|
76
|
+
permission = 'granted';
|
|
77
|
+
return permission;
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
const r = await env.requestPermission();
|
|
81
|
+
permission = r === 'granted' ? 'granted' : 'denied';
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// Not inside a user gesture, or refused.
|
|
85
|
+
permission = 'denied';
|
|
86
|
+
}
|
|
87
|
+
return permission;
|
|
88
|
+
},
|
|
89
|
+
feed(_alpha, beta, gamma, ms) {
|
|
90
|
+
if (!src.enabled)
|
|
91
|
+
return;
|
|
92
|
+
const s = Math.min(MAX_EVENT_MS, Math.max(0, ms)) / 1000;
|
|
93
|
+
// Device axes: x right, y up, z out of the screen. Turning to aim right is a negative turn
|
|
94
|
+
// about the screen's up axis; tilting the top away (aim up) a positive one about its right.
|
|
95
|
+
const angle = (((env.screenAngle?.() ?? 0) % 360) + 360) % 360;
|
|
96
|
+
let up;
|
|
97
|
+
let right;
|
|
98
|
+
if (angle === 90) {
|
|
99
|
+
up = beta;
|
|
100
|
+
right = -gamma;
|
|
101
|
+
}
|
|
102
|
+
else if (angle === 180) {
|
|
103
|
+
up = -gamma;
|
|
104
|
+
right = -beta;
|
|
105
|
+
}
|
|
106
|
+
else if (angle === 270) {
|
|
107
|
+
up = -beta;
|
|
108
|
+
right = gamma;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
up = gamma;
|
|
112
|
+
right = beta;
|
|
113
|
+
}
|
|
114
|
+
yaw += 0 - up * s * DEG;
|
|
115
|
+
pitch += right * s * DEG;
|
|
116
|
+
},
|
|
117
|
+
take(out) {
|
|
118
|
+
const k = src.sensitivity;
|
|
119
|
+
let dx = src.enabled ? yaw * k : 0;
|
|
120
|
+
let dy = src.enabled ? pitch * k * (src.invertY ? -1 : 1) : 0;
|
|
121
|
+
yaw = pitch = 0;
|
|
122
|
+
const a = Math.min(1, Math.max(0, src.smoothing));
|
|
123
|
+
if (a > 0) {
|
|
124
|
+
dx = sx * a + dx * (1 - a);
|
|
125
|
+
dy = sy * a + dy * (1 - a);
|
|
126
|
+
}
|
|
127
|
+
sx = dx;
|
|
128
|
+
sy = dy;
|
|
129
|
+
// `+ 0` keeps a still gyro at +0 under invertY.
|
|
130
|
+
out.dx = dx + 0;
|
|
131
|
+
out.dy = dy + 0;
|
|
132
|
+
return out;
|
|
133
|
+
},
|
|
134
|
+
dispose() {
|
|
135
|
+
target?.removeEventListener('devicemotion', onMotion);
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
target?.addEventListener('devicemotion', onMotion);
|
|
139
|
+
return src;
|
|
140
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { type BindingConflict, findConflicts, isBinding, parseBindings, serializeBindings, } from './bindings.js';
|
|
2
|
+
export { createTickClock, type InputClock, type TickClock, wallClock, } from './clock.js';
|
|
3
|
+
export { Follow, type FollowCamera, type FollowMode, type FollowObstacle, type FollowOptions, type FollowSubject, } from './follow.js';
|
|
4
|
+
export { createGestures, type DragGesture, type GestureAttachOptions, type GestureDevice, type GestureListener, type GestureOptions, type GesturePhase, type GesturePoint, Gestures, type PanGesture, type PinchGesture, type TapGesture, } from './gestures.js';
|
|
5
|
+
export { bindingMatchesDevice, type Glyph, type GlyphKind, glyphForBinding, guessPadLayout, keyLabel, type PadLayout, padAxisLabel, padButtonLabel, } from './glyphs.js';
|
|
6
|
+
export { createGyroSource, type GyroEnv, type GyroMotionEvent, type GyroPermission, type GyroSource, type GyroSourceOptions, } from './gyro.js';
|
|
7
|
+
export { type ActionSource, type AttachOptions, type ContextOptions, type ContextPass, DEFAULT_DOUBLE_TAP_MS, DEFAULT_HOLD_MS, Input, type InputEvents, type InputFeedHook, type InputOptions, type InputPointerPhase, isButtonTarget, isInteractiveTarget, isTextEntryTarget, type ListenOptions, type RumbleOptions, type StickOptions, type StickShape, shapeStick, } from './input.js';
|
|
8
|
+
export type { LookTapListener, LookTapOptions } from './look.js';
|
|
9
|
+
export { createLook, Look, type LookEvents, type LookKeys, type LookMode, type LookOptions, type LookStick, type LookTouchOptions, type LookZoomOptions, type LookZoomPad, type MoveZone, PAD_ZOOM_PER_S, } from './look.js';
|
|
10
|
+
export { type Aim, type Edges, MAGNIFY_DEFAULTS, type MagnifyOptions, type MagnifyTarget, type SnapGrid, snapToGrid, } from './magnify.js';
|
|
11
|
+
export { createPointerDispatcher, POINTER_PRIORITY, type PointerConsumer, type PointerDispatcher, type PointerDispatcherOptions, type PointerRecord, type PointerRecordDevice, } from './pointer-dispatch.js';
|
|
12
|
+
export { createPointerRouter, type PointerActions, type PointerHitEvent, PointerRouter, type PointerRouterEvents, type PointerRouterOptions, type RoutedPointer, } from './pointer-router.js';
|
|
13
|
+
export { createSample, PadCursor, type PadCursorOptions, type PointerDevice, type PointerSample, type PointerSource, ScreenPointers, type XrButtons, } from './pointer-sources.js';
|
|
14
|
+
export { aabbTester, createHit, createRay, type HitTester, type MeshTesterOptions, meshTester, obbTester, type PickHit, planeTester, type Ray, type RayBounds, type RayBox, type RayCamera, type RayPlane, type RayTransform, rayAt, rayTriangle, screenRay, sphereTester, transformRayInto, type Vec3, } from './rays.js';
|
|
15
|
+
export type { InputPointerEntry } from './record.js';
|
|
16
|
+
export { createInputPlayback, createInputRecorder, type InputPlayback, type InputPlaybackOptions, type InputRecorder, type InputRecorderOptions, type InputRecording, InputRecordingError, type InputTick, type InputTickEvents, type InputTickRun, type PadSnapshot, parseRecording, recordingLength, serializeRecording, } from './record.js';
|
|
17
|
+
export { type ButtonsZone, type ButtonsZoneOptions, createTouchZones, type StickZone, type StickZoneOptions, type SwipeDirection, type SwipeZone, type SwipeZoneOptions, type TouchZoneBinding, type TouchZoneKind, type TouchZoneOptions, type TouchZoneReading, type TouchZones, type TouchZonesOptions, type ZoneRect, type ZoneRectFn, } from './touch-zones.js';
|
|
18
|
+
export type { ActionState, Binding, BindingSource, Bindings, GamepadActuatorLike, GamepadLike, GestureKind, Hand, InputDevice, PointerButton, PointerState, PointerTransform, Trigger, TriggerOptions, XrButton, } from './types.js';
|
|
19
|
+
export { XrPointerSource, type XrPointerSourceOptions } from './xr-source.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { findConflicts, isBinding, parseBindings, serializeBindings, } from './bindings.js';
|
|
2
|
+
export { createTickClock, wallClock, } from './clock.js';
|
|
3
|
+
export { Follow, } from './follow.js';
|
|
4
|
+
export { createGestures, Gestures, } from './gestures.js';
|
|
5
|
+
export { bindingMatchesDevice, glyphForBinding, guessPadLayout, keyLabel, padAxisLabel, padButtonLabel, } from './glyphs.js';
|
|
6
|
+
export { createGyroSource, } from './gyro.js';
|
|
7
|
+
export { DEFAULT_DOUBLE_TAP_MS, DEFAULT_HOLD_MS, Input, isButtonTarget, isInteractiveTarget, isTextEntryTarget, shapeStick, } from './input.js';
|
|
8
|
+
export { createLook, Look, PAD_ZOOM_PER_S, } from './look.js';
|
|
9
|
+
export { MAGNIFY_DEFAULTS, snapToGrid, } from './magnify.js';
|
|
10
|
+
export { createPointerDispatcher, POINTER_PRIORITY, } from './pointer-dispatch.js';
|
|
11
|
+
export { createPointerRouter, PointerRouter, } from './pointer-router.js';
|
|
12
|
+
export { createSample, PadCursor, ScreenPointers, } from './pointer-sources.js';
|
|
13
|
+
export { aabbTester, createHit, createRay, meshTester, obbTester, planeTester, rayAt, rayTriangle, screenRay, sphereTester, transformRayInto, } from './rays.js';
|
|
14
|
+
export { createInputPlayback, createInputRecorder, InputRecordingError, parseRecording, recordingLength, serializeRecording, } from './record.js';
|
|
15
|
+
export { createTouchZones, } from './touch-zones.js';
|
|
16
|
+
export { XrPointerSource } from './xr-source.js';
|