@mkbabb/glass-ui 4.0.1 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CardAction-CW7a0m8M.js → CardAction-DlVP2evz.js} +72 -53
- package/dist/{CommandShortcut-DvZNQ_HF.js → CommandShortcut-By-VQcLO.js} +25 -14
- package/dist/{ConfiguratorRow-BR4l-ixA.js → ConfiguratorRow-YMXdINHx.js} +14 -14
- package/dist/ContextMenuContent-CMWn6huB.js +90 -0
- package/dist/{ContextMenuSubContent-xol4sD2q.js → ContextMenuSubContent-DvwWCUc0.js} +16 -16
- package/dist/{DataTable-CuKwF7wr.js → DataTable-C4tG3eIJ.js} +4 -4
- package/dist/DialogContent-D8U9ZfWS.js +121 -0
- package/dist/DialogFooter-DoLy0ewI.js +80 -0
- package/dist/DialogScrollContent-BMekN7gq.js +93 -0
- package/dist/{FadingScroll-DI6hQhT9.js → FadingScroll-P8B30rAD.js} +1 -1
- package/dist/HoverCardContent-DAmGYglo.js +88 -0
- package/dist/{HoverPopover-CbqbNwgU.js → HoverPopover-DYpBOzzF.js} +1 -1
- package/dist/{IconChip-BTD-nay5.js → IconChip-CQa7XZYc.js} +7 -5
- package/dist/{IconTooltip-Bl8gFZ8d.js → IconTooltip-_df8M3xm.js} +1 -1
- package/dist/Input-CyU4_hIC.js +57 -0
- package/dist/{MetricBadge-RHdBP72w.js → MetricBadge-DQt_dGah.js} +1 -1
- package/dist/{Notification-VUwexFUf.js → Notification-BlSPJhtZ.js} +4 -4
- package/dist/NumberFieldContent-Z3VxGu_6.js +140 -0
- package/dist/PagerDots-CYlqVFd4.js +196 -0
- package/dist/PaperBackdrop-DYWgrnh8.js +42 -0
- package/dist/{PopoverContent-DL7E6vJP.js → PopoverContent-BuKyHZSz.js} +2 -2
- package/dist/{Progress-DctG61iZ.js → Progress-C9SsdwIZ.js} +1 -1
- package/dist/{ScrollingText-yOpBzFYq.js → ScrollingText-DY3W1Jfh.js} +2 -2
- package/dist/SelectScrollDownButton-3mFHX_R-.js +260 -0
- package/dist/{SelectSeparator-DXswVdRz.js → SelectSeparator-CNRGG7Ew.js} +1 -1
- package/dist/Separator-Cf9-JFgi.js +44 -0
- package/dist/Switch-uf-UKPA2.js +49 -0
- package/dist/{Toaster-Bw4xR8xV.js → Toaster-ozrsR4mP.js} +2 -2
- package/dist/{ToggleGroupItem-pEM9vIhs.js → ToggleGroupItem-BpzaVzNm.js} +6 -6
- package/dist/TooltipProvider-QQVM_80r.js +109 -0
- package/dist/animated-digit.js +2 -2
- package/dist/api/index.d.ts +16 -32
- package/dist/api/types-extra.d.ts +33 -0
- package/dist/api.js +2 -2
- package/dist/aurora.js +629 -269
- package/dist/badge-Bt14yURi.js +72 -0
- package/dist/badge.js +1 -1
- package/dist/border-progress.js +49 -57
- package/dist/button-D1W9PrzI.js +130 -0
- package/dist/button.js +1 -1
- package/dist/canvas.js +2 -3
- package/dist/card.js +1 -1
- package/dist/carousel.js +235 -106
- package/dist/chipVariants-BJQ0I2kB.js +18 -0
- package/dist/collapsible.js +1 -1
- package/dist/color-B9jZdhJX.js +116 -0
- package/dist/color.js +2 -2
- package/dist/command.js +1 -1
- package/dist/completion-seal.d.ts +1 -0
- package/dist/completion-seal.js +89 -0
- package/dist/components/custom/aurora/Aurora.vue.d.ts +10 -5
- package/dist/components/custom/aurora/composables/color.d.ts +13 -0
- package/dist/components/custom/aurora/composables/frameLoop.d.ts +9 -0
- package/dist/components/custom/aurora/composables/glSetup.d.ts +1 -1
- package/dist/components/custom/aurora/composables/runtime.d.ts +12 -0
- package/dist/components/custom/aurora/composables/uniformBridgeWGPU.d.ts +12 -3
- package/dist/components/custom/aurora/composables/wgpuSetup.d.ts +8 -0
- package/dist/components/custom/aurora/constants/presets.d.ts +47 -0
- package/dist/components/custom/aurora/constants/renderMode.d.ts +16 -8
- package/dist/components/custom/aurora/constants/shaders/aurora-mediums.wgsl.d.ts +1 -0
- package/dist/components/custom/aurora/constants/shaders/aurora.wgsl.d.ts +1 -1
- package/dist/components/custom/aurora/index.d.ts +1 -1
- package/dist/components/custom/border-progress/composables/spectrum-walk.d.ts +25 -0
- package/dist/components/custom/border-progress/composables/useBorderSpectrum.d.ts +14 -18
- package/dist/components/custom/border-progress/index.d.ts +1 -1
- package/dist/components/custom/completion-seal/CompletionSeal.vue.d.ts +21 -0
- package/dist/components/custom/completion-seal/composables/useCompletionSeal.d.ts +37 -0
- package/dist/components/custom/completion-seal/constants.d.ts +46 -0
- package/dist/components/custom/completion-seal/index.d.ts +4 -0
- package/dist/components/custom/concentric/Concentric.vue.d.ts +15 -12
- package/dist/components/custom/concentric/composables/concentricGLSetup.d.ts +12 -0
- package/dist/components/custom/concentric/composables/concentricWGPUSetup.d.ts +13 -0
- package/dist/components/custom/concentric/composables/levelField.d.ts +50 -0
- package/dist/components/custom/concentric/composables/uniformBridgeWGPU.d.ts +7 -3
- package/dist/components/custom/concentric/composables/useConcentric.d.ts +3 -3
- package/dist/components/custom/concentric/constants.d.ts +69 -24
- package/dist/components/custom/concentric/index.d.ts +2 -2
- package/dist/components/custom/concentric/shaders/concentric.glsl.d.ts +2 -2
- package/dist/components/custom/concentric/shaders/concentric.wgsl.d.ts +1 -1
- package/dist/components/custom/configurator/Configurator.vue.d.ts +23 -2
- package/dist/components/custom/configurator/index.d.ts +1 -1
- package/dist/components/custom/confirm-dialog/ConfirmDialog.vue.d.ts +3 -3
- package/dist/components/custom/constellation/Constellation.vue.d.ts +5 -4
- package/dist/components/custom/constellation/composables/constellationGLSetup.d.ts +10 -0
- package/dist/components/custom/constellation/composables/constellationWGPUSetup.d.ts +19 -0
- package/dist/components/custom/constellation/composables/uniformBridgeWGPU.d.ts +66 -0
- package/dist/components/custom/constellation/composables/useConstellation.d.ts +3 -10
- package/dist/components/custom/constellation/constants.d.ts +33 -0
- package/dist/components/custom/constellation/constellationField.d.ts +31 -1
- package/dist/components/custom/constellation/constellationInteraction.d.ts +23 -14
- package/dist/components/custom/constellation/constellationRender.d.ts +25 -0
- package/dist/components/custom/constellation/constellationTypes.d.ts +38 -0
- package/dist/components/custom/constellation/constellationWell.d.ts +15 -0
- package/dist/components/custom/constellation/index.d.ts +5 -5
- package/dist/components/custom/constellation/shaders/constellation-lines.glsl.d.ts +2 -0
- package/dist/components/custom/constellation/shaders/constellation-lines.wgsl.d.ts +1 -0
- package/dist/components/custom/constellation/shaders/constellation-points.glsl.d.ts +2 -0
- package/dist/components/custom/constellation/shaders/constellation-points.wgsl.d.ts +1 -0
- package/dist/components/custom/deck/DeckPager.vue.d.ts +29 -0
- package/dist/components/custom/deck/composables/useDeck.d.ts +27 -0
- package/dist/components/custom/deck/composables/useDeckKeyboard.d.ts +25 -0
- package/dist/components/custom/deck/composables/useDeckSpring.d.ts +22 -0
- package/dist/components/custom/deck/constants.d.ts +14 -0
- package/dist/components/custom/deck/index.d.ts +8 -0
- package/dist/components/custom/dock/DockDropdownTrigger.vue.d.ts +4 -3
- package/dist/components/custom/dock/DockIconButton.vue.d.ts +22 -0
- package/dist/components/custom/dock/DockPopoverTrigger.vue.d.ts +19 -0
- package/dist/components/custom/dock/DockStack.vue.d.ts +78 -0
- package/dist/components/custom/dock/GlassDock.vue.d.ts +21 -3
- package/dist/components/custom/dock/composables/dockMorphContext.d.ts +18 -32
- package/dist/components/custom/dock/composables/dockMorphMeasure.d.ts +78 -67
- package/dist/components/custom/dock/composables/index.d.ts +3 -0
- package/dist/components/custom/dock/composables/railProjection.d.ts +45 -0
- package/dist/components/custom/dock/composables/useDockContextSilhouette.d.ts +192 -0
- package/dist/components/custom/dock/composables/useDockFission.d.ts +158 -0
- package/dist/components/custom/dock/composables/useDockItemDrag.d.ts +18 -0
- package/dist/components/custom/dock/composables/useDockSearch.d.ts +85 -0
- package/dist/components/custom/dock/composables/useDockShellProps.d.ts +49 -0
- package/dist/components/custom/dock/constants.d.ts +32 -17
- package/dist/components/custom/dock/index.d.ts +8 -2
- package/dist/components/custom/dot-flow-field/DotFlowField.vue.d.ts +15 -11
- package/dist/components/custom/dot-flow-field/composables/flowField.d.ts +69 -6
- package/dist/components/custom/dot-flow-field/composables/flowGLProgram.d.ts +8 -0
- package/dist/components/custom/dot-flow-field/composables/flowSetupGL.d.ts +9 -0
- package/dist/components/custom/dot-flow-field/composables/flowSetupGLFlow.d.ts +12 -0
- package/dist/components/custom/dot-flow-field/composables/flowSetupWGPU.d.ts +7 -0
- package/dist/components/custom/dot-flow-field/composables/uniformBridgeWGPU.d.ts +50 -9
- package/dist/components/custom/dot-flow-field/composables/useDotFlowField.d.ts +6 -5
- package/dist/components/custom/dot-flow-field/composables/useFlowParticles.d.ts +23 -9
- package/dist/components/custom/dot-flow-field/constants.d.ts +92 -20
- package/dist/components/custom/dot-flow-field/index.d.ts +2 -2
- package/dist/components/custom/dot-flow-field/shaders/flow-field.compute.wgsl.d.ts +1 -1
- package/dist/components/custom/dot-flow-field/shaders/flow-field.glsl.d.ts +31 -18
- package/dist/components/custom/dot-flow-field/shaders/flow-field.render.wgsl.d.ts +2 -1
- package/dist/components/custom/dot-matrix/DotMatrix.vue.d.ts +43 -0
- package/dist/components/custom/dot-matrix/composables/dotMatrixField.d.ts +89 -0
- package/dist/components/custom/dot-matrix/composables/uniformBridgeWGPU.d.ts +61 -0
- package/dist/components/custom/dot-matrix/composables/useDotMatrix.d.ts +34 -0
- package/dist/components/custom/dot-matrix/composables/useDotSphere.d.ts +34 -0
- package/dist/components/custom/dot-matrix/constants.d.ts +72 -0
- package/dist/components/custom/dot-matrix/index.d.ts +5 -0
- package/dist/components/custom/dot-matrix/shaders/dot-matrix.glsl.d.ts +4 -0
- package/dist/components/custom/dot-matrix/shaders/dot-matrix.wgsl.d.ts +1 -0
- package/dist/components/custom/easing/EasingPicker.vue.d.ts +2 -2
- package/dist/components/custom/easing/composables/useEasingPicker.d.ts +5 -0
- package/dist/components/custom/expandable-container/ExpandableContainer.vue.d.ts +11 -0
- package/dist/components/custom/fourier-field/FourierField.vue.d.ts +44 -47
- package/dist/components/custom/fourier-field/composables/fourierFieldGLSetup.d.ts +24 -0
- package/dist/components/custom/fourier-field/composables/fourierFieldWGPUSetup.d.ts +31 -0
- package/dist/components/custom/fourier-field/composables/uniformBridgeWGPU.d.ts +56 -0
- package/dist/components/custom/fourier-field/composables/useFourierField.d.ts +61 -37
- package/dist/components/custom/fourier-field/constants.d.ts +114 -4
- package/dist/components/custom/fourier-field/index.d.ts +23 -18
- package/dist/components/custom/fourier-field/shaders/fourier-field.compute.wgsl.d.ts +1 -0
- package/dist/components/custom/fourier-field/shaders/fourier-field.glsl.d.ts +4 -0
- package/dist/components/custom/fourier-field/shaders/fourier-field.render.wgsl.d.ts +1 -0
- package/dist/components/custom/goo-blob/GooBlob.vue.d.ts +9 -1
- package/dist/components/custom/goo-blob/composables/easing.d.ts +1 -0
- package/dist/components/custom/goo-blob/composables/useBlobSatellites.d.ts +1 -0
- package/dist/components/custom/goo-blob/constants.d.ts +26 -1
- package/dist/components/custom/goo-blob/index.d.ts +1 -1
- package/dist/components/custom/goo-blob/shaders/metaball-noise.wgsl.d.ts +1 -0
- package/dist/components/custom/goo-blob/shaders/metaball-palette.wgsl.d.ts +1 -0
- package/dist/components/custom/goo-blob/shaders/metaball-uniforms.glsl.d.ts +1 -1
- package/dist/components/custom/goo-blob/shaders/metaball.wgsl.d.ts +1 -1
- package/dist/components/custom/goo-blob/types.d.ts +86 -1
- package/dist/components/custom/goo-dot-matrix/GooDotMatrix.vue.d.ts +49 -0
- package/dist/components/custom/goo-dot-matrix/composables/gooDotLattice.d.ts +24 -0
- package/dist/components/custom/goo-dot-matrix/composables/gooDotSetup.d.ts +79 -0
- package/dist/components/custom/goo-dot-matrix/composables/uniformBridgeWGPU.d.ts +45 -0
- package/dist/components/custom/goo-dot-matrix/composables/useGooDotMatrix.d.ts +31 -0
- package/dist/components/custom/goo-dot-matrix/constants.d.ts +115 -0
- package/dist/components/custom/goo-dot-matrix/index.d.ts +5 -0
- package/dist/components/custom/goo-dot-matrix/shaders/goo-dot.frag.d.ts +13 -0
- package/dist/components/custom/goo-dot-matrix/shaders/goo-dot.wgsl.d.ts +4 -0
- package/dist/components/custom/goo-filter/GooFilter.vue.d.ts +22 -0
- package/dist/components/custom/goo-filter/index.d.ts +1 -0
- package/dist/components/custom/handmark/brush.d.ts +17 -17
- package/dist/components/custom/handmark/constants.d.ts +28 -8
- package/dist/components/custom/handmark/geometry.d.ts +34 -1
- package/dist/components/custom/handmark/index.d.ts +1 -1
- package/dist/components/custom/icon-chip/types.d.ts +10 -0
- package/dist/components/custom/labeled-field/LabeledField.vue.d.ts +21 -2
- package/dist/components/custom/metric-stack/MetricRow.vue.d.ts +15 -0
- package/dist/components/custom/pager-dots/PagerDots.vue.d.ts +9 -0
- package/dist/components/custom/pager-dots/index.d.ts +2 -0
- package/dist/components/custom/pager-dots/pagerWindow.d.ts +9 -0
- package/dist/components/custom/paper-backdrop/PaperBackdrop.vue.d.ts +18 -0
- package/dist/components/custom/paper-grid/PaperGrid.vue.d.ts +42 -0
- package/dist/components/custom/paper-grid/composables/paperGrid.d.ts +105 -0
- package/dist/components/custom/paper-grid/composables/paperGridGLSetup.d.ts +18 -0
- package/dist/components/custom/paper-grid/composables/paperGridWGPUSetup.d.ts +21 -0
- package/dist/components/custom/paper-grid/composables/uniformBridgeWGPU.d.ts +16 -0
- package/dist/components/custom/paper-grid/composables/usePaperGrid.d.ts +31 -0
- package/dist/components/custom/paper-grid/constants.d.ts +95 -0
- package/dist/components/custom/paper-grid/index.d.ts +5 -0
- package/dist/components/custom/paper-grid/shaders/paper-grid.glsl.d.ts +4 -0
- package/dist/components/custom/paper-grid/shaders/paper-grid.wgsl.d.ts +1 -0
- package/dist/components/custom/search/FuzzySearch.vue.d.ts +8 -2
- package/dist/components/custom/search/SearchBar.vue.d.ts +8 -0
- package/dist/components/custom/search/index.d.ts +2 -0
- package/dist/components/custom/search/searchVariants.d.ts +19 -0
- package/dist/components/custom/selectable-chip/SelectableChip.vue.d.ts +50 -0
- package/dist/components/custom/selectable-chip/chipVariants.d.ts +39 -0
- package/dist/components/custom/selectable-chip/index.d.ts +2 -0
- package/dist/components/custom/selectable-chip/selectableChipVariants.d.ts +15 -0
- package/dist/components/custom/split-chars/SplitChars.vue.d.ts +39 -0
- package/dist/components/custom/split-chars/index.d.ts +1 -0
- package/dist/components/custom/tabs/SegmentedTabs.vue.d.ts +8 -6
- package/dist/components/custom/tabs/constants.d.ts +28 -2
- package/dist/components/custom/timeline/ScrubberTimeline.vue.d.ts +16 -0
- package/dist/components/custom/timeline/geometry.d.ts +0 -8
- package/dist/components/custom/toggle-chip/index.d.ts +15 -4
- package/dist/components/custom/watercolor-dot/WatercolorDot.vue.d.ts +32 -17
- package/dist/components/custom/watercolor-dot/useWatercolorBlob.d.ts +10 -5
- package/dist/components/ui/_shared/index.d.ts +2 -0
- package/dist/components/ui/_shared/useControlSize.d.ts +46 -0
- package/dist/components/ui/_shared/useSurfaceAxis.d.ts +17 -3
- package/dist/components/ui/badge/Badge.vue.d.ts +14 -0
- package/dist/components/ui/badge/index.d.ts +1 -0
- package/dist/components/ui/button/Button.vue.d.ts +1 -0
- package/dist/components/ui/button/index.d.ts +1 -1
- package/dist/components/ui/card/Card.vue.d.ts +46 -1
- package/dist/components/ui/card/ScrollCard.vue.d.ts +1 -1
- package/dist/components/ui/card/index.d.ts +1 -1
- package/dist/components/ui/carousel/CarouselContent.vue.d.ts +2 -4
- package/dist/components/ui/carousel/CarouselNext.vue.d.ts +1 -1
- package/dist/components/ui/carousel/CarouselPrevious.vue.d.ts +1 -1
- package/dist/components/ui/command/CommandDialog.vue.d.ts +9 -3
- package/dist/components/ui/command/CommandList.vue.d.ts +3 -0
- package/dist/components/ui/context-menu/ContextMenuContent.vue.d.ts +5 -1
- package/dist/components/ui/dialog/DialogContent.vue.d.ts +9 -0
- package/dist/components/ui/drawer/Drawer.vue.d.ts +33 -14
- package/dist/components/ui/drawer/constants.d.ts +8 -6
- package/dist/components/ui/drawer/index.d.ts +12 -2
- package/dist/components/ui/dropdown-menu/DropdownMenuContent.vue.d.ts +4 -0
- package/dist/components/ui/hover-card/HoverCardContent.vue.d.ts +3 -0
- package/dist/components/ui/input/Input.vue.d.ts +3 -0
- package/dist/components/ui/number-field/NumberFieldInput.vue.d.ts +6 -1
- package/dist/components/ui/select/SelectContent.vue.d.ts +12 -0
- package/dist/components/ui/slider/Slider.vue.d.ts +9 -0
- package/dist/components/ui/switch/Switch.vue.d.ts +2 -0
- package/dist/components/ui/textarea/Textarea.vue.d.ts +3 -0
- package/dist/components/ui/tooltip/TooltipContent.vue.d.ts +3 -0
- package/dist/composables/color/index.d.ts +2 -0
- package/dist/composables/color/useAccentTone.d.ts +34 -0
- package/dist/composables/dom/index.d.ts +1 -0
- package/dist/composables/dom/useDragVelocity.d.ts +46 -0
- package/dist/composables/glass/useVizChoreography.d.ts +123 -0
- package/dist/composables/glass/wave/index.d.ts +4 -0
- package/dist/composables/glass/wave/waveField.d.ts +115 -0
- package/dist/composables/glass/wave/waveField.glsl.d.ts +1 -0
- package/dist/composables/glass/wave/waveField.wgsl.d.ts +1 -0
- package/dist/composables/glass/webgl/createCanvasLifecycle.d.ts +105 -2
- package/dist/composables/glass/webgl/shaders/flow.wgsl.d.ts +1 -0
- package/dist/composables/glass/webgl/useWebGLCanvas.d.ts +40 -2
- package/dist/composables/glass/webgpu/index.d.ts +2 -1
- package/dist/composables/glass/webgpu/useGpuSubstrate.d.ts +65 -7
- package/dist/composables/glass/webgpu/useWebGPUCanvas.d.ts +50 -2
- package/dist/composables/glass/webgpu/webgpuDevice.d.ts +42 -0
- package/dist/composables/motion/core/index.d.ts +7 -0
- package/dist/composables/motion/core/useHaptic.d.ts +48 -0
- package/dist/composables/motion/core/writeVelocityWeight.d.ts +31 -0
- package/dist/composables/motion/index.d.ts +2 -0
- package/dist/composables/motion/scrollReader.d.ts +25 -0
- package/dist/composables/motion/springPresets.d.ts +19 -1
- package/dist/composables/motion/suite.d.ts +2 -2
- package/dist/composables/motion/useBloomUp.d.ts +97 -0
- package/dist/composables/motion/useCelebrationBurst.d.ts +50 -0
- package/dist/composables/motion/useCharStagger.d.ts +44 -0
- package/dist/composables/motion/useDockCtaReceive.d.ts +29 -22
- package/dist/composables/motion/useGooMorph.d.ts +72 -0
- package/dist/composables/motion/useLiquidFlex.d.ts +18 -0
- package/dist/composables/motion/useLiquidMorph.d.ts +108 -0
- package/dist/composables/motion/useLiquidPress.d.ts +12 -0
- package/dist/composables/motion/useLiquidReveal.d.ts +7 -4
- package/dist/composables/motion/useMorphField.d.ts +157 -0
- package/dist/composables/motion/useScrollChrome.d.ts +58 -0
- package/dist/composables/motion/useScrollPin.d.ts +49 -0
- package/dist/composables/motion/useScrollScene.d.ts +67 -0
- package/dist/composables/motion/useScrollTrigger.d.ts +67 -0
- package/dist/composables/motion/useSpringPress.d.ts +5 -5
- package/dist/composables/motion/useStaggerReveal.d.ts +24 -0
- package/dist/composables/sidebar/index.d.ts +4 -1
- package/dist/composables/sidebar/types.d.ts +68 -3
- package/dist/composables/sidebar/useClickDelegate.d.ts +4 -0
- package/dist/composables/sidebar/useLazyLoader.d.ts +5 -0
- package/dist/composables/sidebar/useScrollTo.d.ts +5 -0
- package/dist/composables/virtual/index.d.ts +4 -0
- package/dist/composables/virtual/useVirtualSectionWindow.d.ts +72 -0
- package/dist/composables/virtual/useWindowedStore.d.ts +43 -0
- package/dist/composables/virtual/virtualSectionLayout.d.ts +103 -0
- package/dist/concentric.js +552 -309
- package/dist/configurator.js +2 -2
- package/dist/confirm-dialog.js +62 -47
- package/dist/constellation.js +635 -235
- package/dist/context-menu.js +2 -2
- package/dist/controls.js +2 -2
- package/dist/createCanvasLifecycle-CuCrGRfq.js +173 -0
- package/dist/dark.js +1 -1
- package/dist/data-table.js +1 -1
- package/dist/deck.d.ts +1 -0
- package/dist/deck.js +105 -0
- package/dist/dialog.js +4 -3
- package/dist/dock.js +1320 -631
- package/dist/dockContext-gFVS2gMg.js +18 -0
- package/dist/dom.js +7 -6
- package/dist/dot-flow-field.js +1268 -387
- package/dist/dot-matrix.d.ts +1 -0
- package/dist/dot-matrix.js +774 -0
- package/dist/dotMatrixField-CRO0ZFk4.js +48 -0
- package/dist/drawer.js +106 -96
- package/dist/{dropdown-menu-CofSZuk8.js → dropdown-menu-CCfcCQ68.js} +83 -79
- package/dist/dropdown-menu.js +1 -1
- package/dist/easing.js +188 -176
- package/dist/expandable-container.js +43 -21
- package/dist/fading-scroll.js +1 -1
- package/dist/flow.glsl-DqEGRpl4.js +4 -0
- package/dist/forms.js +64 -62
- package/dist/fourier-field.js +1069 -178
- package/dist/fourier-math.js +1 -1
- package/dist/glass-panel.js +2 -2
- package/dist/glass-ui.css +1 -1
- package/dist/glass-ui.js +164 -119
- package/dist/goo-blob.js +175 -1230
- package/dist/goo-dot-matrix.d.ts +1 -0
- package/dist/goo-dot-matrix.js +811 -0
- package/dist/handmark.js +137 -94
- package/dist/header-ribbon.js +1 -1
- package/dist/hover-card.js +1 -1
- package/dist/hover-popover.js +1 -1
- package/dist/icon-chip.js +1 -1
- package/dist/icon-tooltip.js +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/instrument-chassis.js +1 -1
- package/dist/keyboard.js +1 -1
- package/dist/label.js +1 -1
- package/dist/labeled-field.js +70 -60
- package/dist/metric-badge.js +1 -1
- package/dist/metric-cell.js +1 -1
- package/dist/metric-stack.js +12 -3
- package/dist/motion-core.js +59 -34
- package/dist/motion-curves.js +30 -14
- package/dist/motion.js +231 -96
- package/dist/notification.js +1 -1
- package/dist/number-field.js +1 -1
- package/dist/pager-dots.js +2 -91
- package/dist/paper-backdrop.js +1 -1
- package/dist/paper-grid.d.ts +1 -0
- package/dist/paper-grid.js +761 -0
- package/dist/paperGrid-CXCSMbZ1.js +191 -0
- package/dist/popover.js +1 -1
- package/dist/{presets-BW2b-fr1.js → presets-QvYgnFIZ.js} +14 -13
- package/dist/{procedural-color.glsl-CIFsJhwI.js → procedural-color.wgsl-C1Y5PkM6.js} +2 -2
- package/dist/progress.js +1 -1
- package/dist/pulse.js +2 -2
- package/dist/reactive.js +2 -2
- package/dist/{useCanvas2D-B8w_E3Rr.js → resolveCanvasColor-DsSJk06I.js} +16 -6
- package/dist/scrollReader-rc3Ns_NM.js +42 -0
- package/dist/scrolling-text.js +1 -1
- package/dist/search.js +162 -306
- package/dist/select.js +3 -3
- package/dist/selectable-chip.d.ts +1 -0
- package/dist/selectable-chip.js +48 -0
- package/dist/separator.js +1 -1
- package/dist/{sheet-tZMg0E0w.js → sheet-DUCIoOe0.js} +4 -4
- package/dist/sheet.js +1 -1
- package/dist/sidebar.js +216 -114
- package/dist/slider-CcICPe3u.js +149 -0
- package/dist/slider.js +1 -1
- package/dist/sortable-list.js +3 -3
- package/dist/spectrum-walk-cBNSx_zm.js +33 -0
- package/dist/springPresets-DfoQ6XRY.js +64 -0
- package/dist/stacked-icons.js +54 -39
- package/dist/styles/animations.css +13 -3
- package/dist/styles/cards.css +271 -2
- package/dist/styles/completion-seal.css +131 -0
- package/dist/styles/components.css +1 -4
- package/dist/styles/configurator.css +221 -1
- package/dist/styles/critical-partition.mjs +66 -11
- package/dist/styles/deferred.css +4 -0
- package/dist/styles/dock/adaptive-legibility.css +119 -0
- package/dist/styles/dock/cta-seat.css +87 -0
- package/dist/styles/dock/density.css +167 -6
- package/dist/styles/dock/fission-bridge.css +552 -0
- package/dist/styles/dock/layers.css +90 -78
- package/dist/styles/dock/morph-bridge.css +67 -18
- package/dist/styles/dock/morph.css +57 -118
- package/dist/styles/dock/overflow.css +12 -0
- package/dist/styles/dock/search.css +68 -0
- package/dist/styles/dock/shape.css +250 -0
- package/dist/styles/dock/shell.css +24 -8
- package/dist/styles/dock/stack-rail.css +352 -0
- package/dist/styles/dock-controls/dark-mode-toggle.css +17 -4
- package/dist/styles/dock-controls/icon-button.css +46 -0
- package/dist/styles/dock-controls/triggers.css +23 -1
- package/dist/styles/dock-controls.css +18 -0
- package/dist/styles/dock.css +27 -2
- package/dist/styles/drawer.css +166 -0
- package/dist/styles/glass/accent-tone.css +66 -0
- package/dist/styles/glass/control-surfaces.css +167 -0
- package/dist/styles/glass/glass-atom.css +244 -0
- package/dist/styles/glass/glass-capsule.css +143 -0
- package/dist/styles/glass/glass-chip.css +215 -0
- package/dist/styles/glass/ladder.css +67 -17
- package/dist/styles/glass/liquid-enter.css +252 -0
- package/dist/styles/glass/liquid-morph.css +850 -0
- package/dist/styles/glass/material.css +70 -1
- package/dist/styles/glass/reveal.css +22 -2
- package/dist/styles/glass/rim.css +31 -9
- package/dist/styles/glass/surfaces.css +81 -150
- package/dist/styles/glass.css +21 -0
- package/dist/styles/icon-chip.css +45 -0
- package/dist/styles/index.css +26 -0
- package/dist/styles/jubilance.css +65 -0
- package/dist/styles/motion/morph-field.css +229 -0
- package/dist/styles/paper.css +230 -14
- package/dist/styles/scroll-choreography.css +135 -78
- package/dist/styles/scroll-chrome.css +123 -0
- package/dist/styles/scroll-driven.css +38 -0
- package/dist/styles/segmented-tabs.css +110 -40
- package/dist/styles/select.css +151 -0
- package/dist/styles/theme/bridges.css +22 -0
- package/dist/styles/theme/radius.css +18 -1
- package/dist/styles/tokens/color-radius.css +14 -4
- package/dist/styles/tokens/dark-arm.css +94 -12
- package/dist/styles/tokens/glass-deep.css +33 -4
- package/dist/styles/tokens/glass-fx.css +122 -1
- package/dist/styles/tokens/glass.css +226 -34
- package/dist/styles/tokens/light-dark.css +3 -3
- package/dist/styles/tokens/offsets.css +27 -0
- package/dist/styles/tokens/property-regs.css +277 -0
- package/dist/styles/tokens/scale-paper.css +86 -30
- package/dist/styles/tokens/scheme-motion.css +106 -133
- package/dist/styles/tokens/scheme-spring.css +239 -0
- package/dist/styles/tokens/scroll-tokens.css +15 -15
- package/dist/styles/tokens/shadow.css +73 -13
- package/dist/styles/tokens/sizing-config.css +110 -0
- package/dist/styles/tokens/sizing.css +55 -104
- package/dist/styles/tokens.css +14 -2
- package/dist/styles/typography/semantic.css +18 -5
- package/dist/styles/utilities/a11y-overrides.css +20 -5
- package/dist/styles/utilities/base-misc.css +52 -0
- package/dist/styles/utilities/btn.css +84 -3
- package/dist/styles/utilities/components.css +31 -6
- package/dist/styles/utilities/metal.css +26 -0
- package/dist/switch.js +1 -1
- package/dist/tabs.js +199 -182
- package/dist/timeline.js +241 -206
- package/dist/toast.js +1 -1
- package/dist/toggle-chip.js +14 -41
- package/dist/toggle-group.js +1 -1
- package/dist/tooltip.js +1 -1
- package/dist/typewriter.js +2 -2
- package/dist/uniformBridgeWGPU-BCse1SHU.js +1268 -0
- package/dist/{useAnimatedNumber-BfUq2bUM.js → useAnimatedNumber-BntskVdQ.js} +1 -1
- package/dist/{useConfiguratorState-DNlOh6c8.js → useConfiguratorState-22BcULzF.js} +41 -38
- package/dist/useControlSize-DAZ062x7.js +9 -0
- package/dist/useDockCtaReceive-DX7RDb6_.js +88 -0
- package/dist/{useDragMorph-DgxnsVJz.js → useDragMorph-DGLSewwB.js} +4 -4
- package/dist/useDragVelocity-CjcfX3dA.js +57 -0
- package/dist/useFuzzySearch-0fTYOhS4.js +177 -0
- package/dist/useGooMorph-Cs13NgYL.js +104 -0
- package/dist/useGpuSubstrate-Ceet70xq.js +347 -0
- package/dist/useHaptic-CPz5BT9I.js +134 -0
- package/dist/{useLiquidFlex-mZPMiNXh.js → useLiquidFlex-Cc6PjVJD.js} +8 -3
- package/dist/useLiquidPress-CtOQ8Z0_.js +43 -0
- package/dist/useMorphField-ogBM7ubT.js +141 -0
- package/dist/usePointerVelocityField-BrkqZFhj.js +91 -0
- package/dist/useScrollChrome-JuImi1DM.js +258 -0
- package/dist/{useSpringMount-q1amq1SJ.js → useSpringMount-DFxtzmkR.js} +1 -1
- package/dist/useSpringPress-VM9RgVq3.js +36 -0
- package/dist/{useSurfaceAxis-g0NloYEF.js → useSurfaceAxis-Ci7Dnaw2.js} +1 -1
- package/dist/{useTouchGate-CBZTD4SD.js → useTouchGate-B1Lf9XqN.js} +1 -1
- package/dist/{vendor-CKmzio-i.js → vendor-B2qOlYY3.js} +24 -11
- package/dist/virtual.d.ts +1 -0
- package/dist/virtual.js +225 -0
- package/dist/watercolor-dot.js +107 -74
- package/dist/writeVelocityWeight-Bh83xZfs.js +19 -0
- package/package.json +140 -9
- package/src/styles/animations.css +13 -3
- package/src/styles/cards.css +271 -2
- package/src/styles/completion-seal.css +131 -0
- package/src/styles/configurator.css +221 -1
- package/src/styles/critical-partition.mjs +66 -11
- package/src/styles/dock/adaptive-legibility.css +119 -0
- package/src/styles/dock/cta-seat.css +87 -0
- package/src/styles/dock/density.css +167 -6
- package/src/styles/dock/fission-bridge.css +552 -0
- package/src/styles/dock/layers.css +90 -78
- package/src/styles/dock/morph-bridge.css +67 -18
- package/src/styles/dock/morph.css +57 -118
- package/src/styles/dock/overflow.css +12 -0
- package/src/styles/dock/search.css +68 -0
- package/src/styles/dock/shape.css +250 -0
- package/src/styles/dock/shell.css +24 -8
- package/src/styles/dock/stack-rail.css +352 -0
- package/src/styles/dock-controls/dark-mode-toggle.css +17 -4
- package/src/styles/dock-controls/icon-button.css +46 -0
- package/src/styles/dock-controls/triggers.css +23 -1
- package/src/styles/dock-controls.css +18 -0
- package/src/styles/dock.css +27 -2
- package/src/styles/drawer.css +164 -0
- package/src/styles/glass/accent-tone.css +66 -0
- package/src/styles/glass/control-surfaces.css +167 -0
- package/src/styles/glass/glass-atom.css +244 -0
- package/src/styles/glass/glass-capsule.css +143 -0
- package/src/styles/glass/glass-chip.css +215 -0
- package/src/styles/glass/ladder.css +67 -17
- package/src/styles/glass/liquid-enter.css +252 -0
- package/src/styles/glass/liquid-morph.css +850 -0
- package/src/styles/glass/material.css +70 -1
- package/src/styles/glass/reveal.css +22 -2
- package/src/styles/glass/rim.css +31 -9
- package/src/styles/glass/surfaces.css +81 -150
- package/src/styles/glass.css +21 -0
- package/src/styles/icon-chip.css +45 -0
- package/src/styles/index.css +26 -0
- package/src/styles/jubilance.css +65 -0
- package/src/styles/motion/morph-field.css +229 -0
- package/src/styles/paper.css +230 -14
- package/src/styles/scroll-choreography.css +135 -78
- package/src/styles/scroll-chrome.css +123 -0
- package/src/styles/scroll-driven.css +38 -0
- package/src/styles/segmented-tabs.css +110 -36
- package/src/styles/select.css +151 -0
- package/src/styles/theme/bridges.css +22 -0
- package/src/styles/theme/radius.css +18 -1
- package/src/styles/tokens/color-radius.css +14 -4
- package/src/styles/tokens/dark-arm.css +94 -12
- package/src/styles/tokens/glass-deep.css +33 -4
- package/src/styles/tokens/glass-fx.css +122 -1
- package/src/styles/tokens/glass.css +226 -34
- package/src/styles/tokens/light-dark.css +3 -3
- package/src/styles/tokens/offsets.css +27 -0
- package/src/styles/tokens/property-regs.css +277 -0
- package/src/styles/tokens/scale-paper.css +86 -30
- package/src/styles/tokens/scheme-motion.css +106 -133
- package/src/styles/tokens/scheme-spring.css +239 -0
- package/src/styles/tokens/scroll-tokens.css +15 -15
- package/src/styles/tokens/shadow.css +73 -13
- package/src/styles/tokens/sizing-config.css +110 -0
- package/src/styles/tokens/sizing.css +55 -104
- package/src/styles/tokens.css +14 -2
- package/src/styles/typography/semantic.css +18 -5
- package/src/styles/utilities/a11y-overrides.css +20 -5
- package/src/styles/utilities/base-misc.css +52 -0
- package/src/styles/utilities/btn.css +84 -3
- package/src/styles/utilities/components.css +31 -6
- package/src/styles/utilities/metal.css +26 -0
- package/dist/ContextMenuContent-uWnVxDab.js +0 -85
- package/dist/DialogContent-DcKK8k9i.js +0 -103
- package/dist/DialogFooter-BZNX5aVr.js +0 -165
- package/dist/HoverCardContent-b2uaAMRR.js +0 -83
- package/dist/Input-h9v5LeXf.js +0 -55
- package/dist/NumberFieldContent-Cq7EzX-U.js +0 -138
- package/dist/PaperBackdrop-Vf3tlpvd.js +0 -31
- package/dist/SelectScrollDownButton-CrA8F0iV.js +0 -252
- package/dist/Separator-pKF0oA4M.js +0 -37
- package/dist/Switch-CwYNf8bo.js +0 -47
- package/dist/TooltipProvider-rzvnXz60.js +0 -104
- package/dist/badge-D9XWW4GT.js +0 -53
- package/dist/button-DYCUa-tH.js +0 -126
- package/dist/color-DweYl7pE.js +0 -86
- package/dist/components/custom/concentric/composables/ringField.d.ts +0 -44
- package/dist/components/custom/constellation/composables/useConstellationPointer.d.ts +0 -35
- package/dist/components/custom/constellation/constellationDraw.d.ts +0 -30
- package/dist/components/custom/dock/DockRail.vue.d.ts +0 -89
- package/dist/createCanvasLifecycle-CHD5XrDW.js +0 -82
- package/dist/dockContext-BNfyPLe9.js +0 -17
- package/dist/procedural-color.wgsl-CToRHugY.js +0 -224
- package/dist/resolveCanvasColor-CUyHr5Uu.js +0 -11
- package/dist/slider-DVb4HXU-.js +0 -142
- package/dist/springPresets-CFQGQfdl.js +0 -40
- package/dist/styles/dock/rail-extend.css +0 -397
- package/dist/useLiquidPress-kfb4KX79.js +0 -39
- package/dist/usePointerVelocityField-JbRd5CrM.js +0 -137
- package/dist/useRAFLoop-UYa4zoiN.js +0 -109
- package/dist/useSpringPress-BsqPr7FJ.js +0 -34
- package/src/styles/dock/rail-extend.css +0 -397
- /package/dist/{CollapsibleContent-68dEXIAl.js → CollapsibleContent-D7UNsXQr.js} +0 -0
- /package/dist/{InstrumentChassis-Bx0F_q5g.js → InstrumentChassis-UUJX0-mW.js} +0 -0
- /package/dist/{Label-C2ejNWeC.js → Label-B_HPqi_q.js} +0 -0
- /package/dist/{ModalOverlay-D1VrWyoi.js → ModalOverlay-DfAf7o15.js} +0 -0
- /package/dist/{SelectGroup-DwwjicPY.js → SelectGroup-Dcczq44n.js} +0 -0
- /package/dist/{_plugin-vue_export-helper-C1je1s0u.js → _plugin-vue_export-helper-gLzyemvl.js} +0 -0
- /package/dist/{compile-CQEFRTmx.js → compile-INR_tPk_.js} +0 -0
- /package/dist/{constants-BPOqYJAm.js → constants-BWj7DkMn.js} +0 -0
- /package/dist/{createContext-CpBNTRMI.js → createContext-Cd23P9j0.js} +0 -0
- /package/dist/{math-BINYmg5z.js → math-5RcIgCB4.js} +0 -0
- /package/dist/{menuItemVariants-D8VNHq22.js → menuItemVariants-DAXquKja.js} +0 -0
- /package/dist/{prng-Za0Rmgag.js → prng-B5tIXTtj.js} +0 -0
- /package/dist/{useGlobalDark-C28t0VWJ.js → useGlobalDark-B4HO9LXG.js} +0 -0
- /package/dist/{useIntersectionPause-Bj4sPkMh.js → useIntersectionPause-DO8Vl4gs.js} +0 -0
- /package/dist/{useInterval-CvK1mL92.js → useInterval-BVUI-sez.js} +0 -0
- /package/dist/{useKeyboardShortcuts-BXWXOZ-9.js → useKeyboardShortcuts-BEut54Tk.js} +0 -0
- /package/dist/{useResizeObserver-Bpoi7tRE.js → useResizeObserver-DdEn3v2f.js} +0 -0
- /package/dist/{useResolveTokenColor-vAylyR0x.js → useResolveTokenColor-ChOnCckA.js} +0 -0
- /package/dist/{useScrollProgress-D7bYU2RK.js → useScrollProgress-A0M6qRl7.js} +0 -0
- /package/dist/{useSortable-DHjtZSEd.js → useSortable-DQV_UNDw.js} +0 -0
- /package/dist/{useTextHighlight-CWEi25hf.js → useTextHighlight-Bma3UlKA.js} +0 -0
- /package/dist/{useTimer-BHJOKr35.js → useTimer-BBLGPXR8.js} +0 -0
- /package/dist/{useUserInvalidAria-y5namzeE.js → useUserInvalidAria-EmmwWPOl.js} +0 -0
- /package/dist/{useViewportReady-anbac3m6.js → useViewportReady-C9pYnn7K.js} +0 -0
- /package/dist/{vReveal-Czsb7zQC.js → vReveal-CT1KtwZA.js} +0 -0
- /package/dist/{vSpecular-CQFmLNzA.js → vSpecular-EX7loENl.js} +0 -0
package/dist/dot-flow-field.js
CHANGED
|
@@ -1,154 +1,22 @@
|
|
|
1
|
-
import { t as e } from "./
|
|
2
|
-
import { t } from "./
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { t as e } from "./_plugin-vue_export-helper-gLzyemvl.js";
|
|
2
|
+
import { t } from "./usePointerVelocityField-BrkqZFhj.js";
|
|
3
|
+
import { n, o as r, r as i, s as a } from "./procedural-color.wgsl-C1Y5PkM6.js";
|
|
4
|
+
import { a as o, t as s } from "./useGpuSubstrate-Ceet70xq.js";
|
|
5
|
+
import { c } from "./color-B9jZdhJX.js";
|
|
5
6
|
import { computed as l, createElementBlock as u, createElementVNode as d, defineComponent as f, normalizeStyle as p, onScopeDispose as m, openBlock as h, useTemplateRef as g, watch as _ } from "vue";
|
|
6
|
-
//#region src/components/custom/dot-flow-field/
|
|
7
|
-
var v =
|
|
8
|
-
|
|
9
|
-
const TAU: f32 = 6.283185307179586;
|
|
10
|
-
const FLOW_GRAVITY: f32 = 9.81;
|
|
11
|
-
const MAX_WAVE_COMPONENTS: i32 = 8;
|
|
12
|
-
const MAX_FLOW_STOPS: i32 = 4;
|
|
13
|
-
|
|
14
|
-
struct Particle {
|
|
15
|
-
// (pos.x, pos.y, age, seed)
|
|
16
|
-
data: vec4<f32>,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// ── Render uniforms (the typed-struct source-of-truth — see uniformBridgeWGPU.ts) ──
|
|
20
|
-
struct RenderUniforms {
|
|
21
|
-
// r0: (uTime, uWindSpeed, uCurlStrength, uDomainHalf)
|
|
22
|
-
r0: vec4<f32>,
|
|
23
|
-
// r1: (uDotSize, uDotSizeVelocity, uAspect, uVMax)
|
|
24
|
-
r1: vec4<f32>,
|
|
25
|
-
// ints: (uWaveCount, uStopCount, uParticleCount, _pad)
|
|
26
|
-
ints: vec4<i32>,
|
|
27
|
-
// bg: (background.rgb, hasBackground)
|
|
28
|
-
bg: vec4<f32>,
|
|
29
|
-
// each wave row: (amplitude, wavelength, directionDeg, phase)
|
|
30
|
-
waves: array<vec4<f32>, 8>,
|
|
31
|
-
// each palette stop: linear-sRGB rgb + _pad
|
|
32
|
-
palette: array<vec4<f32>, 4>,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
@group(0) @binding(0) var<uniform> u: RenderUniforms;
|
|
36
|
-
@group(0) @binding(1) var<storage, read> particles: array<Particle>;
|
|
37
|
-
|
|
38
|
-
${r}
|
|
39
|
-
${a}
|
|
40
|
-
|
|
41
|
-
// ── The Gerstner-sum velocity (the SAME transcription as the compute kernel, read here
|
|
42
|
-
// for the per-particle size + color tint — denser-where-calm). ──
|
|
43
|
-
fn gerstnerVelocity(p: vec2<f32>, t: f32) -> vec2<f32> {
|
|
44
|
-
var dhdx = 0.0;
|
|
45
|
-
var dhdy = 0.0;
|
|
46
|
-
let windSpeed = u.r0.y;
|
|
47
|
-
let waveCount = u.ints.x;
|
|
48
|
-
for (var i = 0; i < MAX_WAVE_COMPONENTS; i = i + 1) {
|
|
49
|
-
if (i >= waveCount) { break; }
|
|
50
|
-
let w = u.waves[i];
|
|
51
|
-
let k = TAU / max(w.y, 1e-4);
|
|
52
|
-
let dirRad = w.z * PI / 180.0;
|
|
53
|
-
let d = vec2<f32>(cos(dirRad), sin(dirRad));
|
|
54
|
-
let omega = sqrt(FLOW_GRAVITY * k) * windSpeed;
|
|
55
|
-
let theta = k * (d.x * p.x + d.y * p.y) - omega * t + w.w;
|
|
56
|
-
let akc = w.x * k * cos(theta);
|
|
57
|
-
dhdx = dhdx + akc * d.x;
|
|
58
|
-
dhdy = dhdy + akc * d.y;
|
|
59
|
-
}
|
|
60
|
-
return vec2<f32>(dhdy, -dhdx);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Sample the multi-stop palette (linear-sRGB stops, OKLab mix). t in [0,1].
|
|
64
|
-
fn samplePaletteLin(t: f32) -> vec3<f32> {
|
|
65
|
-
let stopCount = u.ints.y;
|
|
66
|
-
if (stopCount <= 1) { return u.palette[0].rgb; }
|
|
67
|
-
let n = f32(stopCount);
|
|
68
|
-
let ft = clamp(t, 0.0, 1.0) * (n - 1.0);
|
|
69
|
-
let i0 = i32(floor(ft));
|
|
70
|
-
let i1 = min(i0 + 1, stopCount - 1);
|
|
71
|
-
let f = ft - f32(i0);
|
|
72
|
-
let labA = LMS_TO_OKLAB * cbrt3(LINEAR_SRGB_TO_LMS * u.palette[i0].rgb);
|
|
73
|
-
let labB = LMS_TO_OKLAB * cbrt3(LINEAR_SRGB_TO_LMS * u.palette[i1].rgb);
|
|
74
|
-
return oklabToLinearSrgb(mix(labA, labB, f));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
struct VSOut {
|
|
78
|
-
@builtin(position) pos: vec4<f32>,
|
|
79
|
-
@location(0) local: vec2<f32>, // [-1,1] billboard-local coords for the soft circle
|
|
80
|
-
@location(1) tint: f32, // velocity-derived color/alpha tint [0,1]
|
|
81
|
-
@location(2) alphaScale: f32, // velocity-derived alpha scale (denser-where-calm)
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
@vertex
|
|
85
|
-
fn vs_main(
|
|
86
|
-
@builtin(vertex_index) vi: u32,
|
|
87
|
-
@builtin(instance_index) ii: u32,
|
|
88
|
-
) -> VSOut {
|
|
89
|
-
// Two-triangle quad corners in billboard-local space.
|
|
90
|
-
var corners = array<vec2<f32>, 6>(
|
|
91
|
-
vec2<f32>(-1.0, -1.0), vec2<f32>(1.0, -1.0), vec2<f32>(-1.0, 1.0),
|
|
92
|
-
vec2<f32>(-1.0, 1.0), vec2<f32>(1.0, -1.0), vec2<f32>(1.0, 1.0),
|
|
93
|
-
);
|
|
94
|
-
let local = corners[vi];
|
|
95
|
-
|
|
96
|
-
let pr = particles[ii].data;
|
|
97
|
-
let p = pr.xy;
|
|
98
|
-
let t = u.r0.x;
|
|
99
|
-
let half = u.r0.w;
|
|
100
|
-
|
|
101
|
-
// Per-particle velocity → size + tint (denser-where-calm: |v| thins the dot).
|
|
102
|
-
let v = gerstnerVelocity(p, t);
|
|
103
|
-
let speed = length(v);
|
|
104
|
-
let vMax = max(u.r1.w, 1e-4);
|
|
105
|
-
let speedNorm = clamp(speed / vMax, 0.0, 1.0);
|
|
106
|
-
let dotSizeVel = u.r1.y;
|
|
107
|
-
// size_i = base · (1 − speedNorm · sizeVel) — calm = larger dot.
|
|
108
|
-
let sizeWorld = u.r1.x * (1.0 - speedNorm * dotSizeVel);
|
|
109
|
-
let alphaScale = 1.0 - speedNorm * 0.35; // calm = denser/brighter
|
|
110
|
-
|
|
111
|
-
// Position the quad at the particle in clip space. Domain [-half,half] → NDC [-1,1];
|
|
112
|
-
// the quad half-extent rides sizeWorld (in the same domain units, aspect-corrected x).
|
|
113
|
-
let aspect = u.r1.z;
|
|
114
|
-
let ndc = p / half;
|
|
115
|
-
let off = local * sizeWorld / half;
|
|
116
|
-
let offX = off.x / max(aspect, 1e-4);
|
|
117
|
-
|
|
118
|
-
var out: VSOut;
|
|
119
|
-
out.pos = vec4<f32>(ndc.x + offX, ndc.y + off.y, 0.0, 1.0);
|
|
120
|
-
out.local = local;
|
|
121
|
-
out.tint = speedNorm;
|
|
122
|
-
out.alphaScale = alphaScale;
|
|
123
|
-
return out;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
@fragment
|
|
127
|
-
fn fs_main(in: VSOut) -> @location(0) vec4<f32> {
|
|
128
|
-
// Soft circle — radial smoothstep over the billboard-local radius.
|
|
129
|
-
let r = length(in.local);
|
|
130
|
-
let feather = 0.35;
|
|
131
|
-
let mask = 1.0 - smoothstep(1.0 - feather, 1.0, r);
|
|
132
|
-
if (mask < 0.002) { return vec4<f32>(0.0); }
|
|
133
|
-
|
|
134
|
-
let lin = samplePaletteLin(in.tint);
|
|
135
|
-
let alpha = mask * in.alphaScale;
|
|
136
|
-
let rgb = clamp(linearToSrgb(lin), vec3<f32>(0.0), vec3<f32>(1.0));
|
|
137
|
-
// Premultiplied-alpha output.
|
|
138
|
-
return vec4<f32>(rgb * alpha, alpha);
|
|
139
|
-
}
|
|
140
|
-
`, b = 9.81, x = Math.PI * 2;
|
|
141
|
-
function S(e) {
|
|
7
|
+
//#region src/components/custom/dot-flow-field/composables/flowField.ts
|
|
8
|
+
var v = 9.81, y = Math.PI * 2;
|
|
9
|
+
function b(e) {
|
|
142
10
|
let t = e * Math.PI / 180;
|
|
143
11
|
return {
|
|
144
12
|
x: Math.cos(t),
|
|
145
13
|
y: Math.sin(t)
|
|
146
14
|
};
|
|
147
15
|
}
|
|
148
|
-
function
|
|
16
|
+
function x(e, t, n, r) {
|
|
149
17
|
let i = 0, a = 0;
|
|
150
18
|
for (let o of n) {
|
|
151
|
-
let n =
|
|
19
|
+
let n = y / Math.max(o.wavelength, 1e-4), s = b(o.direction), c = Math.sqrt(v * n) * r, l = n * (s.x * e.x + s.y * e.y) - c * t + o.phase, u = Math.cos(l), d = o.amplitude * n * u;
|
|
152
20
|
i += d * s.x, a += d * s.y;
|
|
153
21
|
}
|
|
154
22
|
return {
|
|
@@ -156,8 +24,8 @@ function C(e, t, n, r) {
|
|
|
156
24
|
y: -i
|
|
157
25
|
};
|
|
158
26
|
}
|
|
159
|
-
var
|
|
160
|
-
function
|
|
27
|
+
var S = .012;
|
|
28
|
+
function C(e, t) {
|
|
161
29
|
let n = e * .1031 % 1, r = t * .1031 % 1, i = e * .1031 % 1;
|
|
162
30
|
n < 0 && (n += 1), r < 0 && (r += 1), i < 0 && (i += 1);
|
|
163
31
|
let a = n * (r + 33.33) + r * (i + 33.33) + i * (n + 33.33);
|
|
@@ -165,57 +33,108 @@ function T(e, t) {
|
|
|
165
33
|
let o = (n + r) * i % 1;
|
|
166
34
|
return o < 0 && (o += 1), o;
|
|
167
35
|
}
|
|
168
|
-
function
|
|
36
|
+
function w(e, t, n) {
|
|
169
37
|
return e + (t - e) * n;
|
|
170
38
|
}
|
|
171
|
-
function
|
|
172
|
-
let n = Math.floor(e), r = Math.floor(t), i = e - n, a = t - r, o = i * i * i * (i * (i * 6 - 15) + 10), s = a * a * a * (a * (a * 6 - 15) + 10), c =
|
|
173
|
-
return
|
|
39
|
+
function T(e, t) {
|
|
40
|
+
let n = Math.floor(e), r = Math.floor(t), i = e - n, a = t - r, o = i * i * i * (i * (i * 6 - 15) + 10), s = a * a * a * (a * (a * 6 - 15) + 10), c = C(n, r), l = C(n + 1, r), u = C(n, r + 1), d = C(n + 1, r + 1);
|
|
41
|
+
return w(w(c, l, o), w(u, d, o), s);
|
|
174
42
|
}
|
|
175
|
-
function
|
|
43
|
+
function E(e, t) {
|
|
176
44
|
let n = 0, r = .5, i = 1, a = e, o = t;
|
|
177
45
|
for (let e = 0; e < 3; e++) {
|
|
178
|
-
n += r *
|
|
46
|
+
n += r * T(a * i, o * i);
|
|
179
47
|
let e = .8 * a - .6 * o, t = .6 * a + .8 * o;
|
|
180
48
|
a = e, o = t, i *= 2, r *= .5;
|
|
181
49
|
}
|
|
182
50
|
return n;
|
|
183
51
|
}
|
|
184
|
-
function
|
|
185
|
-
let t =
|
|
52
|
+
function D(e) {
|
|
53
|
+
let t = E(e.x + S, e.y) - E(e.x - S, e.y), n = E(e.x, e.y + S) - E(e.x, e.y - S), r = t / (2 * S);
|
|
186
54
|
return {
|
|
187
|
-
x: n / (2 *
|
|
55
|
+
x: n / (2 * S),
|
|
188
56
|
y: -r
|
|
189
57
|
};
|
|
190
58
|
}
|
|
191
|
-
function
|
|
192
|
-
let a =
|
|
59
|
+
function O(e, t, n, r, i) {
|
|
60
|
+
let a = x(e, t, n, r);
|
|
193
61
|
if (i <= 0) return a;
|
|
194
|
-
let o =
|
|
195
|
-
x: e.x *
|
|
196
|
-
y: e.y *
|
|
62
|
+
let o = D({
|
|
63
|
+
x: e.x * .55 + t * .15,
|
|
64
|
+
y: e.y * .55
|
|
197
65
|
});
|
|
198
66
|
return {
|
|
199
67
|
x: a.x + o.x * i,
|
|
200
68
|
y: a.y + o.y * i
|
|
201
69
|
};
|
|
202
70
|
}
|
|
203
|
-
function
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
71
|
+
function k(e, t) {
|
|
72
|
+
if (!t.active) return {
|
|
73
|
+
x: 0,
|
|
74
|
+
y: 0
|
|
75
|
+
};
|
|
76
|
+
let n = e.x - t.cursor.x, r = e.y - t.cursor.y, i = Math.hypot(n, r), a = Math.max(t.radius, .001), o = Math.exp(-(i * i) / (a * a)), s = -r, c = n, l = Math.hypot(s, c) || 1e-6, u = s / l, d = c / l, f = n / Math.max(i, 1e-4), p = r / Math.max(i, 1e-4), m = u * t.spin + t.pointerVel.x * t.dragGain + f * t.burst * t.burstShove, h = d * t.spin + t.pointerVel.y * t.dragGain + p * t.burst * t.burstShove;
|
|
77
|
+
return {
|
|
78
|
+
x: m * o,
|
|
79
|
+
y: h * o
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
var A = .85;
|
|
83
|
+
function j(e, t, n) {
|
|
84
|
+
let r = Math.max(t, 1), i = e % r, a = Math.floor(e / r), o = (r - 1) * n / 2;
|
|
85
|
+
return {
|
|
86
|
+
x: i * n - o,
|
|
87
|
+
y: a * n - o
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function M(e, t, n, r) {
|
|
91
|
+
let i = 0, a = 0;
|
|
92
|
+
for (let o of n) {
|
|
93
|
+
let n = y / Math.max(o.wavelength, 1e-4), s = b(o.direction), c = Math.sqrt(v * n) * r, l = n * (s.x * e.x + s.y * e.y) - c * t + o.phase;
|
|
94
|
+
i += o.amplitude * Math.sin(l), a += Math.abs(o.amplitude);
|
|
213
95
|
}
|
|
214
|
-
return
|
|
96
|
+
return i / Math.max(a, 1e-4);
|
|
97
|
+
}
|
|
98
|
+
function N(e, t, n, r, i) {
|
|
99
|
+
let a = O(e, t, n, r, i), o = Math.hypot(a.x, a.y);
|
|
100
|
+
if (o < 1e-5) return {
|
|
101
|
+
x: 0,
|
|
102
|
+
y: 0
|
|
103
|
+
};
|
|
104
|
+
let s = Math.tanh(o) / o;
|
|
105
|
+
return {
|
|
106
|
+
x: a.x * s,
|
|
107
|
+
y: a.y * s
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function P(e, t, n) {
|
|
111
|
+
return 1 - F(0, Math.max(n, .001), Math.abs(e - t));
|
|
112
|
+
}
|
|
113
|
+
function F(e, t, n) {
|
|
114
|
+
let r = Math.min(Math.max((n - e) / Math.max(t - e, 1e-6), 0), 1);
|
|
115
|
+
return r * r * (3 - 2 * r);
|
|
116
|
+
}
|
|
117
|
+
function I(e, t = 3, n = 2.5) {
|
|
118
|
+
let r = 2 * A, i = Math.max(n, .5) * r, a = i / y, o = r / 3, s = Math.max(1, Math.min(Math.round(t), 3)), c = [], l = i, u = 1;
|
|
119
|
+
for (let t = 0; t < s; t++) {
|
|
120
|
+
let n = Math.max(l, o), r = y / n, i = Math.exp(-1 / (r * a) ** 2) / (r * r), s = (t % 2 == 0 ? 1 : -1) * (8 + t * 4);
|
|
121
|
+
c.push({
|
|
122
|
+
amplitude: i * u,
|
|
123
|
+
wavelength: n,
|
|
124
|
+
direction: e + s,
|
|
125
|
+
phase: t * 1.618033 % y
|
|
126
|
+
}), l *= .58, u *= .38;
|
|
127
|
+
}
|
|
128
|
+
return c;
|
|
215
129
|
}
|
|
216
130
|
//#endregion
|
|
217
131
|
//#region src/components/custom/dot-flow-field/constants.ts
|
|
218
|
-
var
|
|
132
|
+
var L = 16384, R = 8, z = 4, B = 1.618033988749895;
|
|
133
|
+
function ee(e, t = 1 / 60) {
|
|
134
|
+
let n = Math.max(e, .001);
|
|
135
|
+
return 2 ** (-t / n);
|
|
136
|
+
}
|
|
137
|
+
var V = [{
|
|
219
138
|
L: .92,
|
|
220
139
|
C: .03,
|
|
221
140
|
h: 78
|
|
@@ -223,172 +142,437 @@ var M = 16384, N = 8, P = 4, F = 4e3, I = [{
|
|
|
223
142
|
L: .84,
|
|
224
143
|
C: .07,
|
|
225
144
|
h: 62
|
|
226
|
-
}],
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
145
|
+
}], H = I(35, 3, 2.5), U = {
|
|
146
|
+
mode: "flow",
|
|
147
|
+
particleCount: 12e3,
|
|
148
|
+
trailHalfLife: .55,
|
|
149
|
+
trailScale: .5,
|
|
150
|
+
turnRate: .14,
|
|
151
|
+
speedScale: .9,
|
|
152
|
+
speedGlow: 1.25,
|
|
153
|
+
lifetimeSec: .55 * B,
|
|
154
|
+
edgeBias: .35,
|
|
155
|
+
contentMask: null,
|
|
156
|
+
vortexRadius: .3,
|
|
157
|
+
vortexSpin: 1.6,
|
|
158
|
+
dragGain: 1,
|
|
159
|
+
burstShove: 1.8,
|
|
160
|
+
shadowOffset: .18,
|
|
161
|
+
stretchAmp: .6,
|
|
162
|
+
waveComponents: H,
|
|
163
|
+
windSpeed: .3,
|
|
164
|
+
curlStrength: .12,
|
|
165
|
+
gridPitch: 26,
|
|
166
|
+
dotSize: 2,
|
|
167
|
+
displaceAmp: .18,
|
|
168
|
+
springK: 6,
|
|
169
|
+
waveBandCenter: 0,
|
|
170
|
+
waveBandWidth: .55,
|
|
171
|
+
contrast: .6,
|
|
172
|
+
coherence: .8,
|
|
173
|
+
globeMask: !1,
|
|
174
|
+
palette: V,
|
|
235
175
|
background: "transparent",
|
|
236
|
-
interactive: !
|
|
176
|
+
interactive: !0,
|
|
237
177
|
respectReducedMotion: !0
|
|
238
|
-
},
|
|
178
|
+
}, W = A, te = 16384;
|
|
179
|
+
function G(e, t) {
|
|
180
|
+
let n = Math.min(Math.max(Math.ceil((t || 320) / Math.max(e, 4)) + 2, 4), 128);
|
|
181
|
+
return {
|
|
182
|
+
cols: n,
|
|
183
|
+
count: Math.min(n * n, te),
|
|
184
|
+
pitchDomain: 2 * W / Math.max(n, 1)
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
var ne = 240, K = {
|
|
239
188
|
p0: 0,
|
|
240
189
|
p1: 4,
|
|
241
190
|
ints: 8,
|
|
242
|
-
|
|
191
|
+
f0: 12,
|
|
192
|
+
f1: 16,
|
|
193
|
+
ptr: 20,
|
|
194
|
+
ptr2: 24,
|
|
195
|
+
waves: 28
|
|
196
|
+
}, re = {
|
|
197
|
+
cursorX: 0,
|
|
198
|
+
cursorY: 0,
|
|
199
|
+
velX: 0,
|
|
200
|
+
velY: 0,
|
|
201
|
+
burst: 0,
|
|
202
|
+
active: 0
|
|
243
203
|
};
|
|
244
|
-
function
|
|
245
|
-
let e = new ArrayBuffer(
|
|
204
|
+
function ie() {
|
|
205
|
+
let e = new ArrayBuffer(ne);
|
|
246
206
|
return {
|
|
247
207
|
buffer: e,
|
|
248
208
|
f32: new Float32Array(e),
|
|
249
209
|
i32: new Int32Array(e)
|
|
250
210
|
};
|
|
251
211
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
return o[B.ints + 0] = s, o[B.ints + 1] = i, o[B.ints + 2] = 0, o[B.ints + 3] = 0, q(a, B.waves, t.waveComponents), e;
|
|
212
|
+
function ae(e, t, n, r, i, a, o = re) {
|
|
213
|
+
let { f32: s, i32: c } = e, l = t.mode === "flow";
|
|
214
|
+
s[K.p0 + 0] = n, s[K.p0 + 1] = r, s[K.p0 + 2] = t.windSpeed, s[K.p0 + 3] = t.curlStrength, s[K.p1 + 0] = i.pitchDomain, s[K.p1 + 1] = t.displaceAmp, s[K.p1 + 2] = t.springK, s[K.p1 + 3] = i.cols;
|
|
215
|
+
let u = Math.min(t.waveComponents.length, 8);
|
|
216
|
+
return c[K.ints + 0] = u, c[K.ints + 1] = a, c[K.ints + 2] = i.cols, c[K.ints + 3] = +!!l, s[K.f0 + 0] = t.turnRate, s[K.f0 + 1] = t.speedScale, s[K.f0 + 2] = t.lifetimeSec, s[K.f0 + 3] = W, s[K.f1 + 0] = t.vortexRadius, s[K.f1 + 1] = t.vortexSpin, s[K.f1 + 2] = t.dragGain, s[K.f1 + 3] = t.burstShove, s[K.ptr + 0] = o.cursorX, s[K.ptr + 1] = o.cursorY, s[K.ptr + 2] = o.velX, s[K.ptr + 3] = o.velY, s[K.ptr2 + 0] = o.burst, s[K.ptr2 + 1] = o.active, s[K.ptr2 + 2] = t.edgeBias, s[K.ptr2 + 3] = 0, pe(s, K.waves, t.waveComponents), e;
|
|
258
217
|
}
|
|
259
|
-
var
|
|
218
|
+
var oe = 160, se = .022, q = {
|
|
260
219
|
r0: 0,
|
|
261
220
|
r1: 4,
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
221
|
+
r2: 8,
|
|
222
|
+
ints: 12,
|
|
223
|
+
bg: 16,
|
|
224
|
+
f0: 20,
|
|
225
|
+
palette: 24
|
|
266
226
|
};
|
|
267
|
-
function
|
|
268
|
-
let e = new ArrayBuffer(
|
|
227
|
+
function ce() {
|
|
228
|
+
let e = new ArrayBuffer(oe);
|
|
269
229
|
return {
|
|
270
230
|
buffer: e,
|
|
271
231
|
f32: new Float32Array(e),
|
|
272
232
|
i32: new Int32Array(e)
|
|
273
233
|
};
|
|
274
234
|
}
|
|
275
|
-
|
|
276
|
-
|
|
235
|
+
var le = .22, ue = .4;
|
|
236
|
+
function de(e, t) {
|
|
237
|
+
let n = (t || 320) / (2 * W);
|
|
277
238
|
return e / Math.max(n, 1e-4);
|
|
278
239
|
}
|
|
279
|
-
function
|
|
280
|
-
let { f32:
|
|
281
|
-
|
|
282
|
-
let
|
|
283
|
-
if (
|
|
240
|
+
function fe(e, t, n, r, i, a, o) {
|
|
241
|
+
let { f32: s, i32: l } = e;
|
|
242
|
+
s[q.r0 + 0] = n, s[q.r0 + 1] = t.contrast, s[q.r0 + 2] = le, s[q.r0 + 3] = W, s[q.r1 + 0] = de(t.dotSize, i), s[q.r1 + 1] = ue, s[q.r1 + 2] = r, s[q.r1 + 3] = a.pitchDomain, s[q.r2 + 0] = t.waveBandCenter, s[q.r2 + 1] = t.waveBandWidth, s[q.r2 + 2] = +!!t.globeMask, s[q.r2 + 3] = +(t.mode === "flow"), s[q.f0 + 0] = t.speedGlow, s[q.f0 + 1] = se, s[q.f0 + 2] = t.shadowOffset, s[q.f0 + 3] = t.stretchAmp;
|
|
243
|
+
let u = Math.min(o.length, 4);
|
|
244
|
+
if (l[q.ints + 0] = u, l[q.ints + 1] = a.count, l[q.ints + 2] = 0, l[q.ints + 3] = 0, t.background === "transparent") s[q.bg + 0] = 0, s[q.bg + 1] = 0, s[q.bg + 2] = 0, s[q.bg + 3] = 0;
|
|
284
245
|
else {
|
|
285
|
-
let e =
|
|
286
|
-
|
|
246
|
+
let e = c(t.background);
|
|
247
|
+
s[q.bg + 0] = e[0], s[q.bg + 1] = e[1], s[q.bg + 2] = e[2], s[q.bg + 3] = 1;
|
|
287
248
|
}
|
|
288
|
-
q(o, G.waves, t.waveComponents);
|
|
289
249
|
for (let e = 0; e < 4; e++) {
|
|
290
|
-
let t =
|
|
291
|
-
|
|
250
|
+
let t = q.palette + e * 4, n = c(o[Math.min(e, u - 1)] ?? o[0]);
|
|
251
|
+
s[t + 0] = n[0], s[t + 1] = n[1], s[t + 2] = n[2], s[t + 3] = 0;
|
|
292
252
|
}
|
|
293
253
|
return e;
|
|
294
254
|
}
|
|
295
|
-
function
|
|
255
|
+
function pe(e, t, n) {
|
|
296
256
|
for (let r = 0; r < 8; r++) {
|
|
297
257
|
let i = t + r * 4, a = n[r];
|
|
298
258
|
a ? (e[i + 0] = a.amplitude, e[i + 1] = a.wavelength, e[i + 2] = a.direction, e[i + 3] = a.phase) : (e[i + 0] = 0, e[i + 1] = 1, e[i + 2] = 0, e[i + 3] = 0);
|
|
299
259
|
}
|
|
300
260
|
}
|
|
301
|
-
function
|
|
302
|
-
let t = new Float32Array(
|
|
303
|
-
for (let
|
|
304
|
-
let
|
|
305
|
-
r
|
|
306
|
-
let i = Math.sin(e * 19.31 + 4) * 43758.5453;
|
|
307
|
-
i -= Math.floor(i);
|
|
308
|
-
let a = n * 4;
|
|
309
|
-
t[a + 0] = (r * 2 - 1) * H, t[a + 1] = (i * 2 - 1) * H, t[a + 2] = r * 6 % 6, t[a + 3] = e;
|
|
261
|
+
function me(e) {
|
|
262
|
+
let { cols: t, count: n, pitchDomain: r } = e, i = new Float32Array(n * 4), a = (t - 1) * r / 2;
|
|
263
|
+
for (let e = 0; e < n; e++) {
|
|
264
|
+
let n = e % t, o = Math.floor(e / t), s = e * 4;
|
|
265
|
+
i[s + 0] = n * r - a, i[s + 1] = o * r - a, i[s + 2] = 0, i[s + 3] = 0;
|
|
310
266
|
}
|
|
311
|
-
return
|
|
267
|
+
return i;
|
|
268
|
+
}
|
|
269
|
+
function he(e, t) {
|
|
270
|
+
let n = new Float32Array(e * 4), r = W, i = 2654435769, a = () => (i = i * 1664525 + 1013904223 >>> 0, i / 4294967295);
|
|
271
|
+
for (let i = 0; i < e; i++) {
|
|
272
|
+
let e = i * 4;
|
|
273
|
+
n[e + 0] = (a() * 2 - 1) * r, n[e + 1] = (a() * 2 - 1) * r, n[e + 2] = 0, n[e + 3] = a() * Math.max(t, .001);
|
|
274
|
+
}
|
|
275
|
+
return n;
|
|
312
276
|
}
|
|
313
277
|
//#endregion
|
|
314
|
-
//#region src/components/custom/dot-flow-field/
|
|
315
|
-
var
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
278
|
+
//#region src/components/custom/dot-flow-field/shaders/flow-field.compute.wgsl.ts
|
|
279
|
+
var ge = "\nconst MAX_WAVE_COMPONENTS: i32 = 8;\nconst PI: f32 = 3.141592653589793;\nconst TAU: f32 = 6.283185307179586;\nconst FLOW_GRAVITY: f32 = 9.81;\nconst CURL_EPS: f32 = 0.012;\nconst FBM_ROT: mat2x2<f32> = mat2x2<f32>(0.8, 0.6, -0.6, 0.8);\n\nstruct Particle {\n // field: (pos.x, pos.y, height, |disp|) — the anchored-lattice live state\n // flow: (pos.x, pos.y, speed, life) — the advected-mote live state\n data: vec4<f32>,\n};\n\n// ── Uniforms (the typed-struct source-of-truth — see uniformBridgeWGPU.ts) ──\nstruct FlowUniforms {\n // p0: (uTime, uDt, uWindSpeed, uCurlStrength)\n p0: vec4<f32>,\n // p1: (uGridPitch, uDisplaceAmp, uSpringK, uGridCols) — the lattice geometry (field)\n p1: vec4<f32>,\n // ints: (uWaveCount, uParticleCount, uGridColsI, uMode) — uMode: 0=field, 1=flow\n ints: vec4<i32>,\n // f0: (uTurnRate, uSpeedScale, uLifetimeSec, uDomainHalf) — the flow advection levers\n f0: vec4<f32>,\n // f1: (uVortexRadius, uVortexSpin, uDragGain, uBurstShove) — the cursor vortex\n f1: vec4<f32>,\n // ptr: (cursor.x, cursor.y, vel.x, vel.y) — the pointer in domain space + its velocity\n ptr: vec4<f32>,\n // ptr2: (burst, pointerActive, edgeBias, _pad)\n ptr2: vec4<f32>,\n // each wave row: (amplitude, wavelength, directionDeg, phase)\n waves: array<vec4<f32>, 8>,\n};\n\n@group(0) @binding(0) var<uniform> u: FlowUniforms;\n@group(0) @binding(1) var<storage, read_write> particles: array<Particle>;\n\n// ── The deterministic lattice origin (transcribes flowField.ts gridOrigin) ──\nfn gridOrigin(index: u32, cols: i32, pitch: f32) -> vec2<f32> {\n let c = max(cols, 1);\n let col = i32(index) % c;\n let row = i32(index) / c;\n let half = f32(c - 1) * pitch * 0.5;\n return vec2<f32>(f32(col) * pitch - half, f32(row) * pitch - half);\n}\n\n// ── The Gerstner-sum analytic ∇⊥h velocity (transcribes flowField.ts gerstnerVelocity) ──\nfn gerstnerVelocity(p: vec2<f32>, t: f32) -> vec2<f32> {\n var dhdx = 0.0;\n var dhdy = 0.0;\n let windSpeed = u.p0.z;\n let waveCount = u.ints.x;\n for (var i = 0; i < MAX_WAVE_COMPONENTS; i = i + 1) {\n if (i >= waveCount) { break; }\n let w = u.waves[i];\n let amplitude = w.x;\n let wavelength = max(w.y, 1e-4);\n let dirRad = w.z * PI / 180.0;\n let phase = w.w;\n let k = TAU / wavelength;\n let d = vec2<f32>(cos(dirRad), sin(dirRad));\n let omega = sqrt(FLOW_GRAVITY * k) * windSpeed;\n let theta = k * (d.x * p.x + d.y * p.y) - omega * t + phase;\n let akc = amplitude * k * cos(theta);\n dhdx = dhdx + akc * d.x;\n dhdy = dhdy + akc * d.y;\n }\n // v = ∇⊥h = (∂h/∂y, −∂h/∂x).\n return vec2<f32>(dhdy, -dhdx);\n}\n\n// ── The scalar Gerstner HEIGHT (transcribes flowField.ts sampleHeight — the brightness\n// driver, normalized to ≈[-1,1] by the total amplitude so the band thresholds are\n// wave-table-independent). ──\nfn sampleHeight(o: vec2<f32>, t: f32) -> f32 {\n var h = 0.0;\n var ampSum = 0.0;\n let windSpeed = u.p0.z;\n let waveCount = u.ints.x;\n for (var i = 0; i < MAX_WAVE_COMPONENTS; i = i + 1) {\n if (i >= waveCount) { break; }\n let w = u.waves[i];\n let k = TAU / max(w.y, 1e-4);\n let dirRad = w.z * PI / 180.0;\n let d = vec2<f32>(cos(dirRad), sin(dirRad));\n let omega = sqrt(FLOW_GRAVITY * k) * windSpeed;\n let theta = k * (d.x * o.x + d.y * o.y) - omega * t + w.w;\n h = h + w.x * sin(theta);\n ampSum = ampSum + abs(w.x);\n }\n return h / max(ampSum, 1e-4);\n}\n\n// ── Shared curl-noise basis (the WGSL twin of flow.glsl.ts curlFBM) ──\nfn hash21(p: vec2<f32>) -> f32 {\n var p3 = fract(vec3<f32>(p.x, p.y, p.x) * 0.1031);\n p3 = p3 + dot(p3, p3.yzx + 33.33);\n return fract((p3.x + p3.y) * p3.z);\n}\n\nfn valueNoise(p: vec2<f32>) -> f32 {\n let i = floor(p);\n let f = fract(p);\n let u2 = f * f * f * (f * (f * 6.0 - 15.0) + 10.0);\n let a = hash21(i + vec2<f32>(0.0, 0.0));\n let b = hash21(i + vec2<f32>(1.0, 0.0));\n let c = hash21(i + vec2<f32>(0.0, 1.0));\n let d = hash21(i + vec2<f32>(1.0, 1.0));\n return mix(mix(a, b, u2.x), mix(c, d, u2.x), u2.y);\n}\n\nfn potentialFBM(p0: vec2<f32>) -> f32 {\n var v = 0.0;\n var amp = 0.5;\n var freq = 1.0;\n var p = p0;\n for (var i = 0; i < 3; i = i + 1) {\n v = v + amp * valueNoise(p * freq);\n p = FBM_ROT * p;\n freq = freq * 2.0;\n amp = amp * 0.5;\n }\n return v;\n}\n\nfn curlFBM(p: vec2<f32>) -> vec2<f32> {\n let dx = potentialFBM(p + vec2<f32>(CURL_EPS, 0.0)) - potentialFBM(p - vec2<f32>(CURL_EPS, 0.0));\n let dy = potentialFBM(p + vec2<f32>(0.0, CURL_EPS)) - potentialFBM(p - vec2<f32>(0.0, CURL_EPS));\n let g = vec2<f32>(dx, dy) / (2.0 * CURL_EPS);\n return vec2<f32>(g.y, -g.x);\n}\n\n// The composite flow velocity (transcribes flowField.ts sampleVelocity EXACTLY — the\n// coarse ×0.55 curl domain-scale, the §3.2 inversion).\nfn sampleVelocity(p: vec2<f32>, t: f32) -> vec2<f32> {\n let curlStrength = u.p0.w;\n var v = gerstnerVelocity(p, t);\n if (curlStrength > 0.0) {\n let c = curlFBM(vec2<f32>(p.x * 0.55 + t * 0.15, p.y * 0.55));\n v = v + c * curlStrength;\n }\n return v;\n}\n\n// The sub-cell DISPLACEMENT (transcribes flowField.ts sampleDisplacement — ∇⊥h + the\n// coarse curl break, soft-clamped through tanh so the magnitude rides into [0,1)).\nfn sampleDisplacement(o: vec2<f32>, t: f32) -> vec2<f32> {\n let v = sampleVelocity(o, t);\n let mag = length(v);\n if (mag < 1e-5) { return vec2<f32>(0.0, 0.0); }\n let bounded = tanh(mag);\n return v * (bounded / mag);\n}\n\n// ── The cursor VORTEX injected into the velocity field (transcribes flowField.ts\n// pointerVortex). r = p − cursor; a gaussian fall-off; a TRUE tangential ∇⊥ swirl +\n// a drag-along term + a radial burst shove. Inert when the pointer is inactive. ──\nfn pointerVortex(p: vec2<f32>) -> vec2<f32> {\n if (u.ptr2.y < 0.5) { return vec2<f32>(0.0, 0.0); } // pointer inactive → no vortex\n let cursor = u.ptr.xy;\n let vel = u.ptr.zw;\n let burst = u.ptr2.x;\n let radius = max(u.f1.x, 1e-3);\n let r = p - cursor;\n let d = length(r);\n let fall = exp(-(d * d) / (radius * radius));\n let swirl = normalize(vec2<f32>(-r.y, r.x) + vec2<f32>(1e-6, 0.0)); // tangential ∇⊥\n let radial = r / max(d, 1e-4);\n let v = swirl * u.f1.y // the spin\n + vel * u.f1.z // the drag (streamlines follow the gesture)\n + radial * burst * u.f1.w; // the flick shockwave\n return v * fall;\n}\n\n// ── density-weighted respawn: a hash-stratified seed inside the domain, biased toward the\n// edges by edgeBias (a faint vignette — the field never thins to a hole). ──\nfn respawn(idx: u32, t: f32) -> vec2<f32> {\n let half = u.f0.w;\n let s = f32(idx) * 0.013 + t * 0.37;\n let rx = hash21(vec2<f32>(s, 1.7)) * 2.0 - 1.0;\n let ry = hash21(vec2<f32>(3.1, s)) * 2.0 - 1.0;\n // edgeBias>0 pushes the seed toward the perimeter (a power-curve on |coord|).\n let bias = clamp(u.ptr2.z, 0.0, 1.0);\n let bx = sign(rx) * pow(abs(rx), mix(1.0, 0.5, bias));\n let by = sign(ry) * pow(abs(ry), mix(1.0, 0.5, bias));\n return vec2<f32>(bx, by) * half;\n}\n\n// ── cs_field — the ANCHORED-LATTICE evaluator (BYTE-MOVED from cs_main; the field-mode\n// fence-scoped unit; F1 greps the no-advection/no-reseed witness WITHIN this brace-span).\nfn cs_field(idx: u32, t: f32, dt: f32) {\n let pitch = u.p1.x;\n let displaceAmp = u.p1.y;\n let springK = u.p1.z;\n let cols = u.ints.z;\n\n // The PERMANENT anchor — no wrap, no re-seed (the coherence fix).\n let o = gridOrigin(idx, cols, pitch);\n let disp = sampleDisplacement(o, t);\n let anchorTarget = o + disp * (displaceAmp * pitch);\n\n var pr = particles[idx];\n var pos = pr.data.xy;\n // Framerate-independent critically-damped pull-to-anchor:\n // p ← mix(p, anchorTarget, 1 - exp(-springK·dt)) (the GPGPU influence-pull pattern).\n let k = 1.0 - exp(-springK * dt);\n pos = mix(pos, anchorTarget, k);\n\n let h = sampleHeight(o, t);\n particles[idx] = Particle(vec4<f32>(pos, h, length(disp)));\n}\n\n// ── cs_flow — the AURORA CURRENT (the RE-INVENT register). Momentum-integrated advection\n// along the curl current + the live cursor vortex, with lifetime decay + density-weighted\n// respawn. F1b greps the pos+=v*dt + respawn( + pointerVortex( witness in THIS function.\nfn cs_flow(idx: u32, t: f32, dt: f32) {\n let half = u.f0.w;\n let turnRate = u.f0.x;\n let speedScale = u.f0.y;\n let lifetimeSec = max(u.f0.z, 1e-3);\n\n var pr = particles[idx];\n var pos = pr.data.xy;\n var life = pr.data.w;\n\n // First-frame / dead / out-of-domain seed (the density-weighted respawn).\n let outOfDomain = max(abs(pos.x), abs(pos.y)) > half * 1.05;\n if (life <= 0.0 || outOfDomain) {\n pos = respawn(idx, t);\n // stratify the initial life across [0,lifetime] so deaths don't synchronize.\n life = lifetimeSec * hash21(vec2<f32>(f32(idx) * 0.027, t * 0.11));\n }\n\n // The target velocity: the divergence-free curl current + the cursor vortex.\n let vField = sampleVelocity(pos, t) + pointerVortex(pos);\n // Momentum/inertia: the low turnRate scales how hard the mote commits to the field\n // each step — a weighty ease into the current's turns (arcs, not snaps), the\n // overlapping-action/follow-through on a particle (R4-motion).\n let v = vField * turnRate * speedScale;\n // Forward-Euler advection step (the integrator — F1b's witness pos = pos + v*dt).\n pos = pos + v * dt * 60.0;\n\n life = life - dt;\n let speed = length(v);\n particles[idx] = Particle(vec4<f32>(pos, speed, life));\n}\n\n@compute @workgroup_size(64)\nfn cs_main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let idx = gid.x;\n let count = u32(u.ints.y);\n if (idx >= count) { return; } // bounds-guard the dispatch tail\n\n let t = u.p0.x;\n let dt = u.p0.y;\n let mode = u.ints.w;\n\n if (mode == 1) {\n cs_flow(idx, t, dt);\n } else {\n cs_field(idx, t, dt);\n }\n}\n", _e = `
|
|
280
|
+
const PI: f32 = 3.141592653589793;
|
|
281
|
+
const TAU: f32 = 6.283185307179586;
|
|
282
|
+
const MAX_FLOW_STOPS: i32 = 4;
|
|
283
|
+
|
|
284
|
+
struct Particle {
|
|
285
|
+
// field: (pos.x, pos.y, height, |disp|) flow: (pos.x, pos.y, speed, life)
|
|
286
|
+
data: vec4<f32>,
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
// ── Render uniforms (the typed-struct source-of-truth — see uniformBridgeWGPU.ts) ──
|
|
290
|
+
struct RenderUniforms {
|
|
291
|
+
// r0: (uTime, uContrast, uBaseBright, uDomainHalf)
|
|
292
|
+
r0: vec4<f32>,
|
|
293
|
+
// r1: (uDotSize, uSizePulse, uAspect, uGridPitch)
|
|
294
|
+
r1: vec4<f32>,
|
|
295
|
+
// r2: (uWaveBandCenter, uWaveBandWidth, uGlobeMask, uMode) — uMode: 0=field, 1=flow
|
|
296
|
+
r2: vec4<f32>,
|
|
297
|
+
// ints: (uStopCount, uParticleCount, _pad, _pad)
|
|
298
|
+
ints: vec4<i32>,
|
|
299
|
+
// bg: (background.rgb, hasBackground)
|
|
300
|
+
bg: vec4<f32>,
|
|
301
|
+
// f0: (uSpeedGlow, uSpeedNorm, uShadowOffset, uStretchAmp) — the flow velocity-map levers
|
|
302
|
+
f0: vec4<f32>,
|
|
303
|
+
// each palette stop: linear-sRGB rgb + _pad
|
|
304
|
+
palette: array<vec4<f32>, 4>,
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
@group(0) @binding(0) var<uniform> u: RenderUniforms;
|
|
308
|
+
@group(0) @binding(1) var<storage, read> particles: array<Particle>;
|
|
309
|
+
|
|
310
|
+
${n}
|
|
311
|
+
${i}
|
|
312
|
+
|
|
313
|
+
// The sweeping bright-stripe band (transcribes flowField.ts waveBand): a soft two-sided
|
|
314
|
+
// ridge over the normalized height — 1 at the band center, falling to 0 at ±width.
|
|
315
|
+
fn waveBand(h: f32, center: f32, width: f32) -> f32 {
|
|
316
|
+
let w = max(width, 1e-3);
|
|
317
|
+
let d = abs(h - center);
|
|
318
|
+
return 1.0 - smoothstep(0.0, w, d);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// The optional soft-disc globe mask — a slow Lissajous-drifting radial field (the
|
|
322
|
+
// reference's two-sphere composition). OFF when uGlobeMask <= 0.5 (returns 1).
|
|
323
|
+
fn globeMask(o: vec2<f32>, t: f32, on: f32) -> f32 {
|
|
324
|
+
if (on <= 0.5) { return 1.0; }
|
|
325
|
+
// a slow Lissajous center drift within the domain
|
|
326
|
+
let cx = 0.35 * sin(t * 0.13);
|
|
327
|
+
let cy = 0.28 * cos(t * 0.11);
|
|
328
|
+
let d = length(o - vec2<f32>(cx, cy));
|
|
329
|
+
// a soft disc of radius ~0.6 with a feathered edge
|
|
330
|
+
return 1.0 - smoothstep(0.45, 0.75, d);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// Sample the multi-stop palette (linear-sRGB stops, OKLab mix). t in [0,1].
|
|
334
|
+
fn samplePaletteLin(t: f32) -> vec3<f32> {
|
|
335
|
+
let stopCount = u.ints.x;
|
|
336
|
+
if (stopCount <= 1) { return u.palette[0].rgb; }
|
|
337
|
+
let n = f32(stopCount);
|
|
338
|
+
let ft = clamp(t, 0.0, 1.0) * (n - 1.0);
|
|
339
|
+
let i0 = i32(floor(ft));
|
|
340
|
+
let i1 = min(i0 + 1, stopCount - 1);
|
|
341
|
+
let f = ft - f32(i0);
|
|
342
|
+
let labA = LMS_TO_OKLAB * cbrt3(LINEAR_SRGB_TO_LMS * u.palette[i0].rgb);
|
|
343
|
+
let labB = LMS_TO_OKLAB * cbrt3(LINEAR_SRGB_TO_LMS * u.palette[i1].rgb);
|
|
344
|
+
return oklabToLinearSrgb(mix(labA, labB, f));
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
struct VSOut {
|
|
348
|
+
@builtin(position) pos: vec4<f32>,
|
|
349
|
+
@location(0) local: vec2<f32>, // [-1,1] billboard-local coords for the soft circle
|
|
350
|
+
@location(1) bright: f32, // brightness [0, ~1.6]
|
|
351
|
+
@location(2) ramp: f32, // palette-ramp coord (field: tone, flow: speedNorm)
|
|
352
|
+
@location(3) flowFade: f32, // flow life-fade [0,1] (field: 1)
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
@vertex
|
|
356
|
+
fn vs_main(
|
|
357
|
+
@builtin(vertex_index) vi: u32,
|
|
358
|
+
@builtin(instance_index) ii: u32,
|
|
359
|
+
) -> VSOut {
|
|
360
|
+
// Two-triangle quad corners in billboard-local space.
|
|
361
|
+
var corners = array<vec2<f32>, 6>(
|
|
362
|
+
vec2<f32>(-1.0, -1.0), vec2<f32>(1.0, -1.0), vec2<f32>(-1.0, 1.0),
|
|
363
|
+
vec2<f32>(-1.0, 1.0), vec2<f32>(1.0, -1.0), vec2<f32>(1.0, 1.0),
|
|
364
|
+
);
|
|
365
|
+
let local = corners[vi];
|
|
366
|
+
|
|
367
|
+
let pr = particles[ii].data;
|
|
368
|
+
let p = pr.xy;
|
|
369
|
+
let half = u.r0.w;
|
|
370
|
+
let aspect = u.r1.z;
|
|
371
|
+
let mode = i32(u.r2.w + 0.5);
|
|
372
|
+
|
|
373
|
+
var bright: f32;
|
|
374
|
+
var ramp: f32;
|
|
375
|
+
var sizeWorld: f32;
|
|
376
|
+
var flowFade: f32 = 1.0;
|
|
377
|
+
|
|
378
|
+
if (mode == 1) {
|
|
379
|
+
// ── flow (AURORA CURRENT): speed→hue, speed·life→brightness, speed→size bloom ──
|
|
380
|
+
let speed = pr.z;
|
|
381
|
+
let life = pr.w;
|
|
382
|
+
let speedNorm = clamp(speed / max(u.f0.y, 1e-4), 0.0, 1.0);
|
|
383
|
+
// life fades the mote over its last third (the trail's tail / overlapping-action).
|
|
384
|
+
flowFade = clamp(life * 3.0, 0.0, 1.0);
|
|
385
|
+
ramp = speedNorm;
|
|
386
|
+
bright = (0.35 + speedNorm * u.f0.x) * flowFade;
|
|
387
|
+
// a speed bloom (the cartoon "more" on WGPU — faster motes read as hot speed-cores) +
|
|
388
|
+
// the √φ stretch lever scales the bloom (the squash-stretch as an isotropic core here).
|
|
389
|
+
sizeWorld = u.r1.x * (1.0 + speedNorm * (u.f0.w + 1.0));
|
|
390
|
+
} else {
|
|
391
|
+
// ── field: the sweeping bright band over the anchored lattice (BC.W-VIZ-DOTFLOW) ──
|
|
392
|
+
let h = pr.z;
|
|
393
|
+
let dispMag = pr.w;
|
|
394
|
+
let band = waveBand(h, u.r2.x, u.r2.y);
|
|
395
|
+
bright = (u.r0.z + band * u.r0.y) * globeMask(p, u.r0.x, u.r2.z);
|
|
396
|
+
ramp = clamp(bright, 0.0, 1.0);
|
|
397
|
+
sizeWorld = u.r1.x * (1.0 + dispMag * u.r1.y);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// Position the quad at the dot in clip space. Domain [-half,half] → NDC [-1,1];
|
|
401
|
+
// the quad half-extent rides sizeWorld (in domain units, aspect-corrected x).
|
|
402
|
+
let ndc = p / half;
|
|
403
|
+
let off = local * sizeWorld / half;
|
|
404
|
+
let offX = off.x / max(aspect, 1e-4);
|
|
405
|
+
|
|
406
|
+
var out: VSOut;
|
|
407
|
+
out.pos = vec4<f32>(ndc.x + offX, ndc.y + off.y, 0.0, 1.0);
|
|
408
|
+
out.local = local;
|
|
409
|
+
out.bright = bright;
|
|
410
|
+
out.ramp = ramp;
|
|
411
|
+
out.flowFade = flowFade;
|
|
412
|
+
return out;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
@fragment
|
|
416
|
+
fn fs_main(in: VSOut) -> @location(0) vec4<f32> {
|
|
417
|
+
// Soft circle — radial smoothstep over the billboard-local radius.
|
|
418
|
+
let r = length(in.local);
|
|
419
|
+
let feather = 0.4;
|
|
420
|
+
let mask = 1.0 - smoothstep(1.0 - feather, 1.0, r);
|
|
421
|
+
if (mask < 0.002) { return vec4<f32>(0.0); }
|
|
422
|
+
|
|
423
|
+
let mode = i32(u.r2.w + 0.5);
|
|
424
|
+
let bright = clamp(in.bright, 0.0, 1.6);
|
|
425
|
+
let lin = samplePaletteLin(in.ramp) * bright;
|
|
426
|
+
let rgb = clamp(linearToSrgb(lin), vec3<f32>(0.0), vec3<f32>(1.0));
|
|
427
|
+
|
|
428
|
+
if (mode == 1) {
|
|
429
|
+
// flow: additive premultiplied — a soft glowing core, alpha rides speed·life.
|
|
430
|
+
let coreAlpha = mask * mask; // a tighter hot core (less white wash — H2 cap)
|
|
431
|
+
let a = coreAlpha * clamp(bright, 0.0, 1.0);
|
|
432
|
+
return vec4<f32>(rgb * a, a);
|
|
433
|
+
}
|
|
434
|
+
// field: a floor alpha so even an off-band dot stays a faint lattice point.
|
|
435
|
+
let alpha = mask * clamp(bright * 0.8 + 0.12, 0.0, 1.0);
|
|
436
|
+
return vec4<f32>(rgb * alpha, alpha);
|
|
437
|
+
}
|
|
438
|
+
`, ve = `
|
|
439
|
+
struct TrailUniforms {
|
|
440
|
+
// (decay, hasGround, time, _pad)
|
|
441
|
+
p: vec4<f32>,
|
|
442
|
+
// floor.rgb (linear-sRGB) + _pad
|
|
443
|
+
floorC: vec4<f32>,
|
|
444
|
+
// bloom.rgb (linear-sRGB) + _pad
|
|
445
|
+
bloomC: vec4<f32>,
|
|
446
|
+
};
|
|
447
|
+
@group(0) @binding(0) var<uniform> u: TrailUniforms;
|
|
448
|
+
@group(0) @binding(1) var samp: sampler;
|
|
449
|
+
@group(0) @binding(2) var tex: texture_2d<f32>;
|
|
450
|
+
|
|
451
|
+
${n}
|
|
452
|
+
|
|
453
|
+
struct FSQ { @builtin(position) pos: vec4<f32>, @location(0) uv: vec2<f32> };
|
|
454
|
+
|
|
455
|
+
@vertex
|
|
456
|
+
fn vs_fsq(@builtin(vertex_index) vi: u32) -> FSQ {
|
|
457
|
+
var c = array<vec2<f32>, 3>(
|
|
458
|
+
vec2<f32>(-1.0, -1.0), vec2<f32>(3.0, -1.0), vec2<f32>(-1.0, 3.0),
|
|
459
|
+
);
|
|
460
|
+
let p = c[vi];
|
|
461
|
+
var out: FSQ;
|
|
462
|
+
out.pos = vec4<f32>(p, 0.0, 1.0);
|
|
463
|
+
out.uv = p * 0.5 + 0.5;
|
|
464
|
+
return out;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
@fragment
|
|
468
|
+
fn fs_decay(in: FSQ) -> @location(0) vec4<f32> {
|
|
469
|
+
let prev = textureSample(tex, samp, in.uv);
|
|
470
|
+
return prev * u.p.x; // fade toward black
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
@fragment
|
|
474
|
+
fn fs_present(in: FSQ) -> @location(0) vec4<f32> {
|
|
475
|
+
let trail = textureSample(tex, samp, in.uv).rgb;
|
|
476
|
+
let mapped = trail / (trail + vec3<f32>(0.85)); // Reinhard — hot cores, not white wash
|
|
477
|
+
if (u.p.y < 0.5) {
|
|
478
|
+
let rgb = clamp(linearToSrgb(mapped), vec3<f32>(0.0), vec3<f32>(1.0));
|
|
479
|
+
let a = clamp(max(mapped.r, max(mapped.g, mapped.b)), 0.0, 1.0);
|
|
480
|
+
return vec4<f32>(rgb * a, a);
|
|
481
|
+
}
|
|
482
|
+
let bloom = smoothstep(1.3, 0.0, distance(in.uv, vec2<f32>(0.12, 0.88)));
|
|
483
|
+
let floorLin = u.floorC.rgb + u.bloomC.rgb * bloom * 0.5;
|
|
484
|
+
let lin = floorLin + mapped;
|
|
485
|
+
let rgb = clamp(linearToSrgb(lin), vec3<f32>(0.0), vec3<f32>(1.0));
|
|
486
|
+
return vec4<f32>(rgb, 1.0);
|
|
487
|
+
}
|
|
488
|
+
`, J = 64, ye = 128, Y = 8, be = 16, xe = 4, Se = 1, X = 2, Ce = 4, we = 64;
|
|
489
|
+
function Te(e) {
|
|
490
|
+
let { canvas: t, config: n, getPalette: r, shouldContinue: i, onFrame: a, getPointer: s } = e;
|
|
491
|
+
return function(e, l, u) {
|
|
492
|
+
let d = n.mode === "flow", f = G(n.gridPitch, $(t)), p = d ? He(n) : f.count, m = d ? he(p, n.lifetimeSec) : me(f), h = e.createShaderModule({
|
|
320
493
|
label: "[DotFlowField] flow-field.compute.wgsl",
|
|
321
|
-
code:
|
|
322
|
-
}),
|
|
494
|
+
code: ge
|
|
495
|
+
}), g = e.createShaderModule({
|
|
323
496
|
label: "[DotFlowField] flow-field.render.wgsl",
|
|
324
|
-
code:
|
|
325
|
-
}),
|
|
497
|
+
code: _e
|
|
498
|
+
}), _ = e.createBuffer({
|
|
326
499
|
label: "[DotFlowField] particles",
|
|
327
|
-
size:
|
|
328
|
-
usage:
|
|
500
|
+
size: m.length / 4 * 16,
|
|
501
|
+
usage: ye | Y,
|
|
329
502
|
mappedAtCreation: !0
|
|
330
503
|
});
|
|
331
|
-
new Float32Array(
|
|
332
|
-
let
|
|
504
|
+
new Float32Array(_.getMappedRange()).set(m), _.unmap();
|
|
505
|
+
let v = e.createBuffer({
|
|
333
506
|
label: "[DotFlowField] compute-uniforms",
|
|
334
|
-
size:
|
|
507
|
+
size: ie().buffer.byteLength,
|
|
335
508
|
usage: J | Y
|
|
336
|
-
}),
|
|
509
|
+
}), y = e.createBuffer({
|
|
337
510
|
label: "[DotFlowField] render-uniforms",
|
|
338
|
-
size:
|
|
511
|
+
size: ce().buffer.byteLength,
|
|
339
512
|
usage: J | Y
|
|
340
|
-
}),
|
|
513
|
+
}), b = e.createBindGroupLayout({
|
|
341
514
|
label: "[DotFlowField] compute-bgl",
|
|
342
515
|
entries: [{
|
|
343
516
|
binding: 0,
|
|
344
|
-
visibility:
|
|
517
|
+
visibility: Ce,
|
|
345
518
|
buffer: { type: "uniform" }
|
|
346
519
|
}, {
|
|
347
520
|
binding: 1,
|
|
348
|
-
visibility:
|
|
521
|
+
visibility: Ce,
|
|
349
522
|
buffer: { type: "storage" }
|
|
350
523
|
}]
|
|
351
|
-
}),
|
|
524
|
+
}), x = e.createComputePipeline({
|
|
352
525
|
label: "[DotFlowField] compute-pipeline",
|
|
353
|
-
layout: e.createPipelineLayout({ bindGroupLayouts: [
|
|
526
|
+
layout: e.createPipelineLayout({ bindGroupLayouts: [b] }),
|
|
354
527
|
compute: {
|
|
355
|
-
module:
|
|
528
|
+
module: h,
|
|
356
529
|
entryPoint: "cs_main"
|
|
357
530
|
}
|
|
358
|
-
}),
|
|
531
|
+
}), S = e.createBindGroup({
|
|
359
532
|
label: "[DotFlowField] compute-bg",
|
|
360
|
-
layout:
|
|
533
|
+
layout: b,
|
|
361
534
|
entries: [{
|
|
362
535
|
binding: 0,
|
|
363
|
-
resource: { buffer:
|
|
536
|
+
resource: { buffer: v }
|
|
364
537
|
}, {
|
|
365
538
|
binding: 1,
|
|
366
|
-
resource: { buffer:
|
|
539
|
+
resource: { buffer: _ }
|
|
367
540
|
}]
|
|
368
|
-
}),
|
|
541
|
+
}), C = e.createBindGroupLayout({
|
|
369
542
|
label: "[DotFlowField] render-bgl",
|
|
370
543
|
entries: [{
|
|
371
544
|
binding: 0,
|
|
372
|
-
visibility:
|
|
545
|
+
visibility: Se | X,
|
|
373
546
|
buffer: { type: "uniform" }
|
|
374
547
|
}, {
|
|
375
548
|
binding: 1,
|
|
376
|
-
visibility:
|
|
549
|
+
visibility: Se,
|
|
377
550
|
buffer: { type: "read-only-storage" }
|
|
378
551
|
}]
|
|
379
|
-
}),
|
|
552
|
+
}), w = "rgba16float", T = e.createRenderPipeline({
|
|
380
553
|
label: "[DotFlowField] render-pipeline",
|
|
381
|
-
layout: e.createPipelineLayout({ bindGroupLayouts: [
|
|
554
|
+
layout: e.createPipelineLayout({ bindGroupLayouts: [C] }),
|
|
382
555
|
vertex: {
|
|
383
|
-
module:
|
|
556
|
+
module: g,
|
|
384
557
|
entryPoint: "vs_main"
|
|
385
558
|
},
|
|
386
559
|
fragment: {
|
|
387
|
-
module:
|
|
560
|
+
module: g,
|
|
388
561
|
entryPoint: "fs_main",
|
|
389
562
|
targets: [{
|
|
390
|
-
format:
|
|
391
|
-
blend: {
|
|
563
|
+
format: d ? w : u,
|
|
564
|
+
blend: d ? {
|
|
565
|
+
color: {
|
|
566
|
+
srcFactor: "one",
|
|
567
|
+
dstFactor: "one",
|
|
568
|
+
operation: "add"
|
|
569
|
+
},
|
|
570
|
+
alpha: {
|
|
571
|
+
srcFactor: "one",
|
|
572
|
+
dstFactor: "one",
|
|
573
|
+
operation: "add"
|
|
574
|
+
}
|
|
575
|
+
} : {
|
|
392
576
|
color: {
|
|
393
577
|
srcFactor: "one",
|
|
394
578
|
dstFactor: "one-minus-src-alpha",
|
|
@@ -403,170 +587,867 @@ function oe(e) {
|
|
|
403
587
|
}]
|
|
404
588
|
},
|
|
405
589
|
primitive: { topology: "triangle-list" }
|
|
406
|
-
}),
|
|
590
|
+
}), E = e.createBindGroup({
|
|
407
591
|
label: "[DotFlowField] render-bg",
|
|
408
|
-
layout:
|
|
592
|
+
layout: C,
|
|
409
593
|
entries: [{
|
|
410
594
|
binding: 0,
|
|
411
|
-
resource: { buffer:
|
|
595
|
+
resource: { buffer: y }
|
|
412
596
|
}, {
|
|
413
597
|
binding: 1,
|
|
414
|
-
resource: { buffer:
|
|
598
|
+
resource: { buffer: _ }
|
|
415
599
|
}]
|
|
416
|
-
}),
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
600
|
+
}), D = d ? e.createShaderModule({
|
|
601
|
+
label: "[DotFlowField] flow-field.trail.wgsl",
|
|
602
|
+
code: ve
|
|
603
|
+
}) : null, O = d ? e.createBuffer({
|
|
604
|
+
label: "[DotFlowField] trail-uniforms",
|
|
605
|
+
size: 48,
|
|
606
|
+
usage: J | Y
|
|
607
|
+
}) : null, k = d ? e.createSampler({
|
|
608
|
+
magFilter: "linear",
|
|
609
|
+
minFilter: "linear"
|
|
610
|
+
}) : null, A = d && D ? e.createBindGroupLayout({
|
|
611
|
+
label: "[DotFlowField] trail-bgl",
|
|
612
|
+
entries: [
|
|
613
|
+
{
|
|
614
|
+
binding: 0,
|
|
615
|
+
visibility: X,
|
|
616
|
+
buffer: { type: "uniform" }
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
binding: 1,
|
|
620
|
+
visibility: X,
|
|
621
|
+
sampler: { type: "filtering" }
|
|
435
622
|
},
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
623
|
+
{
|
|
624
|
+
binding: 2,
|
|
625
|
+
visibility: X,
|
|
626
|
+
texture: { sampleType: "float" }
|
|
627
|
+
}
|
|
628
|
+
]
|
|
629
|
+
}) : null, j = d && D && A ? e.createRenderPipeline({
|
|
630
|
+
label: "[DotFlowField] trail-decay-pipeline",
|
|
631
|
+
layout: e.createPipelineLayout({ bindGroupLayouts: [A] }),
|
|
632
|
+
vertex: {
|
|
633
|
+
module: D,
|
|
634
|
+
entryPoint: "vs_fsq"
|
|
635
|
+
},
|
|
636
|
+
fragment: {
|
|
637
|
+
module: D,
|
|
638
|
+
entryPoint: "fs_decay",
|
|
639
|
+
targets: [{ format: w }]
|
|
640
|
+
},
|
|
641
|
+
primitive: { topology: "triangle-list" }
|
|
642
|
+
}) : null, M = d && D && A ? e.createRenderPipeline({
|
|
643
|
+
label: "[DotFlowField] trail-present-pipeline",
|
|
644
|
+
layout: e.createPipelineLayout({ bindGroupLayouts: [A] }),
|
|
645
|
+
vertex: {
|
|
646
|
+
module: D,
|
|
647
|
+
entryPoint: "vs_fsq"
|
|
648
|
+
},
|
|
649
|
+
fragment: {
|
|
650
|
+
module: D,
|
|
651
|
+
entryPoint: "fs_present",
|
|
652
|
+
targets: [{ format: u }]
|
|
653
|
+
},
|
|
654
|
+
primitive: { topology: "triangle-list" }
|
|
655
|
+
}) : null, N = null, P = null, F = null, I = null, L = 0;
|
|
656
|
+
function R() {
|
|
657
|
+
if (!d || !A || !O || !k) return;
|
|
658
|
+
let r = Math.min(Math.max(n.trailScale, .25), 1), i = Math.max(2, Math.round(t.width * r)), a = Math.max(2, Math.round(t.height * r));
|
|
659
|
+
N?.forEach((e) => e.destroy());
|
|
660
|
+
let o = () => e.createTexture({
|
|
661
|
+
label: "[DotFlowField] trail",
|
|
662
|
+
size: {
|
|
663
|
+
width: i,
|
|
664
|
+
height: a
|
|
665
|
+
},
|
|
666
|
+
format: w,
|
|
667
|
+
usage: be | xe
|
|
668
|
+
}), s = o(), c = o();
|
|
669
|
+
N = [s, c], P = [s.createView(), c.createView()];
|
|
670
|
+
let l = (t) => e.createBindGroup({
|
|
671
|
+
layout: A,
|
|
672
|
+
entries: [
|
|
673
|
+
{
|
|
674
|
+
binding: 0,
|
|
675
|
+
resource: { buffer: O }
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
binding: 1,
|
|
679
|
+
resource: k
|
|
680
|
+
},
|
|
681
|
+
{
|
|
682
|
+
binding: 2,
|
|
683
|
+
resource: t
|
|
684
|
+
}
|
|
685
|
+
]
|
|
686
|
+
});
|
|
687
|
+
F = [l(P[1]), l(P[0])], I = [l(P[0]), l(P[1])];
|
|
688
|
+
}
|
|
689
|
+
let z = ie(), B = ce(), V = new Float32Array(12), H = -1;
|
|
690
|
+
function U() {
|
|
691
|
+
let e = o(), r = t.clientWidth || 320, i = t.clientHeight || 320, a = Math.max(1, Math.round(r * e)), s = Math.max(1, Math.round(i * e));
|
|
692
|
+
if ((t.width !== a || t.height !== s) && (t.width = a, t.height = s), !d) {
|
|
693
|
+
let e = G(n.gridPitch, $(t));
|
|
694
|
+
f = {
|
|
695
|
+
...e,
|
|
696
|
+
count: Math.min(e.count, m.length / 4)
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
R();
|
|
700
|
+
}
|
|
701
|
+
function W(i) {
|
|
702
|
+
a?.(i);
|
|
703
|
+
let o = H < 0 ? 0 : Math.min(Math.max(i - H, 0), .05);
|
|
704
|
+
H = i;
|
|
705
|
+
let u = (t.clientWidth || 320) / Math.max(t.clientHeight || 320, 1), m = d ? p : f.count, h = s?.();
|
|
706
|
+
ae(z, n, i, o, f, m, h), e.queue.writeBuffer(v, 0, z.buffer), fe(B, n, i, u, $(t), f, r()), e.queue.writeBuffer(y, 0, B.buffer);
|
|
707
|
+
let g = e.createCommandEncoder({ label: "[DotFlowField] frame" }), _ = g.beginComputePass();
|
|
708
|
+
if (_.setPipeline(x), _.setBindGroup(0, S), _.dispatchWorkgroups(Math.ceil(m / we)), _.end(), d && P && F && I && j && M && O) {
|
|
709
|
+
let t = L, r = 1 - L, a = ee(n.trailHalfLife), o = n.background === "transparent" ? 0 : 1, s = c(n.background === "transparent" ? Be : n.background), u = c(Ve);
|
|
710
|
+
V[0] = a, V[1] = o, V[2] = i, V[4] = s[0], V[5] = s[1], V[6] = s[2], V[8] = u[0], V[9] = u[1], V[10] = u[2], e.queue.writeBuffer(O, 0, V.buffer);
|
|
711
|
+
let d = g.beginRenderPass({ colorAttachments: [{
|
|
712
|
+
view: P[t],
|
|
713
|
+
clearValue: {
|
|
714
|
+
r: 0,
|
|
715
|
+
g: 0,
|
|
716
|
+
b: 0,
|
|
717
|
+
a: 0
|
|
718
|
+
},
|
|
719
|
+
loadOp: "clear",
|
|
720
|
+
storeOp: "store"
|
|
721
|
+
}] });
|
|
722
|
+
d.setPipeline(j), d.setBindGroup(0, F[t]), d.draw(3, 1, 0, 0), d.end();
|
|
723
|
+
let f = g.beginRenderPass({ colorAttachments: [{
|
|
724
|
+
view: P[t],
|
|
725
|
+
loadOp: "load",
|
|
726
|
+
storeOp: "store"
|
|
727
|
+
}] });
|
|
728
|
+
f.setPipeline(T), f.setBindGroup(0, E), f.draw(6, m, 0, 0), f.end();
|
|
729
|
+
let p = l.getCurrentTexture().createView(), h = g.beginRenderPass({ colorAttachments: [{
|
|
730
|
+
view: p,
|
|
731
|
+
clearValue: {
|
|
732
|
+
r: 0,
|
|
733
|
+
g: 0,
|
|
734
|
+
b: 0,
|
|
735
|
+
a: 0
|
|
736
|
+
},
|
|
737
|
+
loadOp: "clear",
|
|
738
|
+
storeOp: "store"
|
|
739
|
+
}] });
|
|
740
|
+
h.setPipeline(M), h.setBindGroup(0, I[t]), h.draw(3, 1, 0, 0), h.end(), L = r;
|
|
741
|
+
} else {
|
|
742
|
+
let e = l.getCurrentTexture().createView(), t = g.beginRenderPass({ colorAttachments: [{
|
|
743
|
+
view: e,
|
|
744
|
+
clearValue: {
|
|
745
|
+
r: 0,
|
|
746
|
+
g: 0,
|
|
747
|
+
b: 0,
|
|
748
|
+
a: 0
|
|
749
|
+
},
|
|
750
|
+
loadOp: "clear",
|
|
751
|
+
storeOp: "store"
|
|
752
|
+
}] });
|
|
753
|
+
t.setPipeline(T), t.setBindGroup(0, E), t.draw(6, m, 0, 0), t.end();
|
|
754
|
+
}
|
|
755
|
+
e.queue.submit([g.finish()]);
|
|
440
756
|
}
|
|
441
757
|
return {
|
|
442
|
-
frame:
|
|
758
|
+
frame: W,
|
|
443
759
|
shouldContinue: i,
|
|
444
|
-
resize:
|
|
760
|
+
resize: U,
|
|
445
761
|
teardown: () => {
|
|
446
|
-
|
|
762
|
+
_.destroy(), v.destroy(), y.destroy(), O?.destroy(), N?.forEach((e) => e.destroy());
|
|
447
763
|
}
|
|
448
764
|
};
|
|
449
765
|
};
|
|
450
766
|
}
|
|
451
767
|
//#endregion
|
|
452
768
|
//#region src/components/custom/dot-flow-field/shaders/flow-field.glsl.ts
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
769
|
+
var Ee = "#version 300 es\nprecision highp float;\nin vec2 aPosition;\nout vec2 vUv;\nvoid main() {\n vUv = aPosition; // [-1,1]² domain\n gl_Position = vec4(aPosition, 0.0, 1.0);\n}", De = `#version 300 es
|
|
770
|
+
precision highp float;
|
|
771
|
+
|
|
772
|
+
#define PI 3.141592653589793
|
|
773
|
+
#define TAU 6.283185307179586
|
|
774
|
+
#define FLOW_GRAVITY 9.81
|
|
775
|
+
#define CURL_EPS 0.012
|
|
776
|
+
#define MAX_WAVE_COMPONENTS 8
|
|
777
|
+
#define MAX_FLOW_STOPS 4
|
|
778
|
+
|
|
779
|
+
in vec2 vUv;
|
|
780
|
+
out vec4 fragColor;
|
|
781
|
+
|
|
782
|
+
uniform float uTime;
|
|
783
|
+
uniform float uWindSpeed;
|
|
784
|
+
uniform float uCurlStrength;
|
|
785
|
+
uniform float uDomainHalf;
|
|
786
|
+
uniform float uAspect;
|
|
787
|
+
uniform float uGridPitchDomain; // lattice pitch in DOMAIN units
|
|
788
|
+
uniform float uDotRadiusDomain; // dot radius in DOMAIN units
|
|
789
|
+
uniform float uDisplaceAmp; // sub-cell drift in pitch fractions
|
|
790
|
+
uniform float uContrast;
|
|
791
|
+
uniform float uBaseBright;
|
|
792
|
+
uniform float uWaveBandCenter;
|
|
793
|
+
uniform float uWaveBandWidth;
|
|
794
|
+
uniform float uGlobeMask;
|
|
795
|
+
uniform int uWaveCount;
|
|
796
|
+
uniform int uStopCount;
|
|
797
|
+
uniform float uHasBackground;
|
|
798
|
+
uniform vec3 uBg;
|
|
799
|
+
uniform vec4 uWaves[MAX_WAVE_COMPONENTS]; // (amplitude, wavelength, directionDeg, phase)
|
|
800
|
+
uniform vec3 uPalette[MAX_FLOW_STOPS]; // linear-sRGB stops
|
|
801
|
+
|
|
802
|
+
const mat2 FBM_ROT = mat2(0.8, 0.6, -0.6, 0.8);
|
|
803
|
+
|
|
804
|
+
${r}
|
|
805
|
+
${a}
|
|
806
|
+
|
|
807
|
+
// ── The Gerstner-sum analytic ∇⊥h velocity (transcribes flowField.ts gerstnerVelocity) ──
|
|
808
|
+
vec2 gerstnerVelocity(vec2 p, float t) {
|
|
809
|
+
float dhdx = 0.0;
|
|
810
|
+
float dhdy = 0.0;
|
|
811
|
+
for (int i = 0; i < MAX_WAVE_COMPONENTS; i++) {
|
|
812
|
+
if (i >= uWaveCount) break;
|
|
813
|
+
vec4 w = uWaves[i];
|
|
814
|
+
float k = TAU / max(w.y, 1e-4);
|
|
815
|
+
float dirRad = w.z * PI / 180.0;
|
|
816
|
+
vec2 d = vec2(cos(dirRad), sin(dirRad));
|
|
817
|
+
float omega = sqrt(FLOW_GRAVITY * k) * uWindSpeed;
|
|
818
|
+
float theta = k * (d.x * p.x + d.y * p.y) - omega * t + w.w;
|
|
819
|
+
float akc = w.x * k * cos(theta);
|
|
820
|
+
dhdx += akc * d.x;
|
|
821
|
+
dhdy += akc * d.y;
|
|
822
|
+
}
|
|
823
|
+
return vec2(dhdy, -dhdx);
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
// ── The scalar Gerstner HEIGHT (transcribes flowField.ts sampleHeight) ──
|
|
827
|
+
float sampleHeight(vec2 o, float t) {
|
|
828
|
+
float h = 0.0;
|
|
829
|
+
float ampSum = 0.0;
|
|
830
|
+
for (int i = 0; i < MAX_WAVE_COMPONENTS; i++) {
|
|
831
|
+
if (i >= uWaveCount) break;
|
|
832
|
+
vec4 w = uWaves[i];
|
|
833
|
+
float k = TAU / max(w.y, 1e-4);
|
|
834
|
+
float dirRad = w.z * PI / 180.0;
|
|
835
|
+
vec2 d = vec2(cos(dirRad), sin(dirRad));
|
|
836
|
+
float omega = sqrt(FLOW_GRAVITY * k) * uWindSpeed;
|
|
837
|
+
float theta = k * (d.x * o.x + d.y * o.y) - omega * t + w.w;
|
|
838
|
+
h += w.x * sin(theta);
|
|
839
|
+
ampSum += abs(w.x);
|
|
840
|
+
}
|
|
841
|
+
return h / max(ampSum, 1e-4);
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
// ── Shared curl-noise basis (the GLSL twin of flow.glsl.ts curlFBM) ──
|
|
845
|
+
float hash21(vec2 p) {
|
|
846
|
+
vec3 p3 = fract(vec3(p.x, p.y, p.x) * 0.1031);
|
|
847
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
848
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
849
|
+
}
|
|
850
|
+
float valueNoise(vec2 p) {
|
|
851
|
+
vec2 i = floor(p);
|
|
852
|
+
vec2 f = fract(p);
|
|
853
|
+
vec2 u2 = f * f * f * (f * (f * 6.0 - 15.0) + 10.0);
|
|
854
|
+
float a = hash21(i + vec2(0.0, 0.0));
|
|
855
|
+
float b = hash21(i + vec2(1.0, 0.0));
|
|
856
|
+
float c = hash21(i + vec2(0.0, 1.0));
|
|
857
|
+
float d = hash21(i + vec2(1.0, 1.0));
|
|
858
|
+
return mix(mix(a, b, u2.x), mix(c, d, u2.x), u2.y);
|
|
859
|
+
}
|
|
860
|
+
float potentialFBM(vec2 p0) {
|
|
861
|
+
float v = 0.0;
|
|
862
|
+
float amp = 0.5;
|
|
863
|
+
float freq = 1.0;
|
|
864
|
+
vec2 p = p0;
|
|
865
|
+
for (int i = 0; i < 3; i++) {
|
|
866
|
+
v += amp * valueNoise(p * freq);
|
|
867
|
+
p = FBM_ROT * p;
|
|
868
|
+
freq *= 2.0;
|
|
869
|
+
amp *= 0.5;
|
|
870
|
+
}
|
|
871
|
+
return v;
|
|
872
|
+
}
|
|
873
|
+
vec2 curlFBM(vec2 p) {
|
|
874
|
+
float dx = potentialFBM(p + vec2(CURL_EPS, 0.0)) - potentialFBM(p - vec2(CURL_EPS, 0.0));
|
|
875
|
+
float dy = potentialFBM(p + vec2(0.0, CURL_EPS)) - potentialFBM(p - vec2(0.0, CURL_EPS));
|
|
876
|
+
vec2 g = vec2(dx, dy) / (2.0 * CURL_EPS);
|
|
877
|
+
return vec2(g.y, -g.x);
|
|
878
|
+
}
|
|
879
|
+
vec2 sampleVelocity(vec2 p, float t) {
|
|
880
|
+
vec2 v = gerstnerVelocity(p, t);
|
|
881
|
+
if (uCurlStrength > 0.0) {
|
|
882
|
+
vec2 c = curlFBM(vec2(p.x * 0.55 + t * 0.15, p.y * 0.55));
|
|
883
|
+
v += c * uCurlStrength;
|
|
884
|
+
}
|
|
885
|
+
return v;
|
|
886
|
+
}
|
|
887
|
+
// sub-cell displacement (transcribes flowField.ts sampleDisplacement — tanh soft-clamp).
|
|
888
|
+
vec2 sampleDisplacement(vec2 o, float t) {
|
|
889
|
+
vec2 v = sampleVelocity(o, t);
|
|
890
|
+
float mag = length(v);
|
|
891
|
+
if (mag < 1e-5) return vec2(0.0);
|
|
892
|
+
return v * (tanh(mag) / mag);
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
// The sweeping bright-stripe band (transcribes flowField.ts waveBand).
|
|
896
|
+
float waveBand(float h, float center, float width) {
|
|
897
|
+
float w = max(width, 1e-3);
|
|
898
|
+
float d = abs(h - center);
|
|
899
|
+
return 1.0 - smoothstep(0.0, w, d);
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
// The optional soft-disc globe mask (the reference's two-sphere composition).
|
|
903
|
+
float globeMask(vec2 o, float t, float on) {
|
|
904
|
+
if (on <= 0.5) return 1.0;
|
|
905
|
+
float cx = 0.35 * sin(t * 0.13);
|
|
906
|
+
float cy = 0.28 * cos(t * 0.11);
|
|
907
|
+
float d = length(o - vec2(cx, cy));
|
|
908
|
+
return 1.0 - smoothstep(0.45, 0.75, d);
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
vec3 samplePaletteLin(float t) {
|
|
912
|
+
if (uStopCount <= 1) return uPalette[0];
|
|
913
|
+
float n = float(uStopCount);
|
|
914
|
+
float ft = clamp(t, 0.0, 1.0) * (n - 1.0);
|
|
915
|
+
int i0 = int(floor(ft));
|
|
916
|
+
int i1 = min(i0 + 1, uStopCount - 1);
|
|
917
|
+
float f = ft - float(i0);
|
|
918
|
+
vec3 lmsA = LINEAR_SRGB_TO_LMS * uPalette[i0];
|
|
919
|
+
vec3 lmsB = LINEAR_SRGB_TO_LMS * uPalette[i1];
|
|
920
|
+
vec3 labA = LMS_TO_OKLAB * (sign(lmsA) * pow(abs(lmsA), vec3(1.0 / 3.0)));
|
|
921
|
+
vec3 labB = LMS_TO_OKLAB * (sign(lmsB) * pow(abs(lmsB), vec3(1.0 / 3.0)));
|
|
922
|
+
return oklabToLinearSrgb(mix(labA, labB, f));
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
void main() {
|
|
926
|
+
float aspect = max(uAspect, 1e-4);
|
|
927
|
+
// Domain-space pixel (aspect-corrected x so the lattice stays square).
|
|
928
|
+
vec2 p = vec2(vUv.x * aspect, vUv.y);
|
|
929
|
+
float pitch = max(uGridPitchDomain, 1e-3);
|
|
930
|
+
|
|
931
|
+
// The nearest lattice cell ORIGIN (the anchored grid — the deterministic gridOrigin
|
|
932
|
+
// mapping, evaluated per-pixel: round p/pitch to the nearest cell center).
|
|
933
|
+
vec2 cell = floor(p / pitch + 0.5);
|
|
934
|
+
vec2 o = cell * pitch;
|
|
935
|
+
|
|
936
|
+
// The dot DRIFTS toward o + disp·displaceAmp·pitch (the same sub-cell offset the
|
|
937
|
+
// compute kernel writes — here evaluated analytically per pixel).
|
|
938
|
+
vec2 disp = sampleDisplacement(o, uTime);
|
|
939
|
+
vec2 dotCenter = o + disp * (uDisplaceAmp * pitch);
|
|
940
|
+
|
|
941
|
+
// The soft circle around the (drifted) dot center.
|
|
942
|
+
float dist = length(p - dotCenter);
|
|
943
|
+
float radius = max(uDotRadiusDomain, 1e-4);
|
|
944
|
+
float mask = 1.0 - smoothstep(radius * 0.6, radius, dist);
|
|
945
|
+
if (mask < 0.002) {
|
|
946
|
+
if (uHasBackground > 0.5) {
|
|
947
|
+
fragColor = vec4(clamp(linearToSrgb(uBg), vec3(0.0), vec3(1.0)), 1.0);
|
|
948
|
+
} else {
|
|
949
|
+
fragColor = vec4(0.0);
|
|
950
|
+
}
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
// The brightness lights the dot — the SWEEPING band over the height at the anchor.
|
|
955
|
+
float h = sampleHeight(o, uTime);
|
|
956
|
+
float band = waveBand(h, uWaveBandCenter, uWaveBandWidth);
|
|
957
|
+
float bright = (uBaseBright + band * uContrast) * globeMask(o, uTime, uGlobeMask);
|
|
958
|
+
bright = clamp(bright, 0.0, 1.6);
|
|
959
|
+
|
|
960
|
+
float tone = clamp(bright, 0.0, 1.0);
|
|
961
|
+
vec3 lin = samplePaletteLin(tone) * bright;
|
|
962
|
+
vec3 rgb = clamp(linearToSrgb(lin), vec3(0.0), vec3(1.0));
|
|
963
|
+
float alpha = mask * clamp(bright * 0.8 + 0.12, 0.0, 1.0);
|
|
964
|
+
|
|
965
|
+
if (uHasBackground > 0.5) {
|
|
966
|
+
vec3 bg = clamp(linearToSrgb(uBg), vec3(0.0), vec3(1.0));
|
|
967
|
+
fragColor = vec4(mix(bg, rgb, alpha), 1.0);
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
fragColor = vec4(rgb * alpha, alpha);
|
|
971
|
+
}`, Oe = "\n#define PI 3.141592653589793\n#define TAU 6.283185307179586\n#define FLOW_GRAVITY 9.81\n#define CURL_EPS 0.012\n#define MAX_WAVE_COMPONENTS 8\nconst mat2 FBM_ROT = mat2(0.8, 0.6, -0.6, 0.8);\n\nuniform float uTime;\nuniform float uWindSpeed;\nuniform float uCurlStrength;\nuniform int uWaveCount;\nuniform vec4 uWaves[MAX_WAVE_COMPONENTS]; // (amplitude, wavelength, directionDeg, phase)\n\nvec2 gerstnerVelocity(vec2 p, float t) {\n float dhdx = 0.0; float dhdy = 0.0;\n for (int i = 0; i < MAX_WAVE_COMPONENTS; i++) {\n if (i >= uWaveCount) break;\n vec4 w = uWaves[i];\n float k = TAU / max(w.y, 1e-4);\n float dirRad = w.z * PI / 180.0;\n vec2 d = vec2(cos(dirRad), sin(dirRad));\n float omega = sqrt(FLOW_GRAVITY * k) * uWindSpeed;\n float theta = k * (d.x * p.x + d.y * p.y) - omega * t + w.w;\n float akc = w.x * k * cos(theta);\n dhdx += akc * d.x; dhdy += akc * d.y;\n }\n return vec2(dhdy, -dhdx);\n}\nfloat hash21f(vec2 p) {\n vec3 p3 = fract(vec3(p.x, p.y, p.x) * 0.1031);\n p3 += dot(p3, p3.yzx + 33.33);\n return fract((p3.x + p3.y) * p3.z);\n}\nfloat valueNoiseF(vec2 p) {\n vec2 i = floor(p); vec2 f = fract(p);\n vec2 u2 = f * f * f * (f * (f * 6.0 - 15.0) + 10.0);\n float a = hash21f(i + vec2(0.0, 0.0));\n float b = hash21f(i + vec2(1.0, 0.0));\n float c = hash21f(i + vec2(0.0, 1.0));\n float d = hash21f(i + vec2(1.0, 1.0));\n return mix(mix(a, b, u2.x), mix(c, d, u2.x), u2.y);\n}\nfloat potentialFBMf(vec2 p0) {\n float v = 0.0; float amp = 0.5; float freq = 1.0; vec2 p = p0;\n for (int i = 0; i < 3; i++) { v += amp * valueNoiseF(p * freq); p = FBM_ROT * p; freq *= 2.0; amp *= 0.5; }\n return v;\n}\nvec2 curlFBMf(vec2 p) {\n float dx = potentialFBMf(p + vec2(CURL_EPS, 0.0)) - potentialFBMf(p - vec2(CURL_EPS, 0.0));\n float dy = potentialFBMf(p + vec2(0.0, CURL_EPS)) - potentialFBMf(p - vec2(0.0, CURL_EPS));\n vec2 g = vec2(dx, dy) / (2.0 * CURL_EPS);\n return vec2(g.y, -g.x);\n}\nvec2 sampleVelocityF(vec2 p, float t) {\n vec2 v = gerstnerVelocity(p, t);\n if (uCurlStrength > 0.0) { v += curlFBMf(vec2(p.x * 0.55 + t * 0.15, p.y * 0.55)) * uCurlStrength; }\n return v;\n}\n", Z = "#version 300 es\nprecision highp float;\nin vec2 aPosition;\nout vec2 vUv;\nvoid main() {\n vUv = aPosition * 0.5 + 0.5; // [0,1] texel space\n gl_Position = vec4(aPosition, 0.0, 1.0);\n}", ke = `#version 300 es
|
|
972
|
+
precision highp float;
|
|
973
|
+
in vec2 vUv;
|
|
974
|
+
out vec4 fragColor;
|
|
975
|
+
|
|
976
|
+
uniform sampler2D uState; // prev particle state (RGBA = pos.xy, speed, life)
|
|
977
|
+
uniform float uDt;
|
|
978
|
+
uniform float uDomainHalf;
|
|
979
|
+
uniform float uTurnRate;
|
|
980
|
+
uniform float uSpeedScale;
|
|
981
|
+
uniform float uLifetimeSec;
|
|
982
|
+
uniform float uEdgeBias;
|
|
983
|
+
uniform vec2 uCursor; // pointer in domain space
|
|
984
|
+
uniform vec2 uPointerVel; // pointer velocity (domain/s)
|
|
985
|
+
uniform float uBurst; // flick-burst impulse
|
|
986
|
+
uniform float uPointerActive; // 0/1
|
|
987
|
+
uniform float uVortexRadius;
|
|
988
|
+
uniform float uVortexSpin;
|
|
989
|
+
uniform float uDragGain;
|
|
990
|
+
uniform float uBurstShove;
|
|
991
|
+
|
|
992
|
+
${Oe}
|
|
993
|
+
|
|
994
|
+
vec2 pointerVortex(vec2 p) {
|
|
995
|
+
if (uPointerActive < 0.5) return vec2(0.0);
|
|
996
|
+
vec2 r = p - uCursor;
|
|
997
|
+
float d = length(r);
|
|
998
|
+
float radius = max(uVortexRadius, 1e-3);
|
|
999
|
+
float fall = exp(-(d * d) / (radius * radius));
|
|
1000
|
+
vec2 swirl = normalize(vec2(-r.y, r.x) + vec2(1e-6, 0.0));
|
|
1001
|
+
vec2 radial = r / max(d, 1e-4);
|
|
1002
|
+
vec2 v = swirl * uVortexSpin + uPointerVel * uDragGain + radial * uBurst * uBurstShove;
|
|
1003
|
+
return v * fall;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
vec2 respawn(vec2 seed, float t) {
|
|
1007
|
+
float rx = hash21f(seed + vec2(t * 0.37, 1.7)) * 2.0 - 1.0;
|
|
1008
|
+
float ry = hash21f(seed.yx + vec2(3.1, t * 0.37)) * 2.0 - 1.0;
|
|
1009
|
+
float bias = clamp(uEdgeBias, 0.0, 1.0);
|
|
1010
|
+
float bx = sign(rx) * pow(abs(rx), mix(1.0, 0.5, bias));
|
|
1011
|
+
float by = sign(ry) * pow(abs(ry), mix(1.0, 0.5, bias));
|
|
1012
|
+
return vec2(bx, by) * uDomainHalf;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
void main() {
|
|
1016
|
+
vec4 st = texture(uState, vUv);
|
|
1017
|
+
vec2 pos = st.xy;
|
|
1018
|
+
float life = st.w;
|
|
1019
|
+
float half = uDomainHalf;
|
|
1020
|
+
|
|
1021
|
+
bool dead = life <= 0.0;
|
|
1022
|
+
bool outOfDomain = max(abs(pos.x), abs(pos.y)) > half * 1.05;
|
|
1023
|
+
if (dead || outOfDomain) {
|
|
1024
|
+
pos = respawn(vUv, uTime);
|
|
1025
|
+
life = max(uLifetimeSec, 1e-3) * hash21f(vUv * 7.0 + uTime * 0.11);
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
vec2 vField = sampleVelocityF(pos, uTime) + pointerVortex(pos);
|
|
1029
|
+
// momentum: low turnRate = weighty arcs (eases into the current's turns).
|
|
1030
|
+
vec2 v = vField * uTurnRate * uSpeedScale;
|
|
1031
|
+
// forward-Euler advection (pos = pos + v*dt — the integrand twin of cs_flow).
|
|
1032
|
+
pos = pos + v * uDt * 60.0;
|
|
1033
|
+
life = life - uDt;
|
|
1034
|
+
|
|
1035
|
+
fragColor = vec4(pos, length(v), life);
|
|
1036
|
+
}`, Ae = "#version 300 es\nprecision highp float;\nuniform sampler2D uState;\nuniform int uStateCols;\nuniform float uDomainHalf;\nuniform float uPointSize;\nuniform float uSpeedNorm; // the speed→[0,1] normalizer (modal-speed at ramp middle)\nuniform float uStretchAmp;\nout float vSpeedNorm;\nout float vFade;\nvoid main() {\n int id = gl_VertexID;\n int col = id % uStateCols;\n int row = id / uStateCols;\n vec2 uv = (vec2(float(col), float(row)) + 0.5) / float(uStateCols);\n vec4 st = texture(uState, uv);\n vec2 pos = st.xy;\n float speed = st.z;\n float life = st.w;\n float sn = clamp(speed / max(uSpeedNorm, 1e-4), 0.0, 1.0);\n vSpeedNorm = sn;\n vFade = clamp(life * 3.0, 0.0, 1.0);\n // NDC: domain [-half,half] → [-1,1].\n gl_Position = vec4(pos / uDomainHalf, 0.0, 1.0);\n // faster motes read as larger hot speed-cores (the cartoon \"more\" as point size).\n gl_PointSize = max(uPointSize * (1.0 + sn * (uStretchAmp + 1.0)), 1.0);\n}", je = `#version 300 es
|
|
1037
|
+
precision highp float;
|
|
1038
|
+
#define MAX_FLOW_STOPS 4
|
|
1039
|
+
in float vSpeedNorm;
|
|
1040
|
+
in float vFade;
|
|
1041
|
+
out vec4 fragColor;
|
|
1042
|
+
uniform int uStopCount;
|
|
1043
|
+
uniform vec3 uPalette[MAX_FLOW_STOPS];
|
|
1044
|
+
uniform float uSpeedGlow;
|
|
1045
|
+
|
|
1046
|
+
${r}
|
|
1047
|
+
${a}
|
|
1048
|
+
|
|
1049
|
+
vec3 samplePaletteLin(float t) {
|
|
1050
|
+
if (uStopCount <= 1) return uPalette[0];
|
|
1051
|
+
float n = float(uStopCount);
|
|
1052
|
+
float ft = clamp(t, 0.0, 1.0) * (n - 1.0);
|
|
1053
|
+
int i0 = int(floor(ft));
|
|
1054
|
+
int i1 = min(i0 + 1, uStopCount - 1);
|
|
1055
|
+
float f = ft - float(i0);
|
|
1056
|
+
vec3 lmsA = LINEAR_SRGB_TO_LMS * uPalette[i0];
|
|
1057
|
+
vec3 lmsB = LINEAR_SRGB_TO_LMS * uPalette[i1];
|
|
1058
|
+
vec3 labA = LMS_TO_OKLAB * (sign(lmsA) * pow(abs(lmsA), vec3(1.0 / 3.0)));
|
|
1059
|
+
vec3 labB = LMS_TO_OKLAB * (sign(lmsB) * pow(abs(lmsB), vec3(1.0 / 3.0)));
|
|
1060
|
+
return oklabToLinearSrgb(mix(labA, labB, f));
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
void main() {
|
|
1064
|
+
// soft round sprite — a tight hot core (mask² caps the white wash, H2).
|
|
1065
|
+
vec2 pc = gl_PointCoord * 2.0 - 1.0;
|
|
1066
|
+
float r = length(pc);
|
|
1067
|
+
float mask = 1.0 - smoothstep(0.55, 1.0, r);
|
|
1068
|
+
if (mask < 0.002) discard;
|
|
1069
|
+
float core = mask * mask;
|
|
1070
|
+
float bright = (0.35 + vSpeedNorm * uSpeedGlow) * vFade;
|
|
1071
|
+
vec3 lin = samplePaletteLin(vSpeedNorm) * bright;
|
|
1072
|
+
vec3 rgb = clamp(linearToSrgb(lin), vec3(0.0), vec3(1.0));
|
|
1073
|
+
float a = core * clamp(bright, 0.0, 1.0);
|
|
1074
|
+
fragColor = vec4(rgb * a, a); // additive premultiplied (the trail braids the ribbons)
|
|
1075
|
+
}`, Me = "#version 300 es\nprecision highp float;\nin vec2 vUv;\nout vec4 fragColor;\nuniform sampler2D uPrev;\nuniform float uDecay; // per-frame trail persistence (DERIVED from trailHalfLife)\nvoid main() {\n vec4 prev = texture(uPrev, vUv);\n fragColor = prev * uDecay; // fade toward black; the warm floor is the present-blit's\n}", Ne = `#version 300 es
|
|
1076
|
+
precision highp float;
|
|
1077
|
+
in vec2 vUv;
|
|
1078
|
+
out vec4 fragColor;
|
|
1079
|
+
uniform sampler2D uTrail;
|
|
1080
|
+
uniform vec3 uFloor; // the deep warm-near-black floor (linear-sRGB)
|
|
1081
|
+
uniform vec3 uBloomColor; // the warm rose/magenta corner-bloom (linear-sRGB)
|
|
1082
|
+
uniform float uHasGround; // 0 → transparent (compose over the page field); 1 → opaque floor
|
|
1083
|
+
|
|
1084
|
+
${r}
|
|
1085
|
+
|
|
1086
|
+
void main() {
|
|
1087
|
+
vec3 trail = texture(uTrail, vUv).rgb;
|
|
1088
|
+
// soft tone-map the accumulated additive trail (Reinhard — hot cores, not white wash).
|
|
1089
|
+
vec3 mapped = trail / (trail + vec3(0.85));
|
|
1090
|
+
if (uHasGround < 0.5) {
|
|
1091
|
+
// compose OVER the page's warm field: emit the lit ribbons premultiplied, no floor.
|
|
1092
|
+
vec3 rgb = clamp(linearToSrgb(mapped), vec3(0.0), vec3(1.0));
|
|
1093
|
+
float a = clamp(max(mapped.r, max(mapped.g, mapped.b)), 0.0, 1.0);
|
|
1094
|
+
fragColor = vec4(rgb * a, a);
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
// the corner-bloom: a faint warm rose radial in one corner (NOT teal).
|
|
1098
|
+
float bloom = smoothstep(1.3, 0.0, distance(vUv, vec2(0.12, 0.88)));
|
|
1099
|
+
vec3 floorLin = uFloor + uBloomColor * bloom * 0.5;
|
|
1100
|
+
vec3 lin = floorLin + mapped; // the ribbons sit OVER the warm floor
|
|
1101
|
+
vec3 rgb = clamp(linearToSrgb(lin), vec3(0.0), vec3(1.0));
|
|
1102
|
+
fragColor = vec4(rgb, 1.0);
|
|
1103
|
+
}`;
|
|
1104
|
+
//#endregion
|
|
1105
|
+
//#region src/components/custom/dot-flow-field/composables/flowGLProgram.ts
|
|
1106
|
+
function Pe(e, t, n) {
|
|
1107
|
+
let r = e.createShader(t);
|
|
1108
|
+
if (e.shaderSource(r, n), e.compileShader(r), !e.getShaderParameter(r, e.COMPILE_STATUS)) {
|
|
1109
|
+
let t = e.getShaderInfoLog(r);
|
|
1110
|
+
throw e.deleteShader(r), Error(`[DotFlowField] shader compile failed: ${t}`);
|
|
1111
|
+
}
|
|
1112
|
+
return r;
|
|
1113
|
+
}
|
|
1114
|
+
function Q(e, t, n) {
|
|
1115
|
+
let r = Pe(e, e.VERTEX_SHADER, t), i = Pe(e, e.FRAGMENT_SHADER, n), a = e.createProgram();
|
|
1116
|
+
if (e.attachShader(a, r), e.attachShader(a, i), e.linkProgram(a), !e.getProgramParameter(a, e.LINK_STATUS)) throw Error(`[DotFlowField] link failed: ${e.getProgramInfoLog(a)}`);
|
|
1117
|
+
return e.deleteShader(r), e.deleteShader(i), a;
|
|
1118
|
+
}
|
|
1119
|
+
function Fe(e, t, n) {
|
|
1120
|
+
let r = e.createTexture(), i = e.createFramebuffer();
|
|
1121
|
+
e.bindTexture(e.TEXTURE_2D, r), e.texImage2D(e.TEXTURE_2D, 0, t, 2, 2, 0, e.RGBA, n, null), e.bindFramebuffer(e.FRAMEBUFFER, i), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, r, 0);
|
|
1122
|
+
let a = e.checkFramebufferStatus(e.FRAMEBUFFER) === e.FRAMEBUFFER_COMPLETE;
|
|
1123
|
+
return e.bindFramebuffer(e.FRAMEBUFFER, null), e.deleteFramebuffer(i), e.deleteTexture(r), a;
|
|
1124
|
+
}
|
|
1125
|
+
function Ie(e) {
|
|
1126
|
+
let t = new Uint16Array(e.length);
|
|
1127
|
+
for (let n = 0; n < e.length; n++) t[n] = Le(e[n]);
|
|
1128
|
+
return t;
|
|
1129
|
+
}
|
|
1130
|
+
function Le(e) {
|
|
1131
|
+
let t = new Float32Array(1), n = new Int32Array(t.buffer);
|
|
1132
|
+
t[0] = e;
|
|
1133
|
+
let r = n[0], i = r >> 16 & 32768, a = (r >> 23 & 255) - 127 + 15, o = r & 8388607;
|
|
1134
|
+
return a <= 0 ? i : a >= 31 ? i | 31744 : (o >>= 13, i | a << 10 | o);
|
|
1135
|
+
}
|
|
1136
|
+
//#endregion
|
|
1137
|
+
//#region src/components/custom/dot-flow-field/composables/flowSetupGLFlow.ts
|
|
1138
|
+
function Re(e) {
|
|
1139
|
+
let { canvas: t, config: n, getPalette: r, shouldContinue: i, onFrame: a, getPointer: s } = e;
|
|
1140
|
+
return function(e) {
|
|
1141
|
+
let l = He(n), u = Ue(l);
|
|
1142
|
+
e.getExtension("EXT_color_buffer_float"), e.getExtension("EXT_color_buffer_half_float"), e.getExtension("OES_texture_float_linear");
|
|
1143
|
+
let d = Fe(e, e.RGBA32F, e.FLOAT) ? {
|
|
1144
|
+
internal: e.RGBA32F,
|
|
1145
|
+
type: e.FLOAT
|
|
1146
|
+
} : {
|
|
1147
|
+
internal: e.RGBA16F,
|
|
1148
|
+
type: e.HALF_FLOAT
|
|
1149
|
+
}, f = Fe(e, e.RGBA16F, e.HALF_FLOAT) ? {
|
|
1150
|
+
internal: e.RGBA16F,
|
|
1151
|
+
type: e.HALF_FLOAT
|
|
1152
|
+
} : {
|
|
1153
|
+
internal: e.RGBA8,
|
|
1154
|
+
type: e.UNSIGNED_BYTE
|
|
1155
|
+
}, p = Q(e, Z, ke), m = Q(e, Ae, je), h = Q(e, Z, Me), g = Q(e, Z, Ne), _ = e.createVertexArray();
|
|
1156
|
+
e.bindVertexArray(_);
|
|
1157
|
+
let v = e.createBuffer();
|
|
1158
|
+
e.bindBuffer(e.ARRAY_BUFFER, v), e.bufferData(e.ARRAY_BUFFER, new Float32Array([
|
|
1159
|
+
-1,
|
|
1160
|
+
-1,
|
|
1161
|
+
3,
|
|
1162
|
+
-1,
|
|
1163
|
+
-1,
|
|
1164
|
+
3
|
|
1165
|
+
]), e.STATIC_DRAW);
|
|
1166
|
+
for (let t of [
|
|
1167
|
+
p,
|
|
1168
|
+
h,
|
|
1169
|
+
g
|
|
1170
|
+
]) {
|
|
1171
|
+
let n = e.getAttribLocation(t, "aPosition");
|
|
1172
|
+
n >= 0 && (e.enableVertexAttribArray(n), e.vertexAttribPointer(n, 2, e.FLOAT, !1, 0, 0));
|
|
1173
|
+
}
|
|
1174
|
+
e.bindVertexArray(null);
|
|
1175
|
+
let y = e.createVertexArray(), b = he(l, n.lifetimeSec), x = new Float32Array(u * u * 4);
|
|
1176
|
+
x.set(b.subarray(0, Math.min(b.length, x.length)));
|
|
1177
|
+
function S(t) {
|
|
1178
|
+
let n = e.createTexture();
|
|
1179
|
+
e.bindTexture(e.TEXTURE_2D, n), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE);
|
|
1180
|
+
let r = t && d.type === e.FLOAT ? t : t ? Ie(t) : null;
|
|
1181
|
+
return e.texImage2D(e.TEXTURE_2D, 0, d.internal, u, u, 0, e.RGBA, d.type, r), n;
|
|
1182
|
+
}
|
|
1183
|
+
let C = [S(x), S(null)], w = [e.createFramebuffer(), e.createFramebuffer()];
|
|
1184
|
+
for (let t = 0; t < 2; t++) e.bindFramebuffer(e.FRAMEBUFFER, w[t]), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, C[t], 0);
|
|
1185
|
+
e.bindFramebuffer(e.FRAMEBUFFER, null);
|
|
1186
|
+
let T = null, E = null, D = 2, O = 2;
|
|
1187
|
+
function k() {
|
|
1188
|
+
let r = Math.min(Math.max(n.trailScale, .25), 1);
|
|
1189
|
+
D = Math.max(2, Math.round(t.width * r)), O = Math.max(2, Math.round(t.height * r)), T?.forEach((t) => e.deleteTexture(t)), E?.forEach((t) => e.deleteFramebuffer(t));
|
|
1190
|
+
let i = () => {
|
|
1191
|
+
let t = e.createTexture();
|
|
1192
|
+
return e.bindTexture(e.TEXTURE_2D, t), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), e.texImage2D(e.TEXTURE_2D, 0, f.internal, D, O, 0, e.RGBA, f.type, null), t;
|
|
1193
|
+
}, a = i(), o = i();
|
|
1194
|
+
T = [a, o];
|
|
1195
|
+
let s = e.createFramebuffer(), c = e.createFramebuffer();
|
|
1196
|
+
e.bindFramebuffer(e.FRAMEBUFFER, s), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, a, 0), e.bindFramebuffer(e.FRAMEBUFFER, c), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, o, 0), e.bindFramebuffer(e.FRAMEBUFFER, null);
|
|
1197
|
+
for (let t of [s, c]) e.bindFramebuffer(e.FRAMEBUFFER, t), e.viewport(0, 0, D, O), e.clearColor(0, 0, 0, 0), e.clear(e.COLOR_BUFFER_BIT);
|
|
1198
|
+
e.bindFramebuffer(e.FRAMEBUFFER, null), E = [s, c];
|
|
1199
|
+
}
|
|
1200
|
+
let A = (t) => e.getUniformLocation(p, t), j = {
|
|
1201
|
+
uState: A("uState"),
|
|
1202
|
+
uDt: A("uDt"),
|
|
1203
|
+
uDomainHalf: A("uDomainHalf"),
|
|
1204
|
+
uTurnRate: A("uTurnRate"),
|
|
1205
|
+
uSpeedScale: A("uSpeedScale"),
|
|
1206
|
+
uLifetimeSec: A("uLifetimeSec"),
|
|
1207
|
+
uEdgeBias: A("uEdgeBias"),
|
|
1208
|
+
uCursor: A("uCursor"),
|
|
1209
|
+
uPointerVel: A("uPointerVel"),
|
|
1210
|
+
uBurst: A("uBurst"),
|
|
1211
|
+
uPointerActive: A("uPointerActive"),
|
|
1212
|
+
uVortexRadius: A("uVortexRadius"),
|
|
1213
|
+
uVortexSpin: A("uVortexSpin"),
|
|
1214
|
+
uDragGain: A("uDragGain"),
|
|
1215
|
+
uBurstShove: A("uBurstShove"),
|
|
1216
|
+
uTime: A("uTime"),
|
|
1217
|
+
uWindSpeed: A("uWindSpeed"),
|
|
1218
|
+
uCurlStrength: A("uCurlStrength"),
|
|
1219
|
+
uWaveCount: A("uWaveCount"),
|
|
1220
|
+
uWaves: A("uWaves[0]")
|
|
1221
|
+
}, M = (t) => e.getUniformLocation(m, t), N = {
|
|
1222
|
+
uState: M("uState"),
|
|
1223
|
+
uStateCols: M("uStateCols"),
|
|
1224
|
+
uDomainHalf: M("uDomainHalf"),
|
|
1225
|
+
uPointSize: M("uPointSize"),
|
|
1226
|
+
uSpeedNorm: M("uSpeedNorm"),
|
|
1227
|
+
uStretchAmp: M("uStretchAmp"),
|
|
1228
|
+
uStopCount: M("uStopCount"),
|
|
1229
|
+
uPalette: M("uPalette[0]"),
|
|
1230
|
+
uSpeedGlow: M("uSpeedGlow")
|
|
1231
|
+
}, P = (t) => e.getUniformLocation(h, t), F = {
|
|
1232
|
+
uPrev: P("uPrev"),
|
|
1233
|
+
uDecay: P("uDecay")
|
|
1234
|
+
}, I = (t) => e.getUniformLocation(g, t), L = {
|
|
1235
|
+
uTrail: I("uTrail"),
|
|
1236
|
+
uFloor: I("uFloor"),
|
|
1237
|
+
uBloom: I("uBloomColor"),
|
|
1238
|
+
uHasGround: I("uHasGround")
|
|
1239
|
+
}, R = 0, z = -1;
|
|
1240
|
+
function B() {
|
|
1241
|
+
let e = o(), n = t.clientWidth || 320, r = t.clientHeight || 320, i = Math.max(1, Math.round(n * e)), a = Math.max(1, Math.round(r * e));
|
|
1242
|
+
(t.width !== i || t.height !== a) && (t.width = i, t.height = a), k();
|
|
1243
|
+
}
|
|
1244
|
+
function V(i) {
|
|
1245
|
+
a?.(i), (!E || !T) && k();
|
|
1246
|
+
let d = z < 0 ? 0 : Math.min(Math.max(i - z, 0), .05);
|
|
1247
|
+
z = i;
|
|
1248
|
+
let f = s?.(), v = R, b = 1 - R;
|
|
1249
|
+
e.disable(e.BLEND), e.bindFramebuffer(e.FRAMEBUFFER, w[v]), e.viewport(0, 0, u, u), e.useProgram(p), e.bindVertexArray(_), e.activeTexture(e.TEXTURE0), e.bindTexture(e.TEXTURE_2D, C[b]), e.uniform1i(j.uState, 0), e.uniform1f(j.uDt, d), e.uniform1f(j.uDomainHalf, W), e.uniform1f(j.uTurnRate, n.turnRate), e.uniform1f(j.uSpeedScale, n.speedScale), e.uniform1f(j.uLifetimeSec, n.lifetimeSec), e.uniform1f(j.uEdgeBias, n.edgeBias), e.uniform1f(j.uTime, i), e.uniform1f(j.uWindSpeed, n.windSpeed), e.uniform1f(j.uCurlStrength, n.curlStrength), e.uniform1f(j.uVortexRadius, n.vortexRadius), e.uniform1f(j.uVortexSpin, n.vortexSpin), e.uniform1f(j.uDragGain, n.dragGain), e.uniform1f(j.uBurstShove, n.burstShove), f ? (e.uniform2f(j.uCursor, f.cursorX, f.cursorY), e.uniform2f(j.uPointerVel, f.velX, f.velY), e.uniform1f(j.uBurst, f.burst), e.uniform1f(j.uPointerActive, f.active)) : e.uniform1f(j.uPointerActive, 0);
|
|
1250
|
+
let x = Math.min(n.waveComponents.length, 8);
|
|
1251
|
+
e.uniform1i(j.uWaveCount, x);
|
|
1252
|
+
let S = new Float32Array(32);
|
|
1253
|
+
for (let e = 0; e < 8; e++) {
|
|
1254
|
+
let t = n.waveComponents[e];
|
|
1255
|
+
S[e * 4 + 0] = t?.amplitude ?? 0, S[e * 4 + 1] = t?.wavelength ?? 1, S[e * 4 + 2] = t?.direction ?? 0, S[e * 4 + 3] = t?.phase ?? 0;
|
|
1256
|
+
}
|
|
1257
|
+
e.uniform4fv(j.uWaves, S), e.drawArrays(e.TRIANGLES, 0, 3), e.bindFramebuffer(e.FRAMEBUFFER, E[v]), e.viewport(0, 0, D, O), e.disable(e.BLEND), e.useProgram(h), e.bindVertexArray(_), e.activeTexture(e.TEXTURE0), e.bindTexture(e.TEXTURE_2D, T[b]), e.uniform1i(F.uPrev, 0), e.uniform1f(F.uDecay, ee(n.trailHalfLife)), e.drawArrays(e.TRIANGLES, 0, 3), e.enable(e.BLEND), e.blendFunc(e.ONE, e.ONE), e.useProgram(m), e.bindVertexArray(y), e.activeTexture(e.TEXTURE0), e.bindTexture(e.TEXTURE_2D, C[v]), e.uniform1i(N.uState, 0), e.uniform1i(N.uStateCols, u), e.uniform1f(N.uDomainHalf, W);
|
|
1258
|
+
let A = o();
|
|
1259
|
+
e.uniform1f(N.uPointSize, Math.max(n.dotSize * A * 1.5, 1)), e.uniform1f(N.uSpeedNorm, se), e.uniform1f(N.uStretchAmp, n.stretchAmp), e.uniform1f(N.uSpeedGlow, n.speedGlow);
|
|
1260
|
+
let M = r(), P = Math.min(M.length, 4);
|
|
1261
|
+
e.uniform1i(N.uStopCount, P);
|
|
1262
|
+
let I = new Float32Array(12);
|
|
1263
|
+
for (let e = 0; e < 4; e++) {
|
|
1264
|
+
let t = c(M[Math.min(e, P - 1)] ?? M[0]);
|
|
1265
|
+
I[e * 3 + 0] = t[0], I[e * 3 + 1] = t[1], I[e * 3 + 2] = t[2];
|
|
1266
|
+
}
|
|
1267
|
+
e.uniform3fv(N.uPalette, I), e.drawArrays(e.POINTS, 0, l), e.bindFramebuffer(e.FRAMEBUFFER, null), e.viewport(0, 0, t.width, t.height), e.disable(e.BLEND), e.useProgram(g), e.bindVertexArray(_), e.activeTexture(e.TEXTURE0), e.bindTexture(e.TEXTURE_2D, T[v]), e.uniform1i(L.uTrail, 0);
|
|
1268
|
+
let B = n.background === "transparent" ? 0 : 1, V = c(n.background === "transparent" ? Be : n.background), H = c(Ve);
|
|
1269
|
+
e.uniform3f(L.uFloor, V[0], V[1], V[2]), e.uniform3f(L.uBloom, H[0], H[1], H[2]), e.uniform1f(L.uHasGround, B), e.drawArrays(e.TRIANGLES, 0, 3), e.bindVertexArray(null), R = b;
|
|
1270
|
+
}
|
|
461
1271
|
return {
|
|
462
|
-
|
|
463
|
-
|
|
1272
|
+
frame: V,
|
|
1273
|
+
shouldContinue: i,
|
|
1274
|
+
resize: B,
|
|
1275
|
+
teardown: () => {
|
|
1276
|
+
e.deleteProgram(p), e.deleteProgram(m), e.deleteProgram(h), e.deleteProgram(g), e.deleteVertexArray(_), e.deleteVertexArray(y), e.deleteBuffer(v), C.forEach((t) => e.deleteTexture(t)), w.forEach((t) => e.deleteFramebuffer(t)), T?.forEach((t) => e.deleteTexture(t)), E?.forEach((t) => e.deleteFramebuffer(t));
|
|
1277
|
+
}
|
|
464
1278
|
};
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
1279
|
+
};
|
|
1280
|
+
}
|
|
1281
|
+
//#endregion
|
|
1282
|
+
//#region src/components/custom/dot-flow-field/composables/flowSetupGL.ts
|
|
1283
|
+
function ze(e) {
|
|
1284
|
+
if (e.config.mode === "flow") return Re(e);
|
|
1285
|
+
let { canvas: t, config: n, getPalette: r, shouldContinue: i, onFrame: a } = e;
|
|
1286
|
+
return function(e) {
|
|
1287
|
+
let s = Q(e, Ee, De), l = e.createVertexArray();
|
|
1288
|
+
e.bindVertexArray(l);
|
|
1289
|
+
let u = e.createBuffer();
|
|
1290
|
+
e.bindBuffer(e.ARRAY_BUFFER, u), e.bufferData(e.ARRAY_BUFFER, new Float32Array([
|
|
1291
|
+
-1,
|
|
1292
|
+
-1,
|
|
1293
|
+
3,
|
|
1294
|
+
-1,
|
|
1295
|
+
-1,
|
|
1296
|
+
3
|
|
1297
|
+
]), e.STATIC_DRAW);
|
|
1298
|
+
let d = e.getAttribLocation(s, "aPosition");
|
|
1299
|
+
e.enableVertexAttribArray(d), e.vertexAttribPointer(d, 2, e.FLOAT, !1, 0, 0), e.bindVertexArray(null);
|
|
1300
|
+
let f = (t) => e.getUniformLocation(s, t), p = f("uTime"), m = f("uWindSpeed"), h = f("uCurlStrength"), g = f("uDomainHalf"), _ = f("uAspect"), v = f("uGridPitchDomain"), y = f("uDotRadiusDomain"), b = f("uDisplaceAmp"), x = f("uContrast"), S = f("uBaseBright"), C = f("uWaveBandCenter"), w = f("uWaveBandWidth"), T = f("uGlobeMask"), E = f("uWaveCount"), D = f("uStopCount"), O = f("uHasBackground"), k = f("uBg"), A = f("uWaves[0]"), j = f("uPalette[0]");
|
|
1301
|
+
function M() {
|
|
1302
|
+
let n = o(), r = t.clientWidth || 320, i = t.clientHeight || 320, a = Math.max(1, Math.round(r * n)), s = Math.max(1, Math.round(i * n));
|
|
1303
|
+
(t.width !== a || t.height !== s) && (t.width = a, t.height = s), e.viewport(0, 0, t.width, t.height);
|
|
480
1304
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
1305
|
+
function N(i) {
|
|
1306
|
+
a?.(i);
|
|
1307
|
+
let o = $(t), u = (t.clientWidth || 320) / Math.max(t.clientHeight || 320, 1), d = G(n.gridPitch, o), f = o / (2 * W), M = n.dotSize / Math.max(f, 1e-4);
|
|
1308
|
+
e.useProgram(s), e.bindVertexArray(l), e.enable(e.BLEND), e.blendFunc(e.ONE, e.ONE_MINUS_SRC_ALPHA), e.clearColor(0, 0, 0, 0), e.clear(e.COLOR_BUFFER_BIT), e.uniform1f(p, i), e.uniform1f(m, n.windSpeed), e.uniform1f(h, n.curlStrength), e.uniform1f(g, W), e.uniform1f(_, u), e.uniform1f(v, d.pitchDomain), e.uniform1f(y, M), e.uniform1f(b, n.displaceAmp), e.uniform1f(x, n.contrast), e.uniform1f(S, le), e.uniform1f(C, n.waveBandCenter), e.uniform1f(w, n.waveBandWidth), e.uniform1f(T, +!!n.globeMask);
|
|
1309
|
+
let N = Math.min(n.waveComponents.length, 8), P = r(), F = Math.min(P.length, 4);
|
|
1310
|
+
if (e.uniform1i(E, N), e.uniform1i(D, F), n.background === "transparent") e.uniform1f(O, 0), e.uniform3f(k, 0, 0, 0);
|
|
1311
|
+
else {
|
|
1312
|
+
e.uniform1f(O, 1);
|
|
1313
|
+
let t = c(n.background);
|
|
1314
|
+
e.uniform3f(k, t[0], t[1], t[2]);
|
|
1315
|
+
}
|
|
1316
|
+
let I = new Float32Array(32);
|
|
1317
|
+
for (let e = 0; e < 8; e++) {
|
|
1318
|
+
let t = n.waveComponents[e];
|
|
1319
|
+
I[e * 4 + 0] = t?.amplitude ?? 0, I[e * 4 + 1] = t?.wavelength ?? 1, I[e * 4 + 2] = t?.direction ?? 0, I[e * 4 + 3] = t?.phase ?? 0;
|
|
1320
|
+
}
|
|
1321
|
+
e.uniform4fv(A, I);
|
|
1322
|
+
let L = new Float32Array(12);
|
|
1323
|
+
for (let e = 0; e < 4; e++) {
|
|
1324
|
+
let t = c(P[Math.min(e, F - 1)] ?? P[0]);
|
|
1325
|
+
L[e * 3 + 0] = t[0], L[e * 3 + 1] = t[1], L[e * 3 + 2] = t[2];
|
|
1326
|
+
}
|
|
1327
|
+
e.uniform3fv(j, L), e.drawArrays(e.TRIANGLES, 0, 3), e.bindVertexArray(null);
|
|
490
1328
|
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
1329
|
+
return {
|
|
1330
|
+
frame: N,
|
|
1331
|
+
shouldContinue: i,
|
|
1332
|
+
resize: M,
|
|
1333
|
+
teardown: () => {
|
|
1334
|
+
e.deleteProgram(s), e.deleteVertexArray(l), e.deleteBuffer(u);
|
|
1335
|
+
}
|
|
1336
|
+
};
|
|
497
1337
|
};
|
|
498
1338
|
}
|
|
499
1339
|
//#endregion
|
|
1340
|
+
//#region src/components/custom/dot-flow-field/composables/useFlowParticles.ts
|
|
1341
|
+
var Be = {
|
|
1342
|
+
L: .11,
|
|
1343
|
+
C: .012,
|
|
1344
|
+
h: 50
|
|
1345
|
+
}, Ve = {
|
|
1346
|
+
L: .5,
|
|
1347
|
+
C: .16,
|
|
1348
|
+
h: 330
|
|
1349
|
+
};
|
|
1350
|
+
function $(e) {
|
|
1351
|
+
return Math.min(e.clientWidth || 320, e.clientHeight || 320);
|
|
1352
|
+
}
|
|
1353
|
+
function He(e) {
|
|
1354
|
+
return Math.min(Math.max(Math.floor(e.particleCount), 1), te);
|
|
1355
|
+
}
|
|
1356
|
+
function Ue(e) {
|
|
1357
|
+
return Math.max(1, Math.ceil(Math.sqrt(e)));
|
|
1358
|
+
}
|
|
1359
|
+
//#endregion
|
|
500
1360
|
//#region src/components/custom/dot-flow-field/composables/useDotFlowField.ts
|
|
501
|
-
function
|
|
502
|
-
let { config:
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
1361
|
+
function We(e, n) {
|
|
1362
|
+
let { config: r, getPalette: i } = n, a = n.mode ?? "live", o = t({ respectReducedMotion: r.respectReducedMotion }), c = {
|
|
1363
|
+
displaceBoost: 1,
|
|
1364
|
+
bloom: 0
|
|
1365
|
+
}, l = { ...re }, u = () => {
|
|
1366
|
+
if (!r.interactive || !o.active.value) return l.active = 0, l;
|
|
1367
|
+
let e = o.position.value, t = o.velocity.value, n = 2 * W;
|
|
1368
|
+
return l.cursorX = (e.x * 2 - 1) * W, l.cursorY = (1 - e.y * 2) * W, l.velX = t.x * n, l.velY = -t.y * n, l.burst = o.burst.value, l.active = 1, l;
|
|
1369
|
+
}, d = { ...r }, f = () => (Object.assign(d, r), d.displaceAmp = r.displaceAmp * c.displaceBoost, d.contrast = r.contrast * (1 + c.bloom * .8), d), p = null, h = 0;
|
|
1370
|
+
function g(e) {
|
|
1371
|
+
let t = h > 0 ? (e - h) * 1e3 : 16.7;
|
|
1372
|
+
if (h = e, o.tick(t), !r.interactive || !o.active.value) {
|
|
1373
|
+
c.displaceBoost += (1 - c.displaceBoost) * .1, c.bloom *= .9;
|
|
1374
|
+
return;
|
|
1375
|
+
}
|
|
1376
|
+
let n = o.speed.value, i = 1 + Math.min(2.5, n * 3);
|
|
1377
|
+
c.displaceBoost += (i - c.displaceBoost) * .2, c.bloom = Math.max(c.bloom * .9, o.burst.value);
|
|
1378
|
+
}
|
|
1379
|
+
let _ = () => {
|
|
1380
|
+
o.onPointerEnter(), r.interactive && p?.wake();
|
|
1381
|
+
}, v = (e) => {
|
|
1382
|
+
o.onPointerMove(e), r.interactive && p?.wake();
|
|
1383
|
+
}, y = (e) => e.parentElement ?? e;
|
|
1384
|
+
function b(e) {
|
|
1385
|
+
let t = y(e);
|
|
1386
|
+
t.addEventListener("pointermove", v), t.addEventListener("pointerenter", _), t.addEventListener("pointerleave", o.onPointerLeave);
|
|
1387
|
+
}
|
|
1388
|
+
function x(e) {
|
|
1389
|
+
let t = y(e);
|
|
1390
|
+
t.removeEventListener("pointermove", v), t.removeEventListener("pointerenter", _), t.removeEventListener("pointerleave", o.onPointerLeave);
|
|
1391
|
+
}
|
|
1392
|
+
let S = () => {
|
|
1393
|
+
let t = e.value;
|
|
1394
|
+
if (!t) return null;
|
|
1395
|
+
if (!p) {
|
|
1396
|
+
b(t);
|
|
1397
|
+
let e = {
|
|
1398
|
+
canvas: t,
|
|
1399
|
+
config: f(),
|
|
1400
|
+
getPalette: i,
|
|
1401
|
+
getPointer: u,
|
|
1402
|
+
shouldContinue: () => !0,
|
|
1403
|
+
onFrame: g
|
|
1404
|
+
};
|
|
1405
|
+
p = s(t, {
|
|
1406
|
+
mode: a,
|
|
1407
|
+
respectReducedMotion: r.respectReducedMotion,
|
|
1408
|
+
setupWGPU: Te({
|
|
1409
|
+
...e,
|
|
1410
|
+
config: d,
|
|
1411
|
+
onFrame: (e) => {
|
|
1412
|
+
g(e), f();
|
|
1413
|
+
}
|
|
515
1414
|
}),
|
|
516
|
-
setupGL: (
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
1415
|
+
setupGL: ze({
|
|
1416
|
+
...e,
|
|
1417
|
+
config: d,
|
|
1418
|
+
onFrame: (e) => {
|
|
1419
|
+
g(e), f();
|
|
1420
|
+
}
|
|
520
1421
|
})
|
|
521
|
-
}),
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
resume: () => r()?.resume("manual"),
|
|
530
|
-
wake: () => r()?.wake(),
|
|
531
|
-
renderAt: (e) => r()?.renderAt(e),
|
|
532
|
-
get reducedMotion() {
|
|
533
|
-
return e?.reducedMotion ?? !1;
|
|
534
|
-
},
|
|
535
|
-
dispose: () => e?.dispose()
|
|
536
|
-
};
|
|
537
|
-
return m(() => i.dispose()), i;
|
|
538
|
-
}
|
|
539
|
-
let l = se(a), u = -1, d = e({
|
|
540
|
-
canvas: () => t.value,
|
|
541
|
-
respectReducedMotion: a.respectReducedMotion,
|
|
542
|
-
autoStart: s === "live",
|
|
543
|
-
setup: (e) => ({ render: (e, n) => {
|
|
544
|
-
let r = n / 1e3, i = u < 0 ? 0 : Math.min(Math.max((n - u) / 1e3, 0), .05);
|
|
545
|
-
u = n, i > 0 && l.step(i, r);
|
|
546
|
-
let s = t.value, d = s?.clientWidth || 320, f = s?.clientHeight || 320, p = o()[0] ?? a.palette[0];
|
|
547
|
-
l.paint(e, d, f, r, c(p));
|
|
548
|
-
} })
|
|
549
|
-
}), f = {
|
|
550
|
-
backend: "webgl2",
|
|
551
|
-
pause: () => d.suspend("manual"),
|
|
552
|
-
resume: () => d.resume("manual"),
|
|
553
|
-
wake: () => d.wake(),
|
|
554
|
-
renderAt: () => {
|
|
555
|
-
d.wake();
|
|
1422
|
+
}), p.armAsync();
|
|
1423
|
+
}
|
|
1424
|
+
return p;
|
|
1425
|
+
};
|
|
1426
|
+
queueMicrotask(() => S());
|
|
1427
|
+
let C = {
|
|
1428
|
+
get backend() {
|
|
1429
|
+
return S()?.backend ?? "webgpu";
|
|
556
1430
|
},
|
|
1431
|
+
pause: () => S()?.suspend("manual"),
|
|
1432
|
+
resume: () => S()?.resume("manual"),
|
|
1433
|
+
wake: () => S()?.wake(),
|
|
1434
|
+
renderAt: (e) => S()?.renderAt(e),
|
|
557
1435
|
get reducedMotion() {
|
|
558
|
-
return
|
|
1436
|
+
return p?.reducedMotion ?? !1;
|
|
559
1437
|
},
|
|
560
|
-
dispose: () =>
|
|
1438
|
+
dispose: () => {
|
|
1439
|
+
let t = e.value;
|
|
1440
|
+
t && x(t), o.dispose(), p?.dispose();
|
|
1441
|
+
}
|
|
561
1442
|
};
|
|
562
|
-
return m(() =>
|
|
1443
|
+
return m(() => C.dispose()), C;
|
|
563
1444
|
}
|
|
564
1445
|
//#endregion
|
|
565
1446
|
//#region src/components/custom/dot-flow-field/DotFlowField.vue
|
|
566
|
-
var
|
|
1447
|
+
var Ge = /* @__PURE__ */ e(/* @__PURE__ */ f({
|
|
567
1448
|
__name: "DotFlowField",
|
|
568
1449
|
props: {
|
|
569
|
-
config: { default: () =>
|
|
1450
|
+
config: { default: () => U },
|
|
570
1451
|
paused: {
|
|
571
1452
|
type: Boolean,
|
|
572
1453
|
default: !1
|
|
@@ -574,7 +1455,7 @@ var ce = /* @__PURE__ */ t(/* @__PURE__ */ f({
|
|
|
574
1455
|
},
|
|
575
1456
|
emits: ["update:paused"],
|
|
576
1457
|
setup(e, { expose: t }) {
|
|
577
|
-
let n = g("canvasRef"), r =
|
|
1458
|
+
let n = g("canvasRef"), r = We(n, {
|
|
578
1459
|
config: e.config,
|
|
579
1460
|
getPalette: () => e.config.palette
|
|
580
1461
|
});
|
|
@@ -599,6 +1480,6 @@ var ce = /* @__PURE__ */ t(/* @__PURE__ */ f({
|
|
|
599
1480
|
"data-testid": "dot-flow-field-canvas"
|
|
600
1481
|
}, null, 512)], 4));
|
|
601
1482
|
}
|
|
602
|
-
}), [["__scopeId", "data-v-
|
|
1483
|
+
}), [["__scopeId", "data-v-01c7721a"]]);
|
|
603
1484
|
//#endregion
|
|
604
|
-
export {
|
|
1485
|
+
export { U as DEFAULT_FLOW_CONFIG, H as DEFAULT_WAVE_COMPONENTS, Ge as DotFlowField, A as FLOW_DOMAIN_HALF, v as FLOW_GRAVITY, z as MAX_FLOW_STOPS, L as MAX_PARTICLES, R as MAX_WAVE_COMPONENTS, V as WARM_IDENTITY_PALETTE, I as buildWaveLadder, D as curlFBM, x as gerstnerVelocity, j as gridOrigin, k as pointerVortex, N as sampleDisplacement, M as sampleHeight, O as sampleVelocity, We as useDotFlowField, P as waveBand };
|