@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,686 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collision shapes and the shape-vs-triangle tests the queries are built on. Every function is
|
|
3
|
+
* pure arithmetic over plain numbers: a triangle is its nine coordinates (so the collider's flat
|
|
4
|
+
* triangle array is read in place), the result goes into an `out` the caller owns, nothing here
|
|
5
|
+
* allocates.
|
|
6
|
+
*/
|
|
7
|
+
/** A zeroed `Contact`, for the caller's preallocated arrays. */
|
|
8
|
+
export function createContact() {
|
|
9
|
+
return { depth: 0, nx: 0, ny: 0, nz: 0, px: 0, py: 0, pz: 0, triangle: -1, source: -1 };
|
|
10
|
+
}
|
|
11
|
+
// `in`, not a field read: loading the double just to test it boxes it at a polymorphic site.
|
|
12
|
+
export function isCapsule(s) {
|
|
13
|
+
return 'halfHeight' in s;
|
|
14
|
+
}
|
|
15
|
+
export function isAabb(s) {
|
|
16
|
+
return 'min' in s;
|
|
17
|
+
}
|
|
18
|
+
export function isBox2(s) {
|
|
19
|
+
return 'hw' in s;
|
|
20
|
+
}
|
|
21
|
+
// ------------------------------------------------------------------ registers
|
|
22
|
+
//
|
|
23
|
+
// V8 boxes every non-integer number that crosses a call it did not inline (arguments and return
|
|
24
|
+
// values become heap numbers), so the hot internal paths pass doubles through these shared typed
|
|
25
|
+
// arrays instead and return booleans. The public functions load them from plain-number
|
|
26
|
+
// parameters; the queries write them directly.
|
|
27
|
+
/** The current triangle: a, b, c as nine coordinates. */
|
|
28
|
+
export const TRI = new Float64Array(9);
|
|
29
|
+
/** A point (0..2) or segment (0..2, 3..5). */
|
|
30
|
+
export const SEG = new Float64Array(6);
|
|
31
|
+
/** A second segment. */
|
|
32
|
+
const SEG2 = new Float64Array(6);
|
|
33
|
+
/** Scalars: `R[0]` the squared distance of the last closest-point query; the rest internal. */
|
|
34
|
+
export const R = new Float64Array(4);
|
|
35
|
+
/** The query point of `closestPointTri`; also the box centre of the box tests. */
|
|
36
|
+
export const PT = new Float64Array(3);
|
|
37
|
+
/** Box state: half extents (0..2), triangle vertices relative to the box centre (3..11), axis (12..14). */
|
|
38
|
+
export const BX = new Float64Array(15);
|
|
39
|
+
/**
|
|
40
|
+
* The query shape: kind (0), then for a sphere or capsule its centre (1..3), half height (4, 0
|
|
41
|
+
* for a sphere) and radius (5); for a box its min (1..3) and max (4..6). Queries read the shape
|
|
42
|
+
* from here, never from the caller's object: field loads from objects of varying layout box
|
|
43
|
+
* their doubles.
|
|
44
|
+
*/
|
|
45
|
+
export const SH = new Float64Array(7);
|
|
46
|
+
export const SH_SPHERE = 0;
|
|
47
|
+
export const SH_CAPSULE = 1;
|
|
48
|
+
export const SH_BOX = 2;
|
|
49
|
+
function loadSphere(s) {
|
|
50
|
+
SH[0] = SH_SPHERE;
|
|
51
|
+
SH[1] = s.x;
|
|
52
|
+
SH[2] = s.y;
|
|
53
|
+
SH[3] = s.z;
|
|
54
|
+
SH[4] = 0;
|
|
55
|
+
SH[5] = s.r;
|
|
56
|
+
}
|
|
57
|
+
function loadCapsule(s) {
|
|
58
|
+
SH[0] = SH_CAPSULE;
|
|
59
|
+
SH[1] = s.x;
|
|
60
|
+
SH[2] = s.y;
|
|
61
|
+
SH[3] = s.z;
|
|
62
|
+
SH[4] = s.halfHeight;
|
|
63
|
+
SH[5] = s.r;
|
|
64
|
+
}
|
|
65
|
+
function loadAabb(s) {
|
|
66
|
+
SH[0] = SH_BOX;
|
|
67
|
+
SH[1] = s.min[0];
|
|
68
|
+
SH[2] = s.min[1];
|
|
69
|
+
SH[3] = s.min[2];
|
|
70
|
+
SH[4] = s.max[0];
|
|
71
|
+
SH[5] = s.max[1];
|
|
72
|
+
SH[6] = s.max[2];
|
|
73
|
+
}
|
|
74
|
+
/** Loads `s` into `SH`. */
|
|
75
|
+
export function loadShape(s) {
|
|
76
|
+
if (isAabb(s))
|
|
77
|
+
loadAabb(s);
|
|
78
|
+
else if (isCapsule(s))
|
|
79
|
+
loadCapsule(s);
|
|
80
|
+
else
|
|
81
|
+
loadSphere(s);
|
|
82
|
+
}
|
|
83
|
+
/** Loads `TRI`. */
|
|
84
|
+
export function loadTri(ax, ay, az, bx, by, bz, cx, cy, cz) {
|
|
85
|
+
TRI[0] = ax;
|
|
86
|
+
TRI[1] = ay;
|
|
87
|
+
TRI[2] = az;
|
|
88
|
+
TRI[3] = bx;
|
|
89
|
+
TRI[4] = by;
|
|
90
|
+
TRI[5] = bz;
|
|
91
|
+
TRI[6] = cx;
|
|
92
|
+
TRI[7] = cy;
|
|
93
|
+
TRI[8] = cz;
|
|
94
|
+
}
|
|
95
|
+
// ------------------------------------------------------------------ point / triangle
|
|
96
|
+
/**
|
|
97
|
+
* The point of triangle `TRI` closest to `PT` (Ericson, Real-Time Collision Detection 5.1.5): the
|
|
98
|
+
* Voronoi region of the point decides between a vertex, an edge and the face. Writes `out`.
|
|
99
|
+
*/
|
|
100
|
+
export function closestPointTri(out) {
|
|
101
|
+
const px = PT[0];
|
|
102
|
+
const py = PT[1];
|
|
103
|
+
const pz = PT[2];
|
|
104
|
+
const ax = TRI[0];
|
|
105
|
+
const ay = TRI[1];
|
|
106
|
+
const az = TRI[2];
|
|
107
|
+
const bx = TRI[3];
|
|
108
|
+
const by = TRI[4];
|
|
109
|
+
const bz = TRI[5];
|
|
110
|
+
const cx = TRI[6];
|
|
111
|
+
const cy = TRI[7];
|
|
112
|
+
const cz = TRI[8];
|
|
113
|
+
const abx = bx - ax;
|
|
114
|
+
const aby = by - ay;
|
|
115
|
+
const abz = bz - az;
|
|
116
|
+
const acx = cx - ax;
|
|
117
|
+
const acy = cy - ay;
|
|
118
|
+
const acz = cz - az;
|
|
119
|
+
const apx = px - ax;
|
|
120
|
+
const apy = py - ay;
|
|
121
|
+
const apz = pz - az;
|
|
122
|
+
const d1 = abx * apx + aby * apy + abz * apz;
|
|
123
|
+
const d2 = acx * apx + acy * apy + acz * apz;
|
|
124
|
+
if (d1 <= 0 && d2 <= 0) {
|
|
125
|
+
out[0] = ax;
|
|
126
|
+
out[1] = ay;
|
|
127
|
+
out[2] = az;
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const bpx = px - bx;
|
|
131
|
+
const bpy = py - by;
|
|
132
|
+
const bpz = pz - bz;
|
|
133
|
+
const d3 = abx * bpx + aby * bpy + abz * bpz;
|
|
134
|
+
const d4 = acx * bpx + acy * bpy + acz * bpz;
|
|
135
|
+
if (d3 >= 0 && d4 <= d3) {
|
|
136
|
+
out[0] = bx;
|
|
137
|
+
out[1] = by;
|
|
138
|
+
out[2] = bz;
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const vc = d1 * d4 - d3 * d2;
|
|
142
|
+
if (vc <= 0 && d1 >= 0 && d3 <= 0) {
|
|
143
|
+
const v = d1 / (d1 - d3);
|
|
144
|
+
out[0] = ax + v * abx;
|
|
145
|
+
out[1] = ay + v * aby;
|
|
146
|
+
out[2] = az + v * abz;
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const cpx = px - cx;
|
|
150
|
+
const cpy = py - cy;
|
|
151
|
+
const cpz = pz - cz;
|
|
152
|
+
const d5 = abx * cpx + aby * cpy + abz * cpz;
|
|
153
|
+
const d6 = acx * cpx + acy * cpy + acz * cpz;
|
|
154
|
+
if (d6 >= 0 && d5 <= d6) {
|
|
155
|
+
out[0] = cx;
|
|
156
|
+
out[1] = cy;
|
|
157
|
+
out[2] = cz;
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const vb = d5 * d2 - d1 * d6;
|
|
161
|
+
if (vb <= 0 && d2 >= 0 && d6 <= 0) {
|
|
162
|
+
const w = d2 / (d2 - d6);
|
|
163
|
+
out[0] = ax + w * acx;
|
|
164
|
+
out[1] = ay + w * acy;
|
|
165
|
+
out[2] = az + w * acz;
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const va = d3 * d6 - d5 * d4;
|
|
169
|
+
if (va <= 0 && d4 - d3 >= 0 && d5 - d6 >= 0) {
|
|
170
|
+
const w = (d4 - d3) / (d4 - d3 + (d5 - d6));
|
|
171
|
+
out[0] = bx + w * (cx - bx);
|
|
172
|
+
out[1] = by + w * (cy - by);
|
|
173
|
+
out[2] = bz + w * (cz - bz);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const denom = 1 / (va + vb + vc);
|
|
177
|
+
const v = vb * denom;
|
|
178
|
+
const w = vc * denom;
|
|
179
|
+
out[0] = ax + abx * v + acx * w;
|
|
180
|
+
out[1] = ay + aby * v + acy * w;
|
|
181
|
+
out[2] = az + abz * v + acz * w;
|
|
182
|
+
}
|
|
183
|
+
/** The point of triangle `a, b, c` closest to `p`, into `out`; returns `out`. */
|
|
184
|
+
export function closestPointTriangle(px, py, pz, ax, ay, az, bx, by, bz, cx, cy, cz, out) {
|
|
185
|
+
loadTri(ax, ay, az, bx, by, bz, cx, cy, cz);
|
|
186
|
+
PT[0] = px;
|
|
187
|
+
PT[1] = py;
|
|
188
|
+
PT[2] = pz;
|
|
189
|
+
closestPointTri(out);
|
|
190
|
+
return out;
|
|
191
|
+
}
|
|
192
|
+
/** The unit normal of `TRI` (counter-clockwise front) into `out`; zero if degenerate. */
|
|
193
|
+
export function triNormal(out) {
|
|
194
|
+
const ax = TRI[0];
|
|
195
|
+
const ay = TRI[1];
|
|
196
|
+
const az = TRI[2];
|
|
197
|
+
const abx = TRI[3] - ax;
|
|
198
|
+
const aby = TRI[4] - ay;
|
|
199
|
+
const abz = TRI[5] - az;
|
|
200
|
+
const acx = TRI[6] - ax;
|
|
201
|
+
const acy = TRI[7] - ay;
|
|
202
|
+
const acz = TRI[8] - az;
|
|
203
|
+
const nx = aby * acz - abz * acy;
|
|
204
|
+
const ny = abz * acx - abx * acz;
|
|
205
|
+
const nz = abx * acy - aby * acx;
|
|
206
|
+
const len = Math.sqrt(nx * nx + ny * ny + nz * nz);
|
|
207
|
+
if (len < 1e-20) {
|
|
208
|
+
out[0] = out[1] = out[2] = 0;
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
out[0] = nx / len;
|
|
212
|
+
out[1] = ny / len;
|
|
213
|
+
out[2] = nz / len;
|
|
214
|
+
}
|
|
215
|
+
/** The unit normal of triangle `a, b, c` (counter-clockwise front) into `out`; zero if degenerate. */
|
|
216
|
+
export function triangleNormal(ax, ay, az, bx, by, bz, cx, cy, cz, out) {
|
|
217
|
+
loadTri(ax, ay, az, bx, by, bz, cx, cy, cz);
|
|
218
|
+
triNormal(out);
|
|
219
|
+
return out;
|
|
220
|
+
}
|
|
221
|
+
// ------------------------------------------------------------------ segments
|
|
222
|
+
/**
|
|
223
|
+
* The closest points between segments `SEG` and `SEG2` (Ericson 5.1.9): the point on the first
|
|
224
|
+
* into `outP`, on the second into `outQ`, the squared distance into `R[0]`.
|
|
225
|
+
*/
|
|
226
|
+
function closestSegSeg(outP, outQ) {
|
|
227
|
+
const p0x = SEG[0];
|
|
228
|
+
const p0y = SEG[1];
|
|
229
|
+
const p0z = SEG[2];
|
|
230
|
+
const q0x = SEG2[0];
|
|
231
|
+
const q0y = SEG2[1];
|
|
232
|
+
const q0z = SEG2[2];
|
|
233
|
+
const d1x = SEG[3] - p0x;
|
|
234
|
+
const d1y = SEG[4] - p0y;
|
|
235
|
+
const d1z = SEG[5] - p0z;
|
|
236
|
+
const d2x = SEG2[3] - q0x;
|
|
237
|
+
const d2y = SEG2[4] - q0y;
|
|
238
|
+
const d2z = SEG2[5] - q0z;
|
|
239
|
+
const rx = p0x - q0x;
|
|
240
|
+
const ry = p0y - q0y;
|
|
241
|
+
const rz = p0z - q0z;
|
|
242
|
+
const a = d1x * d1x + d1y * d1y + d1z * d1z;
|
|
243
|
+
const e = d2x * d2x + d2y * d2y + d2z * d2z;
|
|
244
|
+
const f = d2x * rx + d2y * ry + d2z * rz;
|
|
245
|
+
let s;
|
|
246
|
+
let t;
|
|
247
|
+
const EPS = 1e-12;
|
|
248
|
+
if (a <= EPS && e <= EPS) {
|
|
249
|
+
s = t = 0;
|
|
250
|
+
}
|
|
251
|
+
else if (a <= EPS) {
|
|
252
|
+
s = 0;
|
|
253
|
+
t = Math.min(1, Math.max(0, f / e));
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
const c = d1x * rx + d1y * ry + d1z * rz;
|
|
257
|
+
if (e <= EPS) {
|
|
258
|
+
t = 0;
|
|
259
|
+
s = Math.min(1, Math.max(0, -c / a));
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
const b = d1x * d2x + d1y * d2y + d1z * d2z;
|
|
263
|
+
const denom = a * e - b * b;
|
|
264
|
+
s = denom !== 0 ? Math.min(1, Math.max(0, (b * f - c * e) / denom)) : 0;
|
|
265
|
+
t = (b * s + f) / e;
|
|
266
|
+
if (t < 0) {
|
|
267
|
+
t = 0;
|
|
268
|
+
s = Math.min(1, Math.max(0, -c / a));
|
|
269
|
+
}
|
|
270
|
+
else if (t > 1) {
|
|
271
|
+
t = 1;
|
|
272
|
+
s = Math.min(1, Math.max(0, (b - c) / a));
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
const px = p0x + d1x * s;
|
|
277
|
+
const py = p0y + d1y * s;
|
|
278
|
+
const pz = p0z + d1z * s;
|
|
279
|
+
const qx = q0x + d2x * t;
|
|
280
|
+
const qy = q0y + d2y * t;
|
|
281
|
+
const qz = q0z + d2z * t;
|
|
282
|
+
outP[0] = px;
|
|
283
|
+
outP[1] = py;
|
|
284
|
+
outP[2] = pz;
|
|
285
|
+
outQ[0] = qx;
|
|
286
|
+
outQ[1] = qy;
|
|
287
|
+
outQ[2] = qz;
|
|
288
|
+
const dx = px - qx;
|
|
289
|
+
const dy = py - qy;
|
|
290
|
+
const dz = pz - qz;
|
|
291
|
+
R[0] = dx * dx + dy * dy + dz * dz;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* The closest points between segment `p0 p1` and segment `q0 q1`: writes the point on the first
|
|
295
|
+
* into `outP` and on the second into `outQ`, returns the squared distance.
|
|
296
|
+
*/
|
|
297
|
+
export function closestSegmentSegment(p0x, p0y, p0z, p1x, p1y, p1z, q0x, q0y, q0z, q1x, q1y, q1z, outP, outQ) {
|
|
298
|
+
SEG[0] = p0x;
|
|
299
|
+
SEG[1] = p0y;
|
|
300
|
+
SEG[2] = p0z;
|
|
301
|
+
SEG[3] = p1x;
|
|
302
|
+
SEG[4] = p1y;
|
|
303
|
+
SEG[5] = p1z;
|
|
304
|
+
SEG2[0] = q0x;
|
|
305
|
+
SEG2[1] = q0y;
|
|
306
|
+
SEG2[2] = q0z;
|
|
307
|
+
SEG2[3] = q1x;
|
|
308
|
+
SEG2[4] = q1y;
|
|
309
|
+
SEG2[5] = q1z;
|
|
310
|
+
closestSegSeg(outP, outQ);
|
|
311
|
+
return R[0];
|
|
312
|
+
}
|
|
313
|
+
const scratchP = new Float64Array(3);
|
|
314
|
+
const scratchQ = new Float64Array(3);
|
|
315
|
+
const scratchN = new Float64Array(3);
|
|
316
|
+
const segP = new Float64Array(3);
|
|
317
|
+
const segQ = new Float64Array(3);
|
|
318
|
+
const capS = new Float64Array(3);
|
|
319
|
+
/** Loads triangle edge `i` (0: ab, 1: bc, 2: ca) of `TRI` into `SEG2`. */
|
|
320
|
+
function edgeToSeg2(i) {
|
|
321
|
+
const o0 = i * 3;
|
|
322
|
+
const o1 = ((i + 1) % 3) * 3;
|
|
323
|
+
SEG2[0] = TRI[o0];
|
|
324
|
+
SEG2[1] = TRI[o0 + 1];
|
|
325
|
+
SEG2[2] = TRI[o0 + 2];
|
|
326
|
+
SEG2[3] = TRI[o1];
|
|
327
|
+
SEG2[4] = TRI[o1 + 1];
|
|
328
|
+
SEG2[5] = TRI[o1 + 2];
|
|
329
|
+
}
|
|
330
|
+
/** Takes the candidate pair `s`, `t` when its squared distance `R[0]` beats the best so far, `R[1]`. */
|
|
331
|
+
function takeBest(s, t, outS, outT) {
|
|
332
|
+
if (R[0] < R[1]) {
|
|
333
|
+
R[1] = R[0];
|
|
334
|
+
outS[0] = s[0];
|
|
335
|
+
outS[1] = s[1];
|
|
336
|
+
outS[2] = s[2];
|
|
337
|
+
outT[0] = t[0];
|
|
338
|
+
outT[1] = t[1];
|
|
339
|
+
outT[2] = t[2];
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
/** `R[0]` = the squared distance from `PT` to `scratchQ`. */
|
|
343
|
+
function pointDist2() {
|
|
344
|
+
const dx = PT[0] - scratchQ[0];
|
|
345
|
+
const dy = PT[1] - scratchQ[1];
|
|
346
|
+
const dz = PT[2] - scratchQ[2];
|
|
347
|
+
R[0] = dx * dx + dy * dy + dz * dz;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* The closest points between segment `SEG` and triangle `TRI`: the point on the segment into
|
|
351
|
+
* `outS`, the point on the triangle into `outT`, the squared distance into `R[0]` (0 when the
|
|
352
|
+
* segment crosses the face). Candidates: each endpoint against the face, the segment against
|
|
353
|
+
* each edge, and the face crossing. Clobbers `SEG2`, `PT` and `R[1]`.
|
|
354
|
+
*/
|
|
355
|
+
export function closestSegTri(outS, outT) {
|
|
356
|
+
const p0x = SEG[0];
|
|
357
|
+
const p0y = SEG[1];
|
|
358
|
+
const p0z = SEG[2];
|
|
359
|
+
const p1x = SEG[3];
|
|
360
|
+
const p1y = SEG[4];
|
|
361
|
+
const p1z = SEG[5];
|
|
362
|
+
const ax = TRI[0];
|
|
363
|
+
const ay = TRI[1];
|
|
364
|
+
const az = TRI[2];
|
|
365
|
+
// Does the segment cross the face? Then the distance is zero at the crossing.
|
|
366
|
+
triNormal(scratchN);
|
|
367
|
+
const nx = scratchN[0];
|
|
368
|
+
const ny = scratchN[1];
|
|
369
|
+
const nz = scratchN[2];
|
|
370
|
+
const s0 = (p0x - ax) * nx + (p0y - ay) * ny + (p0z - az) * nz;
|
|
371
|
+
const s1 = (p1x - ax) * nx + (p1y - ay) * ny + (p1z - az) * nz;
|
|
372
|
+
if ((nx !== 0 || ny !== 0 || nz !== 0) && s0 * s1 <= 0 && s0 !== s1) {
|
|
373
|
+
const u = s0 / (s0 - s1);
|
|
374
|
+
PT[0] = p0x + (p1x - p0x) * u;
|
|
375
|
+
PT[1] = p0y + (p1y - p0y) * u;
|
|
376
|
+
PT[2] = p0z + (p1z - p0z) * u;
|
|
377
|
+
closestPointTri(scratchQ);
|
|
378
|
+
pointDist2();
|
|
379
|
+
if (R[0] < 1e-18) {
|
|
380
|
+
outS[0] = outT[0] = PT[0];
|
|
381
|
+
outS[1] = outT[1] = PT[1];
|
|
382
|
+
outS[2] = outT[2] = PT[2];
|
|
383
|
+
R[0] = 0;
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
R[1] = Number.POSITIVE_INFINITY;
|
|
388
|
+
// Endpoints against the face.
|
|
389
|
+
PT[0] = p0x;
|
|
390
|
+
PT[1] = p0y;
|
|
391
|
+
PT[2] = p0z;
|
|
392
|
+
closestPointTri(scratchQ);
|
|
393
|
+
pointDist2();
|
|
394
|
+
takeBest(PT, scratchQ, outS, outT);
|
|
395
|
+
PT[0] = p1x;
|
|
396
|
+
PT[1] = p1y;
|
|
397
|
+
PT[2] = p1z;
|
|
398
|
+
closestPointTri(scratchQ);
|
|
399
|
+
pointDist2();
|
|
400
|
+
takeBest(PT, scratchQ, outS, outT);
|
|
401
|
+
// The segment against each edge.
|
|
402
|
+
for (let e = 0; e < 3; e++) {
|
|
403
|
+
edgeToSeg2(e);
|
|
404
|
+
closestSegSeg(segP, segQ);
|
|
405
|
+
takeBest(segP, segQ, outS, outT);
|
|
406
|
+
}
|
|
407
|
+
R[0] = R[1];
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* The closest points between segment `p0 p1` and triangle `a b c`: the point on the segment
|
|
411
|
+
* into `outS`, the point on the triangle into `outT`; returns the squared distance (0 when the
|
|
412
|
+
* segment crosses the face).
|
|
413
|
+
*/
|
|
414
|
+
export function closestSegmentTriangle(p0x, p0y, p0z, p1x, p1y, p1z, ax, ay, az, bx, by, bz, cx, cy, cz, outS, outT) {
|
|
415
|
+
loadTri(ax, ay, az, bx, by, bz, cx, cy, cz);
|
|
416
|
+
SEG[0] = p0x;
|
|
417
|
+
SEG[1] = p0y;
|
|
418
|
+
SEG[2] = p0z;
|
|
419
|
+
SEG[3] = p1x;
|
|
420
|
+
SEG[4] = p1y;
|
|
421
|
+
SEG[5] = p1z;
|
|
422
|
+
closestSegTri(outS, outT);
|
|
423
|
+
return R[0];
|
|
424
|
+
}
|
|
425
|
+
// ------------------------------------------------------------------ shape / triangle
|
|
426
|
+
/**
|
|
427
|
+
* Fills `out` for a sphere centred at `PT` with radius `R[2]` whose closest triangle point is
|
|
428
|
+
* `scratchP`. When the centre lies on the triangle the normal is the face normal. Returns true
|
|
429
|
+
* for a contact (touching is none).
|
|
430
|
+
*/
|
|
431
|
+
function contactFromClosest(out) {
|
|
432
|
+
const r = R[2];
|
|
433
|
+
const dx = PT[0] - scratchP[0];
|
|
434
|
+
const dy = PT[1] - scratchP[1];
|
|
435
|
+
const dz = PT[2] - scratchP[2];
|
|
436
|
+
const d2 = dx * dx + dy * dy + dz * dz;
|
|
437
|
+
if (d2 >= r * r)
|
|
438
|
+
return false;
|
|
439
|
+
const d = Math.sqrt(d2);
|
|
440
|
+
if (d > 1e-9) {
|
|
441
|
+
out.nx = dx / d;
|
|
442
|
+
out.ny = dy / d;
|
|
443
|
+
out.nz = dz / d;
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
triNormal(scratchN);
|
|
447
|
+
out.nx = scratchN[0];
|
|
448
|
+
out.ny = scratchN[1];
|
|
449
|
+
out.nz = scratchN[2];
|
|
450
|
+
}
|
|
451
|
+
out.depth = r - d;
|
|
452
|
+
out.px = scratchP[0];
|
|
453
|
+
out.py = scratchP[1];
|
|
454
|
+
out.pz = scratchP[2];
|
|
455
|
+
out.triangle = -1;
|
|
456
|
+
out.source = -1;
|
|
457
|
+
return true;
|
|
458
|
+
}
|
|
459
|
+
/** The sphere in `SH` against `TRI`. */
|
|
460
|
+
export function sphereTri(out) {
|
|
461
|
+
PT[0] = SH[1];
|
|
462
|
+
PT[1] = SH[2];
|
|
463
|
+
PT[2] = SH[3];
|
|
464
|
+
R[2] = SH[5];
|
|
465
|
+
closestPointTri(scratchP);
|
|
466
|
+
return contactFromClosest(out);
|
|
467
|
+
}
|
|
468
|
+
/** Sphere against a triangle: true and `out` filled when they overlap (touching is no contact). */
|
|
469
|
+
export function sphereTriangle(s, ax, ay, az, bx, by, bz, cx, cy, cz, out) {
|
|
470
|
+
loadTri(ax, ay, az, bx, by, bz, cx, cy, cz);
|
|
471
|
+
loadSphere(s);
|
|
472
|
+
return sphereTri(out);
|
|
473
|
+
}
|
|
474
|
+
/** The capsule (y axis) in `SH` against `TRI`. */
|
|
475
|
+
export function capsuleTri(out) {
|
|
476
|
+
const h = SH[4];
|
|
477
|
+
const r = SH[5];
|
|
478
|
+
SEG[0] = SH[1];
|
|
479
|
+
SEG[1] = SH[2] - h;
|
|
480
|
+
SEG[2] = SH[3];
|
|
481
|
+
SEG[3] = SH[1];
|
|
482
|
+
SEG[4] = SH[2] + h;
|
|
483
|
+
SEG[5] = SH[3];
|
|
484
|
+
// Not straight into `PT`: `closestSegTri` uses `PT` as scratch while it runs.
|
|
485
|
+
closestSegTri(capS, scratchP);
|
|
486
|
+
if (R[0] >= r * r)
|
|
487
|
+
return false;
|
|
488
|
+
PT[0] = capS[0];
|
|
489
|
+
PT[1] = capS[1];
|
|
490
|
+
PT[2] = capS[2];
|
|
491
|
+
R[2] = r;
|
|
492
|
+
return contactFromClosest(out);
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Capsule (y axis) against a triangle: the closest points between the inner segment and the
|
|
496
|
+
* triangle, then the sphere test there. True and `out` filled when they overlap.
|
|
497
|
+
*/
|
|
498
|
+
export function capsuleTriangle(cap, ax, ay, az, bx, by, bz, cx, cy, cz, out) {
|
|
499
|
+
loadTri(ax, ay, az, bx, by, bz, cx, cy, cz);
|
|
500
|
+
loadCapsule(cap);
|
|
501
|
+
return capsuleTri(out);
|
|
502
|
+
}
|
|
503
|
+
/** Separating-axis state: depth, normal x y z. */
|
|
504
|
+
const sat = new Float64Array(4);
|
|
505
|
+
/**
|
|
506
|
+
* Loads the box in `SH` for the separating-axis tests: half extents into `BX[0..2]`, the
|
|
507
|
+
* vertices of `TRI` relative to the box centre into `BX[3..11]`, the centre into `PT`.
|
|
508
|
+
*/
|
|
509
|
+
export function loadBox() {
|
|
510
|
+
const ccx = (SH[1] + SH[4]) * 0.5;
|
|
511
|
+
const ccy = (SH[2] + SH[5]) * 0.5;
|
|
512
|
+
const ccz = (SH[3] + SH[6]) * 0.5;
|
|
513
|
+
PT[0] = ccx;
|
|
514
|
+
PT[1] = ccy;
|
|
515
|
+
PT[2] = ccz;
|
|
516
|
+
BX[0] = (SH[4] - SH[1]) * 0.5;
|
|
517
|
+
BX[1] = (SH[5] - SH[2]) * 0.5;
|
|
518
|
+
BX[2] = (SH[6] - SH[3]) * 0.5;
|
|
519
|
+
for (let v = 0; v < 9; v += 3) {
|
|
520
|
+
BX[3 + v] = TRI[v] - ccx;
|
|
521
|
+
BX[4 + v] = TRI[v + 1] - ccy;
|
|
522
|
+
BX[5 + v] = TRI[v + 2] - ccz;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Sets `BX[12..14]` to axis `i` of the thirteen box–triangle separating axes: the box axes
|
|
527
|
+
* (0..2), the face normal (3), each edge crossed with each box axis (4..12).
|
|
528
|
+
*/
|
|
529
|
+
export function boxAxis(i) {
|
|
530
|
+
if (i < 3) {
|
|
531
|
+
BX[12] = i === 0 ? 1 : 0;
|
|
532
|
+
BX[13] = i === 1 ? 1 : 0;
|
|
533
|
+
BX[14] = i === 2 ? 1 : 0;
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
if (i === 3) {
|
|
537
|
+
const e0x = BX[6] - BX[3];
|
|
538
|
+
const e0y = BX[7] - BX[4];
|
|
539
|
+
const e0z = BX[8] - BX[5];
|
|
540
|
+
const e1x = BX[9] - BX[6];
|
|
541
|
+
const e1y = BX[10] - BX[7];
|
|
542
|
+
const e1z = BX[11] - BX[8];
|
|
543
|
+
BX[12] = e0y * e1z - e0z * e1y;
|
|
544
|
+
BX[13] = e0z * e1x - e0x * e1z;
|
|
545
|
+
BX[14] = e0x * e1y - e0y * e1x;
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
// Edge `e` (0: ab, 1: bc, 2: ca) crossed with box axis `k`.
|
|
549
|
+
const k = ((i - 4) / 3) | 0;
|
|
550
|
+
const e = (i - 4) % 3;
|
|
551
|
+
const o0 = 3 + e * 3;
|
|
552
|
+
const o1 = 3 + ((e + 1) % 3) * 3;
|
|
553
|
+
const ex = BX[o1] - BX[o0];
|
|
554
|
+
const ey = BX[o1 + 1] - BX[o0 + 1];
|
|
555
|
+
const ez = BX[o1 + 2] - BX[o0 + 2];
|
|
556
|
+
if (k === 0) {
|
|
557
|
+
BX[12] = 0;
|
|
558
|
+
BX[13] = -ez;
|
|
559
|
+
BX[14] = ey;
|
|
560
|
+
}
|
|
561
|
+
else if (k === 1) {
|
|
562
|
+
BX[12] = ez;
|
|
563
|
+
BX[13] = 0;
|
|
564
|
+
BX[14] = -ex;
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
BX[12] = -ey;
|
|
568
|
+
BX[13] = ex;
|
|
569
|
+
BX[14] = 0;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Tests the axis `BX[12..14]` for the loaded box against the loaded triangle. Returns false when
|
|
574
|
+
* the axis separates; otherwise records the axis with the smallest overlap, oriented from the
|
|
575
|
+
* triangle toward the box, in `sat`.
|
|
576
|
+
*/
|
|
577
|
+
function satAxis() {
|
|
578
|
+
const x = BX[12];
|
|
579
|
+
const y = BX[13];
|
|
580
|
+
const z = BX[14];
|
|
581
|
+
const len2 = x * x + y * y + z * z;
|
|
582
|
+
if (len2 < 1e-18)
|
|
583
|
+
return true;
|
|
584
|
+
const p0 = BX[3] * x + BX[4] * y + BX[5] * z;
|
|
585
|
+
const p1 = BX[6] * x + BX[7] * y + BX[8] * z;
|
|
586
|
+
const p2 = BX[9] * x + BX[10] * y + BX[11] * z;
|
|
587
|
+
const r = BX[0] * Math.abs(x) + BX[1] * Math.abs(y) + BX[2] * Math.abs(z);
|
|
588
|
+
const lo = Math.min(p0, Math.min(p1, p2));
|
|
589
|
+
const hi = Math.max(p0, Math.max(p1, p2));
|
|
590
|
+
if (lo >= r || hi <= -r)
|
|
591
|
+
return false;
|
|
592
|
+
// Overlap along this axis: the box spans [-r, r], the triangle [lo, hi].
|
|
593
|
+
const len = Math.sqrt(len2);
|
|
594
|
+
const pushPos = (hi + r) / len; // move the box toward +axis by this to separate
|
|
595
|
+
const pushNeg = (r - lo) / len; // move the box toward -axis by this to separate
|
|
596
|
+
if (pushPos < pushNeg) {
|
|
597
|
+
if (pushPos < sat[0]) {
|
|
598
|
+
sat[0] = pushPos;
|
|
599
|
+
sat[1] = x / len;
|
|
600
|
+
sat[2] = y / len;
|
|
601
|
+
sat[3] = z / len;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
else if (pushNeg < sat[0]) {
|
|
605
|
+
sat[0] = pushNeg;
|
|
606
|
+
sat[1] = -x / len;
|
|
607
|
+
sat[2] = -y / len;
|
|
608
|
+
sat[3] = -z / len;
|
|
609
|
+
}
|
|
610
|
+
return true;
|
|
611
|
+
}
|
|
612
|
+
/** The box in `SH` against `TRI` by the separating-axis test; see `aabbTriangle`. */
|
|
613
|
+
export function aabbTri(out) {
|
|
614
|
+
loadBox();
|
|
615
|
+
sat[0] = Number.POSITIVE_INFINITY;
|
|
616
|
+
for (let i = 0; i < 13; i++) {
|
|
617
|
+
boxAxis(i);
|
|
618
|
+
if (!satAxis())
|
|
619
|
+
return false;
|
|
620
|
+
}
|
|
621
|
+
if (!Number.isFinite(sat[0]))
|
|
622
|
+
return false;
|
|
623
|
+
out.depth = sat[0];
|
|
624
|
+
out.nx = sat[1];
|
|
625
|
+
out.ny = sat[2];
|
|
626
|
+
out.nz = sat[3];
|
|
627
|
+
closestPointTri(scratchP);
|
|
628
|
+
out.px = scratchP[0];
|
|
629
|
+
out.py = scratchP[1];
|
|
630
|
+
out.pz = scratchP[2];
|
|
631
|
+
out.triangle = -1;
|
|
632
|
+
out.source = -1;
|
|
633
|
+
return true;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Axis-aligned box against a triangle by the separating-axis test (Akenine-Möller: the three
|
|
637
|
+
* box axes, the face normal, the nine edge cross products). True and `out` filled when they
|
|
638
|
+
* overlap: the normal is the axis of least penetration pointing from the triangle into the box,
|
|
639
|
+
* `depth` the overlap along it, the point the triangle point closest to the box centre.
|
|
640
|
+
*/
|
|
641
|
+
export function aabbTriangle(box, ax, ay, az, bx, by, bz, cx, cy, cz, out) {
|
|
642
|
+
loadTri(ax, ay, az, bx, by, bz, cx, cy, cz);
|
|
643
|
+
loadAabb(box);
|
|
644
|
+
return aabbTri(out);
|
|
645
|
+
}
|
|
646
|
+
/** The world AABB of the shape in `SH` into `min` and `max`. */
|
|
647
|
+
export function shapeBoundsReg(min, max) {
|
|
648
|
+
if (SH[0] === SH_BOX) {
|
|
649
|
+
min[0] = SH[1];
|
|
650
|
+
min[1] = SH[2];
|
|
651
|
+
min[2] = SH[3];
|
|
652
|
+
max[0] = SH[4];
|
|
653
|
+
max[1] = SH[5];
|
|
654
|
+
max[2] = SH[6];
|
|
655
|
+
}
|
|
656
|
+
else {
|
|
657
|
+
const h = SH[4];
|
|
658
|
+
const r = SH[5];
|
|
659
|
+
min[0] = SH[1] - r;
|
|
660
|
+
min[1] = SH[2] - h - r;
|
|
661
|
+
min[2] = SH[3] - r;
|
|
662
|
+
max[0] = SH[1] + r;
|
|
663
|
+
max[1] = SH[2] + h + r;
|
|
664
|
+
max[2] = SH[3] + r;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
/** The world AABB of a shape into `min` and `max`. */
|
|
668
|
+
export function shapeBounds(s, min, max) {
|
|
669
|
+
loadShape(s);
|
|
670
|
+
shapeBoundsReg(min, max);
|
|
671
|
+
}
|
|
672
|
+
/** The shape in `SH` against `TRI`, dispatching on its kind. */
|
|
673
|
+
export function shapeTri(out) {
|
|
674
|
+
const kind = SH[0];
|
|
675
|
+
if (kind === SH_BOX)
|
|
676
|
+
return aabbTri(out);
|
|
677
|
+
if (kind === SH_CAPSULE)
|
|
678
|
+
return capsuleTri(out);
|
|
679
|
+
return sphereTri(out);
|
|
680
|
+
}
|
|
681
|
+
/** Shape against one triangle, dispatching on the shape kind. */
|
|
682
|
+
export function shapeTriangle(s, ax, ay, az, bx, by, bz, cx, cy, cz, out) {
|
|
683
|
+
loadTri(ax, ay, az, bx, by, bz, cx, cy, cz);
|
|
684
|
+
loadShape(s);
|
|
685
|
+
return shapeTri(out);
|
|
686
|
+
}
|