@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,127 @@
|
|
|
1
|
+
import type { Drawable, Frame } from '../render/frame.js';
|
|
2
|
+
import type { Renderer } from '../render/renderer.js';
|
|
3
|
+
import type { ReadonlyQuat, ReadonlyVec3, Transform } from '../render/transform.js';
|
|
4
|
+
/** `[r, g, b, a]` in linear 0..1 (alpha defaults to 1), or a packed `0xRRGGBBAA` (each 0..255). */
|
|
5
|
+
export type DebugColor = ArrayLike<number> | number;
|
|
6
|
+
/** A point or direction: `[x, y, z]`, a typed array, or an `{ x, y, z }` (a `Transform.position`). */
|
|
7
|
+
export type DebugVec3 = ArrayLike<number> | ReadonlyVec3;
|
|
8
|
+
/** A unit quaternion: `[x, y, z, w]` or `{ x, y, z, w }` (a `Transform.quaternion`). */
|
|
9
|
+
export type DebugQuat = ArrayLike<number> | ReadonlyQuat;
|
|
10
|
+
export interface DebugDrawOptions {
|
|
11
|
+
/** Segments the CPU array and GPU buffer hold before growing by 1.5×. Default 16384. */
|
|
12
|
+
capacity?: number;
|
|
13
|
+
/**
|
|
14
|
+
* `'test'` (default): lines hide behind geometry already drawn (depth tested, never written).
|
|
15
|
+
* `'always'`: no depth test at all, for overlays that must show through walls.
|
|
16
|
+
*/
|
|
17
|
+
depth?: 'test' | 'always';
|
|
18
|
+
/** Keep the segments after `draw` instead of clearing them (static scenes). Default false. */
|
|
19
|
+
retain?: boolean;
|
|
20
|
+
label?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Floats per line vertex: x, y, z, r, g, b, a. */
|
|
23
|
+
export declare const DEBUG_VERTEX_FLOATS = 7;
|
|
24
|
+
/**
|
|
25
|
+
* World-space line drawing without a mesh: wire boxes and spheres, axes, arrows, grids, paths,
|
|
26
|
+
* frustums. Every call appends segments to one CPU `Float32Array` (xyz + rgba per vertex);
|
|
27
|
+
* `draw` uploads the used range in one `writeBuffer` and issues one `'line-list'` draw, so a
|
|
28
|
+
* frame of debug lines costs one draw call however many shapes it holds. Lines are 1 px wide
|
|
29
|
+
* (WebGPU `line-list`), unlit, alpha blended, never written to depth.
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* const debug = createDebugDraw(renderer); // once
|
|
33
|
+
* debug.axes(transform, 1); // every frame, from any system
|
|
34
|
+
* debug.wireSphere(pos, radius, 0x00ff00ff);
|
|
35
|
+
* frame.drawable(debug); // draw(pass, frame) runs in the scene pass
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* Segments clear after `draw` (unless `retain`). The array and GPU buffer grow by 1.5× when
|
|
39
|
+
* full; after that nothing allocates per frame.
|
|
40
|
+
*/
|
|
41
|
+
export declare class DebugDraw implements Drawable {
|
|
42
|
+
private readonly device;
|
|
43
|
+
private readonly label;
|
|
44
|
+
private readonly depth;
|
|
45
|
+
private readonly retain;
|
|
46
|
+
private readonly renderer;
|
|
47
|
+
/**
|
|
48
|
+
* Pipelines per depth format (null: none) × the view target's aux key, built on first use
|
|
49
|
+
* from `renderer.sceneTargets` (ws/render-10).
|
|
50
|
+
*/
|
|
51
|
+
private readonly pipelines;
|
|
52
|
+
private readonly desc;
|
|
53
|
+
private verts;
|
|
54
|
+
private buffer;
|
|
55
|
+
private segments;
|
|
56
|
+
private cap;
|
|
57
|
+
private _uploads;
|
|
58
|
+
private cr;
|
|
59
|
+
private cg;
|
|
60
|
+
private cb;
|
|
61
|
+
private ca;
|
|
62
|
+
constructor(renderer: Renderer, opts?: DebugDrawOptions);
|
|
63
|
+
/** Segments appended since the last clear. */
|
|
64
|
+
get count(): number;
|
|
65
|
+
/** Segments the array holds before the next growth. */
|
|
66
|
+
get capacity(): number;
|
|
67
|
+
/** `writeBuffer` calls so far (one per `draw` with segments). */
|
|
68
|
+
get uploads(): number;
|
|
69
|
+
private color;
|
|
70
|
+
/** Make room for `n` more segments (grows the CPU array by 1.5×; the buffer follows at draw). */
|
|
71
|
+
private reserve;
|
|
72
|
+
/** Append one segment in the current colour. Callers `reserve` first. */
|
|
73
|
+
private seg;
|
|
74
|
+
/** One segment from `a` to `b`. */
|
|
75
|
+
line(a: DebugVec3, b: DebugVec3, color: DebugColor): void;
|
|
76
|
+
/** A segment of `length` from `origin` along `dir` (normalised here; a zero `dir` draws nothing). */
|
|
77
|
+
ray(origin: DebugVec3, dir: DebugVec3, length: number, color: DebugColor): void;
|
|
78
|
+
/**
|
|
79
|
+
* A segment from `a` to `b` with a four-line head at `b`. `headSize` is the head's length
|
|
80
|
+
* along the shaft (default 15% of the arrow, at most the whole shaft); five segments.
|
|
81
|
+
*/
|
|
82
|
+
arrow(a: DebugVec3, b: DebugVec3, color: DebugColor, headSize?: number): void;
|
|
83
|
+
/** The twelve edges of a box of `halfExtents` about `center`, optionally rotated by `rotation`. */
|
|
84
|
+
box(center: DebugVec3, halfExtents: DebugVec3, color: DebugColor, rotation?: DebugQuat): void;
|
|
85
|
+
/** The twelve edges of the cube whose corners sit in `corners` (bit 0 = +x, 1 = +y, 2 = +z). */
|
|
86
|
+
private edges;
|
|
87
|
+
/**
|
|
88
|
+
* Three great circles (XY, XZ and YZ planes) of `radius` about `center`, each of `2 × rings`
|
|
89
|
+
* segments (`rings` at least 3): `6 × rings` segments.
|
|
90
|
+
*/
|
|
91
|
+
wireSphere(center: DebugVec3, radius: number, color: DebugColor, rings?: number): void;
|
|
92
|
+
/**
|
|
93
|
+
* The frame of a `Transform` (its world matrix) or of a 3×4 row-major matrix: x red, y green,
|
|
94
|
+
* z blue, each axis normalised to `size`. Three segments.
|
|
95
|
+
*/
|
|
96
|
+
axes(transform: Transform | ArrayLike<number>, size: number): void;
|
|
97
|
+
/**
|
|
98
|
+
* A square grid in the XZ plane (y = `center.y`) of `size` on a side about `center`, a line
|
|
99
|
+
* every `step` along both axes: `2 × (floor(size / step) + 1)` segments.
|
|
100
|
+
*/
|
|
101
|
+
grid(center: DebugVec3, size: number, step: number, color: DebugColor): void;
|
|
102
|
+
/** A circle of `radius` about `center` in the plane perpendicular to `normal`. */
|
|
103
|
+
circle(center: DebugVec3, normal: DebugVec3, radius: number, color: DebugColor, segments?: number): void;
|
|
104
|
+
/**
|
|
105
|
+
* A polyline through `count` points read from `points` (`stride` floats apart, from float
|
|
106
|
+
* `offset`; default every point in the array): `count - 1` segments.
|
|
107
|
+
*/
|
|
108
|
+
path(points: Float32Array | ArrayLike<number>, color: DebugColor, stride?: number, offset?: number, count?: number): void;
|
|
109
|
+
/**
|
|
110
|
+
* The twelve edges of the view volume of a camera, from the inverse of its view-projection
|
|
111
|
+
* (column-major 4×4, as `Camera.viewProjection` is stored): the clip-space cube x, y in
|
|
112
|
+
* -1..1 and z in 0..1 (WebGPU depth) unprojected and divided by w.
|
|
113
|
+
*/
|
|
114
|
+
frustum(invViewProj: ArrayLike<number>, color: DebugColor): void;
|
|
115
|
+
/** Drop every segment (implicit after `draw` unless `retain`). */
|
|
116
|
+
clear(): void;
|
|
117
|
+
/**
|
|
118
|
+
* Upload the used range and draw it as one `'line-list'` inside the scene pass, with the
|
|
119
|
+
* pipeline for `frame.depthFormat` (built on first use). Nothing is recorded when empty.
|
|
120
|
+
*/
|
|
121
|
+
draw(pass: GPURenderPassEncoder, frame: Frame): void;
|
|
122
|
+
private pipeline;
|
|
123
|
+
/** Free the GPU buffer. The object draws nothing afterwards until segments are appended. */
|
|
124
|
+
destroy(): void;
|
|
125
|
+
}
|
|
126
|
+
/** Make a `DebugDraw` for `renderer`; see the class. */
|
|
127
|
+
export declare function createDebugDraw(renderer: Renderer, opts?: DebugDrawOptions): DebugDraw;
|
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
import { auxSuffix, ScenePipelineCache, sceneVariant } from '../render/scene-pipelines.js';
|
|
2
|
+
import { createShaderModule } from '../render/wgsl.js';
|
|
3
|
+
import { DEBUG_DRAW_WGSL } from './debug-wgsl.js';
|
|
4
|
+
/** Floats per line vertex: x, y, z, r, g, b, a. */
|
|
5
|
+
export const DEBUG_VERTEX_FLOATS = 7;
|
|
6
|
+
/** Floats per segment (two vertices). */
|
|
7
|
+
const SF = DEBUG_VERTEX_FLOATS * 2;
|
|
8
|
+
const STRIDE = DEBUG_VERTEX_FLOATS * 4;
|
|
9
|
+
const DEFAULT_CAPACITY = 16384;
|
|
10
|
+
const GROWTH = 1.5;
|
|
11
|
+
const ALPHA_BLEND = {
|
|
12
|
+
color: { srcFactor: 'src-alpha', dstFactor: 'one-minus-src-alpha', operation: 'add' },
|
|
13
|
+
alpha: { srcFactor: 'one', dstFactor: 'one-minus-src-alpha', operation: 'add' },
|
|
14
|
+
};
|
|
15
|
+
// Scratch vectors shared by the shape writers (never handed out).
|
|
16
|
+
const p1 = new Float32Array(3);
|
|
17
|
+
const p2 = new Float32Array(3);
|
|
18
|
+
const ax = new Float32Array(3);
|
|
19
|
+
const ay = new Float32Array(3);
|
|
20
|
+
const az = new Float32Array(3);
|
|
21
|
+
const corners = new Float32Array(24);
|
|
22
|
+
function vx(v) {
|
|
23
|
+
return typeof v.x === 'number'
|
|
24
|
+
? v.x
|
|
25
|
+
: v[0];
|
|
26
|
+
}
|
|
27
|
+
function vy(v) {
|
|
28
|
+
return typeof v.y === 'number'
|
|
29
|
+
? v.y
|
|
30
|
+
: v[1];
|
|
31
|
+
}
|
|
32
|
+
function vz(v) {
|
|
33
|
+
return typeof v.z === 'number'
|
|
34
|
+
? v.z
|
|
35
|
+
: v[2];
|
|
36
|
+
}
|
|
37
|
+
function qw(q) {
|
|
38
|
+
return typeof q.w === 'number'
|
|
39
|
+
? q.w
|
|
40
|
+
: q[3];
|
|
41
|
+
}
|
|
42
|
+
/** `out` = unit vectors `a`, `b` perpendicular to `d` (any length). Degenerate `d` gives x, y. */
|
|
43
|
+
function basis(dx, dy, dz, a, b) {
|
|
44
|
+
const l = Math.hypot(dx, dy, dz);
|
|
45
|
+
if (l < 1e-12) {
|
|
46
|
+
a[0] = 1;
|
|
47
|
+
a[1] = 0;
|
|
48
|
+
a[2] = 0;
|
|
49
|
+
b[0] = 0;
|
|
50
|
+
b[1] = 1;
|
|
51
|
+
b[2] = 0;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const nx = dx / l;
|
|
55
|
+
const ny = dy / l;
|
|
56
|
+
const nz = dz / l;
|
|
57
|
+
// Cross with the axis least aligned to d.
|
|
58
|
+
if (Math.abs(ny) < 0.9) {
|
|
59
|
+
a[0] = -nz;
|
|
60
|
+
a[1] = 0;
|
|
61
|
+
a[2] = nx;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
a[0] = 0;
|
|
65
|
+
a[1] = nz;
|
|
66
|
+
a[2] = -ny;
|
|
67
|
+
}
|
|
68
|
+
const al = Math.hypot(a[0], a[1], a[2]);
|
|
69
|
+
a[0] /= al;
|
|
70
|
+
a[1] /= al;
|
|
71
|
+
a[2] /= al;
|
|
72
|
+
b[0] = ny * a[2] - nz * a[1];
|
|
73
|
+
b[1] = nz * a[0] - nx * a[2];
|
|
74
|
+
b[2] = nx * a[1] - ny * a[0];
|
|
75
|
+
}
|
|
76
|
+
/** Rotate `(x, y, z)` by the unit quaternion `q` into `out`. */
|
|
77
|
+
function rotate(q, x, y, z, out) {
|
|
78
|
+
const qx = vx(q);
|
|
79
|
+
const qy = vy(q);
|
|
80
|
+
const qz = vz(q);
|
|
81
|
+
const w = qw(q);
|
|
82
|
+
// t = 2 (q.xyz × v)
|
|
83
|
+
const tx = 2 * (qy * z - qz * y);
|
|
84
|
+
const ty = 2 * (qz * x - qx * z);
|
|
85
|
+
const tz = 2 * (qx * y - qy * x);
|
|
86
|
+
out[0] = x + w * tx + (qy * tz - qz * ty);
|
|
87
|
+
out[1] = y + w * ty + (qz * tx - qx * tz);
|
|
88
|
+
out[2] = z + w * tz + (qx * ty - qy * tx);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* World-space line drawing without a mesh: wire boxes and spheres, axes, arrows, grids, paths,
|
|
92
|
+
* frustums. Every call appends segments to one CPU `Float32Array` (xyz + rgba per vertex);
|
|
93
|
+
* `draw` uploads the used range in one `writeBuffer` and issues one `'line-list'` draw, so a
|
|
94
|
+
* frame of debug lines costs one draw call however many shapes it holds. Lines are 1 px wide
|
|
95
|
+
* (WebGPU `line-list`), unlit, alpha blended, never written to depth.
|
|
96
|
+
*
|
|
97
|
+
* ```ts
|
|
98
|
+
* const debug = createDebugDraw(renderer); // once
|
|
99
|
+
* debug.axes(transform, 1); // every frame, from any system
|
|
100
|
+
* debug.wireSphere(pos, radius, 0x00ff00ff);
|
|
101
|
+
* frame.drawable(debug); // draw(pass, frame) runs in the scene pass
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* Segments clear after `draw` (unless `retain`). The array and GPU buffer grow by 1.5× when
|
|
105
|
+
* full; after that nothing allocates per frame.
|
|
106
|
+
*/
|
|
107
|
+
export class DebugDraw {
|
|
108
|
+
device;
|
|
109
|
+
label;
|
|
110
|
+
depth;
|
|
111
|
+
retain;
|
|
112
|
+
renderer;
|
|
113
|
+
/**
|
|
114
|
+
* Pipelines per depth format (null: none) × the view target's aux key, built on first use
|
|
115
|
+
* from `renderer.sceneTargets` (ws/render-10).
|
|
116
|
+
*/
|
|
117
|
+
pipelines = new ScenePipelineCache();
|
|
118
|
+
desc;
|
|
119
|
+
verts;
|
|
120
|
+
buffer = null;
|
|
121
|
+
segments = 0;
|
|
122
|
+
cap;
|
|
123
|
+
_uploads = 0;
|
|
124
|
+
// The current colour, set once per shape call.
|
|
125
|
+
cr = 1;
|
|
126
|
+
cg = 1;
|
|
127
|
+
cb = 1;
|
|
128
|
+
ca = 1;
|
|
129
|
+
constructor(renderer, opts = {}) {
|
|
130
|
+
this.device = renderer.device;
|
|
131
|
+
this.renderer = renderer;
|
|
132
|
+
this.label = opts.label ?? 'debug-draw';
|
|
133
|
+
this.depth = opts.depth ?? 'test';
|
|
134
|
+
this.retain = opts.retain ?? false;
|
|
135
|
+
this.cap = Math.max(1, Math.floor(opts.capacity ?? DEFAULT_CAPACITY));
|
|
136
|
+
this.verts = new Float32Array(this.cap * SF);
|
|
137
|
+
const module = createShaderModule(this.device, DEBUG_DRAW_WGSL, this.label);
|
|
138
|
+
this.desc = {
|
|
139
|
+
label: this.label,
|
|
140
|
+
layout: this.device.createPipelineLayout({ bindGroupLayouts: [renderer.globalsLayout] }),
|
|
141
|
+
vertex: {
|
|
142
|
+
module,
|
|
143
|
+
entryPoint: 'vs',
|
|
144
|
+
buffers: [
|
|
145
|
+
{
|
|
146
|
+
arrayStride: STRIDE,
|
|
147
|
+
attributes: [
|
|
148
|
+
{ shaderLocation: 0, offset: 0, format: 'float32x3' },
|
|
149
|
+
{ shaderLocation: 1, offset: 12, format: 'float32x4' },
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
fragment: {
|
|
155
|
+
module,
|
|
156
|
+
entryPoint: 'fs',
|
|
157
|
+
targets: renderer.sceneTargets(ALPHA_BLEND),
|
|
158
|
+
},
|
|
159
|
+
primitive: { topology: 'line-list' },
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/** Segments appended since the last clear. */
|
|
163
|
+
get count() {
|
|
164
|
+
return this.segments;
|
|
165
|
+
}
|
|
166
|
+
/** Segments the array holds before the next growth. */
|
|
167
|
+
get capacity() {
|
|
168
|
+
return this.cap;
|
|
169
|
+
}
|
|
170
|
+
/** `writeBuffer` calls so far (one per `draw` with segments). */
|
|
171
|
+
get uploads() {
|
|
172
|
+
return this._uploads;
|
|
173
|
+
}
|
|
174
|
+
// ------------------------------------------------------------------ primitives
|
|
175
|
+
color(c) {
|
|
176
|
+
if (typeof c === 'number') {
|
|
177
|
+
const u = c >>> 0;
|
|
178
|
+
this.cr = ((u >>> 24) & 255) / 255;
|
|
179
|
+
this.cg = ((u >>> 16) & 255) / 255;
|
|
180
|
+
this.cb = ((u >>> 8) & 255) / 255;
|
|
181
|
+
this.ca = (u & 255) / 255;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
this.cr = c[0];
|
|
185
|
+
this.cg = c[1];
|
|
186
|
+
this.cb = c[2];
|
|
187
|
+
this.ca = c.length > 3 ? c[3] : 1;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/** Make room for `n` more segments (grows the CPU array by 1.5×; the buffer follows at draw). */
|
|
191
|
+
reserve(n) {
|
|
192
|
+
const need = this.segments + n;
|
|
193
|
+
if (need <= this.cap)
|
|
194
|
+
return;
|
|
195
|
+
let cap = this.cap;
|
|
196
|
+
while (cap < need)
|
|
197
|
+
cap = Math.ceil(cap * GROWTH);
|
|
198
|
+
const next = new Float32Array(cap * SF);
|
|
199
|
+
next.set(this.verts.subarray(0, this.segments * SF));
|
|
200
|
+
this.verts = next;
|
|
201
|
+
this.cap = cap;
|
|
202
|
+
}
|
|
203
|
+
/** Append one segment in the current colour. Callers `reserve` first. */
|
|
204
|
+
seg(ax, ay, az, bx, by, bz) {
|
|
205
|
+
const v = this.verts;
|
|
206
|
+
let o = this.segments * SF;
|
|
207
|
+
v[o++] = ax;
|
|
208
|
+
v[o++] = ay;
|
|
209
|
+
v[o++] = az;
|
|
210
|
+
v[o++] = this.cr;
|
|
211
|
+
v[o++] = this.cg;
|
|
212
|
+
v[o++] = this.cb;
|
|
213
|
+
v[o++] = this.ca;
|
|
214
|
+
v[o++] = bx;
|
|
215
|
+
v[o++] = by;
|
|
216
|
+
v[o++] = bz;
|
|
217
|
+
v[o++] = this.cr;
|
|
218
|
+
v[o++] = this.cg;
|
|
219
|
+
v[o++] = this.cb;
|
|
220
|
+
v[o] = this.ca;
|
|
221
|
+
this.segments++;
|
|
222
|
+
}
|
|
223
|
+
// ------------------------------------------------------------------ shapes
|
|
224
|
+
/** One segment from `a` to `b`. */
|
|
225
|
+
line(a, b, color) {
|
|
226
|
+
this.color(color);
|
|
227
|
+
this.reserve(1);
|
|
228
|
+
this.seg(vx(a), vy(a), vz(a), vx(b), vy(b), vz(b));
|
|
229
|
+
}
|
|
230
|
+
/** A segment of `length` from `origin` along `dir` (normalised here; a zero `dir` draws nothing). */
|
|
231
|
+
ray(origin, dir, length, color) {
|
|
232
|
+
const dx = vx(dir);
|
|
233
|
+
const dy = vy(dir);
|
|
234
|
+
const dz = vz(dir);
|
|
235
|
+
const l = Math.hypot(dx, dy, dz);
|
|
236
|
+
if (l < 1e-12)
|
|
237
|
+
return;
|
|
238
|
+
const s = length / l;
|
|
239
|
+
const ox = vx(origin);
|
|
240
|
+
const oy = vy(origin);
|
|
241
|
+
const oz = vz(origin);
|
|
242
|
+
this.color(color);
|
|
243
|
+
this.reserve(1);
|
|
244
|
+
this.seg(ox, oy, oz, ox + dx * s, oy + dy * s, oz + dz * s);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* A segment from `a` to `b` with a four-line head at `b`. `headSize` is the head's length
|
|
248
|
+
* along the shaft (default 15% of the arrow, at most the whole shaft); five segments.
|
|
249
|
+
*/
|
|
250
|
+
arrow(a, b, color, headSize) {
|
|
251
|
+
const ax0 = vx(a);
|
|
252
|
+
const ay0 = vy(a);
|
|
253
|
+
const az0 = vz(a);
|
|
254
|
+
const bx = vx(b);
|
|
255
|
+
const by = vy(b);
|
|
256
|
+
const bz = vz(b);
|
|
257
|
+
const dx = bx - ax0;
|
|
258
|
+
const dy = by - ay0;
|
|
259
|
+
const dz = bz - az0;
|
|
260
|
+
const l = Math.hypot(dx, dy, dz);
|
|
261
|
+
this.color(color);
|
|
262
|
+
if (l < 1e-12) {
|
|
263
|
+
this.reserve(1);
|
|
264
|
+
this.seg(ax0, ay0, az0, bx, by, bz);
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
const h = Math.min(headSize ?? l * 0.15, l);
|
|
268
|
+
const hw = h * 0.5;
|
|
269
|
+
basis(dx, dy, dz, p1, p2);
|
|
270
|
+
// The head's base point on the shaft.
|
|
271
|
+
const cx = bx - (dx / l) * h;
|
|
272
|
+
const cy = by - (dy / l) * h;
|
|
273
|
+
const cz = bz - (dz / l) * h;
|
|
274
|
+
this.reserve(5);
|
|
275
|
+
this.seg(ax0, ay0, az0, bx, by, bz);
|
|
276
|
+
this.seg(bx, by, bz, cx + p1[0] * hw, cy + p1[1] * hw, cz + p1[2] * hw);
|
|
277
|
+
this.seg(bx, by, bz, cx - p1[0] * hw, cy - p1[1] * hw, cz - p1[2] * hw);
|
|
278
|
+
this.seg(bx, by, bz, cx + p2[0] * hw, cy + p2[1] * hw, cz + p2[2] * hw);
|
|
279
|
+
this.seg(bx, by, bz, cx - p2[0] * hw, cy - p2[1] * hw, cz - p2[2] * hw);
|
|
280
|
+
}
|
|
281
|
+
/** The twelve edges of a box of `halfExtents` about `center`, optionally rotated by `rotation`. */
|
|
282
|
+
box(center, halfExtents, color, rotation) {
|
|
283
|
+
const hx = vx(halfExtents);
|
|
284
|
+
const hy = vy(halfExtents);
|
|
285
|
+
const hz = vz(halfExtents);
|
|
286
|
+
if (rotation) {
|
|
287
|
+
rotate(rotation, hx, 0, 0, ax);
|
|
288
|
+
rotate(rotation, 0, hy, 0, ay);
|
|
289
|
+
rotate(rotation, 0, 0, hz, az);
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
ax[0] = hx;
|
|
293
|
+
ax[1] = 0;
|
|
294
|
+
ax[2] = 0;
|
|
295
|
+
ay[0] = 0;
|
|
296
|
+
ay[1] = hy;
|
|
297
|
+
ay[2] = 0;
|
|
298
|
+
az[0] = 0;
|
|
299
|
+
az[1] = 0;
|
|
300
|
+
az[2] = hz;
|
|
301
|
+
}
|
|
302
|
+
const cx = vx(center);
|
|
303
|
+
const cy = vy(center);
|
|
304
|
+
const cz = vz(center);
|
|
305
|
+
// Corner i: bit 0 = +x, bit 1 = +y, bit 2 = +z.
|
|
306
|
+
for (let i = 0; i < 8; i++) {
|
|
307
|
+
const sx = i & 1 ? 1 : -1;
|
|
308
|
+
const sy = i & 2 ? 1 : -1;
|
|
309
|
+
const sz = i & 4 ? 1 : -1;
|
|
310
|
+
corners[i * 3] = cx + sx * ax[0] + sy * ay[0] + sz * az[0];
|
|
311
|
+
corners[i * 3 + 1] = cy + sx * ax[1] + sy * ay[1] + sz * az[1];
|
|
312
|
+
corners[i * 3 + 2] = cz + sx * ax[2] + sy * ay[2] + sz * az[2];
|
|
313
|
+
}
|
|
314
|
+
this.color(color);
|
|
315
|
+
this.reserve(12);
|
|
316
|
+
this.edges();
|
|
317
|
+
}
|
|
318
|
+
/** The twelve edges of the cube whose corners sit in `corners` (bit 0 = +x, 1 = +y, 2 = +z). */
|
|
319
|
+
edges() {
|
|
320
|
+
for (let i = 0; i < 8; i++) {
|
|
321
|
+
for (let bit = 1; bit < 8; bit <<= 1) {
|
|
322
|
+
if (i & bit)
|
|
323
|
+
continue;
|
|
324
|
+
const j = i | bit;
|
|
325
|
+
this.seg(corners[i * 3], corners[i * 3 + 1], corners[i * 3 + 2], corners[j * 3], corners[j * 3 + 1], corners[j * 3 + 2]);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Three great circles (XY, XZ and YZ planes) of `radius` about `center`, each of `2 × rings`
|
|
331
|
+
* segments (`rings` at least 3): `6 × rings` segments.
|
|
332
|
+
*/
|
|
333
|
+
wireSphere(center, radius, color, rings = 12) {
|
|
334
|
+
const n = Math.max(3, Math.floor(rings)) * 2;
|
|
335
|
+
const cx = vx(center);
|
|
336
|
+
const cy = vy(center);
|
|
337
|
+
const cz = vz(center);
|
|
338
|
+
this.color(color);
|
|
339
|
+
this.reserve(n * 3);
|
|
340
|
+
const step = (Math.PI * 2) / n;
|
|
341
|
+
for (let i = 0; i < n; i++) {
|
|
342
|
+
const a0 = i * step;
|
|
343
|
+
const a1 = (i + 1) * step;
|
|
344
|
+
const c0 = Math.cos(a0) * radius;
|
|
345
|
+
const s0 = Math.sin(a0) * radius;
|
|
346
|
+
const c1 = Math.cos(a1) * radius;
|
|
347
|
+
const s1 = Math.sin(a1) * radius;
|
|
348
|
+
this.seg(cx + c0, cy + s0, cz, cx + c1, cy + s1, cz);
|
|
349
|
+
this.seg(cx + c0, cy, cz + s0, cx + c1, cy, cz + s1);
|
|
350
|
+
this.seg(cx, cy + c0, cz + s0, cx, cy + c1, cz + s1);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* The frame of a `Transform` (its world matrix) or of a 3×4 row-major matrix: x red, y green,
|
|
355
|
+
* z blue, each axis normalised to `size`. Three segments.
|
|
356
|
+
*/
|
|
357
|
+
axes(transform, size) {
|
|
358
|
+
const m = 'world' in transform
|
|
359
|
+
? transform.world
|
|
360
|
+
: transform;
|
|
361
|
+
const ox = m[3];
|
|
362
|
+
const oy = m[7];
|
|
363
|
+
const oz = m[11];
|
|
364
|
+
this.reserve(3);
|
|
365
|
+
for (let c = 0; c < 3; c++) {
|
|
366
|
+
const x = m[c];
|
|
367
|
+
const y = m[4 + c];
|
|
368
|
+
const z = m[8 + c];
|
|
369
|
+
const l = Math.hypot(x, y, z);
|
|
370
|
+
const s = l > 1e-12 ? size / l : 0;
|
|
371
|
+
this.cr = c === 0 ? 1 : 0;
|
|
372
|
+
this.cg = c === 1 ? 1 : 0;
|
|
373
|
+
this.cb = c === 2 ? 1 : 0;
|
|
374
|
+
this.ca = 1;
|
|
375
|
+
this.seg(ox, oy, oz, ox + x * s, oy + y * s, oz + z * s);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* A square grid in the XZ plane (y = `center.y`) of `size` on a side about `center`, a line
|
|
380
|
+
* every `step` along both axes: `2 × (floor(size / step) + 1)` segments.
|
|
381
|
+
*/
|
|
382
|
+
grid(center, size, step, color) {
|
|
383
|
+
if (!(step > 0) || !(size >= 0))
|
|
384
|
+
return;
|
|
385
|
+
const n = Math.floor(size / step + 1e-9);
|
|
386
|
+
const half = (n * step) / 2;
|
|
387
|
+
const cx = vx(center);
|
|
388
|
+
const cy = vy(center);
|
|
389
|
+
const cz = vz(center);
|
|
390
|
+
this.color(color);
|
|
391
|
+
this.reserve((n + 1) * 2);
|
|
392
|
+
for (let i = 0; i <= n; i++) {
|
|
393
|
+
const t = -half + i * step;
|
|
394
|
+
this.seg(cx - half, cy, cz + t, cx + half, cy, cz + t);
|
|
395
|
+
this.seg(cx + t, cy, cz - half, cx + t, cy, cz + half);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
/** A circle of `radius` about `center` in the plane perpendicular to `normal`. */
|
|
399
|
+
circle(center, normal, radius, color, segments = 32) {
|
|
400
|
+
const n = Math.max(3, Math.floor(segments));
|
|
401
|
+
basis(vx(normal), vy(normal), vz(normal), p1, p2);
|
|
402
|
+
const cx = vx(center);
|
|
403
|
+
const cy = vy(center);
|
|
404
|
+
const cz = vz(center);
|
|
405
|
+
this.color(color);
|
|
406
|
+
this.reserve(n);
|
|
407
|
+
const step = (Math.PI * 2) / n;
|
|
408
|
+
let px = cx + p1[0] * radius;
|
|
409
|
+
let py = cy + p1[1] * radius;
|
|
410
|
+
let pz = cz + p1[2] * radius;
|
|
411
|
+
for (let i = 1; i <= n; i++) {
|
|
412
|
+
const c = Math.cos(i * step) * radius;
|
|
413
|
+
const s = Math.sin(i * step) * radius;
|
|
414
|
+
const x = cx + p1[0] * c + p2[0] * s;
|
|
415
|
+
const y = cy + p1[1] * c + p2[1] * s;
|
|
416
|
+
const z = cz + p1[2] * c + p2[2] * s;
|
|
417
|
+
this.seg(px, py, pz, x, y, z);
|
|
418
|
+
px = x;
|
|
419
|
+
py = y;
|
|
420
|
+
pz = z;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* A polyline through `count` points read from `points` (`stride` floats apart, from float
|
|
425
|
+
* `offset`; default every point in the array): `count - 1` segments.
|
|
426
|
+
*/
|
|
427
|
+
path(points, color, stride = 3, offset = 0, count) {
|
|
428
|
+
const n = count ?? Math.floor((points.length - offset) / stride);
|
|
429
|
+
if (n < 2)
|
|
430
|
+
return;
|
|
431
|
+
this.color(color);
|
|
432
|
+
this.reserve(n - 1);
|
|
433
|
+
let o = offset;
|
|
434
|
+
let px = points[o];
|
|
435
|
+
let py = points[o + 1];
|
|
436
|
+
let pz = points[o + 2];
|
|
437
|
+
for (let i = 1; i < n; i++) {
|
|
438
|
+
o += stride;
|
|
439
|
+
const x = points[o];
|
|
440
|
+
const y = points[o + 1];
|
|
441
|
+
const z = points[o + 2];
|
|
442
|
+
this.seg(px, py, pz, x, y, z);
|
|
443
|
+
px = x;
|
|
444
|
+
py = y;
|
|
445
|
+
pz = z;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* The twelve edges of the view volume of a camera, from the inverse of its view-projection
|
|
450
|
+
* (column-major 4×4, as `Camera.viewProjection` is stored): the clip-space cube x, y in
|
|
451
|
+
* -1..1 and z in 0..1 (WebGPU depth) unprojected and divided by w.
|
|
452
|
+
*/
|
|
453
|
+
frustum(invViewProj, color) {
|
|
454
|
+
const m = invViewProj;
|
|
455
|
+
for (let i = 0; i < 8; i++) {
|
|
456
|
+
const x = i & 1 ? 1 : -1;
|
|
457
|
+
const y = i & 2 ? 1 : -1;
|
|
458
|
+
const z = i & 4 ? 1 : 0;
|
|
459
|
+
const w = m[3] * x + m[7] * y + m[11] * z + m[15];
|
|
460
|
+
const iw = Math.abs(w) > 1e-12 ? 1 / w : 0;
|
|
461
|
+
corners[i * 3] = (m[0] * x + m[4] * y + m[8] * z + m[12]) * iw;
|
|
462
|
+
corners[i * 3 + 1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) * iw;
|
|
463
|
+
corners[i * 3 + 2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) * iw;
|
|
464
|
+
}
|
|
465
|
+
this.color(color);
|
|
466
|
+
this.reserve(12);
|
|
467
|
+
this.edges();
|
|
468
|
+
}
|
|
469
|
+
// ------------------------------------------------------------------ draw
|
|
470
|
+
/** Drop every segment (implicit after `draw` unless `retain`). */
|
|
471
|
+
clear() {
|
|
472
|
+
this.segments = 0;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Upload the used range and draw it as one `'line-list'` inside the scene pass, with the
|
|
476
|
+
* pipeline for `frame.depthFormat` (built on first use). Nothing is recorded when empty.
|
|
477
|
+
*/
|
|
478
|
+
draw(pass, frame) {
|
|
479
|
+
const n = this.segments;
|
|
480
|
+
if (n > 0) {
|
|
481
|
+
const bytes = this.cap * SF * 4;
|
|
482
|
+
let buffer = this.buffer;
|
|
483
|
+
if (!buffer || buffer.size < bytes) {
|
|
484
|
+
buffer?.destroy();
|
|
485
|
+
buffer = this.device.createBuffer({
|
|
486
|
+
label: this.label,
|
|
487
|
+
size: bytes,
|
|
488
|
+
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
489
|
+
});
|
|
490
|
+
this.buffer = buffer;
|
|
491
|
+
}
|
|
492
|
+
this.device.queue.writeBuffer(buffer, 0, this.verts, 0, n * SF);
|
|
493
|
+
this._uploads++;
|
|
494
|
+
pass.setPipeline(this.pipeline(frame.depthFormat, frame.auxKey));
|
|
495
|
+
pass.setVertexBuffer(0, buffer, 0, n * SF * 4);
|
|
496
|
+
pass.draw(n * 2);
|
|
497
|
+
}
|
|
498
|
+
if (!this.retain)
|
|
499
|
+
this.segments = 0;
|
|
500
|
+
}
|
|
501
|
+
pipeline(format, aux) {
|
|
502
|
+
const p = this.pipelines.get(format, aux);
|
|
503
|
+
if (p)
|
|
504
|
+
return p;
|
|
505
|
+
return this.pipelines.set(format, aux, this.device.createRenderPipeline(sceneVariant(this.desc, this.renderer.sceneTargets(ALPHA_BLEND, aux), `${this.label}${format ? `:${format}:${this.depth}` : ''}${auxSuffix(aux)}`, format
|
|
506
|
+
? {
|
|
507
|
+
format,
|
|
508
|
+
depthWriteEnabled: false,
|
|
509
|
+
depthCompare: this.depth === 'always' ? 'always' : 'less-equal',
|
|
510
|
+
}
|
|
511
|
+
: undefined)));
|
|
512
|
+
}
|
|
513
|
+
/** Free the GPU buffer. The object draws nothing afterwards until segments are appended. */
|
|
514
|
+
destroy() {
|
|
515
|
+
this.buffer?.destroy();
|
|
516
|
+
this.buffer = null;
|
|
517
|
+
this.segments = 0;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
/** Make a `DebugDraw` for `renderer`; see the class. */
|
|
521
|
+
export function createDebugDraw(renderer, opts = {}) {
|
|
522
|
+
return new DebugDraw(renderer, opts);
|
|
523
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The debug line shader: a vertex is a world position and an RGBA colour (7 floats); the
|
|
3
|
+
* vertex stage projects through the engine camera (`@group(0)`), the fragment writes the colour
|
|
4
|
+
* to the scene's colour target and nothing (alpha 0) to the emissive one. No lighting, no
|
|
5
|
+
* texture. The pipeline draws a `'line-list'`, so a segment is two of these vertices.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEBUG_DRAW_WGSL = "\n\nstruct EngineGlobals {\n logicalSize: vec2f,\n targetSize: vec2f,\n time: f32,\n dt: f32,\n _pad: vec2f,\n};\n@group(0) @binding(0) var<uniform> globals: EngineGlobals;\nstruct EngineCamera {\n view: mat4x4f,\n proj: mat4x4f,\n view_proj: mat4x4f,\n camera_pos: vec4f,\n viewport: vec4f,\n view_index: u32,\n _pad0: u32, _pad1: u32, _pad2: u32,\n inv_view_proj: mat4x4f,\n prev_view_proj: mat4x4f,\n prev_view: mat4x4f,\n jitter: vec4f,\n};\n@group(0) @binding(1) var<uniform> camera: EngineCamera;\n\nstruct VSOut {\n @builtin(position) clip: vec4f,\n @location(0) color: vec4f,\n};\nstruct FragOut {\n @location(0) color: vec4f,\n @location(1) emissive: vec4f,\n};\n\n@vertex fn vs(@location(0) position: vec3f, @location(1) color: vec4f) -> VSOut {\n var o: VSOut;\n o.clip = camera.view_proj * vec4f(position, 1.0);\n o.color = color;\n return o;\n}\n\n@fragment fn fs(in: VSOut) -> FragOut {\n var o: FragOut;\n o.color = in.color;\n o.emissive = vec4f(0.0);\n return o;\n}\n";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { WGSL_GLOBALS } from '../render/wgsl.js';
|
|
2
|
+
/**
|
|
3
|
+
* The debug line shader: a vertex is a world position and an RGBA colour (7 floats); the
|
|
4
|
+
* vertex stage projects through the engine camera (`@group(0)`), the fragment writes the colour
|
|
5
|
+
* to the scene's colour target and nothing (alpha 0) to the emissive one. No lighting, no
|
|
6
|
+
* texture. The pipeline draws a `'line-list'`, so a segment is two of these vertices.
|
|
7
|
+
*/
|
|
8
|
+
export const DEBUG_DRAW_WGSL = /* wgsl */ `
|
|
9
|
+
${WGSL_GLOBALS}
|
|
10
|
+
struct VSOut {
|
|
11
|
+
@builtin(position) clip: vec4f,
|
|
12
|
+
@location(0) color: vec4f,
|
|
13
|
+
};
|
|
14
|
+
struct FragOut {
|
|
15
|
+
@location(0) color: vec4f,
|
|
16
|
+
@location(1) emissive: vec4f,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
@vertex fn vs(@location(0) position: vec3f, @location(1) color: vec4f) -> VSOut {
|
|
20
|
+
var o: VSOut;
|
|
21
|
+
o.clip = camera.view_proj * vec4f(position, 1.0);
|
|
22
|
+
o.color = color;
|
|
23
|
+
return o;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@fragment fn fs(in: VSOut) -> FragOut {
|
|
27
|
+
var o: FragOut;
|
|
28
|
+
o.color = in.color;
|
|
29
|
+
o.emissive = vec4f(0.0);
|
|
30
|
+
return o;
|
|
31
|
+
}
|
|
32
|
+
`;
|