@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,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The lighting block: what every material can read at `@group(0) @binding(2)` as
|
|
3
|
+
* `EngineLights`, beside the globals and the camera. The engine supplies the uniforms; the
|
|
4
|
+
* style (Lambert, toon, rim, nothing at all) is the game's WGSL. A game fills `frame.lights`
|
|
5
|
+
* each frame; the renderer uploads it with the camera block of every view.
|
|
6
|
+
*
|
|
7
|
+
* The default block is unlit: ambient 1, no sun, no point or spot lights, no shadow, no fog. A material
|
|
8
|
+
* that multiplies by `engine_lambert(n, p)` therefore draws its albedo unchanged until the game
|
|
9
|
+
* lights the scene, `engine_shadow` returns 1 and `engine_fog` returns its input, and materials
|
|
10
|
+
* that never read the block are untouched.
|
|
11
|
+
*/
|
|
12
|
+
/** Point lights the block carries; `Lights.points` beyond this many are ignored. */
|
|
13
|
+
export declare const MAX_POINT_LIGHTS = 16;
|
|
14
|
+
/** Floats per point light in the block: position xyz, radius, colour rgb, pad (32 bytes). */
|
|
15
|
+
export declare const POINT_LIGHT_FLOATS = 8;
|
|
16
|
+
/** Float offset of `points[0]` inside the block (ambient, count, sun_dir, sun_color first). */
|
|
17
|
+
export declare const POINT_LIGHTS_OFFSET_FLOATS = 12;
|
|
18
|
+
/** Float offset of `sun_view_proj` (mat4x4f, world → sun clip) inside the block. */
|
|
19
|
+
export declare const SUN_VIEW_PROJ_OFFSET_FLOATS: number;
|
|
20
|
+
/** Float offset of `shadow_params` (bias, texel size, enabled, pad) inside the block. */
|
|
21
|
+
export declare const SHADOW_PARAMS_OFFSET_FLOATS: number;
|
|
22
|
+
/** Float offset of `fog` (rgb, density) inside the block; `fog_range` (near, far) follows it. */
|
|
23
|
+
export declare const FOG_OFFSET_FLOATS: number;
|
|
24
|
+
/**
|
|
25
|
+
* Float offset of `spot_count` (u32) inside the block; `sun_layers` (u32, the sun's layer mask)
|
|
26
|
+
* is the next float, then two pad words.
|
|
27
|
+
*/
|
|
28
|
+
export declare const LAYERS_OFFSET_FLOATS: number;
|
|
29
|
+
/** Float offset of `point_layers` (`array<vec4u, 4>`: one u32 mask per point light slot). */
|
|
30
|
+
export declare const POINT_LAYERS_OFFSET_FLOATS: number;
|
|
31
|
+
/** Spot lights the block carries; `Lights.spots` beyond this many are ignored. */
|
|
32
|
+
export declare const MAX_SPOT_LIGHTS = 8;
|
|
33
|
+
/**
|
|
34
|
+
* Floats per spot light: position xyz, radius, direction xyz, cos(outerAngle), colour rgb,
|
|
35
|
+
* cos(innerAngle), layers (u32), three pad words (64 bytes).
|
|
36
|
+
*/
|
|
37
|
+
export declare const SPOT_LIGHT_FLOATS = 16;
|
|
38
|
+
/** Float offset of `spots[0]` inside the block. */
|
|
39
|
+
export declare const SPOT_LIGHTS_OFFSET_FLOATS: number;
|
|
40
|
+
/** Floats in the WGSL `EngineLights` block (1264 bytes). */
|
|
41
|
+
export declare const LIGHTS_BLOCK_FLOATS: number;
|
|
42
|
+
/** The layer mask a light has when `layers` is unset: every layer. */
|
|
43
|
+
export declare const ALL_LIGHT_LAYERS = 4294967295;
|
|
44
|
+
/**
|
|
45
|
+
* Instance flag bits (`VertexIn.misc.y`, `VSOut.flags`): bit 0 is "does not receive shadow";
|
|
46
|
+
* bits 1..23 carry the instance's low `INSTANCE_LAYER_BITS` layer bits, so a fragment shader
|
|
47
|
+
* can mask lights against them (`engine_instance_layers(in.flags)` in WGSL). The float that
|
|
48
|
+
* carries the flags holds 24 integer bits exactly, so layers above bit 22 are invisible to lights
|
|
49
|
+
* (they still cull against the camera).
|
|
50
|
+
*/
|
|
51
|
+
export declare const INSTANCE_LAYER_SHIFT = 1;
|
|
52
|
+
export declare const INSTANCE_LAYER_BITS = 23;
|
|
53
|
+
/** The instance flags float for `receiveShadow` and a layer mask (see `INSTANCE_LAYER_SHIFT`). */
|
|
54
|
+
export declare function packInstanceFlags(receiveShadow: boolean, layers: number): number;
|
|
55
|
+
/**
|
|
56
|
+
* The cone factor of a spot light, 0..1, mirrored by `engine_spot_cone` in WGSL: 1 inside
|
|
57
|
+
* `innerAngle` of the axis, 0 outside `outerAngle`, a smooth Hermite step between. All three
|
|
58
|
+
* arguments are cosines (`cosTheta` = dot of the light's direction with the direction to the
|
|
59
|
+
* fragment); with `cosInner <= cosOuter` the edge is hard.
|
|
60
|
+
*/
|
|
61
|
+
export declare function spotCone(cosTheta: number, cosOuter: number, cosInner: number): number;
|
|
62
|
+
/**
|
|
63
|
+
* The sun's shadow map: an orthographic box centred on the rendering camera's position, looking
|
|
64
|
+
* along `sun.direction`, `extent` world units of half-width, spanning `near`..`far` along the light
|
|
65
|
+
* (measured from the camera position; defaults `-extent`..`extent`). `size` is the map's side
|
|
66
|
+
* in texels (default 2048); `bias` is subtracted from the receiver's depth before the compare
|
|
67
|
+
* (default `DEFAULT_SHADOW_BIAS`). Set `sun.shadow` to one of these and the renderer encodes a
|
|
68
|
+
* shadow pass per view; leave it null and nothing changes.
|
|
69
|
+
*/
|
|
70
|
+
export interface SunShadow {
|
|
71
|
+
size?: 1024 | 2048 | 4096;
|
|
72
|
+
extent: number;
|
|
73
|
+
near?: number;
|
|
74
|
+
far?: number;
|
|
75
|
+
bias?: number;
|
|
76
|
+
}
|
|
77
|
+
/** Depth bias of `SunShadow` when none is given (in 0..1 shadow-depth units). */
|
|
78
|
+
export declare const DEFAULT_SHADOW_BIAS = 0.0015;
|
|
79
|
+
/**
|
|
80
|
+
* A directional light: `dir` is the direction the light travels (sun → scene), any length.
|
|
81
|
+
* `Lights.sun` is a `SunLight`, which spells it `direction` like `SpotLight`.
|
|
82
|
+
*/
|
|
83
|
+
export interface DirectionalLight {
|
|
84
|
+
dir: ArrayLike<number>;
|
|
85
|
+
/** Linear RGB, HDR allowed. All zero is "no sun". */
|
|
86
|
+
color: ArrayLike<number>;
|
|
87
|
+
/** The sun's shadow map, or null/undefined for none (the default). */
|
|
88
|
+
shadow?: SunShadow | null;
|
|
89
|
+
/** Layer mask (u32): the light reaches instances whose `layers` share a bit. Default all. */
|
|
90
|
+
layers?: number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* `Lights.sun`: a `DirectionalLight` whose direction is spelled `direction`, like
|
|
94
|
+
* `SpotLight.direction` (ws/api-render).
|
|
95
|
+
*/
|
|
96
|
+
export interface SunLight extends Omit<DirectionalLight, 'dir'> {
|
|
97
|
+
/** The direction the light travels (sun → scene), any length. */
|
|
98
|
+
direction: ArrayLike<number>;
|
|
99
|
+
}
|
|
100
|
+
/** A point light: world position, linear RGB colour and the radius where it falls to zero. */
|
|
101
|
+
export interface PointLight {
|
|
102
|
+
position: ArrayLike<number>;
|
|
103
|
+
color: ArrayLike<number>;
|
|
104
|
+
radius: number;
|
|
105
|
+
/** Layer mask (u32): the light reaches instances whose `layers` share a bit. Default all. */
|
|
106
|
+
layers?: number;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* A spot light: a point light with a cone. `direction` is the way the light travels (any
|
|
110
|
+
* length); the cone is full inside `innerAngle` radians of it and gone outside `outerAngle`,
|
|
111
|
+
* with a smooth step between (`spotCone`). `radius` is the distance falloff, as for points.
|
|
112
|
+
*/
|
|
113
|
+
export interface SpotLight {
|
|
114
|
+
position: ArrayLike<number>;
|
|
115
|
+
direction: ArrayLike<number>;
|
|
116
|
+
color: ArrayLike<number>;
|
|
117
|
+
radius: number;
|
|
118
|
+
innerAngle: number;
|
|
119
|
+
outerAngle: number;
|
|
120
|
+
/** Layer mask (u32): the light reaches instances whose `layers` share a bit. Default all. */
|
|
121
|
+
layers?: number;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Distance fog, applied by `engine_fog(color, world_pos)` from the distance between the fragment
|
|
125
|
+
* and the camera. `density` 0 (the default) is no fog. With `far > near` the fog is linear:
|
|
126
|
+
* nothing until `near`, fully `density` (clamped to 1) of `color` at `far`. With `far <= near`
|
|
127
|
+
* it is exponential past `near`: `1 - exp(-density × distance)`.
|
|
128
|
+
*
|
|
129
|
+
* `Lights.fog` is the only depth fog. Post's `mist` (`MistSettings`, formerly `fog`) is a
|
|
130
|
+
* screen-space haze composited on top of the finished scene; the two stack, neither replaces
|
|
131
|
+
* the other.
|
|
132
|
+
*/
|
|
133
|
+
export interface DistanceFog {
|
|
134
|
+
/** Linear RGB the scene fades to. */
|
|
135
|
+
color: ArrayLike<number>;
|
|
136
|
+
density: number;
|
|
137
|
+
near: number;
|
|
138
|
+
far: number;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* What the renderer passes to `Lights.writeBlock` when a shadow pass rendered this view: the
|
|
142
|
+
* sun's world → clip matrix (column-major, 16 floats), the depth bias and one texel in map uv.
|
|
143
|
+
*/
|
|
144
|
+
export interface ShadowUniforms {
|
|
145
|
+
viewProj: ArrayLike<number>;
|
|
146
|
+
bias: number;
|
|
147
|
+
texelSize: number;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* The lights of one frame. Mutate the fields (or push into `points`) and keep the object; the
|
|
151
|
+
* renderer calls `writeBlock` into its own uniform staging each view, so nothing allocates.
|
|
152
|
+
*/
|
|
153
|
+
export declare class Lights {
|
|
154
|
+
/** Linear RGB added to everything the game's lighting touches. Default white (unlit). */
|
|
155
|
+
readonly ambient: Float32Array<ArrayBuffer>;
|
|
156
|
+
/**
|
|
157
|
+
* The one directional light. Default: travelling straight down with no colour, so it
|
|
158
|
+
* contributes nothing; no shadow.
|
|
159
|
+
*/
|
|
160
|
+
readonly sun: SunLight;
|
|
161
|
+
/** Point lights, in order; the first `MAX_POINT_LIGHTS` reach the shader. */
|
|
162
|
+
readonly points: PointLight[];
|
|
163
|
+
/** Spot lights, in order; the first `MAX_SPOT_LIGHTS` reach the shader. */
|
|
164
|
+
readonly spots: SpotLight[];
|
|
165
|
+
/** Distance fog. Default density 0: `engine_fog` is the identity. */
|
|
166
|
+
readonly fog: DistanceFog;
|
|
167
|
+
/** Back to the unlit default: ambient 1, no sun or shadow, `points` and `spots` emptied, no fog. */
|
|
168
|
+
reset(): this;
|
|
169
|
+
/**
|
|
170
|
+
* Write the `EngineLights` block into `out` at float offset `o` (`LIGHTS_BLOCK_FLOATS` floats):
|
|
171
|
+
* `ambient` (0–2), `point_count` as u32 (3, through `u32`, a `Uint32Array` over the same
|
|
172
|
+
* buffer as `out`, like `Camera.writeBlock`), normalised `sun_dir` (4–6), `sun_color` (8–10),
|
|
173
|
+
* `MAX_POINT_LIGHTS` × (`position`, `radius`, `color`, pad), then `sun_view_proj`,
|
|
174
|
+
* `shadow_params` (bias, texel size, enabled) from `shadow` (zeros and enabled 0 when null),
|
|
175
|
+
* `fog` (rgb, density) and `fog_range` (near, far), then `spot_count` and `sun_layers` (u32),
|
|
176
|
+
* `point_layers` (one u32 per point slot) and `MAX_SPOT_LIGHTS` × (`position`, `radius`,
|
|
177
|
+
* normalised `direction`, cos `outerAngle`, `color`, cos `innerAngle`, `layers`, pad). Unset
|
|
178
|
+
* masks are `ALL_LIGHT_LAYERS`. Unused slots are zeroed. No allocation.
|
|
179
|
+
*/
|
|
180
|
+
writeBlock(out: Float32Array, u32: Uint32Array, o?: number, shadow?: ShadowUniforms | null): void;
|
|
181
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The lighting block: what every material can read at `@group(0) @binding(2)` as
|
|
3
|
+
* `EngineLights`, beside the globals and the camera. The engine supplies the uniforms; the
|
|
4
|
+
* style (Lambert, toon, rim, nothing at all) is the game's WGSL. A game fills `frame.lights`
|
|
5
|
+
* each frame; the renderer uploads it with the camera block of every view.
|
|
6
|
+
*
|
|
7
|
+
* The default block is unlit: ambient 1, no sun, no point or spot lights, no shadow, no fog. A material
|
|
8
|
+
* that multiplies by `engine_lambert(n, p)` therefore draws its albedo unchanged until the game
|
|
9
|
+
* lights the scene, `engine_shadow` returns 1 and `engine_fog` returns its input, and materials
|
|
10
|
+
* that never read the block are untouched.
|
|
11
|
+
*/
|
|
12
|
+
/** Point lights the block carries; `Lights.points` beyond this many are ignored. */
|
|
13
|
+
export const MAX_POINT_LIGHTS = 16;
|
|
14
|
+
/** Floats per point light in the block: position xyz, radius, colour rgb, pad (32 bytes). */
|
|
15
|
+
export const POINT_LIGHT_FLOATS = 8;
|
|
16
|
+
/** Float offset of `points[0]` inside the block (ambient, count, sun_dir, sun_color first). */
|
|
17
|
+
export const POINT_LIGHTS_OFFSET_FLOATS = 12;
|
|
18
|
+
/** Float offset of `sun_view_proj` (mat4x4f, world → sun clip) inside the block. */
|
|
19
|
+
export const SUN_VIEW_PROJ_OFFSET_FLOATS = POINT_LIGHTS_OFFSET_FLOATS + MAX_POINT_LIGHTS * POINT_LIGHT_FLOATS;
|
|
20
|
+
/** Float offset of `shadow_params` (bias, texel size, enabled, pad) inside the block. */
|
|
21
|
+
export const SHADOW_PARAMS_OFFSET_FLOATS = SUN_VIEW_PROJ_OFFSET_FLOATS + 16;
|
|
22
|
+
/** Float offset of `fog` (rgb, density) inside the block; `fog_range` (near, far) follows it. */
|
|
23
|
+
export const FOG_OFFSET_FLOATS = SHADOW_PARAMS_OFFSET_FLOATS + 4;
|
|
24
|
+
/**
|
|
25
|
+
* Float offset of `spot_count` (u32) inside the block; `sun_layers` (u32, the sun's layer mask)
|
|
26
|
+
* is the next float, then two pad words.
|
|
27
|
+
*/
|
|
28
|
+
export const LAYERS_OFFSET_FLOATS = FOG_OFFSET_FLOATS + 8;
|
|
29
|
+
/** Float offset of `point_layers` (`array<vec4u, 4>`: one u32 mask per point light slot). */
|
|
30
|
+
export const POINT_LAYERS_OFFSET_FLOATS = LAYERS_OFFSET_FLOATS + 4;
|
|
31
|
+
/** Spot lights the block carries; `Lights.spots` beyond this many are ignored. */
|
|
32
|
+
export const MAX_SPOT_LIGHTS = 8;
|
|
33
|
+
/**
|
|
34
|
+
* Floats per spot light: position xyz, radius, direction xyz, cos(outerAngle), colour rgb,
|
|
35
|
+
* cos(innerAngle), layers (u32), three pad words (64 bytes).
|
|
36
|
+
*/
|
|
37
|
+
export const SPOT_LIGHT_FLOATS = 16;
|
|
38
|
+
/** Float offset of `spots[0]` inside the block. */
|
|
39
|
+
export const SPOT_LIGHTS_OFFSET_FLOATS = POINT_LAYERS_OFFSET_FLOATS + MAX_POINT_LIGHTS;
|
|
40
|
+
/** Floats in the WGSL `EngineLights` block (1264 bytes). */
|
|
41
|
+
export const LIGHTS_BLOCK_FLOATS = SPOT_LIGHTS_OFFSET_FLOATS + MAX_SPOT_LIGHTS * SPOT_LIGHT_FLOATS;
|
|
42
|
+
/** The layer mask a light has when `layers` is unset: every layer. */
|
|
43
|
+
export const ALL_LIGHT_LAYERS = 0xffffffff;
|
|
44
|
+
/**
|
|
45
|
+
* Instance flag bits (`VertexIn.misc.y`, `VSOut.flags`): bit 0 is "does not receive shadow";
|
|
46
|
+
* bits 1..23 carry the instance's low `INSTANCE_LAYER_BITS` layer bits, so a fragment shader
|
|
47
|
+
* can mask lights against them (`engine_instance_layers(in.flags)` in WGSL). The float that
|
|
48
|
+
* carries the flags holds 24 integer bits exactly, so layers above bit 22 are invisible to lights
|
|
49
|
+
* (they still cull against the camera).
|
|
50
|
+
*/
|
|
51
|
+
export const INSTANCE_LAYER_SHIFT = 1;
|
|
52
|
+
export const INSTANCE_LAYER_BITS = 23;
|
|
53
|
+
const INSTANCE_LAYER_MASK = (1 << INSTANCE_LAYER_BITS) - 1;
|
|
54
|
+
/** The instance flags float for `receiveShadow` and a layer mask (see `INSTANCE_LAYER_SHIFT`). */
|
|
55
|
+
export function packInstanceFlags(receiveShadow, layers) {
|
|
56
|
+
return (receiveShadow ? 0 : 1) | ((layers & INSTANCE_LAYER_MASK) << INSTANCE_LAYER_SHIFT);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The cone factor of a spot light, 0..1, mirrored by `engine_spot_cone` in WGSL: 1 inside
|
|
60
|
+
* `innerAngle` of the axis, 0 outside `outerAngle`, a smooth Hermite step between. All three
|
|
61
|
+
* arguments are cosines (`cosTheta` = dot of the light's direction with the direction to the
|
|
62
|
+
* fragment); with `cosInner <= cosOuter` the edge is hard.
|
|
63
|
+
*/
|
|
64
|
+
export function spotCone(cosTheta, cosOuter, cosInner) {
|
|
65
|
+
const t = Math.min(1, Math.max(0, (cosTheta - cosOuter) / Math.max(cosInner - cosOuter, 1e-4)));
|
|
66
|
+
return t * t * (3 - 2 * t);
|
|
67
|
+
}
|
|
68
|
+
/** Depth bias of `SunShadow` when none is given (in 0..1 shadow-depth units). */
|
|
69
|
+
export const DEFAULT_SHADOW_BIAS = 0.0015;
|
|
70
|
+
/**
|
|
71
|
+
* The lights of one frame. Mutate the fields (or push into `points`) and keep the object; the
|
|
72
|
+
* renderer calls `writeBlock` into its own uniform staging each view, so nothing allocates.
|
|
73
|
+
*/
|
|
74
|
+
export class Lights {
|
|
75
|
+
/** Linear RGB added to everything the game's lighting touches. Default white (unlit). */
|
|
76
|
+
ambient = new Float32Array([1, 1, 1]);
|
|
77
|
+
/**
|
|
78
|
+
* The one directional light. Default: travelling straight down with no colour, so it
|
|
79
|
+
* contributes nothing; no shadow.
|
|
80
|
+
*/
|
|
81
|
+
sun = createSun();
|
|
82
|
+
/** Point lights, in order; the first `MAX_POINT_LIGHTS` reach the shader. */
|
|
83
|
+
points = [];
|
|
84
|
+
/** Spot lights, in order; the first `MAX_SPOT_LIGHTS` reach the shader. */
|
|
85
|
+
spots = [];
|
|
86
|
+
/** Distance fog. Default density 0: `engine_fog` is the identity. */
|
|
87
|
+
fog = { color: new Float32Array([0, 0, 0]), density: 0, near: 0, far: 0 };
|
|
88
|
+
/** Back to the unlit default: ambient 1, no sun or shadow, `points` and `spots` emptied, no fog. */
|
|
89
|
+
reset() {
|
|
90
|
+
this.ambient.fill(1);
|
|
91
|
+
const s = this.sun;
|
|
92
|
+
set3(s.direction, 0, -1, 0);
|
|
93
|
+
set3(s.color, 0, 0, 0);
|
|
94
|
+
s.shadow = null;
|
|
95
|
+
s.layers = undefined;
|
|
96
|
+
this.points.length = 0;
|
|
97
|
+
this.spots.length = 0;
|
|
98
|
+
const f = this.fog;
|
|
99
|
+
set3(f.color, 0, 0, 0);
|
|
100
|
+
f.density = 0;
|
|
101
|
+
f.near = 0;
|
|
102
|
+
f.far = 0;
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Write the `EngineLights` block into `out` at float offset `o` (`LIGHTS_BLOCK_FLOATS` floats):
|
|
107
|
+
* `ambient` (0–2), `point_count` as u32 (3, through `u32`, a `Uint32Array` over the same
|
|
108
|
+
* buffer as `out`, like `Camera.writeBlock`), normalised `sun_dir` (4–6), `sun_color` (8–10),
|
|
109
|
+
* `MAX_POINT_LIGHTS` × (`position`, `radius`, `color`, pad), then `sun_view_proj`,
|
|
110
|
+
* `shadow_params` (bias, texel size, enabled) from `shadow` (zeros and enabled 0 when null),
|
|
111
|
+
* `fog` (rgb, density) and `fog_range` (near, far), then `spot_count` and `sun_layers` (u32),
|
|
112
|
+
* `point_layers` (one u32 per point slot) and `MAX_SPOT_LIGHTS` × (`position`, `radius`,
|
|
113
|
+
* normalised `direction`, cos `outerAngle`, `color`, cos `innerAngle`, `layers`, pad). Unset
|
|
114
|
+
* masks are `ALL_LIGHT_LAYERS`. Unused slots are zeroed. No allocation.
|
|
115
|
+
*/
|
|
116
|
+
writeBlock(out, u32, o = 0, shadow = null) {
|
|
117
|
+
const a = this.ambient;
|
|
118
|
+
out[o] = a[0];
|
|
119
|
+
out[o + 1] = a[1];
|
|
120
|
+
out[o + 2] = a[2];
|
|
121
|
+
const n = Math.min(this.points.length, MAX_POINT_LIGHTS);
|
|
122
|
+
u32[o + 3] = n;
|
|
123
|
+
const d = this.sun.direction;
|
|
124
|
+
const dx = d[0] ?? 0;
|
|
125
|
+
const dy = d[1] ?? 0;
|
|
126
|
+
const dz = d[2] ?? 0;
|
|
127
|
+
const len = Math.hypot(dx, dy, dz);
|
|
128
|
+
const k = len > 0 ? 1 / len : 0;
|
|
129
|
+
out[o + 4] = dx * k;
|
|
130
|
+
out[o + 5] = dy * k;
|
|
131
|
+
out[o + 6] = dz * k;
|
|
132
|
+
out[o + 7] = 0;
|
|
133
|
+
const c = this.sun.color;
|
|
134
|
+
out[o + 8] = c[0] ?? 0;
|
|
135
|
+
out[o + 9] = c[1] ?? 0;
|
|
136
|
+
out[o + 10] = c[2] ?? 0;
|
|
137
|
+
out[o + 11] = 0;
|
|
138
|
+
let p = o + POINT_LIGHTS_OFFSET_FLOATS;
|
|
139
|
+
for (let i = 0; i < n; i++, p += POINT_LIGHT_FLOATS) {
|
|
140
|
+
const l = this.points[i];
|
|
141
|
+
const pos = l.position;
|
|
142
|
+
const col = l.color;
|
|
143
|
+
out[p] = pos[0] ?? 0;
|
|
144
|
+
out[p + 1] = pos[1] ?? 0;
|
|
145
|
+
out[p + 2] = pos[2] ?? 0;
|
|
146
|
+
out[p + 3] = l.radius;
|
|
147
|
+
out[p + 4] = col[0] ?? 0;
|
|
148
|
+
out[p + 5] = col[1] ?? 0;
|
|
149
|
+
out[p + 6] = col[2] ?? 0;
|
|
150
|
+
out[p + 7] = 0;
|
|
151
|
+
}
|
|
152
|
+
const sv = o + SUN_VIEW_PROJ_OFFSET_FLOATS;
|
|
153
|
+
const sp = o + SHADOW_PARAMS_OFFSET_FLOATS;
|
|
154
|
+
if (shadow) {
|
|
155
|
+
out.fill(0, p, sv);
|
|
156
|
+
const m = shadow.viewProj;
|
|
157
|
+
for (let i = 0; i < 16; i++)
|
|
158
|
+
out[sv + i] = m[i] ?? 0;
|
|
159
|
+
out[sp] = shadow.bias;
|
|
160
|
+
out[sp + 1] = shadow.texelSize;
|
|
161
|
+
out[sp + 2] = 1;
|
|
162
|
+
out[sp + 3] = 0;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
out.fill(0, p, sp + 4);
|
|
166
|
+
}
|
|
167
|
+
const f = this.fog;
|
|
168
|
+
const fc = f.color;
|
|
169
|
+
const fo = o + FOG_OFFSET_FLOATS;
|
|
170
|
+
out[fo] = fc[0] ?? 0;
|
|
171
|
+
out[fo + 1] = fc[1] ?? 0;
|
|
172
|
+
out[fo + 2] = fc[2] ?? 0;
|
|
173
|
+
out[fo + 3] = f.density;
|
|
174
|
+
out[fo + 4] = f.near;
|
|
175
|
+
out[fo + 5] = f.far;
|
|
176
|
+
out[fo + 6] = 0;
|
|
177
|
+
out[fo + 7] = 0;
|
|
178
|
+
const ns = Math.min(this.spots.length, MAX_SPOT_LIGHTS);
|
|
179
|
+
const lo = o + LAYERS_OFFSET_FLOATS;
|
|
180
|
+
u32[lo] = ns;
|
|
181
|
+
u32[lo + 1] = (this.sun.layers ?? ALL_LIGHT_LAYERS) >>> 0;
|
|
182
|
+
u32[lo + 2] = 0;
|
|
183
|
+
u32[lo + 3] = 0;
|
|
184
|
+
const pl = o + POINT_LAYERS_OFFSET_FLOATS;
|
|
185
|
+
for (let i = 0; i < MAX_POINT_LIGHTS; i++) {
|
|
186
|
+
u32[pl + i] = i < n ? (this.points[i].layers ?? ALL_LIGHT_LAYERS) >>> 0 : 0;
|
|
187
|
+
}
|
|
188
|
+
let sp2 = o + SPOT_LIGHTS_OFFSET_FLOATS;
|
|
189
|
+
for (let i = 0; i < ns; i++, sp2 += SPOT_LIGHT_FLOATS) {
|
|
190
|
+
const l = this.spots[i];
|
|
191
|
+
const pos = l.position;
|
|
192
|
+
const dir = l.direction;
|
|
193
|
+
const col = l.color;
|
|
194
|
+
out[sp2] = pos[0] ?? 0;
|
|
195
|
+
out[sp2 + 1] = pos[1] ?? 0;
|
|
196
|
+
out[sp2 + 2] = pos[2] ?? 0;
|
|
197
|
+
out[sp2 + 3] = l.radius;
|
|
198
|
+
const ddx = dir[0] ?? 0;
|
|
199
|
+
const ddy = dir[1] ?? 0;
|
|
200
|
+
const ddz = dir[2] ?? 0;
|
|
201
|
+
const dl = Math.hypot(ddx, ddy, ddz);
|
|
202
|
+
const dk = dl > 0 ? 1 / dl : 0;
|
|
203
|
+
out[sp2 + 4] = ddx * dk;
|
|
204
|
+
out[sp2 + 5] = ddy * dk;
|
|
205
|
+
out[sp2 + 6] = ddz * dk;
|
|
206
|
+
out[sp2 + 7] = Math.cos(l.outerAngle);
|
|
207
|
+
out[sp2 + 8] = col[0] ?? 0;
|
|
208
|
+
out[sp2 + 9] = col[1] ?? 0;
|
|
209
|
+
out[sp2 + 10] = col[2] ?? 0;
|
|
210
|
+
out[sp2 + 11] = Math.cos(l.innerAngle);
|
|
211
|
+
u32[sp2 + 12] = (l.layers ?? ALL_LIGHT_LAYERS) >>> 0;
|
|
212
|
+
out[sp2 + 13] = 0;
|
|
213
|
+
out[sp2 + 14] = 0;
|
|
214
|
+
out[sp2 + 15] = 0;
|
|
215
|
+
}
|
|
216
|
+
out.fill(0, sp2, o + LIGHTS_BLOCK_FLOATS);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/** The default sun: travelling straight down, no colour, no shadow. */
|
|
220
|
+
function createSun() {
|
|
221
|
+
return {
|
|
222
|
+
direction: new Float32Array([0, -1, 0]),
|
|
223
|
+
color: new Float32Array([0, 0, 0]),
|
|
224
|
+
shadow: null,
|
|
225
|
+
layers: undefined,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function set3(v, x, y, z) {
|
|
229
|
+
const w = v;
|
|
230
|
+
w[0] = x;
|
|
231
|
+
w[1] = y;
|
|
232
|
+
w[2] = z;
|
|
233
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-instance level-of-detail picking for `frame.mesh` (ws/render-5). A `MeshLod` is geom's
|
|
3
|
+
* `LodChain` with its GPU meshes (`createLodChain` + `renderer.createMesh` per geometry): the
|
|
4
|
+
* renderer picks a level per instance from the projected height of its bounding sphere, the
|
|
5
|
+
* way `selectLod` does, with a hysteresis band so an instance on a boundary does not flicker.
|
|
6
|
+
* Pure arithmetic, no allocation.
|
|
7
|
+
*/
|
|
8
|
+
import type { LodChain } from '../geom/lod.js';
|
|
9
|
+
import type { Mesh, MeshDesc } from './mesh.js';
|
|
10
|
+
/**
|
|
11
|
+
* A LOD chain the renderer draws: `meshes[0]` the full mesh, each later one coarser, and
|
|
12
|
+
* `thresholdsPx[i]` the smallest on-screen height (target px) at which level `i` still draws
|
|
13
|
+
* (descending; geom's `LodChain` with its `meshes` filled is one). The draw's bounding sphere
|
|
14
|
+
* is `meshes[0].bounds` through the instance matrix.
|
|
15
|
+
*/
|
|
16
|
+
export type MeshLod = Pick<LodChain<Mesh>, 'thresholdsPx'> & {
|
|
17
|
+
readonly meshes: readonly Mesh[];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* What `renderer.createMeshLod` takes (ws/api-render): geom's `LodChain` as `createLodChain`
|
|
21
|
+
* builds it (`geometries` with level 0 the full one, `thresholdsPx` one fewer than the
|
|
22
|
+
* levels, or as many), plus a label prefix for the meshes (`<label>-lod<i>`).
|
|
23
|
+
*/
|
|
24
|
+
export interface MeshLodDesc {
|
|
25
|
+
geometries: readonly MeshDesc[];
|
|
26
|
+
thresholdsPx: readonly number[];
|
|
27
|
+
/** Mesh label prefix. Default `'lod'`. */
|
|
28
|
+
label?: string;
|
|
29
|
+
}
|
|
30
|
+
/** A `MeshLod` that keeps the geometries it was built from: a full geom `LodChain<Mesh>`. */
|
|
31
|
+
export type MeshLodChain = MeshLod & {
|
|
32
|
+
readonly geometries: readonly MeshDesc[];
|
|
33
|
+
};
|
|
34
|
+
/** True when `m` is a `MeshLod` rather than a single `Mesh`. */
|
|
35
|
+
export declare function isMeshLod(m: Mesh | MeshLod): m is MeshLod;
|
|
36
|
+
/** Default `Renderer.lodHysteresis`: a 10 % band around each threshold. */
|
|
37
|
+
export declare const DEFAULT_LOD_HYSTERESIS = 0.1;
|
|
38
|
+
/**
|
|
39
|
+
* Height in target px that a sphere of world radius `radius` covers at world distance
|
|
40
|
+
* `distance` through `proj` (column-major, the camera's projection) on a viewport `viewportH`
|
|
41
|
+
* px tall: `radius · viewportH · proj[5] / distance` for a perspective projection (geom's
|
|
42
|
+
* `projectedSizePx`, `proj[5]` being `1 / tan(fovY / 2)`), `radius · viewportH · proj[5]` for an
|
|
43
|
+
* orthographic one (distance plays no part). A non-positive distance is `Infinity`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function lodSizePx(radius: number, distance: number, proj: ArrayLike<number>, viewportH: number): number;
|
|
46
|
+
/**
|
|
47
|
+
* The level for an instance whose sphere covers `sizePx`, out of `count` levels with
|
|
48
|
+
* `thresholds` (`selectLod`'s rule: the first `i` with `sizePx >= thresholds[i]`, else the last
|
|
49
|
+
* level), held at `prev` (the level it drew last frame; -1 for none) while the size stays
|
|
50
|
+
* inside a band of `hysteresis` (a fraction) around the boundary: it goes coarser only once
|
|
51
|
+
* `sizePx < thresholds[prev] · (1 - hysteresis)` and finer only to a level `i` with
|
|
52
|
+
* `sizePx >= thresholds[i] · (1 + hysteresis)`.
|
|
53
|
+
*/
|
|
54
|
+
export declare function pickLodLevel(sizePx: number, thresholds: readonly number[], count: number, prev: number, hysteresis: number): number;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** True when `m` is a `MeshLod` rather than a single `Mesh`. */
|
|
2
|
+
export function isMeshLod(m) {
|
|
3
|
+
return m.thresholdsPx !== undefined;
|
|
4
|
+
}
|
|
5
|
+
/** Default `Renderer.lodHysteresis`: a 10 % band around each threshold. */
|
|
6
|
+
export const DEFAULT_LOD_HYSTERESIS = 0.1;
|
|
7
|
+
/**
|
|
8
|
+
* Height in target px that a sphere of world radius `radius` covers at world distance
|
|
9
|
+
* `distance` through `proj` (column-major, the camera's projection) on a viewport `viewportH`
|
|
10
|
+
* px tall: `radius · viewportH · proj[5] / distance` for a perspective projection (geom's
|
|
11
|
+
* `projectedSizePx`, `proj[5]` being `1 / tan(fovY / 2)`), `radius · viewportH · proj[5]` for an
|
|
12
|
+
* orthographic one (distance plays no part). A non-positive distance is `Infinity`.
|
|
13
|
+
*/
|
|
14
|
+
export function lodSizePx(radius, distance, proj, viewportH) {
|
|
15
|
+
const f = proj[5];
|
|
16
|
+
if (proj[11] === 0)
|
|
17
|
+
return radius * viewportH * Math.abs(f);
|
|
18
|
+
if (!(distance > 0))
|
|
19
|
+
return Number.POSITIVE_INFINITY;
|
|
20
|
+
return (radius * viewportH * Math.abs(f)) / distance;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The level for an instance whose sphere covers `sizePx`, out of `count` levels with
|
|
24
|
+
* `thresholds` (`selectLod`'s rule: the first `i` with `sizePx >= thresholds[i]`, else the last
|
|
25
|
+
* level), held at `prev` (the level it drew last frame; -1 for none) while the size stays
|
|
26
|
+
* inside a band of `hysteresis` (a fraction) around the boundary: it goes coarser only once
|
|
27
|
+
* `sizePx < thresholds[prev] · (1 - hysteresis)` and finer only to a level `i` with
|
|
28
|
+
* `sizePx >= thresholds[i] · (1 + hysteresis)`.
|
|
29
|
+
*/
|
|
30
|
+
export function pickLodLevel(sizePx, thresholds, count, prev, hysteresis) {
|
|
31
|
+
const last = Math.max(0, count - 1);
|
|
32
|
+
const n = Math.min(last, thresholds.length);
|
|
33
|
+
let level = last;
|
|
34
|
+
for (let i = 0; i < n; i++) {
|
|
35
|
+
if (sizePx >= thresholds[i]) {
|
|
36
|
+
level = i;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (prev < 0 || prev > last || !(hysteresis > 0) || level === prev)
|
|
41
|
+
return level;
|
|
42
|
+
if (level > prev) {
|
|
43
|
+
// Coarser: hold while the size is still within the band below prev's threshold.
|
|
44
|
+
return prev < n && sizePx >= thresholds[prev] * (1 - hysteresis) ? prev : level;
|
|
45
|
+
}
|
|
46
|
+
// Finer: the finest level whose threshold the size clears by the band, else stay.
|
|
47
|
+
for (let i = level; i < prev; i++) {
|
|
48
|
+
if (sizePx >= thresholds[i] * (1 + hysteresis))
|
|
49
|
+
return i;
|
|
50
|
+
}
|
|
51
|
+
return prev;
|
|
52
|
+
}
|