@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,727 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { buildCapsules, capsuleMaterial, setReveal } from '../ribbon.js';
|
|
3
|
+
import { prepare, applyDraw, applyErase, extentOf, DRAW_METHODS, ERASE_METHODS } from '../methods.js';
|
|
4
|
+
const hex = (h) => new THREE.Color(h);
|
|
5
|
+
const clamp01 = (x) => Math.max(0, Math.min(1, x));
|
|
6
|
+
function mulberry32(a) { return function () { a |= 0; a = (a + 0x6D2B79F5) | 0; let t = Math.imul(a ^ (a >>> 15), 1 | a); t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; return ((t ^ (t >>> 14)) >>> 0) / 4294967296; }; }
|
|
7
|
+
// =========================================================================================
|
|
8
|
+
// frostGrowth - hoarfrost / dendritic ice crystallising on the letters.
|
|
9
|
+
//
|
|
10
|
+
// The maths (all computed once, at build, deterministically):
|
|
11
|
+
// * Ice Ih is hexagonal, so a growing dendrite arm splits sidebranches at +/-60 deg to its own heading (six-fold
|
|
12
|
+
// lattice), forward leaning, each sidebranch shorter than the part of the parent that lies beyond its root (the
|
|
13
|
+
// pointed fern envelope), with occasional tip-splitting into a trident (tip + two 60 deg prongs).
|
|
14
|
+
// * Generation 0 is the rime along every letter contour (the spine). It spreads both ways from a nucleation point.
|
|
15
|
+
// Generation 1 barbs leave the spine at 60 deg to the local tangent (outward into the frost zone; some inward, short),
|
|
16
|
+
// generation 2..4 are sidebranches of sidebranches.
|
|
17
|
+
// * Diffusion-limited screening: a signed-distance grid of the letters bounds the frost zone (reach), and a coarse
|
|
18
|
+
// segment occupancy grid rejects any step that would come closer than a generation-dependent separation to a branch of
|
|
19
|
+
// another lineage, so arms never cross; they stop where they meet (generation by generation = the older, larger arms
|
|
20
|
+
// claim space first, which is exactly what screens the small ones).
|
|
21
|
+
// * Every point gets a birth time = parent's time at the root + latency + distance along the arm / tip speed. DRAW is
|
|
22
|
+
// therefore literally the crystal growing (spines first, tips last); ERASE ('sublimate') is the reverse weighted by
|
|
23
|
+
// thinness: hairs and tips vanish first, the spine last. Shared methods drive only the spine; the branches follow it.
|
|
24
|
+
// * Shading: thickness tapers with generation and along the arm; colour = ramp between a cool deep tone (thick) and a
|
|
25
|
+
// pale blue-white (thin), with a Fresnel-like bright rim; sub-pixel hairs are dimmed by their pixel coverage.
|
|
26
|
+
// =========================================================================================
|
|
27
|
+
const CELL = 0.01; // signed-distance grid cell (em)
|
|
28
|
+
const STEP = [0.016, 0.014, 0.01, 0.007, 0.0055]; // step length per generation
|
|
29
|
+
const SEP = [0.0, 0.0125, 0.0075, 0.0058, 0.0046]; // min distance to a foreign arm per generation
|
|
30
|
+
const SIDE_SP = [0, 0, 0.027, 0.018, 0.012]; // side-branch spacing along an arm of generation g -> children
|
|
31
|
+
const SIDE_RATIO = [0, 0, 0.56, 0.5, 0.46]; // child length / remaining length of the parent
|
|
32
|
+
const MIN_LEN = [0, 0.03, 0.02, 0.014, 0.01];
|
|
33
|
+
const SPEED = [0, 2.4, 3.0, 3.6, 4.2]; // progress per em along an arm of generation g (slower = bigger crystal)
|
|
34
|
+
const LATENCY = [0, 0.03, 0.025, 0.02, 0.015];
|
|
35
|
+
const WF = [0.66, 0.5, 0.4, 0.3, 0.22]; // thickness factor per generation
|
|
36
|
+
const MAX_GEN = 4;
|
|
37
|
+
const MAX_SEG = 24000;
|
|
38
|
+
const SIN60 = Math.sqrt(3) / 2, COS60 = 0.5;
|
|
39
|
+
// ---- signed distance grid of the letters (union by non-zero winding, chamfer distance) ----------------------------
|
|
40
|
+
function buildSDF(strokes, ext, pad) {
|
|
41
|
+
const x0 = ext.x0 - pad, y0 = ext.y0 - pad;
|
|
42
|
+
const W = Math.ceil((ext.w + 2 * pad) / CELL) + 2, H = Math.ceil((ext.h + 2 * pad) / CELL) + 2;
|
|
43
|
+
const rows = new Array(H);
|
|
44
|
+
for (let j = 0; j < H; j++)
|
|
45
|
+
rows[j] = [];
|
|
46
|
+
for (const s of strokes) {
|
|
47
|
+
const n = s.pts.length / 2;
|
|
48
|
+
for (let i = 0; i < n - 1; i++) {
|
|
49
|
+
const ax = s.pts[2 * i], ay = s.pts[2 * i + 1], bx = s.pts[2 * i + 2], by = s.pts[2 * i + 3];
|
|
50
|
+
if (ay === by)
|
|
51
|
+
continue;
|
|
52
|
+
const lo = Math.min(ay, by), hi = Math.max(ay, by), dir = by > ay ? 1 : -1;
|
|
53
|
+
const j0 = Math.max(0, Math.ceil((lo - y0) / CELL - 0.5)), j1 = Math.min(H - 1, Math.ceil((hi - y0) / CELL - 0.5) - 1);
|
|
54
|
+
for (let j = j0; j <= j1; j++) {
|
|
55
|
+
const cy = y0 + (j + 0.5) * CELL;
|
|
56
|
+
rows[j].push(ax + ((cy - ay) * (bx - ax)) / (by - ay), dir);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const ins = new Uint8Array(W * H);
|
|
61
|
+
for (let j = 0; j < H; j++) {
|
|
62
|
+
const r = rows[j];
|
|
63
|
+
const m = r.length / 2;
|
|
64
|
+
if (!m)
|
|
65
|
+
continue;
|
|
66
|
+
const idx = Array.from({ length: m }, (_, k) => k).sort((a, b) => r[2 * a] - r[2 * b]);
|
|
67
|
+
let w = 0;
|
|
68
|
+
for (let k = 0; k < m - 1; k++) {
|
|
69
|
+
w += r[2 * idx[k] + 1];
|
|
70
|
+
if (w !== 0) {
|
|
71
|
+
const i0 = Math.max(0, Math.ceil((r[2 * idx[k]] - x0) / CELL - 0.5)), i1 = Math.min(W - 1, Math.ceil((r[2 * idx[k + 1]] - x0) / CELL - 0.5) - 1);
|
|
72
|
+
for (let i = i0; i <= i1; i++)
|
|
73
|
+
ins[j * W + i] = 1;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const dt = (src) => {
|
|
78
|
+
const d = new Float32Array(W * H);
|
|
79
|
+
const INF = 1e6, R2 = Math.SQRT2;
|
|
80
|
+
for (let k = 0; k < W * H; k++)
|
|
81
|
+
d[k] = ins[k] === src ? 0 : INF;
|
|
82
|
+
for (let j = 0; j < H; j++)
|
|
83
|
+
for (let i = 0; i < W; i++) {
|
|
84
|
+
const k = j * W + i;
|
|
85
|
+
let v = d[k];
|
|
86
|
+
if (i > 0)
|
|
87
|
+
v = Math.min(v, d[k - 1] + 1);
|
|
88
|
+
if (j > 0) {
|
|
89
|
+
v = Math.min(v, d[k - W] + 1);
|
|
90
|
+
if (i > 0)
|
|
91
|
+
v = Math.min(v, d[k - W - 1] + R2);
|
|
92
|
+
if (i < W - 1)
|
|
93
|
+
v = Math.min(v, d[k - W + 1] + R2);
|
|
94
|
+
}
|
|
95
|
+
d[k] = v;
|
|
96
|
+
}
|
|
97
|
+
for (let j = H - 1; j >= 0; j--)
|
|
98
|
+
for (let i = W - 1; i >= 0; i--) {
|
|
99
|
+
const k = j * W + i;
|
|
100
|
+
let v = d[k];
|
|
101
|
+
if (i < W - 1)
|
|
102
|
+
v = Math.min(v, d[k + 1] + 1);
|
|
103
|
+
if (j < H - 1) {
|
|
104
|
+
v = Math.min(v, d[k + W] + 1);
|
|
105
|
+
if (i < W - 1)
|
|
106
|
+
v = Math.min(v, d[k + W + 1] + R2);
|
|
107
|
+
if (i > 0)
|
|
108
|
+
v = Math.min(v, d[k + W - 1] + R2);
|
|
109
|
+
}
|
|
110
|
+
d[k] = v;
|
|
111
|
+
}
|
|
112
|
+
return d;
|
|
113
|
+
};
|
|
114
|
+
const dOut = dt(1), dIn = dt(0);
|
|
115
|
+
const sd = new Float32Array(W * H);
|
|
116
|
+
for (let k = 0; k < W * H; k++)
|
|
117
|
+
sd[k] = (ins[k] ? -(dIn[k] - 0.5) : dOut[k] - 0.5) * CELL;
|
|
118
|
+
return { sample(x, y) {
|
|
119
|
+
const u = (x - x0) / CELL - 0.5, v = (y - y0) / CELL - 0.5;
|
|
120
|
+
const i = Math.floor(u), j = Math.floor(v);
|
|
121
|
+
if (i < 0 || j < 0 || i >= W - 1 || j >= H - 1)
|
|
122
|
+
return 1;
|
|
123
|
+
const fx = u - i, fy = v - j, k = j * W + i;
|
|
124
|
+
return (sd[k] * (1 - fx) + sd[k + 1] * fx) * (1 - fy) + (sd[k + W] * (1 - fx) + sd[k + W + 1] * fx) * fy;
|
|
125
|
+
} };
|
|
126
|
+
}
|
|
127
|
+
// ---- segment occupancy grid (screening) ---------------------------------------------------------------------------
|
|
128
|
+
function makeOccupancy(ext, pad) {
|
|
129
|
+
const OC = 0.03;
|
|
130
|
+
const x0 = ext.x0 - pad, y0 = ext.y0 - pad;
|
|
131
|
+
const OW = Math.ceil((ext.w + 2 * pad) / OC) + 2;
|
|
132
|
+
const cells = new Map();
|
|
133
|
+
const ax = [], ay = [], bx = [], by = [], pid = [];
|
|
134
|
+
const key = (i, j) => i * 4096 + j;
|
|
135
|
+
const cx = (x) => Math.floor((x - x0) / OC), cy = (y) => Math.floor((y - y0) / OC);
|
|
136
|
+
return {
|
|
137
|
+
add(x1, y1, x2, y2, p) {
|
|
138
|
+
const id = ax.length;
|
|
139
|
+
ax.push(x1);
|
|
140
|
+
ay.push(y1);
|
|
141
|
+
bx.push(x2);
|
|
142
|
+
by.push(y2);
|
|
143
|
+
pid.push(p);
|
|
144
|
+
const e = 0.014;
|
|
145
|
+
const i0 = cx(Math.min(x1, x2) - e), i1 = cx(Math.max(x1, x2) + e), j0 = cy(Math.min(y1, y2) - e), j1 = cy(Math.max(y1, y2) + e);
|
|
146
|
+
for (let i = i0; i <= i1; i++)
|
|
147
|
+
for (let j = j0; j <= j1; j++) {
|
|
148
|
+
const k = key(i, j);
|
|
149
|
+
let a = cells.get(k);
|
|
150
|
+
if (!a) {
|
|
151
|
+
a = [];
|
|
152
|
+
cells.set(k, a);
|
|
153
|
+
}
|
|
154
|
+
a.push(id);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
// is (px,py) closer than sep to a segment of another lineage? early = skip ancestors / siblings (they share the root)
|
|
158
|
+
blocked(px, py, p, sep, early, parentOf) {
|
|
159
|
+
const a = cells.get(key(cx(px), cy(py)));
|
|
160
|
+
if (!a)
|
|
161
|
+
return false;
|
|
162
|
+
const par = parentOf[p], gpar = par >= 0 ? parentOf[par] : -1;
|
|
163
|
+
for (let n = 0; n < a.length; n++) {
|
|
164
|
+
const id = a[n];
|
|
165
|
+
const o = pid[id];
|
|
166
|
+
if (o === p)
|
|
167
|
+
continue;
|
|
168
|
+
if (early && (o === par || o === gpar || parentOf[o] === par))
|
|
169
|
+
continue;
|
|
170
|
+
const dx = bx[id] - ax[id], dy = by[id] - ay[id];
|
|
171
|
+
const l2 = dx * dx + dy * dy;
|
|
172
|
+
let t = l2 > 0 ? ((px - ax[id]) * dx + (py - ay[id]) * dy) / l2 : 0;
|
|
173
|
+
t = t < 0 ? 0 : t > 1 ? 1 : t;
|
|
174
|
+
const ex = ax[id] + dx * t - px, ey = ay[id] + dy * t - py;
|
|
175
|
+
if (ex * ex + ey * ey < sep * sep)
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
return false;
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
// ---- the crystal --------------------------------------------------------------------------------------------------
|
|
183
|
+
function growCrystal(spines, cfg, rnd) {
|
|
184
|
+
const ext = extentOf(spines);
|
|
185
|
+
const reach = cfg.reach, br = Math.max(0.2, cfg.branching);
|
|
186
|
+
const pad = reach + 0.2;
|
|
187
|
+
const sdf = buildSDF(spines, ext, pad);
|
|
188
|
+
const occ = makeOccupancy(ext, pad);
|
|
189
|
+
const parentOf = [];
|
|
190
|
+
const nc = spines.length;
|
|
191
|
+
spines.forEach((s, ci) => { parentOf.push(-1); for (let i = 0; i < s.pts.length / 2 - 1; i++)
|
|
192
|
+
occ.add(s.pts[2 * i], s.pts[2 * i + 1], s.pts[2 * i + 2], s.pts[2 * i + 3], ci); });
|
|
193
|
+
let segCount = 0;
|
|
194
|
+
const branches = [];
|
|
195
|
+
const reachCap = reach * 1.12 + 0.012, innerDepth = 0.09;
|
|
196
|
+
// ---- crystal grains: K nucleation sites on the letters (farthest-point spread, seeded). A grain = the (slightly warped) Voronoi
|
|
197
|
+
// cell of its site; inside it every arm lies on the grain's own 60 deg lattice (orientation phi), growth stops at the boundary.
|
|
198
|
+
const K = Math.max(1, Math.min(9, Math.round(cfg.grains)));
|
|
199
|
+
const cand = [];
|
|
200
|
+
spines.forEach((s, ci) => { for (let i = 0; i < s.pts.length / 2 - 1; i += 3)
|
|
201
|
+
cand.push([s.pts[2 * i], s.pts[2 * i + 1], ci, i]); });
|
|
202
|
+
const grains = [];
|
|
203
|
+
for (let k = 0; k < K; k++) {
|
|
204
|
+
let best = null, bd = -1;
|
|
205
|
+
for (let t = 0; t < (k ? 160 : 1); t++) {
|
|
206
|
+
const c = cand[Math.floor(rnd() * cand.length)];
|
|
207
|
+
let md = 1e9;
|
|
208
|
+
for (const g of grains)
|
|
209
|
+
md = Math.min(md, Math.hypot(c[0] - g.x, c[1] - g.y));
|
|
210
|
+
if (k === 0)
|
|
211
|
+
md = 1;
|
|
212
|
+
if (md > bd) {
|
|
213
|
+
bd = md;
|
|
214
|
+
best = c;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
grains.push({ x: best[0], y: best[1], ci: best[2], i: best[3], phi: ((k * 0.618034 + 0.12 * rnd()) % 1) * (Math.PI / 3), delay: k ? rnd() * 0.1 : 0, p1: rnd() * 6.28, p2: rnd() * 6.28, p3: rnd() * 6.28, p4: rnd() * 6.28 });
|
|
218
|
+
}
|
|
219
|
+
const score = (k, x, y) => { const g = grains[k]; return Math.hypot(x - g.x, y - g.y) + 0.02 * Math.sin(x * 7.3 + g.p1) * Math.sin(y * 6.1 + g.p2) + 0.012 * Math.sin(x * 17.0 + y * 11.0 + g.p3); };
|
|
220
|
+
const exactAt = (x, y) => { let b = 0, bs = 1e9; for (let k = 0; k < K; k++) {
|
|
221
|
+
const v = score(k, x, y);
|
|
222
|
+
if (v < bs) {
|
|
223
|
+
bs = v;
|
|
224
|
+
b = k;
|
|
225
|
+
}
|
|
226
|
+
} return b; };
|
|
227
|
+
// label grid (same lattice as the SDF, 1 cell = 1 cm) so the hot loops are a lookup
|
|
228
|
+
const gx0 = ext.x0 - pad, gy0 = ext.y0 - pad, gW = Math.ceil((ext.w + 2 * pad) / CELL) + 2, gH = Math.ceil((ext.h + 2 * pad) / CELL) + 2;
|
|
229
|
+
const gl = new Uint8Array(gW * gH);
|
|
230
|
+
if (K > 1)
|
|
231
|
+
for (let j = 0; j < gH; j++)
|
|
232
|
+
for (let i = 0; i < gW; i++)
|
|
233
|
+
gl[j * gW + i] = exactAt(gx0 + (i + 0.5) * CELL, gy0 + (j + 0.5) * CELL);
|
|
234
|
+
const grainAt = (x, y) => { if (K === 1)
|
|
235
|
+
return 0; const i = Math.floor((x - gx0) / CELL), j = Math.floor((y - gy0) / CELL); if (i < 0 || j < 0 || i >= gW || j >= gH)
|
|
236
|
+
return exactAt(x, y); return gl[j * gW + i]; };
|
|
237
|
+
const TH = Math.PI / 3;
|
|
238
|
+
const snap = (th, phi) => phi + Math.round((th - phi) / TH) * TH;
|
|
239
|
+
const lattice = (phi, nx, ny, sgn, minDot) => { const out = []; for (let m = 0; m < 6; m++) {
|
|
240
|
+
const a = phi + m * TH;
|
|
241
|
+
const dt = (Math.cos(a) * nx + Math.sin(a) * ny) * sgn;
|
|
242
|
+
if (dt >= minDot)
|
|
243
|
+
out.push({ a, dt });
|
|
244
|
+
} out.sort((u, v) => v.dt - u.dt); return out; };
|
|
245
|
+
// trace one arm; returns its polyline or null
|
|
246
|
+
function trace(sp) {
|
|
247
|
+
const g = sp.g, h = STEP[g], n = Math.max(1, Math.floor(sp.len / h));
|
|
248
|
+
const pid = nc + branches.length;
|
|
249
|
+
parentOf[pid] = sp.parent;
|
|
250
|
+
let x = sp.x, y = sp.y, th = sp.th;
|
|
251
|
+
const bend = (rnd() - 0.5) * 0.04;
|
|
252
|
+
const pts = [x, y];
|
|
253
|
+
const phi = grains[sp.grain].phi;
|
|
254
|
+
const m3 = (((Math.round((sp.th - phi) / TH) % 3) + 3) % 3);
|
|
255
|
+
for (let k = 1; k <= n; k++) {
|
|
256
|
+
th += bend * 0.3 + (rnd() - 0.5) * 0.012;
|
|
257
|
+
const nx = x + Math.cos(th) * h, ny = y + Math.sin(th) * h;
|
|
258
|
+
const sd = sdf.sample(nx, ny);
|
|
259
|
+
if (sp.inner) {
|
|
260
|
+
if (k >= 2 && (sd > -0.004 || sd < -innerDepth))
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
else if (k >= 2 && (sd < 0.005 || sd > reachCap))
|
|
264
|
+
break;
|
|
265
|
+
if (K > 1 && grainAt(nx + Math.cos(th) * 0.007, ny + Math.sin(th) * 0.007) !== sp.grain)
|
|
266
|
+
break; // grain boundary: growth stops
|
|
267
|
+
const early = k <= 3;
|
|
268
|
+
if (occ.blocked(nx, ny, pid, SEP[g], early, parentOf) || occ.blocked((x + nx) / 2, (y + ny) / 2, pid, SEP[g], early, parentOf))
|
|
269
|
+
break;
|
|
270
|
+
occ.add(x, y, nx, ny, pid);
|
|
271
|
+
x = nx;
|
|
272
|
+
y = ny;
|
|
273
|
+
pts.push(x, y);
|
|
274
|
+
segCount++;
|
|
275
|
+
}
|
|
276
|
+
if (pts.length < 4) {
|
|
277
|
+
parentOf.length = pid;
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
const rec = { pts, g, pid, parent: sp.parent, pidx: sp.pidx, inner: sp.inner, glyph: sp.glyph, th, rid: rnd(), grain: sp.grain, m3 };
|
|
281
|
+
branches.push(rec);
|
|
282
|
+
return rec;
|
|
283
|
+
}
|
|
284
|
+
// generation 1: barbs along every contour, snapped to the lattice of the grain they sit in.
|
|
285
|
+
const nuc = [];
|
|
286
|
+
let specs = [];
|
|
287
|
+
const rime = [];
|
|
288
|
+
spines.forEach((s, ci) => {
|
|
289
|
+
const L = s.len;
|
|
290
|
+
const list = grains.filter((g) => g.ci === ci).map((g) => ({ c: s.cum[g.i], delay: g.delay }));
|
|
291
|
+
const own = list.length === 0;
|
|
292
|
+
if (own)
|
|
293
|
+
list.push({ c: rnd() * L, delay: 0 });
|
|
294
|
+
nuc.push({ list, own });
|
|
295
|
+
const c0 = list[0].c;
|
|
296
|
+
const at = (c) => {
|
|
297
|
+
c = ((c % L) + L) % L;
|
|
298
|
+
let lo = 0, hi = s.cum.length - 1;
|
|
299
|
+
while (hi - lo > 1) {
|
|
300
|
+
const m = (lo + hi) >> 1;
|
|
301
|
+
if (s.cum[m] <= c)
|
|
302
|
+
lo = m;
|
|
303
|
+
else
|
|
304
|
+
hi = m;
|
|
305
|
+
}
|
|
306
|
+
const f = (c - s.cum[lo]) / Math.max(1e-9, s.cum[hi] - s.cum[lo]);
|
|
307
|
+
return { x: s.pts[2 * lo] + (s.pts[2 * hi] - s.pts[2 * lo]) * f, y: s.pts[2 * lo + 1] + (s.pts[2 * hi + 1] - s.pts[2 * lo + 1]) * f, i: f > 0.5 ? hi : lo };
|
|
308
|
+
};
|
|
309
|
+
const frame = (c) => {
|
|
310
|
+
const p = at(c), a = at(c - 0.014), b = at(c + 0.014);
|
|
311
|
+
let tx = b.x - a.x, ty = b.y - a.y;
|
|
312
|
+
const tl = Math.hypot(tx, ty) || 1;
|
|
313
|
+
tx /= tl;
|
|
314
|
+
ty /= tl;
|
|
315
|
+
let nx = -ty, ny = tx;
|
|
316
|
+
if (sdf.sample(p.x + 0.008 * nx, p.y + 0.008 * ny) < 0) {
|
|
317
|
+
nx = -nx;
|
|
318
|
+
ny = -ny;
|
|
319
|
+
}
|
|
320
|
+
return { p, nx, ny, gi: grainAt(p.x, p.y) };
|
|
321
|
+
};
|
|
322
|
+
const ds0 = 0.07 / br;
|
|
323
|
+
const ph1 = rnd() * 6.28, ph2 = rnd() * 6.28, f1 = 5 + rnd() * 6, f2 = 13 + rnd() * 9;
|
|
324
|
+
for (let c = rnd() * ds0; c < L; c += ds0 * (0.75 + 0.5 * rnd())) {
|
|
325
|
+
let dd0 = c - c0;
|
|
326
|
+
if (dd0 > L / 2)
|
|
327
|
+
dd0 -= L;
|
|
328
|
+
if (dd0 < -L / 2)
|
|
329
|
+
dd0 += L;
|
|
330
|
+
// patchy: ferns are larger near the nucleus (older frost) and in lucky stretches of the contour; some stretches stay bare rime
|
|
331
|
+
const patch = 0.62 + 0.38 * Math.sin(c * f1 / L * 3 + ph1) * Math.cos(c * f2 + ph2) + 0.2 * (1 - Math.abs(dd0) / (L / 2));
|
|
332
|
+
if (patch < 0.3 || rnd() < 0.08)
|
|
333
|
+
continue;
|
|
334
|
+
const { p, nx, ny, gi } = frame(c);
|
|
335
|
+
const phi = grains[gi].phi;
|
|
336
|
+
const r = rnd();
|
|
337
|
+
const outs = lattice(phi, nx, ny, 1, 0.45);
|
|
338
|
+
const a1 = (outs.length > 1 && rnd() < 0.4 ? outs[outs.length - 1] : outs[0]).a + (rnd() - 0.5) * 0.04;
|
|
339
|
+
specs.push({ x: p.x, y: p.y, th: a1, len: (reach * Math.min(1.25, patch) * (0.75 + 0.5 * r)) / SIN60, g: 1, parent: ci, pidx: p.i, inner: false, glyph: s.glyph, grain: gi, key: rnd() });
|
|
340
|
+
if (rnd() < 0.5) {
|
|
341
|
+
const ins = lattice(phi, nx, ny, -1, 0.45);
|
|
342
|
+
specs.push({ x: p.x, y: p.y, th: ins[Math.floor(rnd() * ins.length)].a, len: Math.min(0.07, reach * 0.6) * (0.7 + 0.6 * rnd()), g: 1, parent: ci, pidx: p.i, inner: true, glyph: s.glyph, grain: gi, key: rnd() });
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
// rime fringe: short crystals along the whole edge (generation 2 slots, so they fill what the barbs leave)
|
|
346
|
+
for (let c = rnd() * 0.02; c < L; c += 0.02 * (0.7 + 0.6 * rnd())) {
|
|
347
|
+
if (rnd() < 0.15)
|
|
348
|
+
continue;
|
|
349
|
+
const { p, nx, ny, gi } = frame(c);
|
|
350
|
+
const outs = lattice(grains[gi].phi, nx, ny, 1, 0.45);
|
|
351
|
+
rime.push({ x: p.x, y: p.y, th: outs[Math.floor(rnd() * outs.length)].a, len: (0.012 + 0.03 * rnd()) * Math.min(1, reach / 0.12), g: 2, parent: ci, pidx: p.i, inner: false, glyph: s.glyph, grain: gi, key: rnd() });
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
for (let g = 1; g <= MAX_GEN; g++) {
|
|
355
|
+
specs.sort((a, b) => a.key - b.key); // random order inside a generation: nobody is systematically favoured
|
|
356
|
+
const made = [];
|
|
357
|
+
for (const sp of specs) {
|
|
358
|
+
if (segCount > MAX_SEG)
|
|
359
|
+
break;
|
|
360
|
+
const rec = trace(sp);
|
|
361
|
+
if (rec)
|
|
362
|
+
made.push(rec);
|
|
363
|
+
}
|
|
364
|
+
if (g === MAX_GEN)
|
|
365
|
+
break;
|
|
366
|
+
const next = g === 1 ? rime.splice(0) : [];
|
|
367
|
+
for (const b of made) {
|
|
368
|
+
const P = b.pts, n = P.length / 2;
|
|
369
|
+
const ng = g + 1;
|
|
370
|
+
let Ltot = 0;
|
|
371
|
+
const cum = [0];
|
|
372
|
+
for (let i = 1; i < n; i++) {
|
|
373
|
+
Ltot += Math.hypot(P[2 * i] - P[2 * i - 2], P[2 * i + 1] - P[2 * i - 1]);
|
|
374
|
+
cum.push(Ltot);
|
|
375
|
+
}
|
|
376
|
+
b.cum = cum;
|
|
377
|
+
b.len = Ltot;
|
|
378
|
+
const sp = SIDE_SP[ng] / br;
|
|
379
|
+
let last = 0.022;
|
|
380
|
+
for (let i = 1; i < n - 1; i++) {
|
|
381
|
+
if (cum[i] - last < sp * (0.8 + 0.4 * rnd()))
|
|
382
|
+
continue;
|
|
383
|
+
const hx = P[2 * i + 2] - P[2 * i - 2], hy = P[2 * i + 3] - P[2 * i - 1];
|
|
384
|
+
const th = Math.atan2(hy, hx);
|
|
385
|
+
last = cum[i];
|
|
386
|
+
for (let sd = -1; sd <= 1; sd += 2) {
|
|
387
|
+
if (rnd() > 0.92)
|
|
388
|
+
continue;
|
|
389
|
+
const Ls = SIDE_RATIO[ng] * (Ltot - cum[i]) * (0.7 + 0.6 * rnd());
|
|
390
|
+
if (Ls < MIN_LEN[ng])
|
|
391
|
+
continue;
|
|
392
|
+
next.push({ x: P[2 * i], y: P[2 * i + 1], th: snap(th + sd * TH, grains[b.grain].phi) + (rnd() - 0.5) * 0.03, len: Ls, g: ng, parent: b.pid, pidx: i, inner: b.inner, glyph: b.glyph, grain: b.grain, key: rnd() });
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
// tip splitting: a trident (tip + two 60 deg prongs)
|
|
396
|
+
if (n > 3 && Ltot > 0.06 && rnd() < 0.38 * Math.min(1.6, br))
|
|
397
|
+
for (let sd = -1; sd <= 1; sd += 2) {
|
|
398
|
+
const Ls = Ltot * 0.3 * (0.7 + 0.6 * rnd());
|
|
399
|
+
if (Ls < MIN_LEN[ng])
|
|
400
|
+
continue;
|
|
401
|
+
next.push({ x: P[2 * n - 2], y: P[2 * n - 1], th: snap(b.th + sd * TH, grains[b.grain].phi) + (rnd() - 0.5) * 0.03, len: Ls, g: ng, parent: b.pid, pidx: n - 1, inner: b.inner, glyph: b.glyph, grain: b.grain, key: rnd() });
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
specs = next;
|
|
405
|
+
}
|
|
406
|
+
// ---- grain boundaries: trace the (warped) bisector of every pair of grains through the frost zone -> thin bright seams
|
|
407
|
+
const seams = [];
|
|
408
|
+
if (K > 1) {
|
|
409
|
+
const R = Math.hypot(ext.w, ext.h) / 2 + 0.6, cxm = (ext.x0 + ext.x1) / 2, cym = (ext.y0 + ext.y1) / 2;
|
|
410
|
+
for (let a = 0; a < K; a++)
|
|
411
|
+
for (let b = a + 1; b < K; b++) {
|
|
412
|
+
const A = grains[a], B = grains[b];
|
|
413
|
+
const dx = B.x - A.x, dy = B.y - A.y, dl = Math.hypot(dx, dy) || 1;
|
|
414
|
+
const nx = dx / dl, ny = dy / dl, ux = -ny, uy = nx;
|
|
415
|
+
const mx = (A.x + B.x) / 2, my = (A.y + B.y) / 2;
|
|
416
|
+
let run = [];
|
|
417
|
+
const flush = () => { if (run.length >= 6)
|
|
418
|
+
seams.push({ pts: run.flat() }); run = []; };
|
|
419
|
+
for (let t = -R; t <= R; t += 0.012) {
|
|
420
|
+
const px = mx + ux * t, py = my + uy * t;
|
|
421
|
+
if (Math.abs(px - cxm) > ext.w / 2 + pad || Math.abs(py - cym) > ext.h / 2 + pad) {
|
|
422
|
+
flush();
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
const sp0 = sdf.sample(px, py);
|
|
426
|
+
if (sp0 > reach + 0.12 || sp0 < -0.14) {
|
|
427
|
+
flush();
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
const f = (sv) => score(a, px + nx * sv, py + ny * sv) - score(b, px + nx * sv, py + ny * sv);
|
|
431
|
+
let lo = -0.08, hi = 0.08;
|
|
432
|
+
if (f(lo) * f(hi) > 0) {
|
|
433
|
+
flush();
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
for (let it = 0; it < 12; it++) {
|
|
437
|
+
const m = (lo + hi) / 2;
|
|
438
|
+
if (f(m) * f(lo) > 0)
|
|
439
|
+
lo = m;
|
|
440
|
+
else
|
|
441
|
+
hi = m;
|
|
442
|
+
}
|
|
443
|
+
const qx = px + nx * lo, qy = py + ny * lo;
|
|
444
|
+
const w = grainAt(qx, qy);
|
|
445
|
+
const sdv = sdf.sample(qx, qy);
|
|
446
|
+
if ((w !== a && w !== b) || sdv < 0.008 || sdv > reach * 0.85) {
|
|
447
|
+
flush();
|
|
448
|
+
continue;
|
|
449
|
+
}
|
|
450
|
+
const last = run[run.length - 1];
|
|
451
|
+
if (last && Math.hypot(qx - last[0], qy - last[1]) > 0.035)
|
|
452
|
+
flush();
|
|
453
|
+
run.push([qx, qy]);
|
|
454
|
+
}
|
|
455
|
+
flush();
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return { branches, nuc, nc, seams, grains };
|
|
459
|
+
}
|
|
460
|
+
// ---- schedule: birth times of every point -------------------------------------------------------------------------
|
|
461
|
+
function schedule(spines, crystal, anim, G) {
|
|
462
|
+
const { branches, nuc, nc } = crystal;
|
|
463
|
+
const rnd = mulberry32(991);
|
|
464
|
+
const method = anim.draw.method;
|
|
465
|
+
const tau = []; // tau[pid] = Float32Array per point (raw progress)
|
|
466
|
+
let infoD;
|
|
467
|
+
if (method === 'grow') {
|
|
468
|
+
let half = 1e-3;
|
|
469
|
+
for (const s of spines)
|
|
470
|
+
half = Math.max(half, s.len / 2);
|
|
471
|
+
const vs = 0.26 / half;
|
|
472
|
+
spines.forEach((s, ci) => {
|
|
473
|
+
const n = s.pts.length / 2, L = s.len, t = new Float32Array(n);
|
|
474
|
+
const nu = nuc[ci];
|
|
475
|
+
const g0 = nu.own ? (G > 1 ? 0.12 * (s.glyph / (G - 1)) : 0) + 0.025 * rnd() : 0;
|
|
476
|
+
for (let i = 0; i < n; i++) {
|
|
477
|
+
let m = 1e9;
|
|
478
|
+
for (const q of nu.list) {
|
|
479
|
+
let dd = Math.abs(s.cum[i] - q.c);
|
|
480
|
+
dd = Math.min(dd, L - dd);
|
|
481
|
+
m = Math.min(m, q.delay + dd * vs);
|
|
482
|
+
}
|
|
483
|
+
t[i] = g0 + m;
|
|
484
|
+
} // grains nucleate at their own moment and compete
|
|
485
|
+
tau.push(t);
|
|
486
|
+
});
|
|
487
|
+
infoD = { soft: 0.012, tip: false, fade: false };
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
const ctx = { G: Math.max(1, G), ext: extentOf(spines) };
|
|
491
|
+
infoD = applyDraw(method, spines, anim.draw, ctx);
|
|
492
|
+
spines.forEach((s) => { const n = s.pts.length / 2, t = new Float32Array(n); for (let i = 0; i < n; i++)
|
|
493
|
+
t[i] = 0.5 * (s.seg[0] + s.t[i] * (s.seg[1] - s.seg[0])); tau.push(t); });
|
|
494
|
+
infoD = { ...infoD, tip: false };
|
|
495
|
+
}
|
|
496
|
+
for (const b of branches) {
|
|
497
|
+
const n = b.pts.length / 2, t = new Float32Array(n);
|
|
498
|
+
const t0 = tau[b.parent][Math.min(b.pidx, tau[b.parent].length - 1)] + LATENCY[b.g];
|
|
499
|
+
if (!b.cum) {
|
|
500
|
+
b.cum = [0];
|
|
501
|
+
let L = 0;
|
|
502
|
+
for (let i = 1; i < n; i++) {
|
|
503
|
+
L += Math.hypot(b.pts[2 * i] - b.pts[2 * i - 2], b.pts[2 * i + 1] - b.pts[2 * i - 1]);
|
|
504
|
+
b.cum.push(L);
|
|
505
|
+
}
|
|
506
|
+
b.len = L;
|
|
507
|
+
}
|
|
508
|
+
for (let i = 0; i < n; i++)
|
|
509
|
+
t[i] = t0 + b.cum[i] * SPEED[b.g];
|
|
510
|
+
tau[b.pid] = t;
|
|
511
|
+
}
|
|
512
|
+
// seams appear when the arms of the two grains have reached the boundary: nearest spine point time + arm travel
|
|
513
|
+
(crystal.seams || []).forEach((sm, si) => {
|
|
514
|
+
const n = sm.pts.length / 2, t = new Float32Array(n);
|
|
515
|
+
sm.cum = [0];
|
|
516
|
+
let Lc = 0;
|
|
517
|
+
for (let i = 0; i < n; i++) {
|
|
518
|
+
if (i) {
|
|
519
|
+
Lc += Math.hypot(sm.pts[2 * i] - sm.pts[2 * i - 2], sm.pts[2 * i + 1] - sm.pts[2 * i - 1]);
|
|
520
|
+
sm.cum.push(Lc);
|
|
521
|
+
}
|
|
522
|
+
let bd = 1e9, bt = 0;
|
|
523
|
+
spines.forEach((s, ci) => { for (let k = 0; k < s.pts.length / 2; k += 2) {
|
|
524
|
+
const d2 = (s.pts[2 * k] - sm.pts[2 * i]) ** 2 + (s.pts[2 * k + 1] - sm.pts[2 * i + 1]) ** 2;
|
|
525
|
+
if (d2 < bd) {
|
|
526
|
+
bd = d2;
|
|
527
|
+
bt = tau[ci][k];
|
|
528
|
+
}
|
|
529
|
+
} });
|
|
530
|
+
t[i] = bt + LATENCY[1] + SPEED[1] * Math.sqrt(bd) / SIN60 + 0.03;
|
|
531
|
+
}
|
|
532
|
+
sm.len = Lc;
|
|
533
|
+
tau[nc + branches.length + si] = t;
|
|
534
|
+
sm.pid = nc + branches.length + si;
|
|
535
|
+
});
|
|
536
|
+
let mx = 1e-6;
|
|
537
|
+
for (const t of tau)
|
|
538
|
+
for (let i = 0; i < t.length; i++)
|
|
539
|
+
mx = Math.max(mx, t[i]);
|
|
540
|
+
const f = 0.985 / mx;
|
|
541
|
+
for (const t of tau)
|
|
542
|
+
for (let i = 0; i < t.length; i++)
|
|
543
|
+
t[i] *= f;
|
|
544
|
+
return { tau, infoD };
|
|
545
|
+
}
|
|
546
|
+
// ---- fragment: ice rod cross-section, rim, front glow, sparkle ------------------------------------------------------
|
|
547
|
+
const FROST_FRAG = /* glsl */ `
|
|
548
|
+
uniform vec3 uColor; uniform vec3 uColor2; uniform float uOpacity; uniform float uSparkle; uniform float uHaze; uniform float uW0; uniform float uSeam; uniform float uPhi[9];
|
|
549
|
+
float h11(float x){ return fract(sin(x*127.1 + 7.7)*43758.5453); }
|
|
550
|
+
void main(){
|
|
551
|
+
float d = length(vec2(max(abs(vXY.x) - vHL, 0.0), vXY.y));
|
|
552
|
+
float px = max(length(dFdx(vPos)), length(dFdy(vPos))); px = max(px, 1e-5); // em per pixel
|
|
553
|
+
float seam = step(3.5, vVar); float v2 = vVar - 4.0*seam; float inner = step(1.5, v2); float wf = v2 - 2.0*inner;
|
|
554
|
+
float ig = floor(vGlyph); float grain = floor(ig/4.0); float m3 = ig - 4.0*grain; float lat = step(m3, 2.5);
|
|
555
|
+
float w = uW0*wf;
|
|
556
|
+
float weff = max(w, 0.5*px);
|
|
557
|
+
float amp = min(1.0, w/weff); // sub-pixel hairs are dimmer, never aliased
|
|
558
|
+
float cov = clamp((weff + 0.5*px - d)/px, 0.0, 1.0);
|
|
559
|
+
float s = abs(vXY.y)/weff;
|
|
560
|
+
float rim = smoothstep(0.2, 0.95, s);
|
|
561
|
+
float f = clamp((vXY.x + vHL)/(2.0*max(vHL, 1e-6)), 0.0, 1.0);
|
|
562
|
+
float lit = revealIn(f); float gone = revealOut(f);
|
|
563
|
+
float age = ageAt(f);
|
|
564
|
+
float front = exp(-age/0.28); // the growing front is brighter and whiter
|
|
565
|
+
float settled = smoothstep(0.4, 1.8, age);
|
|
566
|
+
// colour from thickness: thick spines are a deeper cooler tone, thin edges pale blue-white (Fresnel-like rim)
|
|
567
|
+
vec3 body = mix(uColor2, uColor, clamp(0.3 + 1.0*(1.0 - wf), 0.0, 1.0));
|
|
568
|
+
vec3 col = mix(body, uColor, rim*0.85);
|
|
569
|
+
// each grain has its own slightly different cool tint
|
|
570
|
+
float gt = h11(grain*3.7 + 1.3) - 0.5;
|
|
571
|
+
col *= mix(vec3(1.0), vec3(1.0 - 0.24*gt, 1.0 + 0.03*gt, 1.0 + 0.16*gt), lat);
|
|
572
|
+
// facet angle (lattice line orientation of this arm) against a slowly moving light
|
|
573
|
+
float alpha = lat > 0.5 ? uPhi[int(clamp(grain, 0.0, 8.0) + 0.5)] + m3*1.0471976 : h11(vGlyph)*3.14159;
|
|
574
|
+
float psi = 1.1*sin(uTime*0.09*uIdleSpeed) + 0.5*sin(uTime*0.037*uIdleSpeed + 1.3);
|
|
575
|
+
float dl = mod(alpha - psi + 1.5708, 3.14159) - 1.5708;
|
|
576
|
+
float align = exp(-pow(dl/0.22, 2.0));
|
|
577
|
+
float I = (0.64 + 0.36*rim)*(0.5 + 0.5*clamp(wf*1.25, 0.0, 1.0))*(1.0 + 0.16*align*uSparkle*uIdle*lat);
|
|
578
|
+
// grain boundary: thin bright seam / dislocation line
|
|
579
|
+
col = mix(col, mix(uColor, vec3(0.92, 0.98, 1.0), 0.6), seam);
|
|
580
|
+
I = mix(I, uSeam*(0.8 + 0.2*sin(arcAt(f)*120.0)), seam);
|
|
581
|
+
float breath = 1.0 + 0.07*uIdle*sin(uTime*0.5*uIdleSpeed - vPos.x*0.9 + vPos.y*0.4); // slow cold breathing wave through the rim light
|
|
582
|
+
col = mix(col, vec3(1.0), 0.55*front);
|
|
583
|
+
I *= (1.0 + 0.45*front);
|
|
584
|
+
// sublimation: a faint bright edge at the erase front
|
|
585
|
+
float tOv = mix(vTT.z, vTT.w, f); float dE = tOv - vLL.y;
|
|
586
|
+
float sub = (1.0 - uFadeOut)*smoothstep(0.0, 0.03, uE)*exp(-max(dE, 0.0)/0.05)*0.6;
|
|
587
|
+
// sparkle: narrow-peaked glints, each sitting in a cell along its arm and drifting along it while it flashes
|
|
588
|
+
float cellL = 0.05; float aid = vGlyph*61.0;
|
|
589
|
+
float a = arcAt(f)/cellL + aid; float k = floor(a); float fr = fract(a);
|
|
590
|
+
float h1 = h11(k*1.31 + aid), h2 = h11(k*2.17 + aid*3.1), h3 = h11(k*0.73 + aid*5.3);
|
|
591
|
+
float on = step(h3, (0.07 + 0.3*align)*uSparkle);
|
|
592
|
+
float P = mix(3.0, 9.0, h2); float ph = fract(uTime*uIdleSpeed/P + h1);
|
|
593
|
+
float pulse = exp(-pow((ph - 0.5)/0.03, 2.0));
|
|
594
|
+
float cpos = 0.5 + (ph - 0.5)*9.0;
|
|
595
|
+
float da = (fr - cpos)*cellL;
|
|
596
|
+
float rr = length(vec2(da, d));
|
|
597
|
+
float glint = pulse*on*(exp(-pow(rr/0.0035, 2.0)) + 0.35*exp(-pow(rr/0.011, 2.0)) + 0.5*exp(-abs(da)/0.016)*exp(-pow(d/0.0012, 2.0)))*uSparkle*uIdle*settled*(1.0 - 0.5*inner);
|
|
598
|
+
// thin prismatic dispersion: cool to warm with the facet angle against the light, kept close to white
|
|
599
|
+
vec3 spec = mix(vec3(0.92, 0.97, 1.0), mix(vec3(0.55, 0.85, 1.0), vec3(1.0, 0.84, 0.62), 0.5 + 0.5*clamp(dl/0.4, -1.0, 1.0)), 0.6);
|
|
600
|
+
float hz = uHaze*0.2*(0.3 + 0.7*wf)*exp(-pow(d/(0.012 + 0.7*w), 2.0))*(1.0 - 0.5*inner); // frosted glow around the ice
|
|
601
|
+
vec3 hcol = mix(uColor2, uColor, 0.45);
|
|
602
|
+
vec3 c = col*(cov*amp*I*breath*(1.0 - 0.45*inner)) + hcol*hz + uColor*sub*cov + spec*glint*0.95;
|
|
603
|
+
c *= lit*gone*uOpacity;
|
|
604
|
+
gl_FragColor = vec4(c, 1.0);
|
|
605
|
+
#include <tonemapping_fragment>
|
|
606
|
+
#include <colorspace_fragment>
|
|
607
|
+
}`;
|
|
608
|
+
const num = (name, label, description, min, max, step, unit) => ({ name, label, description, type: 'number', min, max, step, ...(unit ? { unit } : {}) });
|
|
609
|
+
const col = (name, label, description) => ({ name, label, description, type: 'color' });
|
|
610
|
+
export default {
|
|
611
|
+
key: 'frostGrowth', source: 'outline', drawMethods: ['grow', ...DRAW_METHODS], eraseMethods: ['sublimate', ...ERASE_METHODS], drawDefault: 'grow', eraseDefault: 'sublimate',
|
|
612
|
+
animDefaults: { drawDuration: 6, drawEase: 'linear', eraseDuration: 3, eraseEase: 'linear' },
|
|
613
|
+
methodInfo: {
|
|
614
|
+
grow: { label: 'Grow', hint: 'Rime spreads along the contours from a nucleation point, branches follow; tips are last' },
|
|
615
|
+
sublimate: { label: 'Sublimate', hint: 'Tips and thin branches vanish first, the spine last' },
|
|
616
|
+
},
|
|
617
|
+
catalog: { name: 'Frost Growth', description: 'Dendritic hoarfrost nucleates in competing crystal grains on the letter outlines, each with its own six-fold lattice and bright boundary seams, then throws prismatic glints. Use for winter, cold-brand and fantasy titles.', tags: ['frost', 'ice', 'crystal', 'dendrite', 'winter', 'cold', 'hoarfrost'] },
|
|
618
|
+
defaults: { reach: 0.15, branching: 1, grains: 5, sparkle: 0.6, thickness: 1, seams: 0.75, haze: 0.5, seed: 7, color: '#d6edff', color2: '#4a90d4', opacity: 1 },
|
|
619
|
+
ui: {
|
|
620
|
+
main: [
|
|
621
|
+
num('reach', 'Reach', 'How far the frost spreads from the letters', 0.04, 0.5, 0.005, 'em'),
|
|
622
|
+
num('branching', 'Branching', 'Side-branch density of the ice ferns', 0.3, 1.8, 0.05),
|
|
623
|
+
num('grains', 'Grains', 'Number of crystal grains; each has its own lattice orientation', 1, 9, 1),
|
|
624
|
+
num('sparkle', 'Sparkle', 'Sharp glints travelling over the crystal facets', 0, 1, 0.01),
|
|
625
|
+
],
|
|
626
|
+
more: [
|
|
627
|
+
num('thickness', 'Thickness', 'Thickness of the ice arms', 0.4, 2.5, 0.05),
|
|
628
|
+
num('seams', 'Grain seams', 'Brightness of the boundary lines where grains meet', 0, 1, 0.01),
|
|
629
|
+
num('haze', 'Frost haze', 'Soft frosted glow around the ice', 0, 1.5, 0.01),
|
|
630
|
+
col('color', 'Ice', 'Pale colour of thin edges and tips'),
|
|
631
|
+
col('color2', 'Deep ice', 'Cooler deeper tone of thick spines'),
|
|
632
|
+
num('opacity', 'Opacity', 'Overall opacity', 0, 1, 0.01),
|
|
633
|
+
num('seed', 'Seed', 'Random seed of the crystal pattern', 0, 999, 1),
|
|
634
|
+
],
|
|
635
|
+
},
|
|
636
|
+
structural: ['reach', 'branching', 'grains', 'seed'],
|
|
637
|
+
presets: [
|
|
638
|
+
{ name: 'Hoarfrost', description: 'Pale blue-white window frost', patch: {} },
|
|
639
|
+
{ name: 'Glacier', description: 'Deep cyan ice, heavier arms', patch: { color: '#9fe6ff', color2: '#1d6fb8', thickness: 1.4, haze: 0.8 } },
|
|
640
|
+
{ name: 'Moonlit', description: 'Silver-violet rime with many glints', patch: { color: '#eaeeff', color2: '#7f8fd8', sparkle: 1, haze: 0.3 } },
|
|
641
|
+
{ name: 'Fine lace', description: 'Hair-fine, faint crystal', patch: { thickness: 0.6, sparkle: 0.35, haze: 0.2, opacity: 0.9 } },
|
|
642
|
+
{ name: 'Arctic', description: 'Teal glow with strong frosted haze', patch: { color: '#c8fff4', color2: '#2aa59a', haze: 1.1, sparkle: 0.8 } },
|
|
643
|
+
],
|
|
644
|
+
build(layout, cfg, anim) {
|
|
645
|
+
const spines = layout.strokes;
|
|
646
|
+
const G = Math.max(1, layout.glyphs.length);
|
|
647
|
+
const empty = !spines.length;
|
|
648
|
+
const group = new THREE.Group();
|
|
649
|
+
if (empty)
|
|
650
|
+
return { object: group, apply() { }, update() { }, dispose() { } };
|
|
651
|
+
prepare(spines, 'outline');
|
|
652
|
+
const rnd = mulberry32(Math.round(cfg.seed) * 7919 + 13);
|
|
653
|
+
const crystal = growCrystal(spines, { reach: cfg.reach, branching: cfg.branching, grains: cfg.grains }, rnd);
|
|
654
|
+
const { tau, infoD } = schedule(spines, crystal, anim, G);
|
|
655
|
+
// strokes: contours first, then arms. Every stroke gets the full window [0,1] and its own per-point birth times.
|
|
656
|
+
const strokes = spines.slice();
|
|
657
|
+
const pr = (g, inner, u) => Math.max(0.1, WF[g] * (1 - 0.5 * u)) + (inner ? 2 : 0);
|
|
658
|
+
const gen = []; // generation per stroke
|
|
659
|
+
spines.forEach((s, i) => { s.t = tau[i]; s.seg = [0, 1]; s.pressure = new Float32Array(s.pts.length / 2).fill(0.66); s.glyphN = 3 + ((i * 0.6180339) % 1) * 0.98; gen.push(0); });
|
|
660
|
+
crystal.branches.forEach((b) => {
|
|
661
|
+
const n = b.pts.length / 2;
|
|
662
|
+
const st = { pts: Float32Array.from(b.pts), cum: Float32Array.from(b.cum), len: Math.max(1e-6, b.len), closed: false, glyph: b.glyph, ptime: Math.max(1e-3, b.len), pt: null };
|
|
663
|
+
st.t = tau[b.pid];
|
|
664
|
+
st.seg = [0, 1];
|
|
665
|
+
st.pressure = new Float32Array(n);
|
|
666
|
+
for (let i = 0; i < n; i++)
|
|
667
|
+
st.pressure[i] = pr(b.g, b.inner, i / Math.max(1, n - 1));
|
|
668
|
+
st.glyphN = b.grain * 4 + b.m3 + b.rid * 0.98;
|
|
669
|
+
strokes.push(st);
|
|
670
|
+
gen.push(b.g);
|
|
671
|
+
});
|
|
672
|
+
crystal.seams.forEach((sm, si) => {
|
|
673
|
+
const n = sm.pts.length / 2;
|
|
674
|
+
const st = { pts: Float32Array.from(sm.pts), cum: Float32Array.from(sm.cum), len: Math.max(1e-6, sm.len), closed: false, glyph: 0, ptime: Math.max(1e-3, sm.len), pt: null };
|
|
675
|
+
st.t = tau[sm.pid];
|
|
676
|
+
st.seg = [0, 1];
|
|
677
|
+
st.pressure = new Float32Array(n).fill(4.38);
|
|
678
|
+
st.glyphN = 3 + ((si * 0.7548777) % 1) * 0.98;
|
|
679
|
+
strokes.push(st);
|
|
680
|
+
gen.push(9);
|
|
681
|
+
});
|
|
682
|
+
// erase
|
|
683
|
+
const ctx = { G, ext: extentOf(strokes), drawSched: strokes.map((s) => ({ seg: s.seg, t: s.t })), drawInfo: infoD };
|
|
684
|
+
let infoE;
|
|
685
|
+
if (anim.erase.method === 'sublimate') {
|
|
686
|
+
// arms: thin and late-born first. spines next; grain seams (the boundaries) are the very last thing to go
|
|
687
|
+
const r2 = mulberry32(4242);
|
|
688
|
+
let mxv = 1e-6, mnv = 1e6;
|
|
689
|
+
const raw = strokes.map((s, si) => {
|
|
690
|
+
const n = s.pts.length / 2, o = new Float32Array(n);
|
|
691
|
+
const jit = (r2() - 0.5) * 0.12;
|
|
692
|
+
for (let i = 0; i < n; i++) {
|
|
693
|
+
o[i] = 0.5 * (1 - s.t[i] / 0.985) + 0.5 * (1 - Math.min(gen[si], MAX_GEN) / MAX_GEN) + jit;
|
|
694
|
+
if (gen[si] >= 1 && gen[si] <= MAX_GEN) {
|
|
695
|
+
mxv = Math.max(mxv, o[i]);
|
|
696
|
+
mnv = Math.min(mnv, o[i]);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
return o;
|
|
700
|
+
});
|
|
701
|
+
mxv = Math.max(mxv, mnv + 1e-3);
|
|
702
|
+
strokes.forEach((s, si) => {
|
|
703
|
+
const g = gen[si];
|
|
704
|
+
s.segO = [0, 1];
|
|
705
|
+
s.tO = raw[si].map((v, i) => g === 0 ? 0.9 + 0.05 * clamp01(1 - s.t[i] / 0.985) : g > MAX_GEN ? 0.97 + 0.03 * clamp01(1 - s.t[i] / 0.985) : 0.88 * clamp01((v - mnv) / (mxv - mnv)));
|
|
706
|
+
});
|
|
707
|
+
infoE = { soft: 0.05, fade: false };
|
|
708
|
+
}
|
|
709
|
+
else
|
|
710
|
+
infoE = applyErase(anim.erase.method, strokes, anim.erase, ctx);
|
|
711
|
+
strokes.forEach((s) => { s.len = 1; }); // arc coordinate becomes absolute em along the arm (glints use it)
|
|
712
|
+
const geo = buildCapsules(strokes);
|
|
713
|
+
const mat = capsuleMaterial(FROST_FRAG, { uColor: { value: hex(cfg.color) }, uColor2: { value: hex(cfg.color2) }, uOpacity: { value: 1 }, uSparkle: { value: cfg.sparkle }, uHaze: { value: cfg.haze }, uSeam: { value: cfg.seams }, uPhi: { value: Array.from({ length: 9 }, (_, k) => (crystal.grains[k] ? crystal.grains[k].phi : 0)) }, uW0: { value: 0.0068 } });
|
|
714
|
+
const mesh = new THREE.Mesh(geo, mat);
|
|
715
|
+
mesh.frustumCulled = false;
|
|
716
|
+
group.add(mesh);
|
|
717
|
+
const api = {
|
|
718
|
+
object: group,
|
|
719
|
+
apply(c) { const u = mat.uniforms; u.uColor.value.set(c.color); u.uColor2.value.set(c.color2); u.uOpacity.value = c.opacity; u.uSparkle.value = c.sparkle; u.uHaze.value = c.haze; u.uSeam.value = c.seams; u.uW0.value = 0.0068 * c.thickness; u.uHalf.value = 0.028 + 0.005 * c.thickness; api.c = c; },
|
|
720
|
+
update(S, time) { setReveal(mat.uniforms, S, infoD, infoE, anim.draw.duration, time); },
|
|
721
|
+
dispose() { geo.dispose(); mat.dispose(); },
|
|
722
|
+
};
|
|
723
|
+
api.stats = { segments: geo.instanceCount, arms: crystal.branches.length };
|
|
724
|
+
api.apply(cfg);
|
|
725
|
+
return api;
|
|
726
|
+
},
|
|
727
|
+
};
|