@3driseai/3drise-viewer 0.1.27 → 0.1.29
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/dist/animationsV2/ClipPlayer.d.ts.map +1 -1
- package/dist/animationsV2/ClipPlayer.js +13 -9
- package/dist/animationsV2/ClipsRuntime.d.ts +44 -3
- package/dist/animationsV2/ClipsRuntime.d.ts.map +1 -1
- package/dist/animationsV2/ClipsRuntime.js +173 -55
- package/dist/animationsV2/appliers.d.ts.map +1 -1
- package/dist/animationsV2/appliers.js +21 -5
- package/dist/animationsV2/index.d.ts +1 -1
- package/dist/animationsV2/index.d.ts.map +1 -1
- package/dist/animationsV2/normalize.d.ts.map +1 -1
- package/dist/animationsV2/normalize.js +7 -3
- package/dist/animationsV2/sequenceUtils.d.ts +44 -6
- package/dist/animationsV2/sequenceUtils.d.ts.map +1 -1
- package/dist/animationsV2/sequenceUtils.js +58 -12
- package/dist/animationsV2/types.d.ts +22 -12
- package/dist/animationsV2/types.d.ts.map +1 -1
- package/dist/api/sceneHandle.d.ts +35 -1
- package/dist/api/sceneHandle.d.ts.map +1 -1
- package/dist/api/sceneHandle.js +88 -17
- package/dist/components/AdvancedGrid.d.ts +1 -5
- package/dist/components/AdvancedGrid.d.ts.map +1 -1
- package/dist/components/AdvancedGrid.js +6 -35
- package/dist/components/AnimatedObject.d.ts.map +1 -1
- package/dist/components/AnimatedObject.js +9 -4
- package/dist/components/ApollonianGrid.d.ts +25 -0
- package/dist/components/ApollonianGrid.d.ts.map +1 -0
- package/dist/components/ApollonianGrid.js +55 -0
- package/dist/components/ChladniGrid.d.ts +1 -1
- package/dist/components/ChladniGrid.d.ts.map +1 -1
- package/dist/components/ChladniGrid.js +6 -35
- package/dist/components/CircuitGrid.d.ts +1 -1
- package/dist/components/CircuitGrid.d.ts.map +1 -1
- package/dist/components/CircuitGrid.js +6 -34
- package/dist/components/ConformalGrid.d.ts +25 -0
- package/dist/components/ConformalGrid.d.ts.map +1 -0
- package/dist/components/ConformalGrid.js +66 -0
- package/dist/components/ContourGrid.d.ts +1 -1
- package/dist/components/ContourGrid.d.ts.map +1 -1
- package/dist/components/ContourGrid.js +6 -34
- package/dist/components/CustomPrimitive.js +1 -1
- package/dist/components/EnvironmentObject.d.ts.map +1 -1
- package/dist/components/EnvironmentObject.js +9 -7
- package/dist/components/FlowNetGrid.d.ts +1 -1
- package/dist/components/FlowNetGrid.d.ts.map +1 -1
- package/dist/components/FlowNetGrid.js +6 -34
- package/dist/components/FractalGrid.d.ts +1 -1
- package/dist/components/FractalGrid.d.ts.map +1 -1
- package/dist/components/FractalGrid.js +6 -37
- package/dist/components/Galaxy.d.ts.map +1 -1
- package/dist/components/Galaxy.js +9 -23
- package/dist/components/GirihGrid.d.ts +1 -1
- package/dist/components/GirihGrid.d.ts.map +1 -1
- package/dist/components/GirihGrid.js +6 -35
- package/dist/components/GravWaveGrid.d.ts +1 -1
- package/dist/components/GravWaveGrid.d.ts.map +1 -1
- package/dist/components/GravWaveGrid.js +6 -35
- package/dist/components/GridsGenerator.d.ts +2 -2
- package/dist/components/GridsGenerator.d.ts.map +1 -1
- package/dist/components/GridsGenerator.js +21 -0
- package/dist/components/HexGrid.d.ts +1 -5
- package/dist/components/HexGrid.d.ts.map +1 -1
- package/dist/components/HexGrid.js +6 -36
- package/dist/components/HilbertGrid.d.ts +25 -0
- package/dist/components/HilbertGrid.d.ts.map +1 -0
- package/dist/components/HilbertGrid.js +66 -0
- package/dist/components/HyperbolicGrid.d.ts +1 -1
- package/dist/components/HyperbolicGrid.d.ts.map +1 -1
- package/dist/components/HyperbolicGrid.js +6 -34
- package/dist/components/LandObject.d.ts +9 -0
- package/dist/components/LandObject.d.ts.map +1 -0
- package/dist/components/LandObject.js +15 -0
- package/dist/components/LensingGrid.d.ts +25 -0
- package/dist/components/LensingGrid.d.ts.map +1 -0
- package/dist/components/LensingGrid.js +55 -0
- package/dist/components/LightsManager.d.ts.map +1 -1
- package/dist/components/LightsManager.js +8 -0
- package/dist/components/ModelBoundary.d.ts +2 -0
- package/dist/components/ModelBoundary.d.ts.map +1 -1
- package/dist/components/ModelBoundary.js +3 -0
- package/dist/components/ModelPrimitive.d.ts.map +1 -1
- package/dist/components/ModelPrimitive.js +6 -0
- package/dist/components/MoireGrid.d.ts +1 -1
- package/dist/components/MoireGrid.d.ts.map +1 -1
- package/dist/components/MoireGrid.js +6 -35
- package/dist/components/MoonDisc.d.ts +11 -0
- package/dist/components/MoonDisc.d.ts.map +1 -0
- package/dist/components/MoonDisc.js +128 -0
- package/dist/components/ObjectNode.d.ts.map +1 -1
- package/dist/components/ObjectNode.js +15 -4
- package/dist/components/ObjectsRenderer.d.ts.map +1 -1
- package/dist/components/ObjectsRenderer.js +7 -5
- package/dist/components/OceanBuilder.d.ts.map +1 -1
- package/dist/components/OceanBuilder.js +2 -0
- package/dist/components/ParastichyGrid.d.ts +25 -0
- package/dist/components/ParastichyGrid.d.ts.map +1 -0
- package/dist/components/ParastichyGrid.js +55 -0
- package/dist/components/PhyllotaxisGrid.d.ts +25 -0
- package/dist/components/PhyllotaxisGrid.d.ts.map +1 -0
- package/dist/components/PhyllotaxisGrid.js +66 -0
- package/dist/components/ProjectLoader.d.ts +5 -3
- package/dist/components/ProjectLoader.d.ts.map +1 -1
- package/dist/components/ProjectLoader.js +6 -3
- package/dist/components/QuasiGrid.d.ts +1 -1
- package/dist/components/QuasiGrid.d.ts.map +1 -1
- package/dist/components/QuasiGrid.js +6 -33
- package/dist/components/RadarGrid.d.ts +1 -1
- package/dist/components/RadarGrid.d.ts.map +1 -1
- package/dist/components/RadarGrid.js +6 -34
- package/dist/components/ReactionDiffusionGrid.d.ts +1 -1
- package/dist/components/ReactionDiffusionGrid.d.ts.map +1 -1
- package/dist/components/ReactionDiffusionGrid.js +6 -35
- package/dist/components/SceneBuilder.d.ts +25 -3
- package/dist/components/SceneBuilder.d.ts.map +1 -1
- package/dist/components/SceneBuilder.js +68 -38
- package/dist/components/SkyController.d.ts +25 -1
- package/dist/components/SkyController.d.ts.map +1 -1
- package/dist/components/SkyController.js +189 -130
- package/dist/components/SkyMesh.d.ts.map +1 -1
- package/dist/components/SkyMesh.js +26 -1
- package/dist/components/SkyStars.d.ts +11 -0
- package/dist/components/SkyStars.d.ts.map +1 -0
- package/dist/components/SkyStars.js +187 -0
- package/dist/components/SkySystem.d.ts +3 -3
- package/dist/components/SkySystem.d.ts.map +1 -1
- package/dist/components/SkySystem.js +8 -2
- package/dist/components/Sun.d.ts +15 -1
- package/dist/components/Sun.d.ts.map +1 -1
- package/dist/components/Sun.js +64 -3
- package/dist/components/SunLight.d.ts +6 -1
- package/dist/components/SunLight.d.ts.map +1 -1
- package/dist/components/SunLight.js +96 -44
- package/dist/components/TerrainBuilder.d.ts.map +1 -1
- package/dist/components/TerrainBuilder.js +2 -0
- package/dist/components/TextGenerator.d.ts +9 -0
- package/dist/components/TextGenerator.d.ts.map +1 -0
- package/dist/components/TextGenerator.js +29 -0
- package/dist/components/TruchetGrid.d.ts +25 -0
- package/dist/components/TruchetGrid.d.ts.map +1 -0
- package/dist/components/TruchetGrid.js +55 -0
- package/dist/components/VoronoiGrid.d.ts +1 -1
- package/dist/components/VoronoiGrid.d.ts.map +1 -1
- package/dist/components/VoronoiGrid.js +6 -33
- package/dist/components/WallpaperGrid.d.ts +1 -1
- package/dist/components/WallpaperGrid.d.ts.map +1 -1
- package/dist/components/WallpaperGrid.js +6 -35
- package/dist/components/environment/Rain.d.ts +15 -0
- package/dist/components/environment/Rain.d.ts.map +1 -0
- package/dist/components/environment/Rain.js +110 -0
- package/dist/components/environment/Rainbow.d.ts +20 -0
- package/dist/components/environment/Rainbow.d.ts.map +1 -0
- package/dist/components/environment/Rainbow.js +974 -0
- package/dist/components/environment/Sandstorm.d.ts +20 -0
- package/dist/components/environment/Sandstorm.d.ts.map +1 -0
- package/dist/components/environment/Sandstorm.js +776 -0
- package/dist/components/environment/Snow.d.ts +20 -0
- package/dist/components/environment/Snow.d.ts.map +1 -0
- package/dist/components/environment/Snow.js +609 -0
- package/dist/components/environment/Thunderstorm.d.ts +20 -0
- package/dist/components/environment/Thunderstorm.d.ts.map +1 -0
- package/dist/components/environment/Thunderstorm.js +731 -0
- package/dist/components/environment/Tornado.d.ts +20 -0
- package/dist/components/environment/Tornado.d.ts.map +1 -0
- package/dist/components/environment/Tornado.js +762 -0
- package/dist/components/environment/index.d.ts +13 -0
- package/dist/components/environment/index.d.ts.map +1 -0
- package/dist/components/environment/index.js +7 -0
- package/dist/components/index.d.ts +24 -10
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +15 -6
- package/dist/components/land/LandPatch.d.ts +15 -0
- package/dist/components/land/LandPatch.d.ts.map +1 -0
- package/dist/components/land/LandPatch.js +170 -0
- package/dist/components/land/index.d.ts +3 -0
- package/dist/components/land/index.d.ts.map +1 -0
- package/dist/components/land/index.js +1 -0
- package/dist/components/space/Earth.d.ts +16 -0
- package/dist/components/space/Earth.d.ts.map +1 -0
- package/dist/components/space/Earth.js +75 -0
- package/dist/components/space/ShootingStar.d.ts +21 -0
- package/dist/components/space/ShootingStar.d.ts.map +1 -0
- package/dist/components/space/ShootingStar.js +101 -0
- package/dist/components/space/ShootingStars.d.ts +16 -0
- package/dist/components/space/ShootingStars.d.ts.map +1 -0
- package/dist/components/space/ShootingStars.js +71 -0
- package/dist/components/space/SolarSystem.d.ts +16 -0
- package/dist/components/space/SolarSystem.d.ts.map +1 -0
- package/dist/components/space/SolarSystem.js +141 -0
- package/dist/components/space/Stars.d.ts +20 -0
- package/dist/components/space/Stars.d.ts.map +1 -0
- package/dist/components/space/Stars.js +160 -0
- package/dist/components/space/index.d.ts +11 -0
- package/dist/components/space/index.d.ts.map +1 -0
- package/dist/components/space/index.js +8 -0
- package/dist/components/terrain/TerrainSurface.d.ts.map +1 -1
- package/dist/components/terrain/TerrainSurface.js +27 -3
- package/dist/components/terrain/types.d.ts +5 -1
- package/dist/components/terrain/types.d.ts.map +1 -1
- package/dist/components/text/BurnAwayText.d.ts +15 -0
- package/dist/components/text/BurnAwayText.d.ts.map +1 -0
- package/dist/components/text/BurnAwayText.js +4 -0
- package/dist/components/text/ChalkboardText.d.ts +15 -0
- package/dist/components/text/ChalkboardText.d.ts.map +1 -0
- package/dist/components/text/ChalkboardText.js +4 -0
- package/dist/components/text/ConstellationText.d.ts +15 -0
- package/dist/components/text/ConstellationText.d.ts.map +1 -0
- package/dist/components/text/ConstellationText.js +4 -0
- package/dist/components/text/EmbroideryText.d.ts +15 -0
- package/dist/components/text/EmbroideryText.d.ts.map +1 -0
- package/dist/components/text/EmbroideryText.js +4 -0
- package/dist/components/text/FourierSketchText.d.ts +15 -0
- package/dist/components/text/FourierSketchText.d.ts.map +1 -0
- package/dist/components/text/FourierSketchText.js +4 -0
- package/dist/components/text/FrostGrowthText.d.ts +15 -0
- package/dist/components/text/FrostGrowthText.d.ts.map +1 -0
- package/dist/components/text/FrostGrowthText.js +4 -0
- package/dist/components/text/HandwritingText.d.ts +15 -0
- package/dist/components/text/HandwritingText.d.ts.map +1 -0
- package/dist/components/text/HandwritingText.js +4 -0
- package/dist/components/text/InkBleedText.d.ts +15 -0
- package/dist/components/text/InkBleedText.d.ts.map +1 -0
- package/dist/components/text/InkBleedText.js +4 -0
- package/dist/components/text/LightPaintingText.d.ts +15 -0
- package/dist/components/text/LightPaintingText.d.ts.map +1 -0
- package/dist/components/text/LightPaintingText.js +4 -0
- package/dist/components/text/LiquidMetalText.d.ts +15 -0
- package/dist/components/text/LiquidMetalText.d.ts.map +1 -0
- package/dist/components/text/LiquidMetalText.js +4 -0
- package/dist/components/text/NeonTubeText.d.ts +15 -0
- package/dist/components/text/NeonTubeText.d.ts.map +1 -0
- package/dist/components/text/NeonTubeText.js +4 -0
- package/dist/components/text/PlasmaDischargeText.d.ts +15 -0
- package/dist/components/text/PlasmaDischargeText.d.ts.map +1 -0
- package/dist/components/text/PlasmaDischargeText.js +4 -0
- package/dist/components/text/TextObjectView.d.ts +12 -0
- package/dist/components/text/TextObjectView.d.ts.map +1 -0
- package/dist/components/text/TextObjectView.js +11 -0
- package/dist/components/text/engine/fieldkit.d.ts +24 -0
- package/dist/components/text/engine/fieldkit.d.ts.map +1 -0
- package/dist/components/text/engine/fieldkit.js +201 -0
- package/dist/components/text/engine/glyphs.d.ts +19 -0
- package/dist/components/text/engine/glyphs.d.ts.map +1 -0
- package/dist/components/text/engine/glyphs.js +269 -0
- package/dist/components/text/engine/looks/burnAway.d.ts +144 -0
- package/dist/components/text/engine/looks/burnAway.d.ts.map +1 -0
- package/dist/components/text/engine/looks/burnAway.js +593 -0
- package/dist/components/text/engine/looks/chalkboard.d.ts +135 -0
- package/dist/components/text/engine/looks/chalkboard.d.ts.map +1 -0
- package/dist/components/text/engine/looks/chalkboard.js +426 -0
- package/dist/components/text/engine/looks/constellation.d.ts +111 -0
- package/dist/components/text/engine/looks/constellation.d.ts.map +1 -0
- package/dist/components/text/engine/looks/constellation.js +496 -0
- package/dist/components/text/engine/looks/embroidery.d.ts +165 -0
- package/dist/components/text/engine/looks/embroidery.d.ts.map +1 -0
- package/dist/components/text/engine/looks/embroidery.js +645 -0
- package/dist/components/text/engine/looks/frostGrowth.d.ts +109 -0
- package/dist/components/text/engine/looks/frostGrowth.d.ts.map +1 -0
- package/dist/components/text/engine/looks/frostGrowth.js +727 -0
- package/dist/components/text/engine/looks/index.d.ts +2 -0
- package/dist/components/text/engine/looks/index.d.ts.map +1 -0
- package/dist/components/text/engine/looks/index.js +48 -0
- package/dist/components/text/engine/looks/inkBleed.d.ts +103 -0
- package/dist/components/text/engine/looks/inkBleed.d.ts.map +1 -0
- package/dist/components/text/engine/looks/inkBleed.js +590 -0
- package/dist/components/text/engine/looks/lightPainting.d.ts +132 -0
- package/dist/components/text/engine/looks/lightPainting.d.ts.map +1 -0
- package/dist/components/text/engine/looks/lightPainting.js +567 -0
- package/dist/components/text/engine/looks/liquidMetal.d.ts +135 -0
- package/dist/components/text/engine/looks/liquidMetal.d.ts.map +1 -0
- package/dist/components/text/engine/looks/liquidMetal.js +655 -0
- package/dist/components/text/engine/looks/plasmaDischarge.d.ts +126 -0
- package/dist/components/text/engine/looks/plasmaDischarge.d.ts.map +1 -0
- package/dist/components/text/engine/looks/plasmaDischarge.js +763 -0
- package/dist/components/text/engine/methods.d.ts +19 -0
- package/dist/components/text/engine/methods.d.ts.map +1 -0
- package/dist/components/text/engine/methods.js +126 -0
- package/dist/components/text/engine/playback.d.ts +40 -0
- package/dist/components/text/engine/playback.d.ts.map +1 -0
- package/dist/components/text/engine/playback.js +114 -0
- package/dist/components/text/engine/ribbon.d.ts +58 -0
- package/dist/components/text/engine/ribbon.d.ts.map +1 -0
- package/dist/components/text/engine/ribbon.js +250 -0
- package/dist/components/text/engine/variants.d.ts +159 -0
- package/dist/components/text/engine/variants.d.ts.map +1 -0
- package/dist/components/text/engine/variants.js +378 -0
- package/dist/components/text/fonts/architects-daughter.outline.d.ts +3 -0
- package/dist/components/text/fonts/architects-daughter.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/architects-daughter.outline.js +4 -0
- package/dist/components/text/fonts/architects-daughter.strokes.d.ts +3 -0
- package/dist/components/text/fonts/architects-daughter.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/architects-daughter.strokes.js +4 -0
- package/dist/components/text/fonts/caveat.outline.d.ts +3 -0
- package/dist/components/text/fonts/caveat.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/caveat.outline.js +4 -0
- package/dist/components/text/fonts/caveat.strokes.d.ts +3 -0
- package/dist/components/text/fonts/caveat.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/caveat.strokes.js +4 -0
- package/dist/components/text/fonts/courgette.outline.d.ts +3 -0
- package/dist/components/text/fonts/courgette.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/courgette.outline.js +4 -0
- package/dist/components/text/fonts/courgette.strokes.d.ts +3 -0
- package/dist/components/text/fonts/courgette.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/courgette.strokes.js +4 -0
- package/dist/components/text/fonts/dancing-script.outline.d.ts +3 -0
- package/dist/components/text/fonts/dancing-script.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/dancing-script.outline.js +4 -0
- package/dist/components/text/fonts/dancing-script.strokes.d.ts +3 -0
- package/dist/components/text/fonts/dancing-script.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/dancing-script.strokes.js +4 -0
- package/dist/components/text/fonts/gochi-hand.outline.d.ts +3 -0
- package/dist/components/text/fonts/gochi-hand.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/gochi-hand.outline.js +4 -0
- package/dist/components/text/fonts/gochi-hand.strokes.d.ts +3 -0
- package/dist/components/text/fonts/gochi-hand.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/gochi-hand.strokes.js +4 -0
- package/dist/components/text/fonts/handlee.outline.d.ts +3 -0
- package/dist/components/text/fonts/handlee.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/handlee.outline.js +4 -0
- package/dist/components/text/fonts/handlee.strokes.d.ts +3 -0
- package/dist/components/text/fonts/handlee.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/handlee.strokes.js +4 -0
- package/dist/components/text/fonts/index.d.ts +5 -0
- package/dist/components/text/fonts/index.d.ts.map +1 -0
- package/dist/components/text/fonts/index.js +44 -0
- package/dist/components/text/fonts/indie-flower.outline.d.ts +3 -0
- package/dist/components/text/fonts/indie-flower.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/indie-flower.outline.js +4 -0
- package/dist/components/text/fonts/indie-flower.strokes.d.ts +3 -0
- package/dist/components/text/fonts/indie-flower.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/indie-flower.strokes.js +4 -0
- package/dist/components/text/fonts/kalam.outline.d.ts +3 -0
- package/dist/components/text/fonts/kalam.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/kalam.outline.js +4 -0
- package/dist/components/text/fonts/kalam.strokes.d.ts +3 -0
- package/dist/components/text/fonts/kalam.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/kalam.strokes.js +4 -0
- package/dist/components/text/fonts/kaushan-script.outline.d.ts +3 -0
- package/dist/components/text/fonts/kaushan-script.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/kaushan-script.outline.js +4 -0
- package/dist/components/text/fonts/kaushan-script.strokes.d.ts +3 -0
- package/dist/components/text/fonts/kaushan-script.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/kaushan-script.strokes.js +4 -0
- package/dist/components/text/fonts/mynerve.outline.d.ts +3 -0
- package/dist/components/text/fonts/mynerve.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/mynerve.outline.js +4 -0
- package/dist/components/text/fonts/mynerve.strokes.d.ts +3 -0
- package/dist/components/text/fonts/mynerve.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/mynerve.strokes.js +4 -0
- package/dist/components/text/fonts/nanum-pen-script.outline.d.ts +3 -0
- package/dist/components/text/fonts/nanum-pen-script.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/nanum-pen-script.outline.js +4 -0
- package/dist/components/text/fonts/nanum-pen-script.strokes.d.ts +3 -0
- package/dist/components/text/fonts/nanum-pen-script.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/nanum-pen-script.strokes.js +4 -0
- package/dist/components/text/fonts/pacifico.outline.d.ts +3 -0
- package/dist/components/text/fonts/pacifico.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/pacifico.outline.js +4 -0
- package/dist/components/text/fonts/pacifico.strokes.d.ts +3 -0
- package/dist/components/text/fonts/pacifico.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/pacifico.strokes.js +4 -0
- package/dist/components/text/fonts/patrick-hand.outline.d.ts +3 -0
- package/dist/components/text/fonts/patrick-hand.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/patrick-hand.outline.js +4 -0
- package/dist/components/text/fonts/patrick-hand.strokes.d.ts +3 -0
- package/dist/components/text/fonts/patrick-hand.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/patrick-hand.strokes.js +4 -0
- package/dist/components/text/fonts/poppins.outline.d.ts +3 -0
- package/dist/components/text/fonts/poppins.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/poppins.outline.js +4 -0
- package/dist/components/text/fonts/poppins.strokes.d.ts +3 -0
- package/dist/components/text/fonts/poppins.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/poppins.strokes.js +4 -0
- package/dist/components/text/fonts/satisfy.outline.d.ts +3 -0
- package/dist/components/text/fonts/satisfy.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/satisfy.outline.js +4 -0
- package/dist/components/text/fonts/satisfy.strokes.d.ts +3 -0
- package/dist/components/text/fonts/satisfy.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/satisfy.strokes.js +4 -0
- package/dist/components/text/fonts/sriracha.outline.d.ts +3 -0
- package/dist/components/text/fonts/sriracha.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/sriracha.outline.js +4 -0
- package/dist/components/text/fonts/sriracha.strokes.d.ts +3 -0
- package/dist/components/text/fonts/sriracha.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/sriracha.strokes.js +4 -0
- package/dist/components/text/index.d.ts +27 -0
- package/dist/components/text/index.d.ts.map +1 -0
- package/dist/components/text/index.js +13 -0
- package/dist/components/text/useTextObject.d.ts +21 -0
- package/dist/components/text/useTextObject.d.ts.map +1 -0
- package/dist/components/text/useTextObject.js +118 -0
- package/dist/components/water/OceanSurface.d.ts.map +1 -1
- package/dist/components/water/OceanSurface.js +3 -1
- package/dist/components/water/WaterBody.d.ts.map +1 -1
- package/dist/components/water/WaterBody.js +3 -1
- package/dist/components/water/types.d.ts +5 -1
- package/dist/components/water/types.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useCloudSun.d.ts +9 -4
- package/dist/hooks/useCloudSun.d.ts.map +1 -1
- package/dist/hooks/useCloudSun.js +17 -7
- package/dist/hooks/useConfigLive.d.ts +3 -2
- package/dist/hooks/useConfigLive.d.ts.map +1 -1
- package/dist/hooks/useContinuousEffects.d.ts.map +1 -1
- package/dist/hooks/useContinuousEffects.js +4 -10
- package/dist/hooks/useEnvironmentProbe.d.ts +3 -22
- package/dist/hooks/useEnvironmentProbe.d.ts.map +1 -1
- package/dist/hooks/useEnvironmentProbe.js +47 -8
- package/dist/hooks/useGridSurface.d.ts +3 -10
- package/dist/hooks/useGridSurface.d.ts.map +1 -1
- package/dist/hooks/useGridSurface.js +5 -31
- package/dist/hooks/useInteraction.d.ts.map +1 -1
- package/dist/hooks/useInteraction.js +19 -72
- package/dist/hooks/useLightConfig.d.ts +2 -1
- package/dist/hooks/useLightConfig.d.ts.map +1 -1
- package/dist/hooks/useOceanMaterial.d.ts +6 -2
- package/dist/hooks/useOceanMaterial.d.ts.map +1 -1
- package/dist/hooks/useOceanMaterial.js +37 -2
- package/dist/hooks/useSkyLive.d.ts +23 -0
- package/dist/hooks/useSkyLive.d.ts.map +1 -0
- package/dist/hooks/useSkyLive.js +30 -0
- package/dist/hooks/useSkyUniforms.d.ts.map +1 -1
- package/dist/hooks/useSkyUniforms.js +2 -10
- package/dist/hooks/useTerrainLive.d.ts +3 -1
- package/dist/hooks/useTerrainLive.d.ts.map +1 -1
- package/dist/hooks/useTerrainTextures.d.ts +38 -0
- package/dist/hooks/useTerrainTextures.d.ts.map +1 -0
- package/dist/hooks/useTerrainTextures.js +149 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/operations/catalogue/blastOff.d.ts +3 -0
- package/dist/operations/catalogue/blastOff.d.ts.map +1 -0
- package/dist/operations/catalogue/blastOff.js +118 -0
- package/dist/operations/catalogue/bounce.d.ts +3 -0
- package/dist/operations/catalogue/bounce.d.ts.map +1 -0
- package/dist/operations/catalogue/bounce.js +34 -0
- package/dist/operations/catalogue/curlSmoke.d.ts.map +1 -1
- package/dist/operations/catalogue/curlSmoke.js +3 -1
- package/dist/operations/catalogue/dissolve.d.ts.map +1 -1
- package/dist/operations/catalogue/dissolve.js +2 -1
- package/dist/operations/catalogue/driftUp.d.ts +3 -0
- package/dist/operations/catalogue/driftUp.d.ts.map +1 -0
- package/dist/operations/catalogue/driftUp.js +57 -0
- package/dist/operations/catalogue/emberAsh.d.ts.map +1 -1
- package/dist/operations/catalogue/emberAsh.js +2 -1
- package/dist/operations/catalogue/flip.d.ts.map +1 -1
- package/dist/operations/catalogue/flip.js +19 -9
- package/dist/operations/catalogue/float.d.ts +3 -0
- package/dist/operations/catalogue/float.d.ts.map +1 -0
- package/dist/operations/catalogue/float.js +39 -0
- package/dist/operations/catalogue/flyBy.d.ts +3 -0
- package/dist/operations/catalogue/flyBy.d.ts.map +1 -0
- package/dist/operations/catalogue/flyBy.js +79 -0
- package/dist/operations/catalogue/frost.d.ts.map +1 -1
- package/dist/operations/catalogue/frost.js +10 -3
- package/dist/operations/catalogue/grow.d.ts +3 -0
- package/dist/operations/catalogue/grow.d.ts.map +1 -0
- package/dist/operations/catalogue/grow.js +19 -0
- package/dist/operations/catalogue/hologram.d.ts.map +1 -1
- package/dist/operations/catalogue/hologram.js +11 -5
- package/dist/operations/catalogue/jelly.d.ts.map +1 -1
- package/dist/operations/catalogue/jelly.js +18 -8
- package/dist/operations/catalogue/knockAway.d.ts +3 -0
- package/dist/operations/catalogue/knockAway.d.ts.map +1 -0
- package/dist/operations/catalogue/knockAway.js +74 -0
- package/dist/operations/catalogue/leafFall.d.ts +3 -0
- package/dist/operations/catalogue/leafFall.d.ts.map +1 -0
- package/dist/operations/catalogue/leafFall.js +74 -0
- package/dist/operations/catalogue/lidarScan.d.ts.map +1 -1
- package/dist/operations/catalogue/lidarScan.js +4 -1
- package/dist/operations/catalogue/metalize.d.ts.map +1 -1
- package/dist/operations/catalogue/metalize.js +8 -2
- package/dist/operations/catalogue/motionTrail.d.ts +6 -0
- package/dist/operations/catalogue/motionTrail.d.ts.map +1 -0
- package/dist/operations/catalogue/motionTrail.js +221 -0
- package/dist/operations/catalogue/petrify.d.ts.map +1 -1
- package/dist/operations/catalogue/petrify.js +9 -3
- package/dist/operations/catalogue/physicalExit.d.ts +55 -0
- package/dist/operations/catalogue/physicalExit.d.ts.map +1 -0
- package/dist/operations/catalogue/physicalExit.js +165 -0
- package/dist/operations/catalogue/physicalHeld.d.ts +41 -0
- package/dist/operations/catalogue/physicalHeld.d.ts.map +1 -0
- package/dist/operations/catalogue/physicalHeld.js +78 -0
- package/dist/operations/catalogue/physicalMix.d.ts +45 -0
- package/dist/operations/catalogue/physicalMix.d.ts.map +1 -0
- package/dist/operations/catalogue/physicalMix.js +144 -0
- package/dist/operations/catalogue/pop.d.ts +3 -0
- package/dist/operations/catalogue/pop.d.ts.map +1 -0
- package/dist/operations/catalogue/pop.js +44 -0
- package/dist/operations/catalogue/print3d.d.ts.map +1 -1
- package/dist/operations/catalogue/print3d.js +5 -1
- package/dist/operations/catalogue/pulse.d.ts +3 -0
- package/dist/operations/catalogue/pulse.d.ts.map +1 -0
- package/dist/operations/catalogue/pulse.js +29 -0
- package/dist/operations/catalogue/restPose.d.ts +5 -7
- package/dist/operations/catalogue/restPose.d.ts.map +1 -1
- package/dist/operations/catalogue/restPose.js +18 -48
- package/dist/operations/catalogue/rotate.d.ts +3 -0
- package/dist/operations/catalogue/rotate.d.ts.map +1 -0
- package/dist/operations/catalogue/rotate.js +49 -0
- package/dist/operations/catalogue/shake.d.ts +3 -0
- package/dist/operations/catalogue/shake.d.ts.map +1 -0
- package/dist/operations/catalogue/shake.js +31 -0
- package/dist/operations/catalogue/shatter.d.ts.map +1 -1
- package/dist/operations/catalogue/shatter.js +5 -1
- package/dist/operations/catalogue/slam.d.ts +3 -0
- package/dist/operations/catalogue/slam.d.ts.map +1 -0
- package/dist/operations/catalogue/slam.js +89 -0
- package/dist/operations/catalogue/slingshot.d.ts +3 -0
- package/dist/operations/catalogue/slingshot.d.ts.map +1 -0
- package/dist/operations/catalogue/slingshot.js +88 -0
- package/dist/operations/catalogue/spin.d.ts.map +1 -1
- package/dist/operations/catalogue/spin.js +24 -13
- package/dist/operations/catalogue/sway.d.ts +3 -0
- package/dist/operations/catalogue/sway.d.ts.map +1 -0
- package/dist/operations/catalogue/sway.js +23 -0
- package/dist/operations/catalogue/swirl.d.ts.map +1 -1
- package/dist/operations/catalogue/swirl.js +6 -5
- package/dist/operations/catalogue/trailCore.d.ts +89 -0
- package/dist/operations/catalogue/trailCore.d.ts.map +1 -0
- package/dist/operations/catalogue/trailCore.js +190 -0
- package/dist/operations/catalogue/trailGhosts.d.ts +5 -0
- package/dist/operations/catalogue/trailGhosts.d.ts.map +1 -0
- package/dist/operations/catalogue/trailGhosts.js +179 -0
- package/dist/operations/catalogue/trailStampStyles.d.ts +11 -0
- package/dist/operations/catalogue/trailStampStyles.d.ts.map +1 -0
- package/dist/operations/catalogue/trailStampStyles.js +479 -0
- package/dist/operations/catalogue/trailStamps.d.ts +57 -0
- package/dist/operations/catalogue/trailStamps.d.ts.map +1 -0
- package/dist/operations/catalogue/trailStamps.js +349 -0
- package/dist/operations/catalogue/trailStreaks.d.ts +3 -0
- package/dist/operations/catalogue/trailStreaks.d.ts.map +1 -0
- package/dist/operations/catalogue/trailStreaks.js +147 -0
- package/dist/operations/catalogue/transitionField.d.ts +30 -0
- package/dist/operations/catalogue/transitionField.d.ts.map +1 -1
- package/dist/operations/catalogue/transitionField.js +21 -0
- package/dist/operations/catalogue/turnAway.d.ts +3 -0
- package/dist/operations/catalogue/turnAway.d.ts.map +1 -0
- package/dist/operations/catalogue/turnAway.js +54 -0
- package/dist/operations/catalogue/vortexDrain.d.ts +3 -0
- package/dist/operations/catalogue/vortexDrain.d.ts.map +1 -0
- package/dist/operations/catalogue/vortexDrain.js +68 -0
- package/dist/operations/catalogue/warp.d.ts +3 -0
- package/dist/operations/catalogue/warp.d.ts.map +1 -0
- package/dist/operations/catalogue/warp.js +73 -0
- package/dist/operations/catalogue/whoosh.d.ts +3 -0
- package/dist/operations/catalogue/whoosh.d.ts.map +1 -0
- package/dist/operations/catalogue/whoosh.js +84 -0
- package/dist/operations/catalogue/wobble.d.ts +3 -0
- package/dist/operations/catalogue/wobble.d.ts.map +1 -0
- package/dist/operations/catalogue/wobble.js +23 -0
- package/dist/operations/clipPreview.d.ts +3 -0
- package/dist/operations/clipPreview.d.ts.map +1 -0
- package/dist/operations/clipPreview.js +20 -0
- package/dist/operations/groupFanout.d.ts +96 -0
- package/dist/operations/groupFanout.d.ts.map +1 -0
- package/dist/operations/groupFanout.js +365 -0
- package/dist/operations/groups.d.ts +20 -0
- package/dist/operations/groups.d.ts.map +1 -0
- package/dist/operations/groups.js +66 -0
- package/dist/operations/index.d.ts +5 -2
- package/dist/operations/index.d.ts.map +1 -1
- package/dist/operations/index.js +5 -2
- package/dist/operations/objectEffects.d.ts +161 -6
- package/dist/operations/objectEffects.d.ts.map +1 -1
- package/dist/operations/objectEffects.js +1091 -17
- package/dist/operations/registry.d.ts.map +1 -1
- package/dist/operations/registry.js +24 -2
- package/dist/operations/runtime.d.ts +57 -2
- package/dist/operations/runtime.d.ts.map +1 -1
- package/dist/operations/runtime.js +161 -18
- package/dist/operations/types.d.ts +60 -3
- package/dist/operations/types.d.ts.map +1 -1
- package/dist/operations/types.js +5 -1
- package/dist/operations/useObjectEffectLayers.d.ts +2 -2
- package/dist/operations/useObjectEffectLayers.d.ts.map +1 -1
- package/dist/operations/useObjectEffectLayers.js +31 -10
- package/dist/operations/usePresentedVisibility.d.ts +10 -0
- package/dist/operations/usePresentedVisibility.d.ts.map +1 -0
- package/dist/operations/usePresentedVisibility.js +53 -0
- package/dist/presets/terrainBiomes.d.ts +67 -0
- package/dist/presets/terrainBiomes.d.ts.map +1 -0
- package/dist/presets/terrainBiomes.js +294 -0
- package/dist/presets/terrainPresets.d.ts +6 -0
- package/dist/presets/terrainPresets.d.ts.map +1 -1
- package/dist/presets/terrainPresets.js +26 -38
- package/dist/shaders/glsl/oceanCore.glsl.d.ts +2 -2
- package/dist/shaders/glsl/oceanCore.glsl.d.ts.map +1 -1
- package/dist/shaders/glsl/oceanCore.glsl.js +17 -0
- package/dist/shaders/glsl/surfaceCore.glsl.d.ts +21 -0
- package/dist/shaders/glsl/surfaceCore.glsl.d.ts.map +1 -0
- package/dist/shaders/glsl/surfaceCore.glsl.js +120 -0
- package/dist/shaders/glsl/terrainCore.glsl.d.ts +16 -3
- package/dist/shaders/glsl/terrainCore.glsl.d.ts.map +1 -1
- package/dist/shaders/glsl/terrainCore.glsl.js +266 -20
- package/dist/shaders/ocean/OceanSurfaceMaterial.d.ts +2 -0
- package/dist/shaders/ocean/OceanSurfaceMaterial.d.ts.map +1 -1
- package/dist/shaders/ocean/OceanSurfaceMaterial.js +3 -0
- package/dist/shaders/terrain/TerrainMaterial.d.ts +17 -0
- package/dist/shaders/terrain/TerrainMaterial.d.ts.map +1 -1
- package/dist/shaders/terrain/TerrainMaterial.js +107 -8
- package/dist/triggers/engine.d.ts +44 -0
- package/dist/triggers/engine.d.ts.map +1 -0
- package/dist/triggers/engine.js +165 -0
- package/dist/triggers/hosts/actions.d.ts +8 -0
- package/dist/triggers/hosts/actions.d.ts.map +1 -0
- package/dist/triggers/hosts/actions.js +22 -0
- package/dist/triggers/hosts/interactions.d.ts +6 -0
- package/dist/triggers/hosts/interactions.d.ts.map +1 -0
- package/dist/triggers/hosts/interactions.js +4 -0
- package/dist/triggers/hosts/timelineCues.d.ts +2 -0
- package/dist/triggers/hosts/timelineCues.d.ts.map +1 -0
- package/dist/triggers/hosts/timelineCues.js +22 -0
- package/dist/triggers/index.d.ts +13 -0
- package/dist/triggers/index.d.ts.map +1 -0
- package/dist/triggers/index.js +9 -0
- package/dist/triggers/kinds/action.d.ts +2 -0
- package/dist/triggers/kinds/action.d.ts.map +1 -0
- package/dist/triggers/kinds/action.js +31 -0
- package/dist/triggers/kinds/animations.d.ts +2 -0
- package/dist/triggers/kinds/animations.d.ts.map +1 -0
- package/dist/triggers/kinds/animations.js +75 -0
- package/dist/triggers/kinds/effects.d.ts +2 -0
- package/dist/triggers/kinds/effects.d.ts.map +1 -0
- package/dist/triggers/kinds/effects.js +27 -0
- package/dist/triggers/kinds/index.d.ts +4 -0
- package/dist/triggers/kinds/index.d.ts.map +1 -0
- package/dist/triggers/kinds/index.js +4 -0
- package/dist/triggers/log.d.ts +21 -0
- package/dist/triggers/log.d.ts.map +1 -0
- package/dist/triggers/log.js +43 -0
- package/dist/triggers/readiness.d.ts +40 -0
- package/dist/triggers/readiness.d.ts.map +1 -0
- package/dist/triggers/readiness.js +158 -0
- package/dist/triggers/registry.d.ts +41 -0
- package/dist/triggers/registry.d.ts.map +1 -0
- package/dist/triggers/registry.js +7 -0
- package/dist/types/gridConfigs.d.ts +117 -19
- package/dist/types/gridConfigs.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/ui/UiAnchorUpdater.d.ts +10 -0
- package/dist/ui/UiAnchorUpdater.d.ts.map +1 -0
- package/dist/ui/UiAnchorUpdater.js +111 -0
- package/dist/ui/UiLayers.d.ts +20 -0
- package/dist/ui/UiLayers.d.ts.map +1 -0
- package/dist/ui/UiLayers.js +57 -0
- package/dist/ui/index.d.ts +9 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +6 -0
- package/dist/ui/uiAnchors.d.ts +21 -0
- package/dist/ui/uiAnchors.d.ts.map +1 -0
- package/dist/ui/uiAnchors.js +22 -0
- package/dist/ui/uiBaseStyles.d.ts +2 -0
- package/dist/ui/uiBaseStyles.d.ts.map +1 -0
- package/dist/ui/uiBaseStyles.js +100 -0
- package/dist/ui/uiBinder.d.ts +30 -0
- package/dist/ui/uiBinder.d.ts.map +1 -0
- package/dist/ui/uiBinder.js +344 -0
- package/dist/utils/configAnimations.d.ts.map +1 -1
- package/dist/utils/configAnimations.js +5 -1
- package/dist/utils/gridConfig.d.ts +1 -1
- package/dist/utils/gridConfig.d.ts.map +1 -1
- package/dist/utils/gridConfig.js +1 -1
- package/dist/utils/landPatch.d.ts +33 -0
- package/dist/utils/landPatch.d.ts.map +1 -0
- package/dist/utils/landPatch.js +114 -0
- package/dist/utils/renderedSky.d.ts +32 -0
- package/dist/utils/renderedSky.d.ts.map +1 -0
- package/dist/utils/renderedSky.js +57 -0
- package/dist/utils/skyMoon.d.ts +35 -0
- package/dist/utils/skyMoon.d.ts.map +1 -0
- package/dist/utils/skyMoon.js +41 -0
- package/dist/utils/terrainHeight.d.ts +4 -0
- package/dist/utils/terrainHeight.d.ts.map +1 -0
- package/dist/utils/terrainHeight.js +150 -0
- package/dist/utils/terrainTextureResolver.d.ts +18 -0
- package/dist/utils/terrainTextureResolver.d.ts.map +1 -0
- package/dist/utils/terrainTextureResolver.js +17 -0
- package/dist/utils/terrainUniforms.d.ts +17 -0
- package/dist/utils/terrainUniforms.d.ts.map +1 -1
- package/dist/utils/terrainUniforms.js +84 -0
- package/dist/utils/textureArrays.d.ts +29 -0
- package/dist/utils/textureArrays.d.ts.map +1 -0
- package/dist/utils/textureArrays.js +140 -0
- package/package.json +2 -2
|
@@ -0,0 +1,731 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from 'react';
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
import { useFrame } from '@react-three/fiber';
|
|
5
|
+
import { DEFAULT_ENVIRONMENT_OBJECTS, ENVIRONMENT_OBJECTS_ANIMATABLE } from '@3driseai/3drise-core';
|
|
6
|
+
import { withConfigDefaults } from '../../utils/configAnimations.js';
|
|
7
|
+
import { useObjectReady } from '../../hooks/useObjectReady.js';
|
|
8
|
+
import { useConfigDriver } from '../../hooks/useConfigDriver.js';
|
|
9
|
+
import { useCloudSun } from '../../hooks/useCloudSun.js';
|
|
10
|
+
import { stepPointerField, usePointerField } from '../../utils/pointerField.js';
|
|
11
|
+
// Generated from Claude outputs/environment-lab (common.mjs + thunderstorm.mjs, the approved lab modules)
|
|
12
|
+
// by gen_family.mjs — edit there and regenerate.
|
|
13
|
+
// ---------------------------------------------------------------------------- shared core
|
|
14
|
+
// Shared core of the environment objects (lab). Inlined verbatim into every generated component.
|
|
15
|
+
//
|
|
16
|
+
// Slice volume: continuous media (dust, rain curtains, funnels) are rendered as N view-aligned
|
|
17
|
+
// slices between the camera and the far side of the volume, drawn back to front in one instanced
|
|
18
|
+
// call. Each slice is a full-screen quad at a fixed view depth, depth-tested against the scene,
|
|
19
|
+
// so objects inside the medium are hidden by exactly the medium in front of them — volume
|
|
20
|
+
// rendering without a depth texture. Slices are spaced geometrically (dense near the eye) and
|
|
21
|
+
// every fragment samples at a per-pixel dithered depth inside its slab, which turns slice
|
|
22
|
+
// banding into fine grain.
|
|
23
|
+
//
|
|
24
|
+
// What a slice volume costs is pixels x slices x the work per sample, so the core keeps all three down:
|
|
25
|
+
// noise vnoise3 is one trilinear fetch from a small 3-D texture holding the very lattice values
|
|
26
|
+
// the hash gave (the smoothstep goes into the coordinate), instead of 8 hashes and 7 mixes.
|
|
27
|
+
// bounds slices cover the volume's box on screen, not the whole screen.
|
|
28
|
+
// density on a dense display (device pixel ratio above 1) neighbouring pixels take turns over the
|
|
29
|
+
// slices (2 or 4 interleaved sets, each sample standing for the slabs it skips), so the
|
|
30
|
+
// samples per CSS pixel — what the eye resolves — stay what they are at ratio 1.
|
|
31
|
+
// reach near layers (streaks, grains, splashes) are not submitted when the camera is too far
|
|
32
|
+
// from the volume to see any of them (layerInReach).
|
|
33
|
+
const WIND_MS_COMMON = 8; // m/s per unit of windStrength (Rain's 0..1 range)
|
|
34
|
+
const DEG_C = Math.PI / 180;
|
|
35
|
+
function mulberry32(a) {
|
|
36
|
+
return function () {
|
|
37
|
+
a |= 0;
|
|
38
|
+
a = (a + 0x6d2b79f5) | 0;
|
|
39
|
+
let t = Math.imul(a ^ (a >>> 15), 1 | a);
|
|
40
|
+
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
|
41
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
// ---------------------------------------------------------------------------- noise texture
|
|
45
|
+
// The lattice of vnoise3 as a texture: NOISE_N^3 values of the same hash the shader used to evaluate,
|
|
46
|
+
// for lattice points -NOISE_N/2 .. NOISE_N/2 - 1 on each axis (beyond that it repeats). One per page,
|
|
47
|
+
// shared by every environment object.
|
|
48
|
+
const NOISE_N = 64;
|
|
49
|
+
let _noiseTex = null;
|
|
50
|
+
function noiseTexture() {
|
|
51
|
+
if (_noiseTex)
|
|
52
|
+
return _noiseTex;
|
|
53
|
+
const N = NOISE_N, H = N / 2, f = Math.fround;
|
|
54
|
+
const fr = (x) => f(x - Math.floor(x));
|
|
55
|
+
const data = new Uint8Array(N * N * N);
|
|
56
|
+
let o = 0;
|
|
57
|
+
for (let z = 0; z < N; z++)
|
|
58
|
+
for (let y = 0; y < N; y++)
|
|
59
|
+
for (let x = 0; x < N; x++) {
|
|
60
|
+
// hash13: p = fract(p * 0.1031); p += dot(p, p.zyx + 31.32); return fract((p.x + p.y) * p.z);
|
|
61
|
+
let px = fr(f((x - H) * f(0.1031))), py = fr(f((y - H) * f(0.1031))), pz = fr(f((z - H) * f(0.1031)));
|
|
62
|
+
const d = f(f(f(px * f(pz + f(31.32))) + f(py * f(py + f(31.32)))) + f(pz * f(px + f(31.32))));
|
|
63
|
+
px = f(px + d);
|
|
64
|
+
py = f(py + d);
|
|
65
|
+
pz = f(pz + d);
|
|
66
|
+
data[o++] = Math.min(255, Math.round(fr(f(f(px + py) * pz)) * 255));
|
|
67
|
+
}
|
|
68
|
+
const tex = new THREE.Data3DTexture(data, N, N, N);
|
|
69
|
+
tex.format = THREE.RedFormat;
|
|
70
|
+
tex.type = THREE.UnsignedByteType;
|
|
71
|
+
tex.minFilter = THREE.LinearFilter;
|
|
72
|
+
tex.magFilter = THREE.LinearFilter;
|
|
73
|
+
tex.wrapS = THREE.RepeatWrapping;
|
|
74
|
+
tex.wrapT = THREE.RepeatWrapping;
|
|
75
|
+
tex.wrapR = THREE.RepeatWrapping;
|
|
76
|
+
tex.unpackAlignment = 1;
|
|
77
|
+
tex.generateMipmaps = false;
|
|
78
|
+
tex.needsUpdate = true;
|
|
79
|
+
_noiseTex = tex;
|
|
80
|
+
return tex;
|
|
81
|
+
}
|
|
82
|
+
function setColor(uniform, v) {
|
|
83
|
+
if (v === undefined || v === null)
|
|
84
|
+
return;
|
|
85
|
+
if (v.isColor)
|
|
86
|
+
uniform.value.copy(v);
|
|
87
|
+
else
|
|
88
|
+
uniform.value.set(v);
|
|
89
|
+
}
|
|
90
|
+
/** Uniforms every environment object has. */
|
|
91
|
+
function createCommonUniforms() {
|
|
92
|
+
return {
|
|
93
|
+
uTime: { value: 0 },
|
|
94
|
+
uWind: { value: new THREE.Vector2() },
|
|
95
|
+
uWindDir: { value: new THREE.Vector2(0, 1) },
|
|
96
|
+
uWindStrength: { value: 0.2 },
|
|
97
|
+
uTurb: { value: 0.3 },
|
|
98
|
+
uTurbPhase: { value: 0 },
|
|
99
|
+
uSpeed: { value: 1 },
|
|
100
|
+
uVolume: { value: new THREE.Vector3(100, 40, 100) },
|
|
101
|
+
uCam: { value: new THREE.Vector3() },
|
|
102
|
+
uCamToLocal: { value: new THREE.Matrix4() },
|
|
103
|
+
uSliceNear: { value: 0.3 },
|
|
104
|
+
uSliceFar: { value: 200 },
|
|
105
|
+
uSliceCount: { value: 32 },
|
|
106
|
+
uSliceRect: { value: new THREE.Vector4(-1.04, -1.04, 1.04, 1.04) },
|
|
107
|
+
uSkip: { value: 1 },
|
|
108
|
+
uSkipMax: { value: 4 },
|
|
109
|
+
uSliceCurve: { value: 0 },
|
|
110
|
+
uNoise: { value: noiseTexture() },
|
|
111
|
+
uFollow: { value: 0 },
|
|
112
|
+
uViewH: { value: 800 },
|
|
113
|
+
uIntensity: { value: 1 },
|
|
114
|
+
uOpacity: { value: 1 },
|
|
115
|
+
uColor: { value: new THREE.Color('#ffffff') },
|
|
116
|
+
uShadeColor: { value: new THREE.Color('#808080') },
|
|
117
|
+
uSunDir: { value: new THREE.Vector3(0.35, 0.42, 0.84).normalize() },
|
|
118
|
+
uSunColor: { value: new THREE.Color(1.0, 0.93, 0.82) },
|
|
119
|
+
uSkyAmbient: { value: new THREE.Color(0.55, 0.65, 0.85) },
|
|
120
|
+
uPointer: { value: new THREE.Vector3() },
|
|
121
|
+
uPointerVel: { value: new THREE.Vector3() },
|
|
122
|
+
uPointerActive: { value: 0 },
|
|
123
|
+
uPointerMode: { value: -1 },
|
|
124
|
+
uPointerStrength: { value: 1 },
|
|
125
|
+
uPointerRadius: { value: 1 },
|
|
126
|
+
uPointerColor: { value: new THREE.Color('#ffffff') },
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/** The base knobs every environment object shares (push point, part 1). */
|
|
130
|
+
function applyCommonConfig(u, c, pointerModes) {
|
|
131
|
+
if (c.intensity !== undefined)
|
|
132
|
+
u.uIntensity.value = c.intensity;
|
|
133
|
+
if (c.speed !== undefined)
|
|
134
|
+
u.uSpeed.value = c.speed;
|
|
135
|
+
if (c.opacity !== undefined)
|
|
136
|
+
u.uOpacity.value = c.opacity;
|
|
137
|
+
setColor(u.uColor, c.color);
|
|
138
|
+
setColor(u.uShadeColor, c.shadeColor);
|
|
139
|
+
setColor(u.uPointerColor, c.pointerColor);
|
|
140
|
+
if (c.windStrength !== undefined)
|
|
141
|
+
u.uWindStrength.value = c.windStrength;
|
|
142
|
+
if (c.windDirection !== undefined)
|
|
143
|
+
u.uWindDir.value.set(Math.sin(c.windDirection * DEG_C), Math.cos(c.windDirection * DEG_C));
|
|
144
|
+
if (c.turbulence !== undefined)
|
|
145
|
+
u.uTurb.value = c.turbulence;
|
|
146
|
+
if (c.pointerStrength !== undefined)
|
|
147
|
+
u.uPointerStrength.value = c.pointerStrength;
|
|
148
|
+
if (c.pointerRadius !== undefined)
|
|
149
|
+
u.uPointerRadius.value = c.pointerRadius;
|
|
150
|
+
if (c.pointerMode !== undefined)
|
|
151
|
+
u.uPointerMode.value = pointerModes.indexOf(c.pointerMode);
|
|
152
|
+
if (c.followCamera !== undefined)
|
|
153
|
+
u.uFollow.value = c.followCamera ? 1 : 0;
|
|
154
|
+
}
|
|
155
|
+
const _cs = new THREE.Vector3(), _cc = new THREE.Vector3(), _cq = new THREE.Quaternion(), _csun = new THREE.Vector3();
|
|
156
|
+
const _cinv = new THREE.Matrix4();
|
|
157
|
+
const _corner = new THREE.Vector3();
|
|
158
|
+
const _cview = new THREE.Matrix4();
|
|
159
|
+
/** Per-frame bookkeeping shared by every object: volume, camera, slice range and bounds, sun, phases. */
|
|
160
|
+
function updateCommon(u, object, camera, dt, viewH, sunWorld, dpr) {
|
|
161
|
+
// the camera may have been moved this frame (controls) without its matrices following yet
|
|
162
|
+
camera.updateMatrixWorld();
|
|
163
|
+
object.updateWorldMatrix(true, false);
|
|
164
|
+
object.getWorldScale(_cs);
|
|
165
|
+
u.uVolume.value.set(Math.max(_cs.x, 0.01), Math.max(_cs.y, 0.01), Math.max(_cs.z, 0.01));
|
|
166
|
+
const V = u.uVolume.value;
|
|
167
|
+
object.worldToLocal(_cc.copy(camera.position));
|
|
168
|
+
u.uCam.value.set(_cc.x * V.x, _cc.y * V.y, _cc.z * V.z);
|
|
169
|
+
_cinv.copy(object.matrixWorld).invert();
|
|
170
|
+
u.uCamToLocal.value.multiplyMatrices(_cinv, camera.matrixWorld);
|
|
171
|
+
if (viewH)
|
|
172
|
+
u.uViewH.value = viewH;
|
|
173
|
+
// slice range: from where the volume starts in front of the eye to its far corner
|
|
174
|
+
const C = u.uCam.value;
|
|
175
|
+
const follow = u.uFollow.value > 0.5;
|
|
176
|
+
const hx = follow ? 1e6 : V.x / 2, hz = follow ? 1e6 : V.z / 2;
|
|
177
|
+
const dx = Math.max(Math.abs(C.x) - hx, 0), dz = Math.max(Math.abs(C.z) - hz, 0);
|
|
178
|
+
const dy = Math.max(-C.y, C.y - V.y, 0);
|
|
179
|
+
const dNear = Math.hypot(dx, dy, dz);
|
|
180
|
+
let dFar = 0;
|
|
181
|
+
for (let i = 0; i < 8; i++) {
|
|
182
|
+
_corner.set((i & 1 ? 1 : -1) * Math.min(hx, 3e3), i & 2 ? V.y : 0, (i & 4 ? 1 : -1) * Math.min(hz, 3e3));
|
|
183
|
+
dFar = Math.max(dFar, _corner.distanceTo(C));
|
|
184
|
+
}
|
|
185
|
+
const far = camera.far !== undefined ? camera.far : 2000;
|
|
186
|
+
u.uSliceNear.value = Math.max(0.3, dNear * 0.6);
|
|
187
|
+
u.uSliceFar.value = Math.max(u.uSliceNear.value * 1.5, Math.min(dFar, 600, far * 0.98));
|
|
188
|
+
// Slice bounds: the volume's box on screen (NDC). Whole screen when the box reaches behind the
|
|
189
|
+
// eye (the camera is inside or right next to it) or follows the camera.
|
|
190
|
+
const R = u.uSliceRect.value.set(-1.04, -1.04, 1.04, 1.04);
|
|
191
|
+
if (!follow && camera.projectionMatrix) {
|
|
192
|
+
_cview.copy(camera.matrixWorld).invert().multiply(object.matrixWorld);
|
|
193
|
+
const P = camera.projectionMatrix.elements, nearZ = camera.near !== undefined ? camera.near : 0.1;
|
|
194
|
+
let x0 = 1e9, y0 = 1e9, x1 = -1e9, y1 = -1e9, ok = true;
|
|
195
|
+
for (let i = 0; i < 8 && ok; i++) {
|
|
196
|
+
_corner.set(i & 1 ? 0.5 : -0.5, i & 2 ? 1 : 0, i & 4 ? 0.5 : -0.5).applyMatrix4(_cview);
|
|
197
|
+
if (_corner.z > -nearZ) {
|
|
198
|
+
ok = false;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
const w = -_corner.z, x = (P[0] * _corner.x + P[8] * _corner.z) / w, y = (P[5] * _corner.y + P[9] * _corner.z) / w;
|
|
202
|
+
if (x < x0)
|
|
203
|
+
x0 = x;
|
|
204
|
+
if (x > x1)
|
|
205
|
+
x1 = x;
|
|
206
|
+
if (y < y0)
|
|
207
|
+
y0 = y;
|
|
208
|
+
if (y > y1)
|
|
209
|
+
y1 = y;
|
|
210
|
+
}
|
|
211
|
+
// the margin covers the depth dither, which slides a sample along its ray but never off its pixel
|
|
212
|
+
if (ok)
|
|
213
|
+
R.set(Math.max(x0 - 0.03, -1.04), Math.max(y0 - 0.03, -1.04), Math.min(x1 + 0.03, 1.04), Math.min(y1 + 0.03, 1.04));
|
|
214
|
+
if (R.z <= R.x || R.w <= R.y)
|
|
215
|
+
R.set(0, 0, 0, 0); // off screen: nothing to draw
|
|
216
|
+
}
|
|
217
|
+
// Interleaved slices on dense displays: pixels take turns over 2 (ratio >= 1.25) or 4 (>= 1.75) sets.
|
|
218
|
+
// An object caps it (buildSlices' interleave): fine, fast-changing structure like the tornado's funnel
|
|
219
|
+
// loses its crispness when neighbours see different slabs, so it takes every slice.
|
|
220
|
+
u.uSkip.value = Math.min(dpr >= 1.75 ? 4 : dpr >= 1.25 ? 2 : 1, u.uSkipMax.value);
|
|
221
|
+
// phases (rates integrated on the CPU, so animating them never jumps)
|
|
222
|
+
const sp = u.uSpeed.value;
|
|
223
|
+
u.uTime.value += dt * sp;
|
|
224
|
+
u.uWind.value.addScaledVector(u.uWindDir.value, dt * sp * u.uWindStrength.value * WIND_MS_COMMON);
|
|
225
|
+
u.uTurbPhase.value += dt * sp * 0.25;
|
|
226
|
+
if (sunWorld) {
|
|
227
|
+
object.getWorldQuaternion(_cq).invert();
|
|
228
|
+
u.uSunDir.value.copy(_csun.copy(sunWorld).normalize().applyQuaternion(_cq));
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* True when a layer that only exists inside the volume and within `reach` metres of the eye can show
|
|
233
|
+
* anything: used to skip submitting near layers (thousands of instances, each fully evaluated per
|
|
234
|
+
* vertex) while the camera is away from the volume.
|
|
235
|
+
*/
|
|
236
|
+
function layerInReach(u, reach) {
|
|
237
|
+
const C = u.uCam.value, V = u.uVolume.value, follow = u.uFollow.value > 0.5;
|
|
238
|
+
const ox = follow ? 0 : Math.max(Math.abs(C.x) - 0.5 * V.x, 0), oz = follow ? 0 : Math.max(Math.abs(C.z) - 0.5 * V.z, 0);
|
|
239
|
+
const oy = Math.max(-C.y, C.y - V.y, 0);
|
|
240
|
+
return ox * ox + oy * oy + oz * oz < reach * reach;
|
|
241
|
+
}
|
|
242
|
+
// Where the pointer plane passes (object-local unit coords; the plane faces the camera):
|
|
243
|
+
// a few metres ahead of the eye inside the volume, else through the volume centre's depth.
|
|
244
|
+
const _pa = new THREE.Vector3(), _pd = new THREE.Vector3(), _pc = new THREE.Vector3();
|
|
245
|
+
function pointerAnchor(object, camera, u, out, ahead) {
|
|
246
|
+
const V = u.uVolume.value, C = u.uCam.value;
|
|
247
|
+
const inside = Math.abs(C.x) < 0.5 * V.x && Math.abs(C.z) < 0.5 * V.z && C.y > 0 && C.y < V.y;
|
|
248
|
+
camera.getWorldDirection(_pd);
|
|
249
|
+
let dist = ahead || 4.5;
|
|
250
|
+
if (!inside) {
|
|
251
|
+
object.updateWorldMatrix(true, false);
|
|
252
|
+
object.localToWorld(_pc.set(0, 0.5, 0));
|
|
253
|
+
dist = Math.max(dist, _pc.sub(camera.position).dot(_pd));
|
|
254
|
+
}
|
|
255
|
+
_pa.copy(camera.position).addScaledVector(_pd, dist);
|
|
256
|
+
return object.worldToLocal(out.copy(_pa));
|
|
257
|
+
}
|
|
258
|
+
const NOISE_GLSL = /* glsl */ `
|
|
259
|
+
uniform highp sampler3D uNoise;
|
|
260
|
+
float hash13(vec3 p) { p = fract(p * 0.1031); p += dot(p, p.zyx + 31.32); return fract((p.x + p.y) * p.z); }
|
|
261
|
+
float hash12(vec2 p) { vec3 q = fract(vec3(p.xyx) * 0.1031); q += dot(q, q.yzx + 33.33); return fract((q.x + q.y) * q.z); }
|
|
262
|
+
// value noise from the lattice texture: the smoothstep is put into the coordinate, the trilinear
|
|
263
|
+
// filter does the eight-corner mix (same lattice values as hash13 around the origin)
|
|
264
|
+
float vnoise3(vec3 p) {
|
|
265
|
+
vec3 i = floor(p); vec3 f = fract(p); f = f * f * (3.0 - 2.0 * f);
|
|
266
|
+
return texture(uNoise, (i + f + ${(0.5 + NOISE_N / 2).toFixed(1)}) / ${NOISE_N.toFixed(1)}).r;
|
|
267
|
+
}
|
|
268
|
+
float vnoise2(vec2 p) {
|
|
269
|
+
vec2 i = floor(p); vec2 f = fract(p); f = f * f * (3.0 - 2.0 * f);
|
|
270
|
+
return mix(mix(hash12(i), hash12(i + vec2(1, 0)), f.x), mix(hash12(i + vec2(0, 1)), hash12(i + vec2(1, 1)), f.x), f.y);
|
|
271
|
+
}
|
|
272
|
+
// three octaves, rotated between octaves so the lattice never lines up
|
|
273
|
+
float fbm3(vec3 p) {
|
|
274
|
+
float s = 0.5 * vnoise3(p);
|
|
275
|
+
p = mat3(0.00, 0.80, 0.60, -0.80, 0.36, -0.48, -0.60, -0.48, 0.64) * p * 2.03;
|
|
276
|
+
s += 0.25 * vnoise3(p);
|
|
277
|
+
p = mat3(0.00, 0.80, 0.60, -0.80, 0.36, -0.48, -0.60, -0.48, 0.64) * p * 2.01;
|
|
278
|
+
s += 0.125 * vnoise3(p);
|
|
279
|
+
return s / 0.875;
|
|
280
|
+
}
|
|
281
|
+
float bump(float x) { float t = clamp(1.0 - x * x, 0.0, 1.0); return t * t; }
|
|
282
|
+
float hgPhase(float mu, float g) { return 0.0795775 * (1.0 - g * g) / pow(1.0 + g * g - 2.0 * g * mu, 1.5); }
|
|
283
|
+
float ign(vec2 px) { return fract(52.9829189 * fract(dot(px, vec2(0.06711056, 0.00583715)))); }
|
|
284
|
+
`;
|
|
285
|
+
const COMMON_UNIFORMS_GLSL = /* glsl */ `
|
|
286
|
+
uniform float uTime, uWindStrength, uTurb, uTurbPhase, uSpeed, uFollow, uViewH;
|
|
287
|
+
uniform vec2 uWind, uWindDir;
|
|
288
|
+
uniform vec3 uVolume, uCam;
|
|
289
|
+
uniform vec3 uSunDir, uSunColor, uSkyAmbient, uColor, uShadeColor, uPointerColor;
|
|
290
|
+
uniform float uIntensity, uOpacity;
|
|
291
|
+
uniform vec3 uPointer, uPointerVel;
|
|
292
|
+
uniform float uPointerActive, uPointerMode, uPointerStrength, uPointerRadius;
|
|
293
|
+
`;
|
|
294
|
+
const FOG_V = /* glsl */ `
|
|
295
|
+
#ifdef USE_FOG
|
|
296
|
+
varying float vFogDepth;
|
|
297
|
+
#endif
|
|
298
|
+
`;
|
|
299
|
+
const FOG_F = /* glsl */ `
|
|
300
|
+
#ifdef USE_FOG
|
|
301
|
+
uniform vec3 fogColor;
|
|
302
|
+
varying float vFogDepth;
|
|
303
|
+
#ifdef FOG_EXP2
|
|
304
|
+
uniform float fogDensity;
|
|
305
|
+
#else
|
|
306
|
+
uniform float fogNear;
|
|
307
|
+
uniform float fogFar;
|
|
308
|
+
#endif
|
|
309
|
+
#endif
|
|
310
|
+
`;
|
|
311
|
+
const FOG_APPLY = /* glsl */ `
|
|
312
|
+
#ifdef USE_FOG
|
|
313
|
+
#ifdef FOG_EXP2
|
|
314
|
+
float fogFactor = 1.0 - exp(-fogDensity * fogDensity * vFogDepth * vFogDepth);
|
|
315
|
+
#else
|
|
316
|
+
float fogFactor = smoothstep(fogNear, fogFar, vFogDepth);
|
|
317
|
+
#endif
|
|
318
|
+
gl_FragColor.rgb = mix(gl_FragColor.rgb, fogColor * gl_FragColor.a, fogFactor);
|
|
319
|
+
#endif
|
|
320
|
+
`;
|
|
321
|
+
/** Soft walls of the volume (metres); the ground is hard. */
|
|
322
|
+
const VOLUME_GLSL = /* glsl */ `
|
|
323
|
+
float volumeFade(vec3 p, float side, float top) {
|
|
324
|
+
float a = step(0.0, p.y) * (1.0 - smoothstep(uVolume.y - top, uVolume.y, p.y));
|
|
325
|
+
if (uFollow < 0.5) {
|
|
326
|
+
vec2 e = 0.5 * uVolume.xz - abs(p.xz);
|
|
327
|
+
a *= smoothstep(0.0, side, e.x) * smoothstep(0.0, side, e.y);
|
|
328
|
+
}
|
|
329
|
+
return a;
|
|
330
|
+
}
|
|
331
|
+
`;
|
|
332
|
+
const SLICE_VERT = /* glsl */ `
|
|
333
|
+
${COMMON_UNIFORMS_GLSL}
|
|
334
|
+
uniform float uSliceNear, uSliceFar, uSliceCount, uSliceCurve;
|
|
335
|
+
uniform vec4 uSliceRect;
|
|
336
|
+
uniform mat4 uCamToLocal;
|
|
337
|
+
attribute vec2 aCorner;
|
|
338
|
+
attribute float aSlice;
|
|
339
|
+
varying vec3 vLocal;
|
|
340
|
+
varying vec3 vRay;
|
|
341
|
+
varying float vDz, vSlice;
|
|
342
|
+
${FOG_V}
|
|
343
|
+
void main() {
|
|
344
|
+
// slice 0 is the farthest: instances draw back to front
|
|
345
|
+
float k = log(uSliceFar / uSliceNear);
|
|
346
|
+
float t0 = 1.0 - (aSlice + 1.0) / uSliceCount;
|
|
347
|
+
float t1 = 1.0 - aSlice / uSliceCount;
|
|
348
|
+
// legacy spacing is geometric; even (quadratic) spacing spends far fewer slabs on the first metres
|
|
349
|
+
float z0 = uSliceCurve > 0.5 ? uSliceNear + (uSliceFar - uSliceNear) * t0 * t0 : uSliceNear * exp(k * t0);
|
|
350
|
+
float z1 = uSliceCurve > 0.5 ? uSliceNear + (uSliceFar - uSliceNear) * t1 * t1 : uSliceNear * exp(k * t1);
|
|
351
|
+
float z = 0.5 * (z0 + z1);
|
|
352
|
+
vDz = z1 - z0;
|
|
353
|
+
// the quad spans the volume's bounds on screen (NDC), not the screen
|
|
354
|
+
vec2 ndc = mix(uSliceRect.xy, uSliceRect.zw, aCorner * 0.5 + 0.5);
|
|
355
|
+
vec3 view = vec3((ndc.x + projectionMatrix[2][0]) * z / projectionMatrix[0][0], (ndc.y + projectionMatrix[2][1]) * z / projectionMatrix[1][1], -z);
|
|
356
|
+
vSlice = aSlice;
|
|
357
|
+
gl_Position = projectionMatrix * vec4(view, 1.0);
|
|
358
|
+
vLocal = (uCamToLocal * vec4(view, 1.0)).xyz * uVolume;
|
|
359
|
+
vRay = vLocal - uCam;
|
|
360
|
+
#ifdef USE_FOG
|
|
361
|
+
vFogDepth = z;
|
|
362
|
+
#endif
|
|
363
|
+
}
|
|
364
|
+
`;
|
|
365
|
+
/**
|
|
366
|
+
* Wraps an object's `vec4 sliceSample(vec3 p, vec3 rd, float dz)` (premultiplied rgb, alpha).
|
|
367
|
+
*
|
|
368
|
+
* The canvas stores display (non-linear) values. By default the premultiplied colour goes through
|
|
369
|
+
* the output transform as it is, which makes a thin layer brighter than its share: the look then
|
|
370
|
+
* depends on how thin the slabs are (the first objects were tuned by eye under it — leave them).
|
|
371
|
+
* `straight` converts the colour first and weights it by alpha after, so a medium looks the same
|
|
372
|
+
* at every slice count, density and quality; new objects use it.
|
|
373
|
+
*/
|
|
374
|
+
function sliceFrag(body, straight) {
|
|
375
|
+
return /* glsl */ `
|
|
376
|
+
${COMMON_UNIFORMS_GLSL}
|
|
377
|
+
uniform float uSkip;
|
|
378
|
+
varying vec3 vLocal;
|
|
379
|
+
varying vec3 vRay;
|
|
380
|
+
varying float vDz, vSlice;
|
|
381
|
+
${FOG_F}
|
|
382
|
+
${NOISE_GLSL}
|
|
383
|
+
${VOLUME_GLSL}
|
|
384
|
+
${body}
|
|
385
|
+
void main() {
|
|
386
|
+
// dense displays: neighbouring pixels take turns over the slices (see updateCommon)
|
|
387
|
+
if (uSkip > 1.5) {
|
|
388
|
+
vec2 px = mod(floor(gl_FragCoord.xy), 2.0);
|
|
389
|
+
float turn = uSkip > 3.0 ? mod(px.x * 2.0 + px.y * 3.0, 4.0) : mod(px.x + px.y, 2.0);
|
|
390
|
+
if (mod(vSlice + turn, uSkip) > 0.5) discard;
|
|
391
|
+
}
|
|
392
|
+
vec3 rd = normalize(vRay);
|
|
393
|
+
// dithered depth inside the slab: banding becomes grain
|
|
394
|
+
vec3 p = vLocal + rd * (ign(gl_FragCoord.xy) - 0.5) * 0.6 * vDz;
|
|
395
|
+
if (p.y < 0.0 || p.y > uVolume.y) discard;
|
|
396
|
+
if (uFollow < 0.5 && (abs(p.x) > 0.5 * uVolume.x || abs(p.z) > 0.5 * uVolume.z)) discard;
|
|
397
|
+
vec4 s = sliceSample(p, rd, vDz);
|
|
398
|
+
s *= uOpacity;
|
|
399
|
+
if (s.a < 0.0015 && dot(s.rgb, vec3(1.0)) < 0.002) discard;
|
|
400
|
+
gl_FragColor = ${straight ? 'vec4(s.rgb / max(s.a, 1e-5) * uIntensity, 1.0)' : 'vec4(s.rgb * uIntensity, s.a)'};
|
|
401
|
+
#include <tonemapping_fragment>
|
|
402
|
+
#include <colorspace_fragment>${straight ? '\n gl_FragColor = vec4(gl_FragColor.rgb * s.a, s.a);' : ''}
|
|
403
|
+
${FOG_APPLY}
|
|
404
|
+
// A pixel that skipped slabs stands for them: it lays down what 2 or 4 copies of its own thin
|
|
405
|
+
// layer would have composited to (colour c (1 + t + ...), transmittance t^n), so the volume
|
|
406
|
+
// keeps exactly the brightness and opacity it has when every pixel takes every slice.
|
|
407
|
+
if (uSkip > 1.5) {
|
|
408
|
+
float t = 1.0 - gl_FragColor.a;
|
|
409
|
+
float t2 = t * t;
|
|
410
|
+
gl_FragColor = uSkip > 3.0 ? vec4(gl_FragColor.rgb * (1.0 + t) * (1.0 + t2), 1.0 - t2 * t2) : vec4(gl_FragColor.rgb * (1.0 + t), 1.0 - t2);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
`;
|
|
414
|
+
}
|
|
415
|
+
function premulMaterial(u, vertexShader, fragmentShader, additive) {
|
|
416
|
+
return new THREE.ShaderMaterial({
|
|
417
|
+
uniforms: Object.assign({}, THREE.UniformsUtils.clone(THREE.UniformsLib.fog), u),
|
|
418
|
+
vertexShader, fragmentShader,
|
|
419
|
+
transparent: true, depthWrite: false, fog: true,
|
|
420
|
+
blending: THREE.CustomBlending,
|
|
421
|
+
blendSrc: THREE.OneFactor, blendDst: additive ? THREE.OneFactor : THREE.OneMinusSrcAlphaFactor,
|
|
422
|
+
blendSrcAlpha: THREE.OneFactor, blendDstAlpha: THREE.OneMinusSrcAlphaFactor,
|
|
423
|
+
premultipliedAlpha: true,
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
/** Bounds-only `position`: the unit volume box, so Box3.expandByObject centres the gizmo on it. */
|
|
427
|
+
function boxPositions(geo) {
|
|
428
|
+
geo.setAttribute('position', new THREE.Float32BufferAttribute([-0.5, 0, -0.5, 0.5, 0, 0.5, 0.5, 1, -0.5, -0.5, 1, 0.5], 3));
|
|
429
|
+
geo.boundingSphere = new THREE.Sphere(new THREE.Vector3(0, 0.5, 0), 0.87);
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* One instanced draw of `count` view-aligned slices. `interleave` (1, 2 or 4, default 4) is the most
|
|
433
|
+
* sets of slices neighbouring pixels may take turns over on a dense display; 1 = every pixel, every slice.
|
|
434
|
+
*/
|
|
435
|
+
function buildSlices(u, fragmentShader, count, interleave, curve) {
|
|
436
|
+
const geo = new THREE.InstancedBufferGeometry();
|
|
437
|
+
boxPositions(geo);
|
|
438
|
+
geo.setAttribute('aCorner', new THREE.Float32BufferAttribute([-1, -1, 1, -1, 1, 1, -1, 1], 2));
|
|
439
|
+
geo.setIndex([0, 1, 2, 0, 2, 3]);
|
|
440
|
+
const idx = new Float32Array(count);
|
|
441
|
+
for (let i = 0; i < count; i++)
|
|
442
|
+
idx[i] = i;
|
|
443
|
+
geo.setAttribute('aSlice', new THREE.InstancedBufferAttribute(idx, 1));
|
|
444
|
+
geo.instanceCount = count;
|
|
445
|
+
u.uSliceCount.value = count;
|
|
446
|
+
u.uSkipMax.value = interleave || 1;
|
|
447
|
+
u.uSliceCurve.value = curve ? 1 : 0;
|
|
448
|
+
const mat = premulMaterial(u, SLICE_VERT, fragmentShader, false);
|
|
449
|
+
const mesh = new THREE.Mesh(geo, mat);
|
|
450
|
+
mesh.frustumCulled = false;
|
|
451
|
+
mesh.raycast = function () { };
|
|
452
|
+
return mesh;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Slice budget by where the eye is (even-spaced volumes only; call after updateCommon). Inside the
|
|
456
|
+
* volume the medium fills the screen and half the slabs give the same picture, because even spacing
|
|
457
|
+
* no longer spends a third of them on the first three metres; seen from outside, thinner slabs are
|
|
458
|
+
* what keeps its brightness, and it covers few pixels, so it takes them all. The count eases between
|
|
459
|
+
* the two over the first stretch outside the wall.
|
|
460
|
+
*/
|
|
461
|
+
function adaptSlices(u, mesh, full) {
|
|
462
|
+
const C = u.uCam.value, V = u.uVolume.value, follow = u.uFollow.value > 0.5;
|
|
463
|
+
const ox = follow ? 0 : Math.max(Math.abs(C.x) - 0.5 * V.x, 0), oz = follow ? 0 : Math.max(Math.abs(C.z) - 0.5 * V.z, 0);
|
|
464
|
+
const d = Math.hypot(ox, Math.max(-C.y, C.y - V.y, 0), oz);
|
|
465
|
+
const t = Math.min(d / Math.max(0.25 * Math.min(V.x, V.z), 1), 1);
|
|
466
|
+
const n = Math.max(4, Math.round(full * (0.5 + 0.5 * t * t * (3 - 2 * t))));
|
|
467
|
+
mesh.geometry.instanceCount = n;
|
|
468
|
+
u.uSliceCount.value = n;
|
|
469
|
+
}
|
|
470
|
+
/** Instanced quad geometry with per-instance seeds (two vec4s). */
|
|
471
|
+
function seededQuads(count, rnd) {
|
|
472
|
+
const geo = new THREE.InstancedBufferGeometry();
|
|
473
|
+
boxPositions(geo);
|
|
474
|
+
geo.setAttribute('aCorner', new THREE.Float32BufferAttribute([-1, -1, 1, -1, 1, 1, -1, 1], 2));
|
|
475
|
+
geo.setIndex([0, 1, 2, 0, 2, 3]);
|
|
476
|
+
const a = new Float32Array(count * 4), b = new Float32Array(count * 4);
|
|
477
|
+
for (let i = 0; i < count * 4; i++) {
|
|
478
|
+
a[i] = rnd();
|
|
479
|
+
b[i] = rnd();
|
|
480
|
+
}
|
|
481
|
+
geo.setAttribute('aSeedA', new THREE.InstancedBufferAttribute(a, 4));
|
|
482
|
+
geo.setAttribute('aSeedB', new THREE.InstancedBufferAttribute(b, 4));
|
|
483
|
+
geo.instanceCount = count;
|
|
484
|
+
return geo;
|
|
485
|
+
}
|
|
486
|
+
/** A streak quad between two view-space points, at least 1 px wide (energy kept by alpha). */
|
|
487
|
+
const STREAK_GLSL = /* glsl */ `
|
|
488
|
+
// returns the clip position of this corner; writes the coverage factor into cover
|
|
489
|
+
vec4 streakCorner(vec4 headV, vec4 tailV, vec2 corner, float widthM, out float cover, out float lenPx) {
|
|
490
|
+
vec4 h = projectionMatrix * headV;
|
|
491
|
+
vec4 t = projectionMatrix * tailV;
|
|
492
|
+
vec2 hs = h.xy / h.w, ts = t.xy / t.w;
|
|
493
|
+
vec2 scr = vec2(uViewH * projectionMatrix[1][1] / projectionMatrix[0][0], uViewH) * 0.5;
|
|
494
|
+
vec2 d = (hs - ts) * scr;
|
|
495
|
+
lenPx = length(d);
|
|
496
|
+
vec2 dir = lenPx > 1e-4 ? d / lenPx : vec2(0.0, 1.0);
|
|
497
|
+
vec2 nrm = vec2(dir.y, -dir.x); // (nrm, dir) right-handed: the quad stays front-facing
|
|
498
|
+
float wPx = widthM * uViewH * projectionMatrix[1][1] * 0.5 / max(-headV.z, 1e-3);
|
|
499
|
+
float w = max(wPx, 1.0);
|
|
500
|
+
cover = wPx / w;
|
|
501
|
+
vec4 base = corner.y > 0.0 ? h : t;
|
|
502
|
+
vec2 off = nrm * corner.x * 0.5 * w / scr;
|
|
503
|
+
// extend half a pixel past both ends so short streaks stay round
|
|
504
|
+
off += dir * corner.y * 0.5 / scr;
|
|
505
|
+
return vec4(base.xy + off * base.w, base.zw);
|
|
506
|
+
}
|
|
507
|
+
`;
|
|
508
|
+
// ---------------------------------------------------------------------------- thunderstorm
|
|
509
|
+
// Thunderstorm — environment object (lab module). Shared core: ./common.mjs.
|
|
510
|
+
// No rain: rain is its own object. This one is the storm's murk and its lightning.
|
|
511
|
+
// Construction:
|
|
512
|
+
// curtains the storm's body in the slice volume: vertically stretched, slowly sinking fbm curtains
|
|
513
|
+
// leaning with the wind, darker where thicker. They are what the lightning lights.
|
|
514
|
+
// lightning flashes arrive as a Poisson process (exponential waits around the mean rate);
|
|
515
|
+
// each flash is 2–5 return strokes ~40–90 ms apart, fast attack, exponential decay —
|
|
516
|
+
// the stutter that reads as lightning. A flash lights the curtains near the bolt
|
|
517
|
+
// (falloff with distance), and drives a real scene light at the bolt so every
|
|
518
|
+
// object in the scene flashes with it. No bolt mesh (that is the Lightning effect).
|
|
519
|
+
const catalog = {
|
|
520
|
+
key: 'thunderstorm',
|
|
521
|
+
name: 'Thunderstorm',
|
|
522
|
+
description: 'A thunderstorm without the rain (rain is its own object): dark storm curtains drifting on the wind, and lightning arriving as a Poisson process of multi-stroke flashes that light the curtains and the whole scene. The cursor calls a strike or clears the murk. Use for storm, noir and dramatic scenes.',
|
|
523
|
+
tags: ['thunderstorm', 'lightning', 'storm', 'weather', 'dramatic'],
|
|
524
|
+
structural: ['density', 'quality', 'seed'],
|
|
525
|
+
pointerModes: ['strike', 'clear'],
|
|
526
|
+
pointerLabels: ['Call a strike', 'Clearing'],
|
|
527
|
+
volume: [140, 60, 140],
|
|
528
|
+
staging: { sky: '#252b33', ground: '#2f3530', fog: 0.0045, sunEl: 12, sunAz: 200, inside: [[0, 1.7, 14], [0, 4, 0]], outside: [[120, 30, 160], [0, 15, 0]] },
|
|
529
|
+
};
|
|
530
|
+
const QUALITY = { low: 18, medium: 28, high: 40 };
|
|
531
|
+
function createUniforms() {
|
|
532
|
+
return Object.assign(createCommonUniforms(), {
|
|
533
|
+
uSigma: { value: 0.02 },
|
|
534
|
+
uShafts: { value: 0.6 },
|
|
535
|
+
uFall: { value: 0 },
|
|
536
|
+
uFlash: { value: 0 },
|
|
537
|
+
uFlashIntensity: { value: 1.5 },
|
|
538
|
+
uFlashColor: { value: new THREE.Color('#cfd8ff') },
|
|
539
|
+
uBolt: { value: new THREE.Vector3() },
|
|
540
|
+
uFlashRate: { value: 6 },
|
|
541
|
+
uFlashTint: { value: new THREE.Color(1, 1, 1) },
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
function applyConfig(u, c) {
|
|
545
|
+
applyCommonConfig(u, c, catalog.pointerModes);
|
|
546
|
+
if (c.shafts !== undefined)
|
|
547
|
+
u.uShafts.value = c.shafts;
|
|
548
|
+
if (c.flashIntensity !== undefined)
|
|
549
|
+
u.uFlashIntensity.value = c.flashIntensity;
|
|
550
|
+
setColor(u.uFlashColor, c.flashColor);
|
|
551
|
+
if (c.flashRate !== undefined)
|
|
552
|
+
u.uFlashRate.value = c.flashRate;
|
|
553
|
+
}
|
|
554
|
+
const FLASH_GLSL = /* glsl */ `
|
|
555
|
+
uniform float uFlash, uFlashIntensity;
|
|
556
|
+
uniform vec3 uFlashColor, uBolt, uFlashTint;
|
|
557
|
+
// light of the current flash at p: the bolt's channel lights its own rain most
|
|
558
|
+
vec3 flashAt(vec3 p) {
|
|
559
|
+
float dd = length((p - uBolt) * vec3(1.0, 0.35, 1.0));
|
|
560
|
+
return uFlashColor * uFlashTint * uFlash * uFlashIntensity * (0.25 + 1.2 * exp(-dd / (0.25 * uVolume.x)));
|
|
561
|
+
}
|
|
562
|
+
// the cursor's clearing: the murk is swept out of a column under it
|
|
563
|
+
float clearing(vec3 p) {
|
|
564
|
+
if (uPointerMode < 0.5 || uPointerActive < 0.001) return 0.0;
|
|
565
|
+
vec3 P = uPointer * uVolume, V = uPointerVel * uVolume;
|
|
566
|
+
float R = max(uPointerRadius * 2.0, 0.1), S = uPointerStrength * uPointerActive;
|
|
567
|
+
vec3 C = P - V * 0.2;
|
|
568
|
+
float below = smoothstep(C.y + 0.4, C.y - 0.6, p.y);
|
|
569
|
+
return clamp(S * bump(length(p.xz - C.xz) / (1.1 * R)) * below, 0.0, 1.0);
|
|
570
|
+
}
|
|
571
|
+
`;
|
|
572
|
+
const SHAFT = /* glsl */ `
|
|
573
|
+
uniform float uSigma, uShafts, uFall;
|
|
574
|
+
${FLASH_GLSL}
|
|
575
|
+
vec4 sliceSample(vec3 p, vec3 rd, float dz) {
|
|
576
|
+
vec3 q = p; q.xz -= uWind * 0.9;
|
|
577
|
+
// falling texture tilted by the wind
|
|
578
|
+
q.y += uFall; q.xz -= uWindDir * uWindStrength * 0.9 * (uVolume.y - p.y) * 0.4;
|
|
579
|
+
float w = vnoise3(q * 0.015 + vec3(uTurbPhase * 0.3));
|
|
580
|
+
q.xz += (w - 0.5) * uTurb * 30.0;
|
|
581
|
+
float n = fbm3(q * vec3(0.03, 0.008, 0.03));
|
|
582
|
+
// the streaky detail only where there is a curtain
|
|
583
|
+
float shaft = smoothstep(0.48, 0.7, n);
|
|
584
|
+
if (shaft > 0.0) shaft *= 0.7 + 0.6 * vnoise3(vec3(p.x * 0.4, q.y * 0.08, p.z * 0.4));
|
|
585
|
+
float d = uShafts * (0.15 + 2.2 * shaft) * (1.0 - clearing(p)) * volumeFade(p, min(10.0, 0.08 * uVolume.x), min(6.0, 0.12 * uVolume.y));
|
|
586
|
+
if (d < 0.002) return vec4(0.0);
|
|
587
|
+
float a = 1.0 - exp(-uSigma * d * dz);
|
|
588
|
+
vec3 amb = uSkyAmbient * uShadeColor * 0.9 + uSunColor * smoothstep(-0.05, 0.1, uSunDir.y) * 0.06;
|
|
589
|
+
vec3 col = uColor * (amb * (1.0 - 0.4 * shaft) + flashAt(p) * 0.55);
|
|
590
|
+
return vec4(col * a, a);
|
|
591
|
+
}
|
|
592
|
+
`;
|
|
593
|
+
function build(u, c) {
|
|
594
|
+
const count = QUALITY[c.quality] || QUALITY.medium;
|
|
595
|
+
const dens = Math.max(0.05, c.density ?? 1);
|
|
596
|
+
u.uSigma.value = 0.02 * dens;
|
|
597
|
+
const slices = buildSlices(u, sliceFrag(SHAFT, false), count, 1, true);
|
|
598
|
+
slices.renderOrder = 1;
|
|
599
|
+
// the scene light the lightning drives (self-owned, no shadows)
|
|
600
|
+
const light = new THREE.DirectionalLight(0xffffff, 0);
|
|
601
|
+
light.castShadow = false;
|
|
602
|
+
const object = new THREE.Group();
|
|
603
|
+
object.name = 'thunderstorm';
|
|
604
|
+
object.add(slices, light, light.target);
|
|
605
|
+
light.target.position.set(0, 0, 0);
|
|
606
|
+
// flash process: Poisson arrivals, 2-5 return strokes each
|
|
607
|
+
const rng = mulberry32((c.seed ?? 9) * 7919 + 1);
|
|
608
|
+
let wait = 1.5, clock = 0, strokes = [], cooldown = 0;
|
|
609
|
+
const bolt = u.uBolt.value;
|
|
610
|
+
const _d = new THREE.Vector3(), _o = new THREE.Vector3(), _w = new THREE.Vector3();
|
|
611
|
+
function fire(camera, at) {
|
|
612
|
+
// a strike the cursor calls takes the pointer colour
|
|
613
|
+
if (at)
|
|
614
|
+
u.uFlashTint.value.copy(u.uPointerColor.value);
|
|
615
|
+
else
|
|
616
|
+
u.uFlashTint.value.setRGB(1, 1, 1);
|
|
617
|
+
const V = u.uVolume.value;
|
|
618
|
+
if (at)
|
|
619
|
+
bolt.set(at.x, V.y * 0.9, at.z);
|
|
620
|
+
else {
|
|
621
|
+
// somewhere the camera can see: a random point on screen, at cloud height
|
|
622
|
+
let ok = false;
|
|
623
|
+
for (let i = 0; i < 4 && !ok; i++) {
|
|
624
|
+
_d.set((rng() * 2 - 1) * 0.75, 0.1 + rng() * 0.5, 0.5).unproject(camera).sub(camera.position).normalize();
|
|
625
|
+
object.worldToLocal(_o.copy(camera.position));
|
|
626
|
+
_w.copy(camera.position).add(_d);
|
|
627
|
+
object.worldToLocal(_w);
|
|
628
|
+
const dir = _w.sub(_o).multiply(V);
|
|
629
|
+
const o = _o.multiply(V);
|
|
630
|
+
const tY = (V.y * 0.9 - o.y) / (dir.y || 1e-6);
|
|
631
|
+
if (tY > 0 && tY < 2000) {
|
|
632
|
+
bolt.copy(o).addScaledVector(dir, tY);
|
|
633
|
+
ok = Math.abs(bolt.x) < V.x / 2 && Math.abs(bolt.z) < V.z / 2;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
if (!ok)
|
|
637
|
+
bolt.set((rng() - 0.5) * V.x * 0.8, V.y * 0.9, (rng() - 0.5) * V.z * 0.8);
|
|
638
|
+
}
|
|
639
|
+
const n = 2 + Math.floor(rng() * 4);
|
|
640
|
+
let t = clock;
|
|
641
|
+
strokes = [];
|
|
642
|
+
for (let i = 0; i < n; i++) {
|
|
643
|
+
strokes.push({ start: t, peak: i === 0 ? 1 : 0.4 + rng() * 0.6 });
|
|
644
|
+
t += 0.04 + rng() * 0.05;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
return {
|
|
648
|
+
object,
|
|
649
|
+
materials: [slices.material],
|
|
650
|
+
apply: function (cfg) { applyConfig(u, cfg); },
|
|
651
|
+
update: function (dt, camera, viewH, sunWorld, dpr) {
|
|
652
|
+
updateCommon(u, object, camera, dt, viewH, sunWorld, dpr);
|
|
653
|
+
adaptSlices(u, slices, count);
|
|
654
|
+
const sp = u.uSpeed.value;
|
|
655
|
+
u.uFall.value += dt * sp * 6.0;
|
|
656
|
+
clock += dt;
|
|
657
|
+
cooldown -= dt;
|
|
658
|
+
const rate = Math.max(0, u.uFlashRate.value);
|
|
659
|
+
wait -= dt * sp;
|
|
660
|
+
if (rate > 0 && wait <= 0) {
|
|
661
|
+
fire(camera, null);
|
|
662
|
+
wait = -Math.log(1 - rng()) * 60 / rate;
|
|
663
|
+
}
|
|
664
|
+
// the cursor calls a strike: a quick sweep, then a short cooldown
|
|
665
|
+
if (u.uPointerMode.value === 0 && u.uPointerActive.value > 0.5 && cooldown <= 0) {
|
|
666
|
+
const v = u.uPointerVel.value.length() * u.uVolume.value.x;
|
|
667
|
+
if (v > 6 * Math.max(0.2, 1 / Math.max(u.uPointerStrength.value, 0.01))) {
|
|
668
|
+
const P = u.uPointer.value, V = u.uVolume.value;
|
|
669
|
+
fire(camera, { x: P.x * V.x, z: P.z * V.z });
|
|
670
|
+
cooldown = 1.6;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
let f = 0;
|
|
674
|
+
for (const s of strokes) {
|
|
675
|
+
const t = clock - s.start;
|
|
676
|
+
if (t < 0)
|
|
677
|
+
continue;
|
|
678
|
+
f = Math.max(f, s.peak * (t < 0.006 ? t / 0.006 : Math.exp(-(t - 0.006) / 0.07)));
|
|
679
|
+
}
|
|
680
|
+
u.uFlash.value = f;
|
|
681
|
+
const V = u.uVolume.value;
|
|
682
|
+
light.position.set(bolt.x / V.x, bolt.y / V.y, bolt.z / V.z);
|
|
683
|
+
light.color.copy(u.uFlashColor.value).multiply(u.uFlashTint.value);
|
|
684
|
+
light.intensity = f * u.uFlashIntensity.value * 3.0;
|
|
685
|
+
},
|
|
686
|
+
dispose: function () { slices.geometry.dispose(); slices.material.dispose(); light.dispose(); },
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
// =============================================================================
|
|
690
|
+
// Component
|
|
691
|
+
// =============================================================================
|
|
692
|
+
const DEFAULTS = DEFAULT_ENVIRONMENT_OBJECTS.thunderstorm;
|
|
693
|
+
/** Knobs that rebuild the object: never live, they change once, on commit. */
|
|
694
|
+
const STRUCTURAL = ['density', 'quality', 'seed'];
|
|
695
|
+
/** Knobs a keyframe or pointer binding may drive per frame — exactly what applyConfig pushes. */
|
|
696
|
+
const ANIMATABLE = new Set(ENVIRONMENT_OBJECTS_ANIMATABLE.thunderstorm.map((p) => p.value));
|
|
697
|
+
/** The scene's sky fill is brighter than the medium's own ambient term expects. */
|
|
698
|
+
const SKY_FILL = 0.5;
|
|
699
|
+
/**
|
|
700
|
+
* A thunderstorm without the rain (rain is its own object): dark storm curtains drifting on the wind, and lightning arriving as a Poisson process of multi-stroke flashes that light the curtains and the whole scene. The cursor calls a strike or clears the murk. Use for storm, noir and dramatic scenes.
|
|
701
|
+
*
|
|
702
|
+
* The volume is the parent's transform: x / z span its scale, y rises from its origin to scale.y.
|
|
703
|
+
*/
|
|
704
|
+
const Thunderstorm = ({ config, id, keyframes, mouseMove, onObjectReady, onObjectDispose }) => {
|
|
705
|
+
const rootRef = useRef(null);
|
|
706
|
+
useObjectReady(rootRef, config, onObjectReady, onObjectDispose);
|
|
707
|
+
const cfg = useMemo(() => withConfigDefaults(DEFAULTS, config), [config]);
|
|
708
|
+
// uniforms outlive rebuilds, so phases and keyframes survive a structural change
|
|
709
|
+
const uniforms = useMemo(() => createUniforms(), []);
|
|
710
|
+
const instance = useMemo(() => build(uniforms, cfg), [uniforms, cfg.density, cfg.quality, cfg.seed]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
711
|
+
useEffect(() => () => instance.dispose(), [instance]);
|
|
712
|
+
useLayoutEffect(() => { applyConfig(uniforms, cfg); }, [uniforms, cfg]);
|
|
713
|
+
const push = useCallback((merged) => { applyConfig(uniforms, merged); }, [uniforms]);
|
|
714
|
+
useConfigDriver({ rootRef, id, family: 'environment', base: cfg, structural: STRUCTURAL, allowed: ANIMATABLE, keyframes, mouseMove, push });
|
|
715
|
+
const pointer = usePointerField();
|
|
716
|
+
// the scene's sun, read-only: the same one the clouds, the water and the key light use
|
|
717
|
+
const sun = useCloudSun();
|
|
718
|
+
const anchor = useMemo(() => new THREE.Vector3(), []);
|
|
719
|
+
const buffer = useMemo(() => new THREE.Vector2(), []);
|
|
720
|
+
useFrame((state, delta) => {
|
|
721
|
+
const dt = Math.min(delta, 0.1);
|
|
722
|
+
const s = sun.update();
|
|
723
|
+
uniforms.uSunColor.value.copy(s.color);
|
|
724
|
+
uniforms.uSkyAmbient.value.copy(s.skyAmbient).multiplyScalar(SKY_FILL);
|
|
725
|
+
state.gl.getDrawingBufferSize(buffer);
|
|
726
|
+
instance.update(dt, state.camera, buffer.y, s.direction, state.viewport.dpr);
|
|
727
|
+
stepPointerField(uniforms, pointer, state.camera, instance.object, 1, dt, pointerAnchor(instance.object, state.camera, uniforms, anchor, 4.5));
|
|
728
|
+
});
|
|
729
|
+
return (_jsx("group", { ref: rootRef, children: _jsx("primitive", { object: instance.object }) }));
|
|
730
|
+
};
|
|
731
|
+
export default Thunderstorm;
|