@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,8 @@
|
|
|
1
|
+
export { applyTransform, type ColliderBounds, type ColliderSource, type ColliderTransform, createStaticCollider, type GeometryMeshSource, type GeometrySource, type HeightfieldSource, type PositionsSource, SOURCE_GEOMETRY, SOURCE_GRID, SOURCE_HEIGHTFIELD, type SourceKind, type SourceRecord, StaticCollider, type StaticColliderOptions, type TileGridSource, } from './bvh.js';
|
|
2
|
+
export { colliderWireframe, colliderWireframeLength, type WireframeMode } from './debug.js';
|
|
3
|
+
export { type GridSource, gridSolid, gridTriangles } from './grid.js';
|
|
4
|
+
export { ALL_LAYERS, colliderTriangle, createHit, createSweepHit, overlap, overlap2, type RayHit, raycast, raycast2, raycastReg, type SweepHit, sweep, sweep2, } from './queries.js';
|
|
5
|
+
export { exportCollider, importCollider } from './serialize.js';
|
|
6
|
+
export { aabbTriangle, type Box2, type Capsule, type Circle, type Contact, capsuleTriangle, closestPointTriangle, closestSegmentSegment, closestSegmentTriangle, createContact, type GeomAabb, isAabb, isBox2, isCapsule, type Shape, type Shape2, type Sphere, shapeBounds, shapeTriangle, sphereTriangle, triangleNormal, type Vec3Out, } from './shapes.js';
|
|
7
|
+
export { createSlideResult, type SlideOptions, type SlideResult, slide, slide2, } from './slide.js';
|
|
8
|
+
export { carryBy, createTileSlideResult, slideTiles, TILE_EMPTY, TILE_ONE_WAY, TILE_SOLID, type TileBox, type TileKind, type TileMover, type TileQuery, type TileSlideOptions, type TileSlideResult, } from './tile-slide.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { applyTransform, createStaticCollider, SOURCE_GEOMETRY, SOURCE_GRID, SOURCE_HEIGHTFIELD, StaticCollider, } from './bvh.js';
|
|
2
|
+
export { colliderWireframe, colliderWireframeLength } from './debug.js';
|
|
3
|
+
export { gridSolid, gridTriangles } from './grid.js';
|
|
4
|
+
export { ALL_LAYERS, colliderTriangle, createHit, createSweepHit, overlap, overlap2, raycast, raycast2, raycastReg, sweep, sweep2, } from './queries.js';
|
|
5
|
+
export { exportCollider, importCollider } from './serialize.js';
|
|
6
|
+
export { aabbTriangle, capsuleTriangle, closestPointTriangle, closestSegmentSegment, closestSegmentTriangle, createContact, isAabb, isBox2, isCapsule, shapeBounds, shapeTriangle, sphereTriangle, triangleNormal, } from './shapes.js';
|
|
7
|
+
export { createSlideResult, slide, slide2, } from './slide.js';
|
|
8
|
+
export { carryBy, createTileSlideResult, slideTiles, TILE_EMPTY, TILE_ONE_WAY, TILE_SOLID, } from './tile-slide.js';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { StaticCollider } from './bvh.js';
|
|
2
|
+
import { type Contact, type Shape, type Shape2 } from './shapes.js';
|
|
3
|
+
/** All layers. */
|
|
4
|
+
export declare const ALL_LAYERS = 4294967295;
|
|
5
|
+
/** Where a ray met the collider. `t` is the distance along the ray; `n` the triangle normal facing the ray. */
|
|
6
|
+
export interface RayHit {
|
|
7
|
+
t: number;
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
z: number;
|
|
11
|
+
nx: number;
|
|
12
|
+
ny: number;
|
|
13
|
+
nz: number;
|
|
14
|
+
triangle: number;
|
|
15
|
+
source: number;
|
|
16
|
+
userData: unknown;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Where a swept shape first touches: `t` in 0..1 along the displacement (0 with `depth > 0` when
|
|
20
|
+
* it started overlapping), the point on the triangle and the unit normal pointing into the shape.
|
|
21
|
+
*/
|
|
22
|
+
export interface SweepHit extends RayHit {
|
|
23
|
+
depth: number;
|
|
24
|
+
}
|
|
25
|
+
export declare function createHit(): RayHit;
|
|
26
|
+
export declare function createSweepHit(): SweepHit;
|
|
27
|
+
/** Writes triangle `index`'s nine coordinates into `out` (at `offset`) and returns `out`. */
|
|
28
|
+
export declare function colliderTriangle(c: StaticCollider, index: number, out: Float32Array, offset?: number): Float32Array;
|
|
29
|
+
/**
|
|
30
|
+
* The nearest triangle along the ray from `origin` in `dir` (any length; `t` is in world units)
|
|
31
|
+
* within `maxDist`. Writes `out` and returns true, or returns false (out untouched) for a miss.
|
|
32
|
+
* Back faces hit too; the normal is turned to face the ray.
|
|
33
|
+
*/
|
|
34
|
+
export declare function raycast(c: StaticCollider, origin: ArrayLike<number>, dir: ArrayLike<number>, maxDist: number, out: RayHit, layerMask?: number): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* `raycast` in register form: the origin and direction as six numbers, so a caller with the
|
|
37
|
+
* ray in locals (`slide`'s line probe, a game's per-frame checks) needs no scratch arrays.
|
|
38
|
+
*/
|
|
39
|
+
export declare function raycastReg(c: StaticCollider, ox: number, oy: number, oz: number, dx: number, dy: number, dz: number, maxDist: number, out: RayHit, layerMask?: number): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Every triangle `shape` penetrates, as contacts into `out` (preallocated with `createContact`),
|
|
42
|
+
* at most `maxContacts` (default `out.length`). Returns the number written. Touching is not a
|
|
43
|
+
* contact; contacts come in BVH order, not by depth.
|
|
44
|
+
*/
|
|
45
|
+
export declare function overlap(c: StaticCollider, shape: Shape, out: Contact[], maxContacts?: number, layerMask?: number): number;
|
|
46
|
+
/** Sweep registers: the displacement xyz (0..2), the shape radius (3), the time limit (4). */
|
|
47
|
+
export declare const SW: Float64Array<ArrayBuffer>;
|
|
48
|
+
/**
|
|
49
|
+
* `sweep` of the shape in `SH` with the displacement read from `SW[0..2]`: the allocation-free
|
|
50
|
+
* entry `slide` uses.
|
|
51
|
+
*/
|
|
52
|
+
export declare function sweepMove(c: StaticCollider, out: SweepHit, layerMask?: number): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Moves `shape` by `(dx, dy, dz)` and finds the first triangle it touches: true and `out` filled
|
|
55
|
+
* with the time of impact `t` in 0..1, the triangle point and the normal into the shape; false
|
|
56
|
+
* when the whole displacement is free. A shape already overlapping reports `t` 0 and `depth`.
|
|
57
|
+
*/
|
|
58
|
+
export declare function sweep(c: StaticCollider, shape: Shape, dx: number, dy: number, dz: number, out: SweepHit, layerMask?: number): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* The 2D shape into `SH` as a 3D one spanning the collider's height, a hair inside its y range:
|
|
61
|
+
* a circle becomes a capsule (a sphere when the collider is flatter than its diameter), a 2D box
|
|
62
|
+
* a box.
|
|
63
|
+
*/
|
|
64
|
+
export declare function liftShape(c: StaticCollider, s: Shape2): void;
|
|
65
|
+
/** `raycast` in the xz plane at the collider's mid height; `t` is the distance in xz. */
|
|
66
|
+
export declare function raycast2(c: StaticCollider, ox: number, oz: number, dx: number, dz: number, maxDist: number, out: RayHit, layerMask?: number): boolean;
|
|
67
|
+
/** `overlap` for a circle or 2D box; contact normals lie in xz. */
|
|
68
|
+
export declare function overlap2(c: StaticCollider, shape: Shape2, out: Contact[], maxContacts?: number, layerMask?: number): number;
|
|
69
|
+
/** `sweep` for a circle or 2D box moving by `(dx, dz)`. */
|
|
70
|
+
export declare function sweep2(c: StaticCollider, shape: Shape2, dx: number, dz: number, out: SweepHit, layerMask?: number): boolean;
|
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queries against a `StaticCollider`: `raycast`, `overlap` and `sweep` in 3D, `raycast2`,
|
|
3
|
+
* `overlap2` and `sweep2` in the xz plane. Every query walks the BVH with one shared stack and
|
|
4
|
+
* writes into an `out` the caller owns; nothing allocates after the first call.
|
|
5
|
+
*
|
|
6
|
+
* Sweeps: a sphere or capsule advances conservatively along the displacement (the distance from
|
|
7
|
+
* the inner segment to the triangle over the closing speed, the bound a convex distance function
|
|
8
|
+
* allows, so a face-on approach lands in one step and an edge in a few); a box sweeps by the
|
|
9
|
+
* separating-axis test on the thirteen box–triangle axes, which is exact for a linear motion.
|
|
10
|
+
* The 2D shapes are lifted to the collider's height (a circle to a capsule, a box to a box
|
|
11
|
+
* spanning its y range, shrunk a hair so coplanar floors and ceilings do not register) and run
|
|
12
|
+
* through the 3D code.
|
|
13
|
+
*
|
|
14
|
+
* The per-triangle work passes its doubles through the shared registers of `shapes.ts` (`TRI`,
|
|
15
|
+
* `SEG`, `PT`, `BX`) and the ones below rather than as arguments: V8 boxes a double that crosses
|
|
16
|
+
* a call it did not inline, and these are the calls it does not inline.
|
|
17
|
+
*/
|
|
18
|
+
import { rayTriangle } from '../../input/rays.js';
|
|
19
|
+
import { aabbTri, BX, boxAxis, closestPointTri, closestSegTri, isBox2, loadBox, loadShape, PT, R, SEG, SH, SH_BOX, SH_CAPSULE, SH_SPHERE, shapeBoundsReg, shapeTri, TRI, triNormal, } from './shapes.js';
|
|
20
|
+
/** All layers. */
|
|
21
|
+
export const ALL_LAYERS = 0xffffffff;
|
|
22
|
+
export function createHit() {
|
|
23
|
+
return {
|
|
24
|
+
t: 0,
|
|
25
|
+
x: 0,
|
|
26
|
+
y: 0,
|
|
27
|
+
z: 0,
|
|
28
|
+
nx: 0,
|
|
29
|
+
ny: 0,
|
|
30
|
+
nz: 0,
|
|
31
|
+
triangle: -1,
|
|
32
|
+
source: -1,
|
|
33
|
+
userData: undefined,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function createSweepHit() {
|
|
37
|
+
return { ...createHit(), depth: 0 };
|
|
38
|
+
}
|
|
39
|
+
/** Writes triangle `index`'s nine coordinates into `out` (at `offset`) and returns `out`. */
|
|
40
|
+
export function colliderTriangle(c, index, out, offset = 0) {
|
|
41
|
+
const o = index * 9;
|
|
42
|
+
for (let k = 0; k < 9; k++)
|
|
43
|
+
out[offset + k] = c.tris[o + k];
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
// ------------------------------------------------------------------ traversal
|
|
47
|
+
let stack = new Int32Array(256);
|
|
48
|
+
function ensureStack(c) {
|
|
49
|
+
// A median-split tree has depth about log2(n / leafSize) + the top level; 2 × node count is a hard bound.
|
|
50
|
+
const need = Math.min(2 * c.nodeLeaf.length + 8, 4096);
|
|
51
|
+
if (stack.length < need)
|
|
52
|
+
stack = new Int32Array(need);
|
|
53
|
+
}
|
|
54
|
+
function layerOk(c, tri, mask) {
|
|
55
|
+
const s = c.sources[c.triSource[tri]];
|
|
56
|
+
return ((1 << s.layer) & mask) !== 0;
|
|
57
|
+
}
|
|
58
|
+
/** Loads triangle `o / 9` of `tris` into the `TRI` register. */
|
|
59
|
+
function loadTriAt(tris, o) {
|
|
60
|
+
for (let k = 0; k < 9; k++)
|
|
61
|
+
TRI[k] = tris[o + k];
|
|
62
|
+
}
|
|
63
|
+
const EPS_2D = 1e-3;
|
|
64
|
+
// ------------------------------------------------------------------ raycast
|
|
65
|
+
const ray = { origin: [0, 0, 0], dir: [0, 0, 1] };
|
|
66
|
+
const triA = [0, 0, 0];
|
|
67
|
+
const triB = [0, 0, 0];
|
|
68
|
+
const triC = [0, 0, 0];
|
|
69
|
+
const normal = [0, 0, 0];
|
|
70
|
+
function loadTriangle(tris, o) {
|
|
71
|
+
triA[0] = tris[o];
|
|
72
|
+
triA[1] = tris[o + 1];
|
|
73
|
+
triA[2] = tris[o + 2];
|
|
74
|
+
triB[0] = tris[o + 3];
|
|
75
|
+
triB[1] = tris[o + 4];
|
|
76
|
+
triB[2] = tris[o + 5];
|
|
77
|
+
triC[0] = tris[o + 6];
|
|
78
|
+
triC[1] = tris[o + 7];
|
|
79
|
+
triC[2] = tris[o + 8];
|
|
80
|
+
}
|
|
81
|
+
/** Ray registers: origin (0..2), inverse direction (3..5), the entry distance of the last `rayNode` (6). */
|
|
82
|
+
const RAY = new Float64Array(7);
|
|
83
|
+
/** Slab test: `RAY[6]` = the entry distance of the (unit) ray into node `n`, or +∞ for a miss. */
|
|
84
|
+
function rayNode(c, n) {
|
|
85
|
+
const o = n * 3;
|
|
86
|
+
if (c.nodeMin[o] > c.nodeMax[o]) {
|
|
87
|
+
RAY[6] = Number.POSITIVE_INFINITY; // removed source
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
let t0 = (c.nodeMin[o] - RAY[0]) * RAY[3];
|
|
91
|
+
let t1 = (c.nodeMax[o] - RAY[0]) * RAY[3];
|
|
92
|
+
let tmin = Math.min(t0, t1);
|
|
93
|
+
let tmax = Math.max(t0, t1);
|
|
94
|
+
t0 = (c.nodeMin[o + 1] - RAY[1]) * RAY[4];
|
|
95
|
+
t1 = (c.nodeMax[o + 1] - RAY[1]) * RAY[4];
|
|
96
|
+
tmin = Math.max(tmin, Math.min(t0, t1));
|
|
97
|
+
tmax = Math.min(tmax, Math.max(t0, t1));
|
|
98
|
+
t0 = (c.nodeMin[o + 2] - RAY[2]) * RAY[5];
|
|
99
|
+
t1 = (c.nodeMax[o + 2] - RAY[2]) * RAY[5];
|
|
100
|
+
tmin = Math.max(tmin, Math.min(t0, t1));
|
|
101
|
+
tmax = Math.min(tmax, Math.max(t0, t1));
|
|
102
|
+
tmin = Math.max(tmin, 0);
|
|
103
|
+
RAY[6] = tmax < tmin ? Number.POSITIVE_INFINITY : tmin;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The nearest triangle along the ray from `origin` in `dir` (any length; `t` is in world units)
|
|
107
|
+
* within `maxDist`. Writes `out` and returns true, or returns false (out untouched) for a miss.
|
|
108
|
+
* Back faces hit too; the normal is turned to face the ray.
|
|
109
|
+
*/
|
|
110
|
+
export function raycast(c, origin, dir, maxDist, out, layerMask = ALL_LAYERS) {
|
|
111
|
+
return raycastReg(c, origin[0], origin[1], origin[2], dir[0], dir[1], dir[2], maxDist, out, layerMask);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* `raycast` in register form: the origin and direction as six numbers, so a caller with the
|
|
115
|
+
* ray in locals (`slide`'s line probe, a game's per-frame checks) needs no scratch arrays.
|
|
116
|
+
*/
|
|
117
|
+
export function raycastReg(c, ox, oy, oz, dx, dy, dz, maxDist, out, layerMask = ALL_LAYERS) {
|
|
118
|
+
const len = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
119
|
+
if (!(len > 0))
|
|
120
|
+
return false;
|
|
121
|
+
dx /= len;
|
|
122
|
+
dy /= len;
|
|
123
|
+
dz /= len;
|
|
124
|
+
ray.origin[0] = ox;
|
|
125
|
+
ray.origin[1] = oy;
|
|
126
|
+
ray.origin[2] = oz;
|
|
127
|
+
ray.dir[0] = dx;
|
|
128
|
+
ray.dir[1] = dy;
|
|
129
|
+
ray.dir[2] = dz;
|
|
130
|
+
RAY[0] = ox;
|
|
131
|
+
RAY[1] = oy;
|
|
132
|
+
RAY[2] = oz;
|
|
133
|
+
RAY[3] = 1 / dx;
|
|
134
|
+
RAY[4] = 1 / dy;
|
|
135
|
+
RAY[5] = 1 / dz;
|
|
136
|
+
ensureStack(c);
|
|
137
|
+
let best = maxDist;
|
|
138
|
+
let bestTri = -1;
|
|
139
|
+
let sp = 0;
|
|
140
|
+
stack[sp++] = c.root;
|
|
141
|
+
const tris = c.tris;
|
|
142
|
+
while (sp > 0) {
|
|
143
|
+
const n = stack[--sp];
|
|
144
|
+
rayNode(c, n);
|
|
145
|
+
if (RAY[6] >= best)
|
|
146
|
+
continue;
|
|
147
|
+
if (c.nodeLeaf[n]) {
|
|
148
|
+
const t0 = c.nodeA[n];
|
|
149
|
+
const t1 = t0 + c.nodeB[n];
|
|
150
|
+
for (let t = t0; t < t1; t++) {
|
|
151
|
+
if (layerMask !== ALL_LAYERS && !layerOk(c, t, layerMask))
|
|
152
|
+
continue;
|
|
153
|
+
loadTriangle(tris, t * 9);
|
|
154
|
+
const d = rayTriangle(ray, triA, triB, triC, false, null);
|
|
155
|
+
if (d >= 0 && d < best) {
|
|
156
|
+
best = d;
|
|
157
|
+
bestTri = t;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
stack[sp++] = c.nodeA[n];
|
|
163
|
+
stack[sp++] = c.nodeB[n];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (bestTri < 0)
|
|
167
|
+
return false;
|
|
168
|
+
loadTriangle(tris, bestTri * 9);
|
|
169
|
+
rayTriangle(ray, triA, triB, triC, false, normal);
|
|
170
|
+
out.t = best;
|
|
171
|
+
out.x = ox + dx * best;
|
|
172
|
+
out.y = oy + dy * best;
|
|
173
|
+
out.z = oz + dz * best;
|
|
174
|
+
out.nx = normal[0];
|
|
175
|
+
out.ny = normal[1];
|
|
176
|
+
out.nz = normal[2];
|
|
177
|
+
out.triangle = bestTri;
|
|
178
|
+
const src = c.triSource[bestTri];
|
|
179
|
+
out.source = src;
|
|
180
|
+
out.userData = c.sources[src].userData;
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
// ------------------------------------------------------------------ overlap
|
|
184
|
+
const qMin = new Float64Array(3);
|
|
185
|
+
const qMax = new Float64Array(3);
|
|
186
|
+
function nodeOverlapsBox(c, n) {
|
|
187
|
+
const o = n * 3;
|
|
188
|
+
return (c.nodeMin[o] <= qMax[0] &&
|
|
189
|
+
c.nodeMax[o] >= qMin[0] &&
|
|
190
|
+
c.nodeMin[o + 1] <= qMax[1] &&
|
|
191
|
+
c.nodeMax[o + 1] >= qMin[1] &&
|
|
192
|
+
c.nodeMin[o + 2] <= qMax[2] &&
|
|
193
|
+
c.nodeMax[o + 2] >= qMin[2]);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Every triangle `shape` penetrates, as contacts into `out` (preallocated with `createContact`),
|
|
197
|
+
* at most `maxContacts` (default `out.length`). Returns the number written. Touching is not a
|
|
198
|
+
* contact; contacts come in BVH order, not by depth.
|
|
199
|
+
*/
|
|
200
|
+
export function overlap(c, shape, out, maxContacts = out.length, layerMask = ALL_LAYERS) {
|
|
201
|
+
loadShape(shape);
|
|
202
|
+
return overlapReg(c, out, maxContacts, layerMask);
|
|
203
|
+
}
|
|
204
|
+
/** `overlap` of the shape in `SH`. */
|
|
205
|
+
function overlapReg(c, out, maxContacts, layerMask) {
|
|
206
|
+
shapeBoundsReg(qMin, qMax);
|
|
207
|
+
ensureStack(c);
|
|
208
|
+
let count = 0;
|
|
209
|
+
let sp = 0;
|
|
210
|
+
stack[sp++] = c.root;
|
|
211
|
+
const tris = c.tris;
|
|
212
|
+
const limit = Math.min(maxContacts, out.length);
|
|
213
|
+
while (sp > 0 && count < limit) {
|
|
214
|
+
const n = stack[--sp];
|
|
215
|
+
if (!nodeOverlapsBox(c, n))
|
|
216
|
+
continue;
|
|
217
|
+
if (c.nodeLeaf[n]) {
|
|
218
|
+
const t0 = c.nodeA[n];
|
|
219
|
+
const t1 = t0 + c.nodeB[n];
|
|
220
|
+
for (let t = t0; t < t1 && count < limit; t++) {
|
|
221
|
+
if (layerMask !== ALL_LAYERS && !layerOk(c, t, layerMask))
|
|
222
|
+
continue;
|
|
223
|
+
loadTriAt(tris, t * 9);
|
|
224
|
+
const contact = out[count];
|
|
225
|
+
if (shapeTri(contact)) {
|
|
226
|
+
contact.triangle = t;
|
|
227
|
+
contact.source = c.triSource[t];
|
|
228
|
+
count++;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
stack[sp++] = c.nodeA[n];
|
|
234
|
+
stack[sp++] = c.nodeB[n];
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return count;
|
|
238
|
+
}
|
|
239
|
+
// ------------------------------------------------------------------ sweep
|
|
240
|
+
const SWEEP_TOL = 1e-6;
|
|
241
|
+
const SWEEP_ITERATIONS = 48;
|
|
242
|
+
/** Sweep registers: the displacement xyz (0..2), the shape radius (3), the time limit (4). */
|
|
243
|
+
export const SW = new Float64Array(5);
|
|
244
|
+
const SW_R = 3;
|
|
245
|
+
const SW_TMAX = 4;
|
|
246
|
+
/** The swept segment at t = 0. */
|
|
247
|
+
const seg0 = new Float64Array(6);
|
|
248
|
+
const sS = new Float64Array(3);
|
|
249
|
+
const sT = new Float64Array(3);
|
|
250
|
+
const sN = new Float64Array(3);
|
|
251
|
+
const sweepContact = {
|
|
252
|
+
depth: 0,
|
|
253
|
+
nx: 0,
|
|
254
|
+
ny: 0,
|
|
255
|
+
nz: 0,
|
|
256
|
+
px: 0,
|
|
257
|
+
py: 0,
|
|
258
|
+
pz: 0,
|
|
259
|
+
triangle: -1,
|
|
260
|
+
source: -1,
|
|
261
|
+
};
|
|
262
|
+
/** Results of the per-triangle sweeps: t, point xyz, normal xyz, depth. */
|
|
263
|
+
const H = new Float64Array(8);
|
|
264
|
+
const H_T = 0;
|
|
265
|
+
const H_PX = 1;
|
|
266
|
+
const H_PY = 2;
|
|
267
|
+
const H_PZ = 3;
|
|
268
|
+
const H_NX = 4;
|
|
269
|
+
const H_NY = 5;
|
|
270
|
+
const H_NZ = 6;
|
|
271
|
+
const H_DEPTH = 7;
|
|
272
|
+
/** `H` normal and point from the last closest-point pair, normal turned against the motion when degenerate. */
|
|
273
|
+
function hitFromClosest() {
|
|
274
|
+
let nx = sS[0] - sT[0];
|
|
275
|
+
let ny = sS[1] - sT[1];
|
|
276
|
+
let nz = sS[2] - sT[2];
|
|
277
|
+
const nl = Math.sqrt(nx * nx + ny * ny + nz * nz);
|
|
278
|
+
if (nl > 1e-12) {
|
|
279
|
+
nx /= nl;
|
|
280
|
+
ny /= nl;
|
|
281
|
+
nz /= nl;
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
triNormal(sN);
|
|
285
|
+
nx = sN[0];
|
|
286
|
+
ny = sN[1];
|
|
287
|
+
nz = sN[2];
|
|
288
|
+
if (nx * SW[0] + ny * SW[1] + nz * SW[2] > 0) {
|
|
289
|
+
nx = -nx;
|
|
290
|
+
ny = -ny;
|
|
291
|
+
nz = -nz;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
H[H_NX] = nx;
|
|
295
|
+
H[H_NY] = ny;
|
|
296
|
+
H[H_NZ] = nz;
|
|
297
|
+
H[H_PX] = sT[0];
|
|
298
|
+
H[H_PY] = sT[1];
|
|
299
|
+
H[H_PZ] = sT[2];
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Conservative advancement of the segment `seg0` with radius `SW[3]` along `SW[0..2]` against
|
|
303
|
+
* `TRI`. Returns true with `H` filled when it touches before `SW[4]`.
|
|
304
|
+
*/
|
|
305
|
+
function sweepSegTri() {
|
|
306
|
+
const dx = SW[0];
|
|
307
|
+
const dy = SW[1];
|
|
308
|
+
const dz = SW[2];
|
|
309
|
+
const r = SW[SW_R];
|
|
310
|
+
const tMax = SW[SW_TMAX];
|
|
311
|
+
// A contact needs the motion to go into the surface by at least this much of its length:
|
|
312
|
+
// a shape skimming a face it already touches, or crossing a triangle's edge from above, is
|
|
313
|
+
// not a hit (the next move's depenetration catches the hair of overlap this can let through).
|
|
314
|
+
const minClosing = 1e-2 * Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
315
|
+
let t = 0;
|
|
316
|
+
for (let i = 0; i < SWEEP_ITERATIONS; i++) {
|
|
317
|
+
SEG[0] = seg0[0] + dx * t;
|
|
318
|
+
SEG[1] = seg0[1] + dy * t;
|
|
319
|
+
SEG[2] = seg0[2] + dz * t;
|
|
320
|
+
SEG[3] = seg0[3] + dx * t;
|
|
321
|
+
SEG[4] = seg0[4] + dy * t;
|
|
322
|
+
SEG[5] = seg0[5] + dz * t;
|
|
323
|
+
closestSegTri(sS, sT);
|
|
324
|
+
const dist = Math.sqrt(R[0]) - r;
|
|
325
|
+
hitFromClosest();
|
|
326
|
+
// Closing speed along the separation direction; moving away or sideways never touches.
|
|
327
|
+
const closing = -(dx * H[H_NX] + dy * H[H_NY] + dz * H[H_NZ]);
|
|
328
|
+
if (dist <= SWEEP_TOL) {
|
|
329
|
+
if (i === 0 && dist < -SWEEP_TOL) {
|
|
330
|
+
// Started overlapping: report the penetration, no motion.
|
|
331
|
+
H[H_T] = 0;
|
|
332
|
+
H[H_DEPTH] = -dist;
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
// Touching: only a contact when the motion goes into the surface.
|
|
336
|
+
if (closing <= minClosing)
|
|
337
|
+
return false;
|
|
338
|
+
H[H_T] = t;
|
|
339
|
+
H[H_DEPTH] = 0;
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
if (closing <= minClosing)
|
|
343
|
+
return false;
|
|
344
|
+
t += dist / closing;
|
|
345
|
+
if (t >= tMax)
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
// Out of iterations while still closing: take the conservative time reached.
|
|
349
|
+
H[H_T] = t;
|
|
350
|
+
H[H_DEPTH] = 0;
|
|
351
|
+
return true;
|
|
352
|
+
}
|
|
353
|
+
/** Separating-axis state for the swept box: entry, exit, normal xyz. */
|
|
354
|
+
const SAT = new Float64Array(5);
|
|
355
|
+
const SAT_ENTRY = 0;
|
|
356
|
+
const SAT_EXIT = 1;
|
|
357
|
+
/** One axis (`BX[12..14]`) of the swept separating-axis test; false once the box can never meet the triangle. */
|
|
358
|
+
function sweptAxis() {
|
|
359
|
+
const x = BX[12];
|
|
360
|
+
const y = BX[13];
|
|
361
|
+
const z = BX[14];
|
|
362
|
+
const len2 = x * x + y * y + z * z;
|
|
363
|
+
if (len2 < 1e-18)
|
|
364
|
+
return true;
|
|
365
|
+
const p0 = BX[3] * x + BX[4] * y + BX[5] * z;
|
|
366
|
+
const p1 = BX[6] * x + BX[7] * y + BX[8] * z;
|
|
367
|
+
const p2 = BX[9] * x + BX[10] * y + BX[11] * z;
|
|
368
|
+
const r = BX[0] * Math.abs(x) + BX[1] * Math.abs(y) + BX[2] * Math.abs(z);
|
|
369
|
+
const lo = Math.min(p0, Math.min(p1, p2));
|
|
370
|
+
const hi = Math.max(p0, Math.max(p1, p2));
|
|
371
|
+
const v = SW[0] * x + SW[1] * y + SW[2] * z;
|
|
372
|
+
if (Math.abs(v) < 1e-18) {
|
|
373
|
+
return lo < r && hi > -r;
|
|
374
|
+
}
|
|
375
|
+
// The box spans [-r, r] + v t; it overlaps (lo, hi) for t between these two.
|
|
376
|
+
let tEnter = (lo - r) / v;
|
|
377
|
+
let tLeave = (hi + r) / v;
|
|
378
|
+
let sign = -1; // the box's leading face is +axis when v > 0: the normal points -axis
|
|
379
|
+
if (tEnter > tLeave) {
|
|
380
|
+
const tmp = tEnter;
|
|
381
|
+
tEnter = tLeave;
|
|
382
|
+
tLeave = tmp;
|
|
383
|
+
sign = 1;
|
|
384
|
+
}
|
|
385
|
+
if (tEnter > SAT[SAT_ENTRY]) {
|
|
386
|
+
SAT[SAT_ENTRY] = tEnter;
|
|
387
|
+
const len = Math.sqrt(len2);
|
|
388
|
+
SAT[2] = (sign * x) / len;
|
|
389
|
+
SAT[3] = (sign * y) / len;
|
|
390
|
+
SAT[4] = (sign * z) / len;
|
|
391
|
+
}
|
|
392
|
+
if (tLeave < SAT[SAT_EXIT])
|
|
393
|
+
SAT[SAT_EXIT] = tLeave;
|
|
394
|
+
return SAT[SAT_ENTRY] <= SAT[SAT_EXIT];
|
|
395
|
+
}
|
|
396
|
+
/** Swept separating-axis test of the box in `SH` along `SW[0..2]` against `TRI`. */
|
|
397
|
+
function sweepBoxTri() {
|
|
398
|
+
loadBox();
|
|
399
|
+
SAT[SAT_ENTRY] = Number.NEGATIVE_INFINITY;
|
|
400
|
+
SAT[SAT_EXIT] = Number.POSITIVE_INFINITY;
|
|
401
|
+
SAT[2] = 0;
|
|
402
|
+
SAT[3] = 0;
|
|
403
|
+
SAT[4] = 0;
|
|
404
|
+
for (let i = 0; i < 13; i++) {
|
|
405
|
+
boxAxis(i);
|
|
406
|
+
if (!sweptAxis())
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
const entry = SAT[SAT_ENTRY];
|
|
410
|
+
if (SAT[SAT_EXIT] < 0 || entry >= SW[SW_TMAX])
|
|
411
|
+
return false;
|
|
412
|
+
if (entry <= 0) {
|
|
413
|
+
// Already overlapping (or touching): report the penetration at t = 0.
|
|
414
|
+
if (!aabbTri(sweepContact))
|
|
415
|
+
return false;
|
|
416
|
+
H[H_T] = 0;
|
|
417
|
+
H[H_DEPTH] = sweepContact.depth;
|
|
418
|
+
H[H_NX] = sweepContact.nx;
|
|
419
|
+
H[H_NY] = sweepContact.ny;
|
|
420
|
+
H[H_NZ] = sweepContact.nz;
|
|
421
|
+
H[H_PX] = sweepContact.px;
|
|
422
|
+
H[H_PY] = sweepContact.py;
|
|
423
|
+
H[H_PZ] = sweepContact.pz;
|
|
424
|
+
return true;
|
|
425
|
+
}
|
|
426
|
+
H[H_T] = entry;
|
|
427
|
+
H[H_DEPTH] = 0;
|
|
428
|
+
H[H_NX] = SAT[2];
|
|
429
|
+
H[H_NY] = SAT[3];
|
|
430
|
+
H[H_NZ] = SAT[4];
|
|
431
|
+
// `PT` holds the box centre from `loadBox`; move it to the time of impact.
|
|
432
|
+
PT[0] += SW[0] * entry;
|
|
433
|
+
PT[1] += SW[1] * entry;
|
|
434
|
+
PT[2] += SW[2] * entry;
|
|
435
|
+
closestPointTri(sT);
|
|
436
|
+
H[H_PX] = sT[0];
|
|
437
|
+
H[H_PY] = sT[1];
|
|
438
|
+
H[H_PZ] = sT[2];
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
441
|
+
/** Sweeps the shape in `SH` along `SW` against triangle `o / 9` of `tris`. */
|
|
442
|
+
function sweepTri(tris, o) {
|
|
443
|
+
loadTriAt(tris, o);
|
|
444
|
+
if (SH[0] === SH_BOX)
|
|
445
|
+
return sweepBoxTri();
|
|
446
|
+
const h = SH[4];
|
|
447
|
+
seg0[0] = seg0[3] = SH[1];
|
|
448
|
+
seg0[1] = SH[2] - h;
|
|
449
|
+
seg0[4] = SH[2] + h;
|
|
450
|
+
seg0[2] = seg0[5] = SH[3];
|
|
451
|
+
SW[SW_R] = SH[5];
|
|
452
|
+
return sweepSegTri();
|
|
453
|
+
}
|
|
454
|
+
const sMin = new Float64Array(3);
|
|
455
|
+
const sMax = new Float64Array(3);
|
|
456
|
+
/** The box swept by the shape's bounds over `[0, SW[4]]` of the displacement, into `qMin`/`qMax`. */
|
|
457
|
+
function sweptBounds() {
|
|
458
|
+
const t = SW[SW_TMAX];
|
|
459
|
+
for (let k = 0; k < 3; k++) {
|
|
460
|
+
qMin[k] = Math.min(sMin[k], sMin[k] + SW[k] * t);
|
|
461
|
+
qMax[k] = Math.max(sMax[k], sMax[k] + SW[k] * t);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* `sweep` of the shape in `SH` with the displacement read from `SW[0..2]`: the allocation-free
|
|
466
|
+
* entry `slide` uses.
|
|
467
|
+
*/
|
|
468
|
+
export function sweepMove(c, out, layerMask = ALL_LAYERS) {
|
|
469
|
+
shapeBoundsReg(sMin, sMax);
|
|
470
|
+
// Pad by the tolerance so a shape resting a hair off a face still finds it.
|
|
471
|
+
for (let k = 0; k < 3; k++) {
|
|
472
|
+
sMin[k] -= SWEEP_TOL * 4;
|
|
473
|
+
sMax[k] += SWEEP_TOL * 4;
|
|
474
|
+
}
|
|
475
|
+
ensureStack(c);
|
|
476
|
+
SW[SW_TMAX] = 1;
|
|
477
|
+
let bestTri = -1;
|
|
478
|
+
let found = false;
|
|
479
|
+
sweptBounds();
|
|
480
|
+
let sp = 0;
|
|
481
|
+
stack[sp++] = c.root;
|
|
482
|
+
const tris = c.tris;
|
|
483
|
+
while (sp > 0) {
|
|
484
|
+
const n = stack[--sp];
|
|
485
|
+
if (!nodeOverlapsBox(c, n))
|
|
486
|
+
continue;
|
|
487
|
+
if (c.nodeLeaf[n]) {
|
|
488
|
+
const t0 = c.nodeA[n];
|
|
489
|
+
const t1 = t0 + c.nodeB[n];
|
|
490
|
+
for (let t = t0; t < t1; t++) {
|
|
491
|
+
if (layerMask !== ALL_LAYERS && !layerOk(c, t, layerMask))
|
|
492
|
+
continue;
|
|
493
|
+
if (!sweepTri(tris, t * 9))
|
|
494
|
+
continue;
|
|
495
|
+
const ht = H[H_T];
|
|
496
|
+
const best = SW[SW_TMAX];
|
|
497
|
+
// Among initial overlaps the deepest wins; otherwise the earliest.
|
|
498
|
+
if (!found || ht < best || (ht === 0 && best === 0 && H[H_DEPTH] > out.depth)) {
|
|
499
|
+
found = true;
|
|
500
|
+
bestTri = t;
|
|
501
|
+
SW[SW_TMAX] = ht;
|
|
502
|
+
out.t = ht;
|
|
503
|
+
out.depth = H[H_DEPTH];
|
|
504
|
+
out.x = H[H_PX];
|
|
505
|
+
out.y = H[H_PY];
|
|
506
|
+
out.z = H[H_PZ];
|
|
507
|
+
out.nx = H[H_NX];
|
|
508
|
+
out.ny = H[H_NY];
|
|
509
|
+
out.nz = H[H_NZ];
|
|
510
|
+
sweptBounds();
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
stack[sp++] = c.nodeA[n];
|
|
516
|
+
stack[sp++] = c.nodeB[n];
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
if (!found)
|
|
520
|
+
return false;
|
|
521
|
+
out.triangle = bestTri;
|
|
522
|
+
const src = c.triSource[bestTri];
|
|
523
|
+
out.source = src;
|
|
524
|
+
out.userData = c.sources[src].userData;
|
|
525
|
+
return true;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Moves `shape` by `(dx, dy, dz)` and finds the first triangle it touches: true and `out` filled
|
|
529
|
+
* with the time of impact `t` in 0..1, the triangle point and the normal into the shape; false
|
|
530
|
+
* when the whole displacement is free. A shape already overlapping reports `t` 0 and `depth`.
|
|
531
|
+
*/
|
|
532
|
+
export function sweep(c, shape, dx, dy, dz, out, layerMask = ALL_LAYERS) {
|
|
533
|
+
loadShape(shape);
|
|
534
|
+
SW[0] = dx;
|
|
535
|
+
SW[1] = dy;
|
|
536
|
+
SW[2] = dz;
|
|
537
|
+
return sweepMove(c, out, layerMask);
|
|
538
|
+
}
|
|
539
|
+
// ------------------------------------------------------------------ 2D
|
|
540
|
+
/**
|
|
541
|
+
* The 2D shape into `SH` as a 3D one spanning the collider's height, a hair inside its y range:
|
|
542
|
+
* a circle becomes a capsule (a sphere when the collider is flatter than its diameter), a 2D box
|
|
543
|
+
* a box.
|
|
544
|
+
*/
|
|
545
|
+
export function liftShape(c, s) {
|
|
546
|
+
const y0 = c.bounds.min[1] === Number.POSITIVE_INFINITY ? 0 : c.bounds.min[1] + EPS_2D;
|
|
547
|
+
const y1 = c.bounds.max[1] === Number.NEGATIVE_INFINITY ? 0 : c.bounds.max[1] - EPS_2D;
|
|
548
|
+
if (isBox2(s)) {
|
|
549
|
+
SH[0] = SH_BOX;
|
|
550
|
+
SH[1] = s.x - s.hw;
|
|
551
|
+
SH[2] = Math.min(y0, y1);
|
|
552
|
+
SH[3] = s.z - s.hh;
|
|
553
|
+
SH[4] = s.x + s.hw;
|
|
554
|
+
SH[5] = Math.max(y0, y1);
|
|
555
|
+
SH[6] = s.z + s.hh;
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
const half = (y1 - y0) / 2 - s.r;
|
|
559
|
+
SH[0] = half <= 0 ? SH_SPHERE : SH_CAPSULE;
|
|
560
|
+
SH[1] = s.x;
|
|
561
|
+
SH[2] = (y0 + y1) / 2;
|
|
562
|
+
SH[3] = s.z;
|
|
563
|
+
SH[4] = Math.max(0, half);
|
|
564
|
+
SH[5] = s.r;
|
|
565
|
+
}
|
|
566
|
+
/** `raycast` in the xz plane at the collider's mid height; `t` is the distance in xz. */
|
|
567
|
+
export function raycast2(c, ox, oz, dx, dz, maxDist, out, layerMask = ALL_LAYERS) {
|
|
568
|
+
const oy = (c.bounds.min[1] + c.bounds.max[1]) / 2;
|
|
569
|
+
return raycastReg(c, ox, oy, oz, dx, 0, dz, maxDist, out, layerMask);
|
|
570
|
+
}
|
|
571
|
+
/** `overlap` for a circle or 2D box; contact normals lie in xz. */
|
|
572
|
+
export function overlap2(c, shape, out, maxContacts = out.length, layerMask = ALL_LAYERS) {
|
|
573
|
+
liftShape(c, shape);
|
|
574
|
+
return overlapReg(c, out, maxContacts, layerMask);
|
|
575
|
+
}
|
|
576
|
+
/** `sweep` for a circle or 2D box moving by `(dx, dz)`. */
|
|
577
|
+
export function sweep2(c, shape, dx, dz, out, layerMask = ALL_LAYERS) {
|
|
578
|
+
liftShape(c, shape);
|
|
579
|
+
SW[0] = dx;
|
|
580
|
+
SW[1] = 0;
|
|
581
|
+
SW[2] = dz;
|
|
582
|
+
return sweepMove(c, out, layerMask);
|
|
583
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A built collider as bytes, so a level's BVH is baked once and loaded, not rebuilt on every
|
|
3
|
+
* start. Little-endian, versioned, typed arrays laid out whole; `userData` is not serialised
|
|
4
|
+
* (pass it to `importCollider` to reattach, by source index). Re-exporting an imported collider
|
|
5
|
+
* gives identical bytes.
|
|
6
|
+
*/
|
|
7
|
+
import { StaticCollider } from './bvh.js';
|
|
8
|
+
/** Serialises `c` to a self-contained buffer. */
|
|
9
|
+
export declare function exportCollider(c: StaticCollider): ArrayBuffer;
|
|
10
|
+
/**
|
|
11
|
+
* Rebuilds a collider from `exportCollider` bytes. The arrays are copied out of `buf`, so it may
|
|
12
|
+
* be released. `userData[i]` is attached to source `i` when given.
|
|
13
|
+
*/
|
|
14
|
+
export declare function importCollider(buf: ArrayBuffer, userData?: unknown[]): StaticCollider;
|