@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,413 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cutting geometry apart: `splitGeometry` into connected islands or caller-chosen groups,
|
|
3
|
+
* `sliceGeometry` by a plane into the parts above and below, the cut optionally capped
|
|
4
|
+
* (`triangulate`). Build-time work: allocates freely, deterministic for a given input.
|
|
5
|
+
*/
|
|
6
|
+
import { VERTEX_LAYOUT_3D, VERTEX_LAYOUT_3D_TANGENT } from '../render/mesh.js';
|
|
7
|
+
import { cloneGeometry, computeBounds, createIndices } from './geometry.js';
|
|
8
|
+
import { triangulate } from './triangulate.js';
|
|
9
|
+
function floatsOf(g, what) {
|
|
10
|
+
if (g.layout !== VERTEX_LAYOUT_3D && g.layout !== VERTEX_LAYOUT_3D_TANGENT) {
|
|
11
|
+
throw new Error(`geom: ${what} needs a 3D vertex layout, got '${g.layout.name}'`);
|
|
12
|
+
}
|
|
13
|
+
return g.layout.floats;
|
|
14
|
+
}
|
|
15
|
+
/** A geometry from `g`'s vertices over a list of its triangle indices (only the used vertices). */
|
|
16
|
+
function subset(g, F, tris) {
|
|
17
|
+
const map = new Map();
|
|
18
|
+
for (const t of tris) {
|
|
19
|
+
for (let k = 0; k < 3; k++) {
|
|
20
|
+
const i = g.indices[t * 3 + k];
|
|
21
|
+
if (!map.has(i))
|
|
22
|
+
map.set(i, map.size);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const vertices = new Float32Array(map.size * F);
|
|
26
|
+
for (const [i, o] of map)
|
|
27
|
+
vertices.set(g.vertices.subarray(i * F, i * F + F), o * F);
|
|
28
|
+
const indices = createIndices(map.size, tris.length * 3);
|
|
29
|
+
let o = 0;
|
|
30
|
+
for (const t of tris)
|
|
31
|
+
for (let k = 0; k < 3; k++)
|
|
32
|
+
indices[o++] = map.get(g.indices[t * 3 + k]);
|
|
33
|
+
return { vertices, indices, bounds: computeBounds(vertices, F), layout: g.layout };
|
|
34
|
+
}
|
|
35
|
+
/** Position key: exact xyz with -0 folded into 0, so seam duplicates of a vertex share one. */
|
|
36
|
+
function posKey(v, o) {
|
|
37
|
+
return `${v[o] + 0},${v[o + 1] + 0},${v[o + 2] + 0}`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Split `g` into parts. `'island'`: connected components, triangles joined where they share a
|
|
41
|
+
* vertex position (so a UV or normal seam does not split a mesh), in order of each island's
|
|
42
|
+
* first triangle. A function: `by(triangle)` (the triangle's index, `indices[3t..3t+2]`) names
|
|
43
|
+
* each triangle's group, a negative number drops it, and the groups come back in ascending
|
|
44
|
+
* order of their number. Each part holds only the vertices it uses, in `g`'s layout.
|
|
45
|
+
*/
|
|
46
|
+
export function splitGeometry(g, by) {
|
|
47
|
+
const F = floatsOf(g, 'splitGeometry');
|
|
48
|
+
const T = Math.floor(g.indices.length / 3);
|
|
49
|
+
const group = new Float64Array(T);
|
|
50
|
+
if (by === 'island') {
|
|
51
|
+
// Union-find over positions, then each triangle takes its first corner's root.
|
|
52
|
+
const ids = new Map();
|
|
53
|
+
const pos = new Int32Array(g.vertices.length / F);
|
|
54
|
+
for (let i = 0; i < pos.length; i++) {
|
|
55
|
+
const k = posKey(g.vertices, i * F);
|
|
56
|
+
let id = ids.get(k);
|
|
57
|
+
if (id === undefined) {
|
|
58
|
+
id = ids.size;
|
|
59
|
+
ids.set(k, id);
|
|
60
|
+
}
|
|
61
|
+
pos[i] = id;
|
|
62
|
+
}
|
|
63
|
+
const parent = Int32Array.from({ length: ids.size }, (_, i) => i);
|
|
64
|
+
const find = (a) => {
|
|
65
|
+
while (parent[a] !== a) {
|
|
66
|
+
parent[a] = parent[parent[a]];
|
|
67
|
+
a = parent[a];
|
|
68
|
+
}
|
|
69
|
+
return a;
|
|
70
|
+
};
|
|
71
|
+
const join = (a, b) => {
|
|
72
|
+
const ra = find(a);
|
|
73
|
+
const rb = find(b);
|
|
74
|
+
if (ra !== rb)
|
|
75
|
+
parent[Math.max(ra, rb)] = Math.min(ra, rb);
|
|
76
|
+
};
|
|
77
|
+
for (let t = 0; t < T; t++) {
|
|
78
|
+
const a = pos[g.indices[t * 3]];
|
|
79
|
+
join(a, pos[g.indices[t * 3 + 1]]);
|
|
80
|
+
join(a, pos[g.indices[t * 3 + 2]]);
|
|
81
|
+
}
|
|
82
|
+
// Number islands by first appearance.
|
|
83
|
+
const order = new Map();
|
|
84
|
+
for (let t = 0; t < T; t++) {
|
|
85
|
+
const r = find(pos[g.indices[t * 3]]);
|
|
86
|
+
let n = order.get(r);
|
|
87
|
+
if (n === undefined) {
|
|
88
|
+
n = order.size;
|
|
89
|
+
order.set(r, n);
|
|
90
|
+
}
|
|
91
|
+
group[t] = n;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
for (let t = 0; t < T; t++)
|
|
96
|
+
group[t] = by(t);
|
|
97
|
+
}
|
|
98
|
+
const buckets = new Map();
|
|
99
|
+
for (let t = 0; t < T; t++) {
|
|
100
|
+
const k = group[t];
|
|
101
|
+
if (!(k >= 0))
|
|
102
|
+
continue;
|
|
103
|
+
const list = buckets.get(k);
|
|
104
|
+
if (list)
|
|
105
|
+
list.push(t);
|
|
106
|
+
else
|
|
107
|
+
buckets.set(k, [t]);
|
|
108
|
+
}
|
|
109
|
+
return [...buckets.keys()].sort((a, b) => a - b).map((k) => subset(g, F, buckets.get(k)));
|
|
110
|
+
}
|
|
111
|
+
/** Growable float and index buffers for one half. */
|
|
112
|
+
class Part {
|
|
113
|
+
F;
|
|
114
|
+
verts = [];
|
|
115
|
+
idx = [];
|
|
116
|
+
constructor(F) {
|
|
117
|
+
this.F = F;
|
|
118
|
+
}
|
|
119
|
+
add(src, o) {
|
|
120
|
+
const at = this.verts.length / this.F;
|
|
121
|
+
for (let k = 0; k < this.F; k++)
|
|
122
|
+
this.verts.push(src[o + k]);
|
|
123
|
+
return at;
|
|
124
|
+
}
|
|
125
|
+
build(layout) {
|
|
126
|
+
const vertices = new Float32Array(this.verts);
|
|
127
|
+
const n = vertices.length / this.F;
|
|
128
|
+
const indices = createIndices(n, this.idx.length);
|
|
129
|
+
indices.set(this.idx);
|
|
130
|
+
return { vertices, indices, bounds: computeBounds(vertices, this.F), layout };
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Cut `g` by `plane` into the triangles above it and below it, each triangle the plane crosses
|
|
135
|
+
* split along the cut (every lane interpolated linearly; normals and tangents renormalised), so
|
|
136
|
+
* the two halves meet without cracks. A triangle lying in the plane goes below when it faces the
|
|
137
|
+
* normal's way and above otherwise, so slicing a box at its top face leaves it whole below.
|
|
138
|
+
* A plane that misses `g` leaves everything on one side and an empty geometry on the other.
|
|
139
|
+
* Both halves are in `g`'s layout.
|
|
140
|
+
*/
|
|
141
|
+
export function sliceGeometry(g, plane, opts = {}) {
|
|
142
|
+
const F = floatsOf(g, 'sliceGeometry');
|
|
143
|
+
const tangent = g.layout === VERTEX_LAYOUT_3D_TANGENT;
|
|
144
|
+
const nl = Math.hypot(plane.nx, plane.ny, plane.nz);
|
|
145
|
+
if (!(nl > 0))
|
|
146
|
+
throw new Error('geom: sliceGeometry needs a plane with a non-zero normal');
|
|
147
|
+
const nx = plane.nx / nl;
|
|
148
|
+
const ny = plane.ny / nl;
|
|
149
|
+
const nz = plane.nz / nl;
|
|
150
|
+
const d = plane.d / nl;
|
|
151
|
+
const v = g.vertices;
|
|
152
|
+
const vCount = v.length / F;
|
|
153
|
+
const eps = 1e-6 * Math.max(1, g.bounds.radius);
|
|
154
|
+
const side = new Float64Array(vCount);
|
|
155
|
+
for (let i = 0; i < vCount; i++) {
|
|
156
|
+
const s = nx * v[i * F] + ny * v[i * F + 1] + nz * v[i * F + 2] - d;
|
|
157
|
+
side[i] = Math.abs(s) <= eps ? 0 : s;
|
|
158
|
+
}
|
|
159
|
+
// Wholly on one side: that side is a copy of `g` (vertex order kept), the other empty.
|
|
160
|
+
let minSide = Number.POSITIVE_INFINITY;
|
|
161
|
+
let maxSide = Number.NEGATIVE_INFINITY;
|
|
162
|
+
for (let i = 0; i < vCount; i++) {
|
|
163
|
+
if (side[i] < minSide)
|
|
164
|
+
minSide = side[i];
|
|
165
|
+
if (side[i] > maxSide)
|
|
166
|
+
maxSide = side[i];
|
|
167
|
+
}
|
|
168
|
+
if (maxSide < 0 || minSide > 0) {
|
|
169
|
+
const empty = new Part(F).build(g.layout);
|
|
170
|
+
return maxSide < 0
|
|
171
|
+
? { above: empty, below: cloneGeometry(g) }
|
|
172
|
+
: { above: cloneGeometry(g), below: empty };
|
|
173
|
+
}
|
|
174
|
+
const above = new Part(F);
|
|
175
|
+
const below = new Part(F);
|
|
176
|
+
/** Source vertex → its index in each half. */
|
|
177
|
+
const inAbove = new Int32Array(vCount).fill(-1);
|
|
178
|
+
const inBelow = new Int32Array(vCount).fill(-1);
|
|
179
|
+
const vertexIn = (part, map, i) => {
|
|
180
|
+
if (map[i] < 0)
|
|
181
|
+
map[i] = part.add(v, i * F);
|
|
182
|
+
return map[i];
|
|
183
|
+
};
|
|
184
|
+
/** Cut points by source edge (`min · n + max`), one vertex shared by both halves' copies. */
|
|
185
|
+
const cutAbove = new Map();
|
|
186
|
+
const cutBelow = new Map();
|
|
187
|
+
const tmp = new Float64Array(F);
|
|
188
|
+
const cutPoint = (i, j) => {
|
|
189
|
+
const a = Math.min(i, j);
|
|
190
|
+
const b = Math.max(i, j);
|
|
191
|
+
const t = side[a] / (side[a] - side[b]);
|
|
192
|
+
for (let k = 0; k < F; k++)
|
|
193
|
+
tmp[k] = v[a * F + k] + (v[b * F + k] - v[a * F + k]) * t;
|
|
194
|
+
// Project onto the plane exactly, then renormalise the direction lanes.
|
|
195
|
+
const s = nx * tmp[0] + ny * tmp[1] + nz * tmp[2] - d;
|
|
196
|
+
tmp[0] = tmp[0] - nx * s;
|
|
197
|
+
tmp[1] = tmp[1] - ny * s;
|
|
198
|
+
tmp[2] = tmp[2] - nz * s;
|
|
199
|
+
const l = Math.hypot(tmp[3], tmp[4], tmp[5]);
|
|
200
|
+
if (l > 0)
|
|
201
|
+
for (let k = 3; k < 6; k++)
|
|
202
|
+
tmp[k] = tmp[k] / l;
|
|
203
|
+
if (tangent) {
|
|
204
|
+
const m = Math.hypot(tmp[12], tmp[13], tmp[14]);
|
|
205
|
+
if (m > 0)
|
|
206
|
+
for (let k = 12; k < 15; k++)
|
|
207
|
+
tmp[k] = tmp[k] / m;
|
|
208
|
+
tmp[15] = v[a * F + 15];
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const cutIn = (part, map, i, j) => {
|
|
212
|
+
const key = Math.min(i, j) * vCount + Math.max(i, j);
|
|
213
|
+
let at = map.get(key);
|
|
214
|
+
if (at === undefined) {
|
|
215
|
+
cutPoint(i, j);
|
|
216
|
+
at = part.add(tmp, 0);
|
|
217
|
+
map.set(key, at);
|
|
218
|
+
}
|
|
219
|
+
return at;
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* The below half's cut outline, as directed segments (xyz pairs, six floats each) wound
|
|
223
|
+
* counter-clockwise about `+n`: every below edge lying in the plane, reversed. A face lying in
|
|
224
|
+
* the plane contributes too, so its edges cancel the walls' (`capCut` drops opposite pairs).
|
|
225
|
+
*/
|
|
226
|
+
const segments = [];
|
|
227
|
+
const inPlane = (c) => typeof c !== 'number' || side[c] === 0;
|
|
228
|
+
const emit = (part, vmap, cmap, poly) => {
|
|
229
|
+
const at = poly.map((c) => typeof c === 'number' ? vertexIn(part, vmap, c) : cutIn(part, cmap, c[0], c[1]));
|
|
230
|
+
for (let k = 1; k + 1 < at.length; k++)
|
|
231
|
+
part.idx.push(at[0], at[k], at[k + 1]);
|
|
232
|
+
if (part !== below)
|
|
233
|
+
return;
|
|
234
|
+
const p = part.verts;
|
|
235
|
+
for (let k = 0; k < poly.length; k++) {
|
|
236
|
+
const n = (k + 1) % poly.length;
|
|
237
|
+
if (!inPlane(poly[k]) || !inPlane(poly[n]))
|
|
238
|
+
continue;
|
|
239
|
+
const a = at[n] * F;
|
|
240
|
+
const b = at[k] * F;
|
|
241
|
+
segments.push(p[a], p[a + 1], p[a + 2], p[b], p[b + 1], p[b + 2]);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
const idx = g.indices;
|
|
245
|
+
for (let t = 0; t + 2 < idx.length; t += 3) {
|
|
246
|
+
const tri = [idx[t], idx[t + 1], idx[t + 2]];
|
|
247
|
+
const s0 = side[tri[0]];
|
|
248
|
+
const s1 = side[tri[1]];
|
|
249
|
+
const s2 = side[tri[2]];
|
|
250
|
+
const pos = (s0 > 0 ? 1 : 0) + (s1 > 0 ? 1 : 0) + (s2 > 0 ? 1 : 0);
|
|
251
|
+
const neg = (s0 < 0 ? 1 : 0) + (s1 < 0 ? 1 : 0) + (s2 < 0 ? 1 : 0);
|
|
252
|
+
if (neg === 0 && pos === 0) {
|
|
253
|
+
// In the plane: below when it faces along the normal.
|
|
254
|
+
const [a, b, c] = tri;
|
|
255
|
+
const ux = v[b * F] - v[a * F];
|
|
256
|
+
const uy = v[b * F + 1] - v[a * F + 1];
|
|
257
|
+
const uz = v[b * F + 2] - v[a * F + 2];
|
|
258
|
+
const wx = v[c * F] - v[a * F];
|
|
259
|
+
const wy = v[c * F + 1] - v[a * F + 1];
|
|
260
|
+
const wz = v[c * F + 2] - v[a * F + 2];
|
|
261
|
+
const dot = nx * (uy * wz - uz * wy) + ny * (uz * wx - ux * wz) + nz * (ux * wy - uy * wx);
|
|
262
|
+
if (dot > 0)
|
|
263
|
+
emit(below, inBelow, cutBelow, tri);
|
|
264
|
+
else
|
|
265
|
+
emit(above, inAbove, cutAbove, tri);
|
|
266
|
+
}
|
|
267
|
+
else if (neg === 0) {
|
|
268
|
+
emit(above, inAbove, cutAbove, tri);
|
|
269
|
+
}
|
|
270
|
+
else if (pos === 0) {
|
|
271
|
+
emit(below, inBelow, cutBelow, tri);
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
// Crossing: walk the corners, dropping a cut point on every sign change.
|
|
275
|
+
const up = [];
|
|
276
|
+
const down = [];
|
|
277
|
+
for (let k = 0; k < 3; k++) {
|
|
278
|
+
const i = tri[k];
|
|
279
|
+
const j = tri[(k + 1) % 3];
|
|
280
|
+
const si = side[i];
|
|
281
|
+
const sj = side[j];
|
|
282
|
+
if (si >= 0)
|
|
283
|
+
up.push(i);
|
|
284
|
+
if (si <= 0)
|
|
285
|
+
down.push(i);
|
|
286
|
+
if ((si > 0 && sj < 0) || (si < 0 && sj > 0)) {
|
|
287
|
+
const c = [i, j];
|
|
288
|
+
up.push(c);
|
|
289
|
+
down.push(c);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
emit(above, inAbove, cutAbove, up);
|
|
293
|
+
emit(below, inBelow, cutBelow, down);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (opts.cap)
|
|
297
|
+
capCut(segments, nx, ny, nz, F, tangent, above, below, eps);
|
|
298
|
+
return { above: above.build(g.layout), below: below.build(g.layout) };
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Chain the cut segments into loops and triangulate each into both halves: facing `+n` on the
|
|
302
|
+
* below half, `-n` on the above half.
|
|
303
|
+
*/
|
|
304
|
+
function capCut(segments, nx, ny, nz, F, tangent, above, below, eps) {
|
|
305
|
+
// The plane basis: u, w with u × w = n.
|
|
306
|
+
const ax = Math.abs(nx) < 0.9 ? 1 : 0;
|
|
307
|
+
const ay = ax ? 0 : 1;
|
|
308
|
+
let ux = ay * nz;
|
|
309
|
+
let uy = -ax * nz;
|
|
310
|
+
let uz = ax * ny - ay * nx;
|
|
311
|
+
const ul = Math.hypot(ux, uy, uz);
|
|
312
|
+
ux /= ul;
|
|
313
|
+
uy /= ul;
|
|
314
|
+
uz /= ul;
|
|
315
|
+
const wx = ny * uz - nz * uy;
|
|
316
|
+
const wy = nz * ux - nx * uz;
|
|
317
|
+
const wz = nx * uy - ny * ux;
|
|
318
|
+
// Points welded by quantised position; each segment a directed link start → end.
|
|
319
|
+
const q = 1 / (eps * 10);
|
|
320
|
+
const key = (o) => `${Math.round(segments[o] * q)},${Math.round(segments[o + 1] * q)},${Math.round(segments[o + 2] * q)}`;
|
|
321
|
+
const ids = new Map();
|
|
322
|
+
const pts = [];
|
|
323
|
+
const idOf = (o) => {
|
|
324
|
+
const k = key(o);
|
|
325
|
+
let id = ids.get(k);
|
|
326
|
+
if (id === undefined) {
|
|
327
|
+
id = ids.size;
|
|
328
|
+
ids.set(k, id);
|
|
329
|
+
pts.push(segments[o], segments[o + 1], segments[o + 2]);
|
|
330
|
+
}
|
|
331
|
+
return id;
|
|
332
|
+
};
|
|
333
|
+
// Opposite segments cancel (an edge between a wall and a face lying in the plane).
|
|
334
|
+
const links = new Map();
|
|
335
|
+
for (let s = 0; s < segments.length; s += 6) {
|
|
336
|
+
const a = idOf(s);
|
|
337
|
+
const b = idOf(s + 3);
|
|
338
|
+
if (a === b)
|
|
339
|
+
continue;
|
|
340
|
+
const back = `${b}>${a}`;
|
|
341
|
+
const n = links.get(back) ?? 0;
|
|
342
|
+
if (n > 0)
|
|
343
|
+
links.set(back, n - 1);
|
|
344
|
+
else
|
|
345
|
+
links.set(`${a}>${b}`, (links.get(`${a}>${b}`) ?? 0) + 1);
|
|
346
|
+
}
|
|
347
|
+
const nextOf = new Map();
|
|
348
|
+
for (const [k, n] of links) {
|
|
349
|
+
if (n <= 0)
|
|
350
|
+
continue;
|
|
351
|
+
const [a, b] = k.split('>').map(Number);
|
|
352
|
+
nextOf.set(a, b);
|
|
353
|
+
}
|
|
354
|
+
const used = new Set();
|
|
355
|
+
const vert = new Float32Array(F);
|
|
356
|
+
for (const start of [...nextOf.keys()].sort((a, b) => a - b)) {
|
|
357
|
+
if (used.has(start))
|
|
358
|
+
continue;
|
|
359
|
+
const loop = [];
|
|
360
|
+
let p = start;
|
|
361
|
+
while (p !== undefined && !used.has(p)) {
|
|
362
|
+
used.add(p);
|
|
363
|
+
loop.push(p);
|
|
364
|
+
p = nextOf.get(p);
|
|
365
|
+
}
|
|
366
|
+
if (p !== start || loop.length < 3)
|
|
367
|
+
continue; // open chain: nothing to close
|
|
368
|
+
const profile = [];
|
|
369
|
+
for (const id of loop) {
|
|
370
|
+
const x = pts[id * 3];
|
|
371
|
+
const y = pts[id * 3 + 1];
|
|
372
|
+
const z = pts[id * 3 + 2];
|
|
373
|
+
profile.push(x * ux + y * uy + z * uz, x * wx + y * wy + z * wz);
|
|
374
|
+
}
|
|
375
|
+
const tris = triangulate(profile);
|
|
376
|
+
for (const [part, sign] of [
|
|
377
|
+
[below, 1],
|
|
378
|
+
[above, -1],
|
|
379
|
+
]) {
|
|
380
|
+
const base = part.verts.length / F;
|
|
381
|
+
for (let k = 0; k < loop.length; k++) {
|
|
382
|
+
const id = loop[k];
|
|
383
|
+
vert.fill(0);
|
|
384
|
+
vert[0] = pts[id * 3];
|
|
385
|
+
vert[1] = pts[id * 3 + 1];
|
|
386
|
+
vert[2] = pts[id * 3 + 2];
|
|
387
|
+
vert[3] = nx * sign;
|
|
388
|
+
vert[4] = ny * sign;
|
|
389
|
+
vert[5] = nz * sign;
|
|
390
|
+
vert[6] = profile[k * 2];
|
|
391
|
+
vert[7] = profile[k * 2 + 1];
|
|
392
|
+
vert[8] = vert[9] = vert[10] = vert[11] = 1;
|
|
393
|
+
if (tangent) {
|
|
394
|
+
vert[12] = ux * sign;
|
|
395
|
+
vert[13] = uy * sign;
|
|
396
|
+
vert[14] = uz * sign;
|
|
397
|
+
vert[15] = 1;
|
|
398
|
+
}
|
|
399
|
+
part.add(vert, 0);
|
|
400
|
+
}
|
|
401
|
+
// `triangulate` winds counter-clockwise in (u, w), which faces +n.
|
|
402
|
+
for (let t = 0; t < tris.length; t += 3) {
|
|
403
|
+
const a = base + tris[t];
|
|
404
|
+
const b = base + tris[t + 1];
|
|
405
|
+
const c = base + tris[t + 2];
|
|
406
|
+
if (sign > 0)
|
|
407
|
+
part.idx.push(a, b, c);
|
|
408
|
+
else
|
|
409
|
+
part.idx.push(a, c, b);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shapes swept from 2D profiles, all in `VERTEX_LAYOUT_3D`: `extrude` (a closed outline pushed
|
|
3
|
+
* along +z with capped, optionally bevelled ends), `lathe` (an open profile revolved around +y),
|
|
4
|
+
* `sweep` (a closed outline carried along a 3D path with rotation-minimising or Frenet frames),
|
|
5
|
+
* `tube` (a circle swept) and `polygon` (a flat triangulated outline facing +y).
|
|
6
|
+
*
|
|
7
|
+
* Every surface is wound counter-clockwise from outside with u along the outline and v along the
|
|
8
|
+
* sweep, so the tangent frame `computeTangents` derives is right-handed (handedness +1) throughout.
|
|
9
|
+
* Outlines are `Profile2D` (x, y pairs, counter-clockwise; clockwise is reversed on entry).
|
|
10
|
+
*/
|
|
11
|
+
import { type Geometry, type GeometryOptions } from './geometry.js';
|
|
12
|
+
import { type Profile2D } from './triangulate.js';
|
|
13
|
+
export type { Profile2D } from './triangulate.js';
|
|
14
|
+
export interface ExtrudeOptions extends GeometryOptions {
|
|
15
|
+
/** Extent along z, centred on the origin. Default 1. */
|
|
16
|
+
depth?: number;
|
|
17
|
+
/** Rows along the depth (≥ 1). Default 1. */
|
|
18
|
+
segments?: number;
|
|
19
|
+
/** Close both ends with triangulated caps. Default true. */
|
|
20
|
+
caps?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* A 45° chamfer of this size between each cap and the sides: the caps are inset by it along
|
|
23
|
+
* the outline's mitred normals and the sides shortened by it at each end. Default 0 (none);
|
|
24
|
+
* needs `caps`. Keep it below half the depth and the outline's narrowest feature.
|
|
25
|
+
*/
|
|
26
|
+
bevel?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A closed outline pushed along z from -depth/2 to +depth/2: flat side normals (two vertices per
|
|
30
|
+
* outline point per row), ear-clipped caps facing ±z, an optional 45° bevel. Side u runs around
|
|
31
|
+
* the outline by arc length (0 at the first point) and v along z (0 at the back); cap uvs span
|
|
32
|
+
* the outline's box in 0..1 (the back cap mirrored in u).
|
|
33
|
+
*/
|
|
34
|
+
export declare function extrude(profile: Profile2D, opts?: ExtrudeOptions): Geometry;
|
|
35
|
+
export interface LatheOptions extends GeometryOptions {
|
|
36
|
+
/** Steps around the axis (≥ 3). Default 24. */
|
|
37
|
+
segments?: number;
|
|
38
|
+
/** Angle swept, radians. Default 2π (closed ring); less leaves the ends open. */
|
|
39
|
+
angle?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* An open profile of (radius, y) points, ordered along the surface, revolved around +y: smooth
|
|
43
|
+
* normals (adjacent edge normals averaged, outward for a profile traced bottom to top), u around
|
|
44
|
+
* (0 at +z, as `cylinder`), v along the profile by arc length. A zero radius makes a pole.
|
|
45
|
+
*/
|
|
46
|
+
export declare function lathe(profile: Profile2D, opts?: LatheOptions): Geometry;
|
|
47
|
+
export interface SweepOptions extends GeometryOptions {
|
|
48
|
+
/** The path loops: the last ring joins the first and no end is left open. Default false. */
|
|
49
|
+
closed?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* How the profile's plane turns along the path: `'rmf'` (rotation-minimising frames by double
|
|
52
|
+
* reflection, no twist, the default) or `'frenet'` (the curvature direction, which flips at
|
|
53
|
+
* inflections and is undefined on straight runs, where the previous frame is kept).
|
|
54
|
+
*/
|
|
55
|
+
frames?: 'frenet' | 'rmf';
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A closed outline carried along `path` (x, y, z triples, at least 2 points; the first and last
|
|
59
|
+
* point of a closed path are distinct). Each path point gets a ring of the outline in its frame
|
|
60
|
+
* (outline x along the frame's normal, y along its binormal), smooth normals across the outline,
|
|
61
|
+
* u around the outline by arc length, v along the path by point index. A closed sweep spreads the
|
|
62
|
+
* frame's end-to-start twist over the rings so the seam matches.
|
|
63
|
+
*/
|
|
64
|
+
export declare function sweep(profile: Profile2D, path: ArrayLike<number>, opts?: SweepOptions): Geometry;
|
|
65
|
+
export interface TubeOptions extends SweepOptions {
|
|
66
|
+
/** Radius of the circular section. Default 0.1. */
|
|
67
|
+
radius?: number;
|
|
68
|
+
/** Points around the section (≥ 3). Default 12. */
|
|
69
|
+
segments?: number;
|
|
70
|
+
}
|
|
71
|
+
/** `sweep` of a circle: a round tube along `path` (`SweepOptions` apply). */
|
|
72
|
+
export declare function tube(path: ArrayLike<number>, opts?: TubeOptions): Geometry;
|
|
73
|
+
export interface PolygonOptions extends GeometryOptions {
|
|
74
|
+
/** Height of the plane. Default 0. */
|
|
75
|
+
y?: number;
|
|
76
|
+
/** Also draw the underside (its own vertices, facing -y). Default false. */
|
|
77
|
+
doubleSided?: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A flat outline in the xz plane facing +y: outline x → x, outline y → -z (so a counter-clockwise
|
|
81
|
+
* outline stays counter-clockwise seen from above), ear-clipped, uv the outline's box in 0..1.
|
|
82
|
+
*/
|
|
83
|
+
export declare function polygon(points: Profile2D, opts?: PolygonOptions): Geometry;
|