@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,645 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { buildCapsules, capsuleMaterial, frag, uniformsBase, setReveal, headPoint, REVEAL_UNIFORMS } from '../ribbon.js';
|
|
3
|
+
import { prepare, applyAnim, DRAW_METHODS, ERASE_METHODS } from '../methods.js';
|
|
4
|
+
const hex = (h) => new THREE.Color(h);
|
|
5
|
+
const clamp = (x, a, b) => Math.max(a, Math.min(b, 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
|
+
// embroidery — satin stitch along the pen strokes.
|
|
9
|
+
// Geometry: every stroke is cut into stitches spaced `1/density` apart along arc length (deterministic jitter); a stitch
|
|
10
|
+
// is a straight thread from one edge of the stroke band to the other at the slant angle theta to the tangent
|
|
11
|
+
// (D = cos(theta) T + sin(theta) N, half length = W / (2 sin theta), W = pen width * pressure * thickness), drawn as a
|
|
12
|
+
// round-capped pill. Thread radius r = 0.62 * spacing * sin(theta) so neighbours overlap by ~20%: later stitches lie over
|
|
13
|
+
// earlier ones, which is what hides the ends ("tucked") and what the cast self-shadow on the previous stitch models.
|
|
14
|
+
// Shading: each thread is a lump with a cylinder height profile h = sqrt(1 - s^2) (s = distance / radius, round ends) and a
|
|
15
|
+
// ply twist: slanted bands in the surface normal. The fibre direction on the lump is the thread axis rotated about the
|
|
16
|
+
// normal by the twist angle; specular is Kajiya-Kay, spec = pow(sqrt(1 - (T.H)^2), shininess): a thin line light that
|
|
17
|
+
// is brightest where the fibres are perpendicular to the half vector. Because satin stitches turn with the letter, a slowly
|
|
18
|
+
// orbiting key light lights up the stitches of one orientation at a time: a soft sheen sweeping over the lettering.
|
|
19
|
+
// Draw: the needle pulls each thread through from one end to the other (age since the pen passed); erase: threads are
|
|
20
|
+
// unpicked (lift = fade + shrink in width and length).
|
|
21
|
+
// =========================================================================================
|
|
22
|
+
function lightAt(time, out) {
|
|
23
|
+
// closed form of time: azimuth turns once in ~45 s, elevation breathes slowly
|
|
24
|
+
const a = 0.9 + time * 0.14, e = 0.46 + 0.14 * Math.sin(time * 0.093 + 0.7);
|
|
25
|
+
out.set(Math.cos(a) * Math.cos(e), Math.sin(a) * Math.cos(e), Math.sin(e));
|
|
26
|
+
}
|
|
27
|
+
// ---- CPU: stitches ------------------------------------------------------------------------
|
|
28
|
+
// Stitch vocabulary, chosen per stroke / per run like an embroiderer would:
|
|
29
|
+
// satin broad strokes: slanted threads across the band (kind 0)
|
|
30
|
+
// stem thin runs: overlapping slanted stitches that twist into a rope line (kind 0)
|
|
31
|
+
// couch long near-straight strokes: laid thread(s) tacked down by small cross stitches (kind 0 + tacks, kind 3)
|
|
32
|
+
// knot dots, tittles and the ends of stem lines: a wound French knot (kind 2)
|
|
33
|
+
// border contrast running stitch along satin edges (kind 1)
|
|
34
|
+
function makeSampler(s) {
|
|
35
|
+
const n = s.pts.length / 2, P = s.pts, cum = s.cum, T = s.t, TO = s.tO, WF = s.wfactor;
|
|
36
|
+
return function at(a, o) {
|
|
37
|
+
a = clamp(a, 0, s.len);
|
|
38
|
+
let lo = 0, hi = n - 1;
|
|
39
|
+
while (hi - lo > 1) {
|
|
40
|
+
const m = (lo + hi) >> 1;
|
|
41
|
+
if (cum[m] <= a)
|
|
42
|
+
lo = m;
|
|
43
|
+
else
|
|
44
|
+
hi = m;
|
|
45
|
+
}
|
|
46
|
+
const f = clamp((a - cum[lo]) / Math.max(1e-9, cum[hi] - cum[lo]), 0, 1);
|
|
47
|
+
o.x = P[2 * lo] + (P[2 * hi] - P[2 * lo]) * f;
|
|
48
|
+
o.y = P[2 * lo + 1] + (P[2 * hi + 1] - P[2 * lo + 1]) * f;
|
|
49
|
+
o.t = T[lo] + (T[hi] - T[lo]) * f;
|
|
50
|
+
o.to = TO[lo] + (TO[hi] - TO[lo]) * f;
|
|
51
|
+
o.w = WF ? WF[lo] + (WF[hi] - WF[lo]) * f : 1;
|
|
52
|
+
return o;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// thin runs of a stroke: smoothed local width factor with hysteresis, short runs dropped
|
|
56
|
+
function thinRuns(s, at, thin) {
|
|
57
|
+
const L = s.len, st = 0.01, n = Math.max(2, Math.ceil(L / st)), w = new Float32Array(n + 1), o = {};
|
|
58
|
+
for (let i = 0; i <= n; i++)
|
|
59
|
+
w[i] = at(Math.min(L, i * st), o).w;
|
|
60
|
+
const sm = new Float32Array(n + 1);
|
|
61
|
+
for (let i = 0; i <= n; i++) {
|
|
62
|
+
let a = 0, c = 0;
|
|
63
|
+
for (let j = Math.max(0, i - 4); j <= Math.min(n, i + 4); j++) {
|
|
64
|
+
a += w[j];
|
|
65
|
+
c++;
|
|
66
|
+
}
|
|
67
|
+
sm[i] = a / c;
|
|
68
|
+
}
|
|
69
|
+
const runs = [];
|
|
70
|
+
let on = false, a0 = 0;
|
|
71
|
+
for (let i = 0; i <= n; i++) {
|
|
72
|
+
if (!on && sm[i] < thin) {
|
|
73
|
+
on = true;
|
|
74
|
+
a0 = i * st;
|
|
75
|
+
}
|
|
76
|
+
else if (on && sm[i] > thin * 1.14) {
|
|
77
|
+
on = false;
|
|
78
|
+
runs.push([a0, i * st]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (on)
|
|
82
|
+
runs.push([a0, L]);
|
|
83
|
+
return runs.filter((r) => r[1] - r[0] > 0.1).map((r) => [r[0] < 0.02 ? 0 : r[0], r[1] > L - 0.02 ? L : r[1]]);
|
|
84
|
+
}
|
|
85
|
+
const STYLES = ['auto', 'satin', 'stem', 'couching']; // config.style values (index = forced mode, 0 = automatic)
|
|
86
|
+
function genStitches(strokes, natural, density, slantDeg, thick, style) {
|
|
87
|
+
const th = (clamp(slantDeg, 20, 89) * Math.PI) / 180, sinT = Math.sin(th);
|
|
88
|
+
const nom = natural * thick;
|
|
89
|
+
function gen(sp) {
|
|
90
|
+
const rows = [];
|
|
91
|
+
const B = {}, C = {}, TA = {}, TB = {};
|
|
92
|
+
for (let si = 0; si < strokes.length; si++) {
|
|
93
|
+
const s = strokes[si];
|
|
94
|
+
if (!(s.len > 1e-5))
|
|
95
|
+
continue;
|
|
96
|
+
const at = makeSampler(s);
|
|
97
|
+
const rnd = mulberry32(7919 + s.glyph * 131 + si * 17);
|
|
98
|
+
const L = s.len, G = s.glyphN || 0;
|
|
99
|
+
const tang = (a, o, d) => { const dd = d || Math.max(0.012, sp * 0.9); at(a - dd, TA); at(a + dd, TB); const dx = TB.x - TA.x, dy = TB.y - TA.y, l = Math.hypot(dx, dy) || 1; o[0] = dx / l; o[1] = dy / l; };
|
|
100
|
+
const push = (x, y, dx, dy, hl, r, kind, a, tt) => rows.push([x, y, dx, dy, hl, r, kind, rnd(), tt.t, tt.to, s.seg[0], s.seg[1], s.segO[0], s.segO[1], a / L, G]);
|
|
101
|
+
const knot = (a, R) => { at(a, C); push(C.x, C.y, 1, 0, 0, R, 2, a, C); };
|
|
102
|
+
const T0 = [0, 0], T1 = [0, 0];
|
|
103
|
+
// --- dots / tittles: French knot
|
|
104
|
+
if (s.dot || L < 0.05) {
|
|
105
|
+
at(L / 2, C);
|
|
106
|
+
const W = Math.max(0.03, nom * C.w);
|
|
107
|
+
knot(L / 2, clamp(0.5 * W, 0.02, 0.07));
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
at(L, C);
|
|
111
|
+
const cx1 = C.x, cy1 = C.y;
|
|
112
|
+
at(0, C);
|
|
113
|
+
const straight = Math.hypot(cx1 - C.x, cy1 - C.y) / L;
|
|
114
|
+
const mode = style === 1 ? 'satin' : style === 2 ? 'stem' : style === 3 ? 'couch' : (L > 0.5 && straight > 0.975 ? 'couch' : 'auto');
|
|
115
|
+
const runs = mode === 'stem' ? [[0, L]] : mode === 'auto' ? thinRuns(s, at, 0.8) : [];
|
|
116
|
+
const inRun = (a) => { for (const r of runs)
|
|
117
|
+
if (a >= r[0] - 0.004 && a <= r[1] + 0.004)
|
|
118
|
+
return true; return false; };
|
|
119
|
+
if (mode === 'couch') {
|
|
120
|
+
let wm = 0, wc = 0;
|
|
121
|
+
for (let a = 0; a <= L; a += 0.02) {
|
|
122
|
+
wm += at(a, C).w;
|
|
123
|
+
wc++;
|
|
124
|
+
}
|
|
125
|
+
const Wc = Math.max(0.03, nom * wm / wc);
|
|
126
|
+
const rc = clamp(0.5 * Wc, 0.009, 0.026), rows_ = Math.max(1, Math.floor(Wc / (2 * rc) + 0.35)), gap = 2 * rc * 0.94;
|
|
127
|
+
const ns = Math.max(1, Math.ceil(L / 0.16));
|
|
128
|
+
for (let i = 0; i < ns; i++) {
|
|
129
|
+
const a0 = (i * L) / ns, a1 = ((i + 1) * L) / ns;
|
|
130
|
+
for (let j = 0; j < rows_; j++) {
|
|
131
|
+
const o = (j - (rows_ - 1) / 2) * gap;
|
|
132
|
+
tang(a0, T0);
|
|
133
|
+
at(a0, C);
|
|
134
|
+
const x0 = C.x - T0[1] * o, y0 = C.y + T0[0] * o, tt = { t: C.t, to: C.to };
|
|
135
|
+
tang(a1, T1);
|
|
136
|
+
at(a1, C);
|
|
137
|
+
const x1 = C.x - T1[1] * o, y1 = C.y + T1[0] * o;
|
|
138
|
+
const dx = x1 - x0, dy = y1 - y0, l = Math.hypot(dx, dy) || 1;
|
|
139
|
+
push((x0 + x1) / 2, (y0 + y1) / 2, dx / l, dy / l, Math.max(0.003, l / 2 - 0.55 * rc), rc, 0, a0, tt);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// tacks: tiny contrast cross stitches over the laid thread(s)
|
|
143
|
+
const nt = Math.max(1, Math.round(L / 0.11)), across = rows_ * rc * 0.95 + 0.4 * rc, tht = 1.0, rt = clamp(0.28 * rc, 0.0035, 0.007);
|
|
144
|
+
for (let j = 0; j < nt; j++) {
|
|
145
|
+
const a = clamp((j + 0.5 + (rnd() - 0.5) * 0.3) * L / nt, 0, L);
|
|
146
|
+
at(a, C);
|
|
147
|
+
tang(a, T0);
|
|
148
|
+
const Nx = -T0[1], Ny = T0[0];
|
|
149
|
+
for (const sg of rows_ === 1 ? [-1, 1] : [j % 2 ? -1 : 1]) {
|
|
150
|
+
const dx = Math.cos(tht) * T0[0] + sg * Math.sin(tht) * Nx, dy = Math.cos(tht) * T0[1] + sg * Math.sin(tht) * Ny;
|
|
151
|
+
push(C.x, C.y, dx, dy, Math.max(0.003, across / Math.sin(tht) - 0.5 * rt), rt, 3, a, C);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (rows_ === 1)
|
|
155
|
+
knot(L, clamp(1.25 * rc, 0.012, 0.03));
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
// --- satin over the broad parts
|
|
159
|
+
const n = Math.max(2, Math.round(L / sp)), step = L / n;
|
|
160
|
+
for (let k = 0; k < n; k++) {
|
|
161
|
+
const r1 = rnd(), r2 = rnd(), r3 = rnd(), r4 = rnd();
|
|
162
|
+
const a = clamp((k + 0.5 + (r1 - 0.5) * 0.36) * step, 0, L);
|
|
163
|
+
if (inRun(a))
|
|
164
|
+
continue;
|
|
165
|
+
at(a, C);
|
|
166
|
+
tang(a, T0);
|
|
167
|
+
const dc = Math.max(0.03, step * 2);
|
|
168
|
+
tang(a - dc, T0);
|
|
169
|
+
tang(a + dc, T1);
|
|
170
|
+
const kap = Math.abs(Math.atan2(T0[0] * T1[1] - T0[1] * T1[0], T0[0] * T1[0] + T0[1] * T1[1])) / (2 * dc);
|
|
171
|
+
tang(a, T0);
|
|
172
|
+
const W = Math.max(0.03, nom * C.w);
|
|
173
|
+
const theta = th + (r2 - 0.5) * 0.09;
|
|
174
|
+
const sT = Math.sin(theta), cT = Math.cos(theta);
|
|
175
|
+
const r = 0.62 * step * sT * (1 + clamp(kap * W * 0.5 * 0.6, 0, 0.45));
|
|
176
|
+
const Nx = -T0[1], Ny = T0[0];
|
|
177
|
+
const hl = Math.max(0.004, (W * 0.5 / sT - 0.45 * r) * (1 + 0.08 * (r3 - 0.5)));
|
|
178
|
+
rows.push([C.x, C.y, cT * T0[0] + sT * Nx, cT * T0[1] + sT * Ny, hl, r, 0, r4, C.t, C.to, s.seg[0], s.seg[1], s.segO[0], s.segO[1], a / L, G]);
|
|
179
|
+
}
|
|
180
|
+
// --- stem stitch over the thin runs: each stitch starts half-way along the previous one, slanted: a twisted rope
|
|
181
|
+
for (const rn of runs) {
|
|
182
|
+
const len = rn[1] - rn[0];
|
|
183
|
+
at((rn[0] + rn[1]) / 2, C);
|
|
184
|
+
const r0 = clamp(0.2 * nom * C.w, 0.006, 0.02), pitch = 1.1 * r0, m = Math.max(1, Math.round(len / pitch)), pst = len / m;
|
|
185
|
+
for (let j = 0; j < m; j++) {
|
|
186
|
+
const a = clamp(rn[0] + (j + 0.5 + (rnd() - 0.5) * 0.2) * pst, 0, L);
|
|
187
|
+
at(a, C);
|
|
188
|
+
tang(a, T0);
|
|
189
|
+
const r = clamp(0.2 * nom * C.w, 0.006, 0.02), phi = 0.5 + (rnd() - 0.5) * 0.08, Nx = -T0[1], Ny = T0[0];
|
|
190
|
+
push(C.x, C.y, Math.cos(phi) * T0[0] + Math.sin(phi) * Nx, Math.cos(phi) * T0[1] + Math.sin(phi) * Ny, Math.max(0.004, pst * 1.7 - 0.4 * r), r, 0, a, C);
|
|
191
|
+
}
|
|
192
|
+
if (rn[1] >= L - 1e-6)
|
|
193
|
+
knot(L, clamp(1.3 * r0, 0.012, 0.04));
|
|
194
|
+
}
|
|
195
|
+
// --- border row: running stitch on both edges of the satin band
|
|
196
|
+
const rB = 0.62 * sp * sinT * 0.36, dashHL = 3.2 * rB, perD = 9.5 * rB;
|
|
197
|
+
const m = Math.max(1, Math.round(L / perD)), stp = L / m;
|
|
198
|
+
for (let side = -1; side <= 1; side += 2) {
|
|
199
|
+
for (let j = 0; j < m; j++) {
|
|
200
|
+
const ac = (j + 0.5 + (side > 0 ? 0.5 : 0)) * stp;
|
|
201
|
+
if (ac > L + 1e-6 && side > 0)
|
|
202
|
+
continue;
|
|
203
|
+
if (inRun(ac))
|
|
204
|
+
continue;
|
|
205
|
+
const a0 = clamp(ac - dashHL, 0, L), a1 = clamp(ac + dashHL, 0, L);
|
|
206
|
+
if (a1 - a0 < dashHL * 0.5)
|
|
207
|
+
continue;
|
|
208
|
+
const edge = (a, o) => { at(a, B); tang(a, T0); const W = Math.max(0.03, nom * B.w); o.x = B.x - side * T0[1] * W * 0.5; o.y = B.y + side * T0[0] * W * 0.5; return o; };
|
|
209
|
+
const e0 = edge(a0, {}), e1 = edge(a1, {});
|
|
210
|
+
const dx = e1.x - e0.x, dy = e1.y - e0.y, l = Math.hypot(dx, dy);
|
|
211
|
+
if (l < 1e-5)
|
|
212
|
+
continue;
|
|
213
|
+
at(ac, C);
|
|
214
|
+
push((e0.x + e1.x) / 2, (e0.y + e1.y) / 2, dx / l, dy / l, Math.max(0.003, l / 2 - 0.5 * rB), rB, 1, ac, C);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return rows;
|
|
219
|
+
}
|
|
220
|
+
let sp = 1 / Math.max(4, density), rows = gen(sp);
|
|
221
|
+
for (let it = 0; it < 8 && rows.length > 12000; it++) {
|
|
222
|
+
sp *= 1.12;
|
|
223
|
+
rows = gen(sp);
|
|
224
|
+
}
|
|
225
|
+
return rows;
|
|
226
|
+
}
|
|
227
|
+
// ---- CPU: fabric pucker field -------------------------------------------------------------------
|
|
228
|
+
// Dense stitching draws the cloth together. From the stitch coverage we build a smoothed density field (RG) and a wrinkle
|
|
229
|
+
// height field (R): ridges that radiate across the stroke from the stitching (phase = arc length along the nearest stroke,
|
|
230
|
+
// amplitude = proximity x local density). Only the fabric layer reads it: the threads never move.
|
|
231
|
+
function blur1(src, nx, ny, rad) {
|
|
232
|
+
const tmp = new Float32Array(src.length), out = new Float32Array(src.length), k = 1 / (2 * rad + 1);
|
|
233
|
+
for (let y = 0; y < ny; y++) {
|
|
234
|
+
const o = y * nx;
|
|
235
|
+
let acc = 0;
|
|
236
|
+
for (let x = -rad; x <= rad; x++)
|
|
237
|
+
acc += src[o + clamp(x, 0, nx - 1)];
|
|
238
|
+
for (let x = 0; x < nx; x++) {
|
|
239
|
+
tmp[o + x] = acc * k;
|
|
240
|
+
acc += src[o + Math.min(nx - 1, x + rad + 1)] - src[o + Math.max(0, x - rad)];
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
for (let x = 0; x < nx; x++) {
|
|
244
|
+
let acc = 0;
|
|
245
|
+
for (let y = -rad; y <= rad; y++)
|
|
246
|
+
acc += tmp[clamp(y, 0, ny - 1) * nx + x];
|
|
247
|
+
for (let y = 0; y < ny; y++) {
|
|
248
|
+
out[y * nx + x] = acc * k;
|
|
249
|
+
acc += tmp[Math.min(ny - 1, y + rad + 1) * nx + x] - tmp[Math.max(0, y - rad) * nx + x];
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return out;
|
|
253
|
+
}
|
|
254
|
+
function boxBlur(src, nx, ny, rad, passes) { let a = src; for (let p = 0; p < passes; p++)
|
|
255
|
+
a = blur1(a, nx, ny, rad); return a; }
|
|
256
|
+
function bakePucker(strokes, rows, natural, thick) {
|
|
257
|
+
let x0 = 1e9, y0 = 1e9, x1 = -1e9, y1 = -1e9;
|
|
258
|
+
for (const s of strokes)
|
|
259
|
+
for (let i = 0; i < s.pts.length; i += 2) {
|
|
260
|
+
x0 = Math.min(x0, s.pts[i]);
|
|
261
|
+
x1 = Math.max(x1, s.pts[i]);
|
|
262
|
+
y0 = Math.min(y0, s.pts[i + 1]);
|
|
263
|
+
y1 = Math.max(y1, s.pts[i + 1]);
|
|
264
|
+
}
|
|
265
|
+
const mg = 0.35, cell = Math.max(0.014, Math.max(x1 - x0, y1 - y0) / 520);
|
|
266
|
+
const ox = x0 - mg, oy = y0 - mg, nx = Math.ceil((x1 - x0 + 2 * mg) / cell) + 1, ny = Math.ceil((y1 - y0 + 2 * mg) / cell) + 1;
|
|
267
|
+
const cov = new Float32Array(nx * ny), cA = cell * cell;
|
|
268
|
+
const wk = [1, 0.3, 0.8, 0.2];
|
|
269
|
+
for (const r of rows)
|
|
270
|
+
for (let k = -1; k <= 1; k++) {
|
|
271
|
+
const x = r[0] + r[2] * r[4] * k, y = r[1] + r[3] * r[4] * k, ix = Math.round((x - ox) / cell), iy = Math.round((y - oy) / cell);
|
|
272
|
+
if (ix >= 0 && iy >= 0 && ix < nx && iy < ny)
|
|
273
|
+
cov[iy * nx + ix] += wk[r[6]] * (4 * Math.max(r[4], r[5]) * r[5]) / 3 / cA;
|
|
274
|
+
}
|
|
275
|
+
const dsm = boxBlur(cov, nx, ny, 2, 2), dbig = boxBlur(dsm, nx, ny, 7, 2);
|
|
276
|
+
const best = new Float32Array(nx * ny).fill(1e9), bA = new Float32Array(nx * ny), bH = new Float32Array(nx * ny), bW = new Float32Array(nx * ny), bP = new Float32Array(nx * ny);
|
|
277
|
+
strokes.forEach((s, si) => {
|
|
278
|
+
if (!(s.len > 1e-5))
|
|
279
|
+
return;
|
|
280
|
+
const at = makeSampler(s), o = {}, ph0 = (si * 2.399) % 6.283;
|
|
281
|
+
for (let a = 0; a <= s.len + 1e-6; a += 0.008) {
|
|
282
|
+
at(a, o);
|
|
283
|
+
const hw = Math.max(0.015, 0.5 * natural * thick * o.w), R = hw + 0.17, wgt = clamp(hw * 2 / 0.1, 0.4, 1.2);
|
|
284
|
+
const ix0 = Math.max(0, Math.floor((o.x - R - ox) / cell)), ix1 = Math.min(nx - 1, Math.ceil((o.x + R - ox) / cell)), iy0 = Math.max(0, Math.floor((o.y - R - oy) / cell)), iy1 = Math.min(ny - 1, Math.ceil((o.y + R - oy) / cell));
|
|
285
|
+
for (let iy = iy0; iy <= iy1; iy++)
|
|
286
|
+
for (let ix = ix0; ix <= ix1; ix++) {
|
|
287
|
+
const d = Math.hypot(ox + ix * cell - o.x, oy + iy * cell - o.y), id = iy * nx + ix;
|
|
288
|
+
if (d < R && d < best[id]) {
|
|
289
|
+
best[id] = d;
|
|
290
|
+
bA[id] = a;
|
|
291
|
+
bH[id] = hw;
|
|
292
|
+
bW[id] = wgt;
|
|
293
|
+
bP[id] = ph0;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
let hgt = new Float32Array(nx * ny);
|
|
299
|
+
for (let i = 0; i < hgt.length; i++) {
|
|
300
|
+
if (best[i] > 1e8)
|
|
301
|
+
continue;
|
|
302
|
+
const env = Math.exp(-Math.pow(Math.max(best[i] - bH[i], 0) / 0.085, 2)), ph = 6.2832 * (bA[i] / 0.07 + 0.2 * Math.sin(bA[i] * 4.7 + bP[i])) + bP[i];
|
|
303
|
+
hgt[i] = bW[i] * env * Math.sin(ph) * (0.4 + 0.9 * clamp(dsm[i], 0, 1));
|
|
304
|
+
}
|
|
305
|
+
hgt = boxBlur(hgt, nx, ny, 1, 1);
|
|
306
|
+
const data = new Uint8Array(nx * ny * 4);
|
|
307
|
+
for (let i = 0; i < nx * ny; i++) {
|
|
308
|
+
data[4 * i] = Math.round(clamp(hgt[i] * 0.5 + 0.5, 0, 1) * 255);
|
|
309
|
+
data[4 * i + 1] = Math.round(clamp(dsm[i], 0, 1) * 255);
|
|
310
|
+
data[4 * i + 2] = Math.round(clamp(dbig[i] * 1.6, 0, 1) * 255);
|
|
311
|
+
data[4 * i + 3] = 255;
|
|
312
|
+
}
|
|
313
|
+
const tex = new THREE.DataTexture(data, nx, ny, THREE.RGBAFormat, THREE.UnsignedByteType);
|
|
314
|
+
tex.magFilter = THREE.LinearFilter;
|
|
315
|
+
tex.minFilter = THREE.LinearFilter;
|
|
316
|
+
tex.wrapS = tex.wrapT = THREE.ClampToEdgeWrapping;
|
|
317
|
+
tex.needsUpdate = true;
|
|
318
|
+
return { tex, ox, oy, w: nx * cell, h: ny * cell, nx, ny, cell };
|
|
319
|
+
}
|
|
320
|
+
function buildStitchGeometry(rows) {
|
|
321
|
+
const n = rows.length;
|
|
322
|
+
const g = new THREE.InstancedBufferGeometry();
|
|
323
|
+
g.setAttribute('aq', new THREE.BufferAttribute(new Float32Array([-1, -1, 1, -1, 1, 1, -1, 1]), 2));
|
|
324
|
+
g.setIndex([0, 1, 2, 0, 2, 3]);
|
|
325
|
+
const cols = [['iC', 0, 2], ['iD', 2, 2], ['iP', 4, 4], ['iT', 8, 2], ['iSg', 10, 4], ['iX', 14, 2]];
|
|
326
|
+
for (const [name, off, sz] of cols) {
|
|
327
|
+
const a = new Float32Array(n * sz);
|
|
328
|
+
for (let i = 0; i < n; i++)
|
|
329
|
+
for (let j = 0; j < sz; j++)
|
|
330
|
+
a[i * sz + j] = rows[i][off + j];
|
|
331
|
+
g.setAttribute(name, new THREE.InstancedBufferAttribute(a, sz));
|
|
332
|
+
}
|
|
333
|
+
g.instanceCount = n;
|
|
334
|
+
g.boundingSphere = new THREE.Sphere(new THREE.Vector3(), 1e3);
|
|
335
|
+
return g;
|
|
336
|
+
}
|
|
337
|
+
// ---- GLSL: thread ----------------------------------------------------------------------------
|
|
338
|
+
const VARY = /* glsl */ `varying float vSide; varying vec2 vUU; varying vec4 vTT; varying vec2 vLL; varying vec2 vSI; varying float vVar; varying float vGlyph; varying float vSeed; varying vec2 vPos;
|
|
339
|
+
varying vec2 vXY; varying vec4 vGeo; varying vec2 vDir;`;
|
|
340
|
+
const STITCH_VERT = /* glsl */ `
|
|
341
|
+
attribute vec2 aq; attribute vec2 iC; attribute vec2 iD; attribute vec4 iP; attribute vec2 iT; attribute vec4 iSg; attribute vec2 iX;
|
|
342
|
+
${REVEAL_UNIFORMS}
|
|
343
|
+
${VARY}
|
|
344
|
+
void main(){
|
|
345
|
+
float hl = iP.x; float r = iP.y;
|
|
346
|
+
vec2 loc = vec2(aq.x*(hl + r*1.75), aq.y*r*1.75);
|
|
347
|
+
vec2 perp = vec2(-iD.y, iD.x);
|
|
348
|
+
vec2 w = iC + iD*loc.x + perp*loc.y;
|
|
349
|
+
gl_Position = projectionMatrix*modelViewMatrix*vec4(w, 0.0, 1.0);
|
|
350
|
+
float sp = max(iSg.y - iSg.x, 1e-4), so = max(iSg.w - iSg.z, 1e-4);
|
|
351
|
+
vXY = loc; vGeo = vec4(hl, r, iP.z, 0.0); vDir = iD; vSide = 0.0; vVar = iP.w; vGlyph = iX.y; vPos = w;
|
|
352
|
+
vTT = vec4(iT.x, iT.x, iT.y, iT.y); vUU = vec2(iX.x); vSI = vec2(iSg.x, sp);
|
|
353
|
+
vLL = vec2((uHead - iSg.x)/sp, (uErase - iSg.z)/so);
|
|
354
|
+
vSeed = iSg.x*91.7 + iX.y*13.1;
|
|
355
|
+
}`;
|
|
356
|
+
// kind: 0 thread (satin / stem / laid), 1 border running stitch, 2 French knot, 3 couching tack
|
|
357
|
+
const STITCH_FRAG = /* glsl */ `
|
|
358
|
+
uniform vec3 uColor; uniform vec3 uColor2; uniform float uOpacity; uniform float uSheen; uniform float uRelief; uniform float uOutline; uniform vec3 uL;
|
|
359
|
+
void main(){
|
|
360
|
+
float hl = vGeo.x; float r0 = vGeo.y; float kind = vGeo.z; vec2 loc = vXY;
|
|
361
|
+
float kB = step(0.5, kind)*(1.0 - step(1.5, kind));
|
|
362
|
+
float kK = step(1.5, kind)*(1.0 - step(2.5, kind));
|
|
363
|
+
float kT = step(2.5, kind);
|
|
364
|
+
float kC2 = kB + kT; float kSym = kB + kT + 0.6*kK;
|
|
365
|
+
float lit = revealIn(0.0); float gone = revealOut(0.0); float age = ageAt(0.0);
|
|
366
|
+
// needle pulls the thread through from its entry end (a knot winds up and settles); unpicking lifts it: fade + shrink
|
|
367
|
+
float pull = uFadeIn > 0.5 ? 1.0 : mix(smoothstep(0.0, 0.16, age), smoothstep(0.0, 0.3, age), kK);
|
|
368
|
+
float lift = 1.0 - gone;
|
|
369
|
+
float r = mix(r0*(0.84 + 0.16*pull), r0*(0.5 + 0.5*pull + 0.1*sin(pull*3.14159)), kK)*(1.0 - 0.35*lift);
|
|
370
|
+
float a = -hl*(1.0 - 0.3*lift); float bF = hl*(1.0 - 0.3*lift); float b = mix(a, bF, pull);
|
|
371
|
+
float c = 0.5*(a + b); float sh = 0.5*(b - a);
|
|
372
|
+
vec2 q = vec2(loc.x - c - clamp(loc.x - c, -sh, sh), loc.y);
|
|
373
|
+
float ang = atan(q.y, q.x + 1e-5);
|
|
374
|
+
float s = length(q)/r*(1.0 + kK*(0.03*sin(ang*3.0 + vVar*30.0) + 0.02*sin(ang*5.0 + vVar*17.0)));
|
|
375
|
+
float fw = max(fwidth(s), 1e-4);
|
|
376
|
+
float u = (loc.x + hl)/r0; float v = q.y/r;
|
|
377
|
+
float ph = mix(u*0.60 + v*0.50 + vVar*5.0, s*5.5 - ang/6.2832 + vVar*5.0, kK);
|
|
378
|
+
float fwp = mix(fwidth(ph), fwidth(s*5.5), kK);
|
|
379
|
+
float fibP = mix(v*4.2 + u*0.45 + vVar*11.0, s*7.0 - ang/6.2832*2.0 + vVar*11.0, kK);
|
|
380
|
+
float fwf = mix(fwidth(fibP), fwidth(s*7.0), kK);
|
|
381
|
+
float body = 1.0 - smoothstep(1.0 - 1.1*fw, 1.0 + 1.1*fw, s);
|
|
382
|
+
float vis = lit*gone*smoothstep(0.0, 0.12, pull)*uOpacity*mix(1.0, uOutline, kB);
|
|
383
|
+
// cast self-shadow of this thread on the previous one (it lies on the +y side); symmetric and weaker for small stitches
|
|
384
|
+
float ds = max(s - 1.0, 0.0);
|
|
385
|
+
float skSide = mix(smoothstep(-0.15, 0.55, q.y/r), 0.5, clamp(kSym, 0.0, 1.0));
|
|
386
|
+
float aS = uRelief*mix(0.5, 0.26, clamp(kB + kT, 0.0, 1.0))*skSide*(1.0 - smoothstep(0.0, 0.7, ds))*(1.0 - body)*vis;
|
|
387
|
+
float aB = body*vis;
|
|
388
|
+
if (aB + aS < 0.003) discard;
|
|
389
|
+
float rl = 0.3 + 0.55*uRelief;
|
|
390
|
+
float hh = sqrt(max(1.0 - s*s, 0.0));
|
|
391
|
+
float aaP = 1.0 - smoothstep(0.2, 0.5, fwp);
|
|
392
|
+
float R = 0.5 + 0.5*cos(6.2832*ph);
|
|
393
|
+
vec3 n; vec3 Tf;
|
|
394
|
+
if (kK < 0.5) {
|
|
395
|
+
// thread: round pill with a slanted ply twist; fibres run along the axis rotated about the normal by the twist angle
|
|
396
|
+
n = vec3(q/r*rl*(0.35 + 0.9*s), max(hh, 0.06));
|
|
397
|
+
n.xy += vec2(0.60, 0.50)*sin(6.2832*ph)*0.16*hh*aaP*(0.3 + 0.5*uRelief);
|
|
398
|
+
n = normalize(n);
|
|
399
|
+
float al = 0.40 + 0.05*R + (vVar - 0.5)*0.12;
|
|
400
|
+
Tf = vec3(cos(al), sin(al)*n.z, -sin(al)*n.y); Tf = normalize(Tf - n*dot(Tf, n));
|
|
401
|
+
} else {
|
|
402
|
+
// French knot: a dome of thread wound in a spiral; the fibre runs round the coil, so the highlight is a crescent ring
|
|
403
|
+
vec2 rad = q/max(length(q), 1e-4);
|
|
404
|
+
n = vec3(rad*s*rl*(0.7 + 0.5*s), max(hh, 0.08));
|
|
405
|
+
n.xy += rad*sin(6.2832*ph)*0.30*aaP*hh*(0.3 + 0.6*uRelief);
|
|
406
|
+
n = normalize(n);
|
|
407
|
+
vec3 e = cross(n, vec3(rad, 0.0)); e = normalize(e + vec3(1e-4, 0.0, 0.0));
|
|
408
|
+
float al = 0.30 + 0.06*R + (vVar - 0.5)*0.12;
|
|
409
|
+
Tf = normalize(e*cos(al) + cross(n, e)*sin(al));
|
|
410
|
+
}
|
|
411
|
+
vec2 perp = vec2(-vDir.y, vDir.x);
|
|
412
|
+
vec3 L = normalize(vec3(dot(uL.xy, vDir), dot(uL.xy, perp), uL.z));
|
|
413
|
+
vec3 H = normalize(L + vec3(0.0, 0.0, 1.0));
|
|
414
|
+
float TH = dot(Tf, H); float sinTH = sqrt(max(1.0 - TH*TH, 0.0));
|
|
415
|
+
float TL = dot(Tf, L); float sinTL = sqrt(max(1.0 - TL*TL, 0.0));
|
|
416
|
+
float nl = max(dot(n, L), 0.0);
|
|
417
|
+
float diff = mix(nl, sinTL, 0.45);
|
|
418
|
+
float shadowL = smoothstep(-0.05, 0.3, dot(n, L));
|
|
419
|
+
// ambient occlusion: groove at the flanks, thread ends dive under the neighbours, ply grooves, the knot's dimple
|
|
420
|
+
float aoEdge = smoothstep(0.3, 1.0, s);
|
|
421
|
+
float aoEnd = clamp(max(abs(loc.x) - (hl - 1.2*r0), 0.0)/(1.6*r0), 0.0, 1.0)*(1.0 - kK);
|
|
422
|
+
float aoPly = (1.0 - R)*0.07*aaP;
|
|
423
|
+
float ao = clamp(1.0 - uRelief*(0.42*aoEdge + 0.4*aoEnd + aoPly + kK*0.5*exp(-s*s*38.0)), 0.0, 1.0);
|
|
424
|
+
vec3 alb = mix(uColor, uColor2, kC2)*(0.9 + 0.2*vVar);
|
|
425
|
+
float fpp = fract(ph); float groove = (1.0 - smoothstep(0.0, 0.11 + fwp, min(fpp, 1.0 - fpp)))*aaP;
|
|
426
|
+
alb *= (0.95 + 0.1*R*aaP)*(1.0 - 0.34*groove);
|
|
427
|
+
alb *= 1.0 - 0.16*(0.5 + 0.5*sin(6.2832*fibP))*(1.0 - smoothstep(0.25, 0.5, fwf));
|
|
428
|
+
vec3 col = alb*(0.07 + 0.66*diff*(0.3 + 0.7*shadowL))*ao;
|
|
429
|
+
vec3 sheenCol = mix(alb, vec3(1.0), 0.55);
|
|
430
|
+
float boost = 1.0 + 1.6*exp(-age/0.3)*step(0.5, 1.0 - uFadeIn);
|
|
431
|
+
float sp1 = pow(sinTH, 70.0)*(0.7 + 0.6*R*aaP + 0.3*(1.0 - aaP));
|
|
432
|
+
float sp2 = pow(sinTH, 9.0);
|
|
433
|
+
col += (sheenCol*sp1*1.15 + alb*1.3*sp2*0.55)*uSheen*boost*shadowL*(0.5 + 0.5*ao)*(1.0 + 0.5*lift);
|
|
434
|
+
// soft shoulder: sustained brightness stays below 1, thin peaks may reach it
|
|
435
|
+
float m = max(max(col.r, col.g), col.b);
|
|
436
|
+
if (m > 0.78) col *= (0.78 + 0.28*(1.0 - exp(-(m - 0.78)/0.28)))/m;
|
|
437
|
+
gl_FragColor = vec4(col*aB, aB + aS*(1.0 - aB));
|
|
438
|
+
#include <tonemapping_fragment>
|
|
439
|
+
#include <colorspace_fragment>
|
|
440
|
+
}`;
|
|
441
|
+
// ---- GLSL: linen weave + pucker under the stitching (capsule field around the strokes) ---------------
|
|
442
|
+
// The weave is displaced and lit by the baked wrinkle height field (R) and darkened by the large-scale stitch density (B);
|
|
443
|
+
// it is lit by the same moving key light as the thread, so the gathers glint slowly. Fabric layer only.
|
|
444
|
+
const FABRIC_FRAG = /* glsl */ `
|
|
445
|
+
uniform vec3 uColor; uniform float uFabric; uniform float uOpacity; uniform float uPitch; uniform float uBase; uniform float uPucker; uniform vec3 uL;
|
|
446
|
+
uniform sampler2D uPk; uniform vec2 uPkO; uniform vec2 uPkI; uniform vec2 uPkT; uniform float uPkC;
|
|
447
|
+
float hh2(vec2 p){ return fract(sin(dot(p, vec2(41.7, 289.3)))*43758.5453); }
|
|
448
|
+
void main(){
|
|
449
|
+
float dist = length(vec2(max(abs(vXY.x) - vHL, 0.0), vXY.y));
|
|
450
|
+
float s = dist/uBase;
|
|
451
|
+
vec2 uv = (vPos - uPkO)*uPkI;
|
|
452
|
+
vec3 tx = texture2D(uPk, uv).rgb;
|
|
453
|
+
float hx = texture2D(uPk, uv + vec2(uPkT.x, 0.0)).r - texture2D(uPk, uv - vec2(uPkT.x, 0.0)).r;
|
|
454
|
+
float hy = texture2D(uPk, uv + vec2(0.0, uPkT.y)).r - texture2D(uPk, uv - vec2(0.0, uPkT.y)).r;
|
|
455
|
+
vec2 grad = vec2(hx, hy)/uPkC;
|
|
456
|
+
float pk = uPucker;
|
|
457
|
+
vec2 p = (vPos + pk*0.0006*grad)/uPitch; vec2 fp = fwidth(p);
|
|
458
|
+
float lit = revealIn(0.5)*revealOut(0.5);
|
|
459
|
+
vec2 cell = floor(p); vec2 f = fract(p);
|
|
460
|
+
float chk = mod(cell.x + cell.y, 2.0);
|
|
461
|
+
float tx2 = sin(3.14159*f.x), ty = sin(3.14159*f.y);
|
|
462
|
+
float hgt = mix(ty, tx2, chk)*(0.86 + 0.28*hh2(cell));
|
|
463
|
+
float shade = 0.3 + 0.7*pow(clamp(hgt, 0.0, 1.0), 0.8);
|
|
464
|
+
float contrast = 1.0 - smoothstep(0.3, 0.7, max(fp.x, fp.y));
|
|
465
|
+
shade = mix(0.62, shade, contrast);
|
|
466
|
+
shade = mix(0.8, shade, clamp(uFabric*1.6, 0.0, 1.0));
|
|
467
|
+
vec3 nn = normalize(vec3(-pk*0.06*grad, 1.0));
|
|
468
|
+
float lam = clamp(dot(nn, uL)/max(uL.z, 0.25), 0.4, 1.6);
|
|
469
|
+
shade *= mix(1.0, lam, 0.8);
|
|
470
|
+
shade *= 1.0 - 0.5*pk*smoothstep(0.3, 0.85, tx.b); // tight counters sit deeper in the gathered cloth
|
|
471
|
+
float fv = clamp(uFabric + 0.3*pk, 0.0, 1.0);
|
|
472
|
+
float mask = 1.0 - smoothstep(0.2, 0.9, s);
|
|
473
|
+
mask = max(mask, smoothstep(0.25, 0.6, tx.b)*pk*0.45);
|
|
474
|
+
vec3 lin = mix(vec3(0.62, 0.57, 0.48), uColor, 0.2);
|
|
475
|
+
vec3 col = lin*shade*fv*0.2*mask*lit*uOpacity;
|
|
476
|
+
gl_FragColor = vec4(col, 1.0);
|
|
477
|
+
#include <tonemapping_fragment>
|
|
478
|
+
#include <colorspace_fragment>
|
|
479
|
+
}`;
|
|
480
|
+
// ---- needle + thread tail at the pen tip ---------------------------------------------------------
|
|
481
|
+
const NEEDLE_VERT = /* glsl */ `
|
|
482
|
+
attribute vec2 aq; attribute vec3 iPos; varying vec2 vP; varying float vA;
|
|
483
|
+
void main(){ vec2 p = aq*0.24 + vec2(0.08, 0.08); vP = p; vA = iPos.z; gl_Position = projectionMatrix*modelViewMatrix*vec4(iPos.xy + p, 0.0, 1.0); }`;
|
|
484
|
+
const NEEDLE_FRAG = /* glsl */ `
|
|
485
|
+
precision highp float; uniform vec3 uColor; uniform float uTime; uniform float uOn;
|
|
486
|
+
varying vec2 vP; varying float vA;
|
|
487
|
+
float segd(vec2 p, vec2 a, vec2 b){ vec2 pa = p - a, ba = b - a; float h = clamp(dot(pa, ba)/dot(ba, ba), 0.0, 1.0); return length(pa - ba*h); }
|
|
488
|
+
void main(){
|
|
489
|
+
vec2 nd = normalize(vec2(0.5, 0.86)); float NL = 0.15; vec2 perp = vec2(-nd.y, nd.x);
|
|
490
|
+
float aa = max(fwidth(vP.x), 0.0012);
|
|
491
|
+
float t = clamp(dot(vP, nd)/NL, 0.0, 1.0); vec2 ax = nd*NL*t;
|
|
492
|
+
float rad = mix(0.0013, 0.0042, smoothstep(0.0, 0.35, t));
|
|
493
|
+
float dn = length(vP - ax); float needle = 1.0 - smoothstep(rad - aa, rad + aa, dn);
|
|
494
|
+
float cs = dot(vP - ax, perp)/rad;
|
|
495
|
+
vec3 steel = vec3(0.62, 0.66, 0.72)*(0.55 + 0.45*(1.0 - abs(cs - 0.35)));
|
|
496
|
+
float gl = exp(-pow((t - fract(uTime*0.23))*7.0, 2.0)); steel += vec3(0.5)*gl*(1.0 - abs(cs));
|
|
497
|
+
float eye = 1.0 - smoothstep(0.0, 0.0018, abs(length(vP - nd*0.135 - perp*0.0) - 0.0) - 0.0);
|
|
498
|
+
vec2 E = nd*0.134; float th = 1.0e3; vec2 prev = E;
|
|
499
|
+
for (int i = 1; i <= 12; i++) { float u = float(i)/12.0;
|
|
500
|
+
vec2 cur = E + vec2(0.105*u, 0.045*u - 0.085*u*u + 0.010*u*sin(u*8.0 - uTime*2.0));
|
|
501
|
+
th = min(th, segd(vP, prev, cur)); prev = cur; }
|
|
502
|
+
float tr = 0.0024; float thread = (1.0 - smoothstep(tr - aa, tr + aa, th))*0.9;
|
|
503
|
+
vec3 tc = uColor*(0.8 + 0.3*(1.0 - smoothstep(0.0, tr, th))) + vec3(0.12);
|
|
504
|
+
float a = max(needle, thread)*vA*uOn;
|
|
505
|
+
vec3 col = mix(tc, steel, needle);
|
|
506
|
+
col = min(col, vec3(0.95));
|
|
507
|
+
gl_FragColor = vec4(col*a, a);
|
|
508
|
+
#include <tonemapping_fragment>
|
|
509
|
+
#include <colorspace_fragment>
|
|
510
|
+
}`;
|
|
511
|
+
export default {
|
|
512
|
+
key: 'embroidery', source: 'hand',
|
|
513
|
+
drawMethods: ['stitch', ...DRAW_METHODS], eraseMethods: ['undraw', 'unpick', ...ERASE_METHODS.filter((m) => m !== 'undraw')],
|
|
514
|
+
drawDefault: 'stitch', eraseDefault: 'undraw',
|
|
515
|
+
methodInfo: {
|
|
516
|
+
stitch: { label: 'Stitch', hint: 'A needle pulls each satin stitch through, one after the other along the stroke' },
|
|
517
|
+
unpick: { label: 'Unpick', hint: 'Stitches are pulled out in reverse, lifting and thinning as they go' },
|
|
518
|
+
},
|
|
519
|
+
catalog: { name: 'Embroidery', description: 'Hand-embroidered lettering that picks satin, stem stitch, couching and French knots per stroke, with silk thread sheen under a moving light on puckered linen. Use for monograms, heritage brands and textile titles.', tags: ['embroidery', 'satin-stitch', 'thread', 'silk', 'textile', 'sewing', 'stitch'] },
|
|
520
|
+
defaults: { color: '#c92f48', color2: '#e8c47a', density: 44, slant: 66, thickness: 1.35, sheen: 1, relief: 1, outline: 0.65, fabric: 0.4, pucker: 0.6, style: 'auto', opacity: 1 },
|
|
521
|
+
ui: {
|
|
522
|
+
main: [
|
|
523
|
+
{ name: 'color', label: 'Thread', description: 'Main satin thread colour', type: 'color' },
|
|
524
|
+
{ name: 'sheen', label: 'Sheen', description: 'Strength of the silk highlight that sweeps over the stitching', type: 'number', min: 0, max: 2, step: 0.01 },
|
|
525
|
+
{ name: 'density', label: 'Density', description: 'Stitches per em along the stroke', type: 'number', min: 14, max: 70, step: 1, unit: '/em' },
|
|
526
|
+
{ name: 'thickness', label: 'Thickness', description: 'Width of the satin column relative to the pen stroke', type: 'number', min: 0.6, max: 2.4, step: 0.01 },
|
|
527
|
+
],
|
|
528
|
+
more: [
|
|
529
|
+
{ name: 'color2', label: 'Contrast thread', description: 'Border running-stitch thread', type: 'color' },
|
|
530
|
+
{ name: 'relief', label: 'Relief', description: 'Raised look: thread height, groove shadows and stitch ends diving under neighbours', type: 'number', min: 0, max: 1.5, step: 0.01 },
|
|
531
|
+
{ name: 'outline', label: 'Border row', description: 'Visibility of the contrast running-stitch border', type: 'number', min: 0, max: 1, step: 0.01 },
|
|
532
|
+
{ name: 'fabric', label: 'Fabric', description: 'Faint linen weave behind the stitching', type: 'number', min: 0, max: 1, step: 0.01 },
|
|
533
|
+
{ name: 'pucker', label: 'Pucker', description: 'Dense stitching gathers the cloth: soft wrinkles around the stitching, deeper tight counters (fabric layer only)', type: 'number', min: 0, max: 1, step: 0.01 },
|
|
534
|
+
{ name: 'style', label: 'Stitch style', description: 'Automatic picks per stroke: satin, stem stitch, couching, French knots. Or force one', type: 'select', options: ['auto', 'satin', 'stem', 'couching'], optionLabels: ['Automatic', 'Satin', 'Stem', 'Couching'] },
|
|
535
|
+
{ name: 'slant', label: 'Slant', description: 'Satin stitch angle to the stroke direction', type: 'number', min: 40, max: 85, step: 1, unit: '°' },
|
|
536
|
+
{ name: 'opacity', label: 'Opacity', description: 'Overall opacity', type: 'number', min: 0, max: 1, step: 0.01 },
|
|
537
|
+
],
|
|
538
|
+
},
|
|
539
|
+
structural: ['density', 'slant', 'thickness', 'style'],
|
|
540
|
+
presets: [
|
|
541
|
+
{ name: 'Crimson silk', description: 'Red satin with a gold running-stitch border', patch: {} },
|
|
542
|
+
{ name: 'Ivory & gold', description: 'Cream thread, gold border, glossy', patch: { color: '#eadfc6', color2: '#d4a24a', sheen: 1.2, fabric: 0.3 } },
|
|
543
|
+
{ name: 'Indigo on linen', description: 'Blue thread on a visible linen weave', patch: { color: '#4766e0', color2: '#d9defa', sheen: 0.8, fabric: 0.85, outline: 0.5, pucker: 0.9 } },
|
|
544
|
+
{ name: 'Matte cotton', description: 'Soft, low-sheen floss with strong relief', patch: { color: '#e4cfae', color2: '#b9553f', sheen: 0.25, relief: 1.3, fabric: 0.55, outline: 0.8, pucker: 0.8 } },
|
|
545
|
+
{ name: 'Emerald satin', description: 'Deep green, high gloss, bold border', patch: { color: '#14a66f', color2: '#f2d27a', sheen: 1.6, outline: 0.95, fabric: 0.2, pucker: 0.4 } },
|
|
546
|
+
],
|
|
547
|
+
build(layout, cfg, anim) {
|
|
548
|
+
const strokes = layout.strokes;
|
|
549
|
+
prepare(strokes, 'hand');
|
|
550
|
+
const G = layout.glyphs.length;
|
|
551
|
+
strokes.forEach((s) => { s.glyphN = s.glyph / Math.max(1, G - 1); });
|
|
552
|
+
const a2 = { ...anim, draw: { ...anim.draw, method: anim.draw.method === 'stitch' ? 'pen' : anim.draw.method }, erase: { ...anim.erase, method: anim.erase.method === 'unpick' ? 'undraw' : anim.erase.method } };
|
|
553
|
+
const { infoD: iD0, infoE: iE0 } = applyAnim(strokes, a2, G);
|
|
554
|
+
const infoD = { ...iD0, tip: iD0.tip && !iD0.fade };
|
|
555
|
+
const infoE = { ...iE0 };
|
|
556
|
+
if (!infoE.fade)
|
|
557
|
+
infoE.soft = Math.max(infoE.soft, 0.03); // threads leave over a short window, never pop
|
|
558
|
+
const natural = layout.natural || 0.05;
|
|
559
|
+
const rows = genStitches(strokes, natural, cfg.density, cfg.slant, cfg.thickness, STYLES.indexOf(cfg.style));
|
|
560
|
+
const geo = buildStitchGeometry(rows);
|
|
561
|
+
const mat = new THREE.ShaderMaterial({
|
|
562
|
+
uniforms: { ...uniformsBase(), uColor: { value: hex(cfg.color) }, uColor2: { value: hex(cfg.color2) }, uOpacity: { value: 1 }, uSheen: { value: 1 }, uRelief: { value: 1 }, uOutline: { value: 1 }, uL: { value: new THREE.Vector3(0, 0, 1) } },
|
|
563
|
+
vertexShader: STITCH_VERT, fragmentShader: frag(STITCH_FRAG, 'varying vec2 vXY; varying vec4 vGeo; varying vec2 vDir;\n'),
|
|
564
|
+
transparent: true, depthWrite: false, side: THREE.DoubleSide,
|
|
565
|
+
blending: THREE.CustomBlending, blendEquation: THREE.AddEquation, blendSrc: THREE.OneFactor, blendDst: THREE.OneMinusSrcAlphaFactor,
|
|
566
|
+
});
|
|
567
|
+
const mesh = new THREE.Mesh(geo, mat);
|
|
568
|
+
mesh.frustumCulled = false;
|
|
569
|
+
mesh.renderOrder = 1;
|
|
570
|
+
// fabric: capsule field around the strokes
|
|
571
|
+
const fgeo = buildCapsules(strokes);
|
|
572
|
+
const pk = bakePucker(strokes, rows, natural, cfg.thickness);
|
|
573
|
+
const fBase = natural * cfg.thickness * 0.6 + 0.05;
|
|
574
|
+
const fmat = capsuleMaterial(FABRIC_FRAG, { uColor: { value: hex(cfg.color) }, uFabric: { value: cfg.fabric }, uOpacity: { value: 1 }, uPitch: { value: 0.022 }, uBase: { value: fBase }, uPucker: { value: cfg.pucker }, uL: { value: new THREE.Vector3(0, 0, 1) },
|
|
575
|
+
uPk: { value: pk.tex }, uPkO: { value: new THREE.Vector2(pk.ox, pk.oy) }, uPkI: { value: new THREE.Vector2(1 / pk.w, 1 / pk.h) }, uPkT: { value: new THREE.Vector2(1 / pk.nx, 1 / pk.ny) }, uPkC: { value: pk.cell } });
|
|
576
|
+
fmat.uniforms.uHalf.value = fBase + 0.07 * cfg.pucker;
|
|
577
|
+
const fab = new THREE.Mesh(fgeo, fmat);
|
|
578
|
+
fab.frustumCulled = false;
|
|
579
|
+
fab.renderOrder = 0;
|
|
580
|
+
// needle pool
|
|
581
|
+
const NP = 8;
|
|
582
|
+
const ng = new THREE.InstancedBufferGeometry();
|
|
583
|
+
ng.setAttribute('aq', new THREE.BufferAttribute(new Float32Array([-1, -1, 1, -1, 1, 1, -1, 1]), 2));
|
|
584
|
+
ng.setIndex([0, 1, 2, 0, 2, 3]);
|
|
585
|
+
const iPos = new THREE.InstancedBufferAttribute(new Float32Array(NP * 3), 3);
|
|
586
|
+
iPos.setUsage(THREE.DynamicDrawUsage);
|
|
587
|
+
ng.setAttribute('iPos', iPos);
|
|
588
|
+
ng.instanceCount = 0;
|
|
589
|
+
ng.boundingSphere = new THREE.Sphere(new THREE.Vector3(), 1e3);
|
|
590
|
+
const nmat = new THREE.ShaderMaterial({ uniforms: { uColor: { value: hex(cfg.color) }, uTime: { value: 0 }, uOn: { value: 1 } }, vertexShader: NEEDLE_VERT, fragmentShader: NEEDLE_FRAG, transparent: true, depthWrite: false, side: THREE.DoubleSide, blending: THREE.CustomBlending, blendEquation: THREE.AddEquation, blendSrc: THREE.OneFactor, blendDst: THREE.OneMinusSrcAlphaFactor });
|
|
591
|
+
const needle = new THREE.Mesh(ng, nmat);
|
|
592
|
+
needle.frustumCulled = false;
|
|
593
|
+
needle.renderOrder = 2;
|
|
594
|
+
const group = new THREE.Group();
|
|
595
|
+
group.add(fab, mesh, needle);
|
|
596
|
+
const api = {
|
|
597
|
+
object: group,
|
|
598
|
+
apply(c) {
|
|
599
|
+
const u = mat.uniforms;
|
|
600
|
+
u.uColor.value.set(c.color);
|
|
601
|
+
u.uColor2.value.set(c.color2);
|
|
602
|
+
u.uOpacity.value = c.opacity;
|
|
603
|
+
u.uSheen.value = c.sheen;
|
|
604
|
+
u.uRelief.value = c.relief;
|
|
605
|
+
u.uOutline.value = c.outline;
|
|
606
|
+
fmat.uniforms.uColor.value.set(c.color);
|
|
607
|
+
fmat.uniforms.uFabric.value = c.fabric;
|
|
608
|
+
fmat.uniforms.uOpacity.value = c.opacity;
|
|
609
|
+
fmat.uniforms.uPucker.value = c.pucker;
|
|
610
|
+
fmat.uniforms.uHalf.value = fBase + 0.07 * c.pucker;
|
|
611
|
+
nmat.uniforms.uColor.value.set(c.color);
|
|
612
|
+
nmat.uniforms.uOn.value = c.opacity;
|
|
613
|
+
api.c = c;
|
|
614
|
+
},
|
|
615
|
+
update(S, time, px) {
|
|
616
|
+
setReveal(mat.uniforms, S, infoD, infoE, anim.draw.duration, time);
|
|
617
|
+
setReveal(fmat.uniforms, S, infoD, infoE, anim.draw.duration, time);
|
|
618
|
+
lightAt(time, mat.uniforms.uL.value);
|
|
619
|
+
fmat.uniforms.uL.value.copy(mat.uniforms.uL.value);
|
|
620
|
+
nmat.uniforms.uTime.value = time;
|
|
621
|
+
let k = 0;
|
|
622
|
+
if (infoD.tip && S.d > 0 && S.d < 1 && S.e <= 0) {
|
|
623
|
+
const head = mat.uniforms.uHead.value;
|
|
624
|
+
for (const s of strokes) {
|
|
625
|
+
if (k >= NP)
|
|
626
|
+
break;
|
|
627
|
+
const p = headPoint(s, head);
|
|
628
|
+
if (!p)
|
|
629
|
+
continue;
|
|
630
|
+
const u = (head - s.seg[0]) / Math.max(1e-6, s.seg[1] - s.seg[0]);
|
|
631
|
+
iPos.setXYZ(k++, p[0], p[1], Math.min(1, u / 0.04, (1 - u) / 0.04));
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
ng.instanceCount = k;
|
|
635
|
+
if (k)
|
|
636
|
+
iPos.needsUpdate = true;
|
|
637
|
+
},
|
|
638
|
+
dispose() { geo.dispose(); mat.dispose(); fgeo.dispose(); fmat.dispose(); pk.tex.dispose(); ng.dispose(); nmat.dispose(); },
|
|
639
|
+
};
|
|
640
|
+
api.apply(cfg);
|
|
641
|
+
api.count = rows.length;
|
|
642
|
+
api.kinds = [0, 1, 2, 3].map((k) => rows.filter((r) => r[6] === k).length);
|
|
643
|
+
return api;
|
|
644
|
+
},
|
|
645
|
+
};
|