fancy-ui-react 0.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/LICENSE +21 -0
- package/PORTING.md +118 -0
- package/README.md +643 -0
- package/dist/cameleon/FancyProvider.d.ts +11 -0
- package/dist/cameleon/FancyProvider.js +42 -0
- package/dist/cameleon/context.d.ts +22 -0
- package/dist/cameleon/context.js +16 -0
- package/dist/cameleon/index.d.ts +31 -0
- package/dist/cameleon/index.js +39 -0
- package/dist/cameleon/primitives/Badge.d.ts +10 -0
- package/dist/cameleon/primitives/Badge.js +12 -0
- package/dist/cameleon/primitives/Button.d.ts +11 -0
- package/dist/cameleon/primitives/Button.js +43 -0
- package/dist/cameleon/primitives/Checkbox.d.ts +10 -0
- package/dist/cameleon/primitives/Checkbox.js +39 -0
- package/dist/cameleon/primitives/Input.d.ts +10 -0
- package/dist/cameleon/primitives/Input.js +13 -0
- package/dist/cameleon/primitives/Radio.d.ts +12 -0
- package/dist/cameleon/primitives/Radio.js +29 -0
- package/dist/cameleon/primitives/Select.d.ts +10 -0
- package/dist/cameleon/primitives/Select.js +27 -0
- package/dist/cameleon/primitives/Slider.d.ts +7 -0
- package/dist/cameleon/primitives/Slider.js +22 -0
- package/dist/cameleon/primitives/Switch.d.ts +9 -0
- package/dist/cameleon/primitives/Switch.js +33 -0
- package/dist/cameleon/primitives/Textarea.d.ts +9 -0
- package/dist/cameleon/primitives/Textarea.js +13 -0
- package/dist/cameleon/primitives/Tooltip.d.ts +14 -0
- package/dist/cameleon/primitives/Tooltip.js +15 -0
- package/dist/cameleon/primitives/index.d.ts +10 -0
- package/dist/cameleon/skins/aurora/index.d.ts +2 -0
- package/dist/cameleon/skins/aurora/index.js +16 -0
- package/dist/cameleon/skins/aurora/meta.d.ts +3 -0
- package/dist/cameleon/skins/aurora/meta.js +61 -0
- package/dist/cameleon/skins/aurora/recipes.d.ts +24 -0
- package/dist/cameleon/skins/aurora/recipes.js +124 -0
- package/dist/cameleon/skins/aurora/tokens.d.ts +6 -0
- package/dist/cameleon/skins/aurora/tokens.js +18 -0
- package/dist/cameleon/skins/brutal/index.d.ts +2 -0
- package/dist/cameleon/skins/brutal/index.js +35 -0
- package/dist/cameleon/skins/brutal/meta.d.ts +3 -0
- package/dist/cameleon/skins/brutal/meta.js +73 -0
- package/dist/cameleon/skins/brutal/ornaments.d.ts +7 -0
- package/dist/cameleon/skins/brutal/ornaments.js +18 -0
- package/dist/cameleon/skins/brutal/recipes.d.ts +23 -0
- package/dist/cameleon/skins/brutal/recipes.js +113 -0
- package/dist/cameleon/skins/brutal/tokens.d.ts +8 -0
- package/dist/cameleon/skins/brutal/tokens.js +23 -0
- package/dist/cameleon/skins/default.d.ts +2 -0
- package/dist/cameleon/skins/default.js +79 -0
- package/dist/cameleon/skins/glass/index.d.ts +2 -0
- package/dist/cameleon/skins/glass/index.js +16 -0
- package/dist/cameleon/skins/glass/meta.d.ts +3 -0
- package/dist/cameleon/skins/glass/meta.js +63 -0
- package/dist/cameleon/skins/glass/recipes.d.ts +24 -0
- package/dist/cameleon/skins/glass/recipes.js +124 -0
- package/dist/cameleon/skins/glass/tokens.d.ts +5 -0
- package/dist/cameleon/skins/glass/tokens.js +18 -0
- package/dist/cameleon/skins/retro-os/index.d.ts +2 -0
- package/dist/cameleon/skins/retro-os/index.js +24 -0
- package/dist/cameleon/skins/retro-os/meta.d.ts +3 -0
- package/dist/cameleon/skins/retro-os/meta.js +61 -0
- package/dist/cameleon/skins/retro-os/ornaments.d.ts +9 -0
- package/dist/cameleon/skins/retro-os/ornaments.js +28 -0
- package/dist/cameleon/skins/retro-os/recipes.d.ts +35 -0
- package/dist/cameleon/skins/retro-os/recipes.js +126 -0
- package/dist/cameleon/skins/retro-os/tokens.d.ts +16 -0
- package/dist/cameleon/skins/retro-os/tokens.js +23 -0
- package/dist/cameleon/skins/terminal/index.d.ts +2 -0
- package/dist/cameleon/skins/terminal/index.js +24 -0
- package/dist/cameleon/skins/terminal/meta.d.ts +3 -0
- package/dist/cameleon/skins/terminal/meta.js +70 -0
- package/dist/cameleon/skins/terminal/ornaments.d.ts +7 -0
- package/dist/cameleon/skins/terminal/ornaments.js +8 -0
- package/dist/cameleon/skins/terminal/recipes.d.ts +25 -0
- package/dist/cameleon/skins/terminal/recipes.js +125 -0
- package/dist/cameleon/skins/terminal/tokens.d.ts +5 -0
- package/dist/cameleon/skins/terminal/tokens.js +18 -0
- package/dist/cameleon/types.d.ts +133 -0
- package/dist/components/agent-plan/AgentPlan.d.ts +25 -0
- package/dist/components/agent-plan/AgentPlan.js +181 -0
- package/dist/components/agent-plan/index.d.ts +2 -0
- package/dist/components/ai-data-table/AiDataTable.d.ts +54 -0
- package/dist/components/ai-data-table/AiDataTable.js +110 -0
- package/dist/components/ai-data-table/index.d.ts +2 -0
- package/dist/components/alert-dialog/AlertDialog.d.ts +35 -0
- package/dist/components/alert-dialog/AlertDialog.js +109 -0
- package/dist/components/alert-dialog/index.d.ts +2 -0
- package/dist/components/animated-beam/AnimatedBeam.d.ts +39 -0
- package/dist/components/animated-beam/AnimatedBeam.js +192 -0
- package/dist/components/animated-beam/index.d.ts +2 -0
- package/dist/components/animated-testimonials/AnimatedTestimonials.d.ts +32 -0
- package/dist/components/animated-testimonials/AnimatedTestimonials.js +172 -0
- package/dist/components/animated-testimonials/index.d.ts +2 -0
- package/dist/components/animated-tooltip/AnimatedTooltip.d.ts +13 -0
- package/dist/components/animated-tooltip/AnimatedTooltip.js +137 -0
- package/dist/components/animated-tooltip/index.d.ts +2 -0
- package/dist/components/apple-card-carousel/AppleCard.d.ts +30 -0
- package/dist/components/apple-card-carousel/AppleCard.js +219 -0
- package/dist/components/apple-card-carousel/AppleCardCarousel.d.ts +14 -0
- package/dist/components/apple-card-carousel/AppleCardCarousel.js +30 -0
- package/dist/components/apple-card-carousel/index.d.ts +4 -0
- package/dist/components/approval-card/ApprovalCard.d.ts +57 -0
- package/dist/components/approval-card/ApprovalCard.js +153 -0
- package/dist/components/approval-card/index.d.ts +2 -0
- package/dist/components/artifact-card/ArtifactCard.d.ts +44 -0
- package/dist/components/artifact-card/ArtifactCard.js +204 -0
- package/dist/components/artifact-card/index.d.ts +2 -0
- package/dist/components/autocomplete/Autocomplete.d.ts +36 -0
- package/dist/components/autocomplete/Autocomplete.js +186 -0
- package/dist/components/autocomplete/AutocompletePanel.d.ts +12 -0
- package/dist/components/autocomplete/AutocompletePanel.js +123 -0
- package/dist/components/autocomplete/index.d.ts +4 -0
- package/dist/components/autocomplete/match.d.ts +6 -0
- package/dist/components/autocomplete/match.js +10 -0
- package/dist/components/autocomplete/types.d.ts +52 -0
- package/dist/components/autocomplete/types.js +6 -0
- package/dist/components/bento-grid/BentoGrid.d.ts +6 -0
- package/dist/components/bento-grid/BentoGrid.js +19 -0
- package/dist/components/bento-grid/BentoGridCard.d.ts +11 -0
- package/dist/components/bento-grid/BentoGridCard.js +49 -0
- package/dist/components/bento-grid/BentoGridItem.d.ts +9 -0
- package/dist/components/bento-grid/BentoGridItem.js +33 -0
- package/dist/components/bento-grid/index.d.ts +6 -0
- package/dist/components/bg-falling-stars/FallingStarsBg.d.ts +24 -0
- package/dist/components/bg-falling-stars/FallingStarsBg.js +134 -0
- package/dist/components/bg-falling-stars/index.d.ts +2 -0
- package/dist/components/bg-stars/StarsBackground.d.ts +40 -0
- package/dist/components/bg-stars/StarsBackground.js +188 -0
- package/dist/components/bg-stars/index.d.ts +2 -0
- package/dist/components/blur-reveal/BlurReveal.d.ts +19 -0
- package/dist/components/blur-reveal/BlurReveal.js +50 -0
- package/dist/components/blur-reveal/index.d.ts +2 -0
- package/dist/components/book/Book.d.ts +13 -0
- package/dist/components/book/Book.js +94 -0
- package/dist/components/book/BookDescription.d.ts +6 -0
- package/dist/components/book/BookDescription.js +9 -0
- package/dist/components/book/BookHeader.d.ts +6 -0
- package/dist/components/book/BookHeader.js +9 -0
- package/dist/components/book/BookTitle.d.ts +6 -0
- package/dist/components/book/BookTitle.js +9 -0
- package/dist/components/book/index.d.ts +132 -0
- package/dist/components/book/index.js +48 -0
- package/dist/components/border-beam/BorderBeam.d.ts +25 -0
- package/dist/components/border-beam/BorderBeam.js +45 -0
- package/dist/components/border-beam/index.d.ts +2 -0
- package/dist/components/box-reveal/BoxReveal.d.ts +20 -0
- package/dist/components/box-reveal/BoxReveal.js +58 -0
- package/dist/components/box-reveal/index.d.ts +2 -0
- package/dist/components/breadcrumb/Breadcrumb.d.ts +49 -0
- package/dist/components/breadcrumb/Breadcrumb.js +61 -0
- package/dist/components/breadcrumb/index.d.ts +2 -0
- package/dist/components/button/Button.d.ts +44 -0
- package/dist/components/button/Button.js +120 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button/types.d.ts +4 -0
- package/dist/components/button-group/ButtonGroup.d.ts +23 -0
- package/dist/components/button-group/ButtonGroup.js +30 -0
- package/dist/components/button-group/index.d.ts +4 -0
- package/dist/components/button-group/types.d.ts +34 -0
- package/dist/components/button-group/types.js +7 -0
- package/dist/components/card-3d/CardBody.d.ts +8 -0
- package/dist/components/card-3d/CardBody.js +9 -0
- package/dist/components/card-3d/CardContainer.d.ts +19 -0
- package/dist/components/card-3d/CardContainer.js +61 -0
- package/dist/components/card-3d/CardItem.d.ts +22 -0
- package/dist/components/card-3d/CardItem.js +29 -0
- package/dist/components/card-3d/index.d.ts +6 -0
- package/dist/components/card-spotlight/CardSpotlight.d.ts +16 -0
- package/dist/components/card-spotlight/CardSpotlight.js +65 -0
- package/dist/components/card-spotlight/index.d.ts +2 -0
- package/dist/components/chat-error/ChatError.d.ts +32 -0
- package/dist/components/chat-error/ChatError.js +75 -0
- package/dist/components/chat-error/index.d.ts +2 -0
- package/dist/components/chat-message/ChatMessage.d.ts +43 -0
- package/dist/components/chat-message/ChatMessage.js +127 -0
- package/dist/components/chat-message/ChatMessageAction.d.ts +20 -0
- package/dist/components/chat-message/ChatMessageAction.js +58 -0
- package/dist/components/chat-message/ChatMessageActions.d.ts +14 -0
- package/dist/components/chat-message/ChatMessageActions.js +30 -0
- package/dist/components/chat-message/ChatMessageBranches.d.ts +15 -0
- package/dist/components/chat-message/ChatMessageBranches.js +93 -0
- package/dist/components/chat-message/index.d.ts +10 -0
- package/dist/components/chat-message/types.d.ts +38 -0
- package/dist/components/chat-message/types.js +7 -0
- package/dist/components/chat-panel/ChatEmptyState.d.ts +17 -0
- package/dist/components/chat-panel/ChatEmptyState.js +42 -0
- package/dist/components/chat-panel/ChatPanel.d.ts +31 -0
- package/dist/components/chat-panel/ChatPanel.js +163 -0
- package/dist/components/chat-panel/index.d.ts +4 -0
- package/dist/components/checkbox/Checkbox.d.ts +64 -0
- package/dist/components/checkbox/Checkbox.js +123 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/code-diff/CodeDiff.d.ts +39 -0
- package/dist/components/code-diff/CodeDiff.js +213 -0
- package/dist/components/code-diff/index.d.ts +2 -0
- package/dist/components/colourful-text/ColourfulText.d.ts +28 -0
- package/dist/components/colourful-text/ColourfulText.js +73 -0
- package/dist/components/colourful-text/index.d.ts +2 -0
- package/dist/components/combobox/Combobox.d.ts +53 -0
- package/dist/components/combobox/Combobox.js +248 -0
- package/dist/components/combobox/ComboboxPanel.d.ts +28 -0
- package/dist/components/combobox/ComboboxPanel.js +110 -0
- package/dist/components/combobox/index.d.ts +4 -0
- package/dist/components/combobox/match.d.ts +15 -0
- package/dist/components/combobox/match.js +14 -0
- package/dist/components/combobox/types.d.ts +60 -0
- package/dist/components/combobox/types.js +6 -0
- package/dist/components/command-menu/CommandMenu.d.ts +37 -0
- package/dist/components/command-menu/CommandMenu.js +386 -0
- package/dist/components/command-menu/index.d.ts +3 -0
- package/dist/components/command-menu/match.d.ts +19 -0
- package/dist/components/command-menu/match.js +45 -0
- package/dist/components/command-menu/types.d.ts +19 -0
- package/dist/components/compare/Compare.d.ts +31 -0
- package/dist/components/compare/Compare.js +300 -0
- package/dist/components/compare/StarField.d.ts +22 -0
- package/dist/components/compare/StarField.js +66 -0
- package/dist/components/compare/index.d.ts +4 -0
- package/dist/components/composer/Composer.d.ts +56 -0
- package/dist/components/composer/Composer.js +155 -0
- package/dist/components/composer/ComposerAttachment.d.ts +14 -0
- package/dist/components/composer/ComposerAttachment.js +127 -0
- package/dist/components/composer/ComposerAttachments.d.ts +18 -0
- package/dist/components/composer/ComposerAttachments.js +85 -0
- package/dist/components/composer/ComposerCommandMenu.d.ts +37 -0
- package/dist/components/composer/ComposerCommandMenu.js +208 -0
- package/dist/components/composer/ComposerInput.d.ts +22 -0
- package/dist/components/composer/ComposerInput.js +96 -0
- package/dist/components/composer/ComposerModelPicker.d.ts +32 -0
- package/dist/components/composer/ComposerModelPicker.js +223 -0
- package/dist/components/composer/ComposerSubmit.d.ts +16 -0
- package/dist/components/composer/ComposerSubmit.js +52 -0
- package/dist/components/composer/ComposerToolbar.d.ts +38 -0
- package/dist/components/composer/ComposerToolbar.js +9 -0
- package/dist/components/composer/caret.d.ts +69 -0
- package/dist/components/composer/caret.js +112 -0
- package/dist/components/composer/index.d.ts +18 -0
- package/dist/components/composer/types.d.ts +86 -0
- package/dist/components/composer/types.js +7 -0
- package/dist/components/confetti/Confetti.d.ts +37 -0
- package/dist/components/confetti/Confetti.js +45 -0
- package/dist/components/confetti/ConfettiButton.d.ts +23 -0
- package/dist/components/confetti/ConfettiButton.js +29 -0
- package/dist/components/confetti/context.d.ts +21 -0
- package/dist/components/confetti/context.js +6 -0
- package/dist/components/confetti/index.d.ts +4 -0
- package/dist/components/container-scroll/ContainerScroll.d.ts +10 -0
- package/dist/components/container-scroll/ContainerScroll.js +74 -0
- package/dist/components/container-scroll/index.d.ts +2 -0
- package/dist/components/container-text-flip/ContainerTextFlip.d.ts +9 -0
- package/dist/components/container-text-flip/ContainerTextFlip.js +58 -0
- package/dist/components/container-text-flip/index.d.ts +2 -0
- package/dist/components/context-menu/ContextMenu.d.ts +39 -0
- package/dist/components/context-menu/ContextMenu.js +105 -0
- package/dist/components/context-menu/ContextMenuContent.d.ts +27 -0
- package/dist/components/context-menu/ContextMenuContent.js +97 -0
- package/dist/components/context-menu/ContextMenuTrigger.d.ts +26 -0
- package/dist/components/context-menu/ContextMenuTrigger.js +37 -0
- package/dist/components/context-menu/index.d.ts +20 -0
- package/dist/components/context-menu/types.d.ts +52 -0
- package/dist/components/context-menu/types.js +17 -0
- package/dist/components/context-ring/ContextRing.d.ts +33 -0
- package/dist/components/context-ring/ContextRing.js +257 -0
- package/dist/components/context-ring/index.d.ts +2 -0
- package/dist/components/copy-button/CopyButton.d.ts +39 -0
- package/dist/components/copy-button/CopyButton.js +124 -0
- package/dist/components/copy-button/index.d.ts +2 -0
- package/dist/components/date-picker/DatePicker.d.ts +58 -0
- package/dist/components/date-picker/DatePicker.js +331 -0
- package/dist/components/date-picker/date-utils.d.ts +39 -0
- package/dist/components/date-picker/date-utils.js +85 -0
- package/dist/components/date-picker/index.d.ts +2 -0
- package/dist/components/dialog/Dialog.d.ts +29 -0
- package/dist/components/dialog/Dialog.js +105 -0
- package/dist/components/dialog/DialogSurface.d.ts +2 -0
- package/dist/components/dialog/DialogSurface.js +98 -0
- package/dist/components/dialog/index.d.ts +2 -0
- package/dist/components/dialog/types.d.ts +61 -0
- package/dist/components/dim-siblings/DimSiblings.d.ts +30 -0
- package/dist/components/dim-siblings/DimSiblings.js +47 -0
- package/dist/components/dim-siblings/index.d.ts +2 -0
- package/dist/components/direction-aware-hover/DirectionAwareHover.d.ts +10 -0
- package/dist/components/direction-aware-hover/DirectionAwareHover.js +185 -0
- package/dist/components/direction-aware-hover/index.d.ts +2 -0
- package/dist/components/displacement-text/DisplacementText.d.ts +26 -0
- package/dist/components/displacement-text/DisplacementText.js +185 -0
- package/dist/components/displacement-text/index.d.ts +2 -0
- package/dist/components/dock/Dock.d.ts +28 -0
- package/dist/components/dock/Dock.js +80 -0
- package/dist/components/dock/DockIcon.d.ts +17 -0
- package/dist/components/dock/DockIcon.js +38 -0
- package/dist/components/dock/DockSeparator.d.ts +6 -0
- package/dist/components/dock/DockSeparator.js +20 -0
- package/dist/components/dock/index.d.ts +7 -0
- package/dist/components/dock/types.d.ts +47 -0
- package/dist/components/dock/types.js +15 -0
- package/dist/components/drawer/Drawer.d.ts +34 -0
- package/dist/components/drawer/Drawer.js +237 -0
- package/dist/components/drawer/index.d.ts +2 -0
- package/dist/components/dropdown-menu/DropdownMenu.d.ts +38 -0
- package/dist/components/dropdown-menu/DropdownMenu.js +99 -0
- package/dist/components/dropdown-menu/DropdownMenuContent.d.ts +15 -0
- package/dist/components/dropdown-menu/DropdownMenuContent.js +111 -0
- package/dist/components/dropdown-menu/DropdownMenuItem.d.ts +26 -0
- package/dist/components/dropdown-menu/DropdownMenuItem.js +74 -0
- package/dist/components/dropdown-menu/DropdownMenuLabel.d.ts +15 -0
- package/dist/components/dropdown-menu/DropdownMenuLabel.js +18 -0
- package/dist/components/dropdown-menu/DropdownMenuSeparator.d.ts +6 -0
- package/dist/components/dropdown-menu/DropdownMenuSeparator.js +15 -0
- package/dist/components/dropdown-menu/DropdownMenuSub.d.ts +10 -0
- package/dist/components/dropdown-menu/DropdownMenuSub.js +110 -0
- package/dist/components/dropdown-menu/DropdownMenuSubContent.d.ts +15 -0
- package/dist/components/dropdown-menu/DropdownMenuSubContent.js +139 -0
- package/dist/components/dropdown-menu/DropdownMenuSubTrigger.d.ts +17 -0
- package/dist/components/dropdown-menu/DropdownMenuSubTrigger.js +104 -0
- package/dist/components/dropdown-menu/DropdownMenuTrigger.d.ts +16 -0
- package/dist/components/dropdown-menu/DropdownMenuTrigger.js +67 -0
- package/dist/components/dropdown-menu/index.d.ts +20 -0
- package/dist/components/dropdown-menu/menu-shared.d.ts +39 -0
- package/dist/components/dropdown-menu/menu-shared.js +48 -0
- package/dist/components/dropdown-menu/types.d.ts +159 -0
- package/dist/components/dropdown-menu/types.js +32 -0
- package/dist/components/editorial-engine/EditorialEngine.d.ts +21 -0
- package/dist/components/editorial-engine/EditorialEngine.js +68 -0
- package/dist/components/editorial-engine/engine.d.ts +7 -0
- package/dist/components/editorial-engine/engine.js +558 -0
- package/dist/components/editorial-engine/index.d.ts +2 -0
- package/dist/components/file-upload/FileUpload.d.ts +63 -0
- package/dist/components/file-upload/FileUpload.js +438 -0
- package/dist/components/file-upload/index.d.ts +2 -0
- package/dist/components/fireworks-hdr/FireworksHdr.d.ts +56 -0
- package/dist/components/fireworks-hdr/FireworksHdr.js +426 -0
- package/dist/components/fireworks-hdr/dev.d.ts +1 -0
- package/dist/components/fireworks-hdr/dev.js +8 -0
- package/dist/components/fireworks-hdr/fireworks-shared.d.ts +444 -0
- package/dist/components/fireworks-hdr/fireworks-shared.js +1205 -0
- package/dist/components/fireworks-hdr/index.d.ts +4 -0
- package/dist/components/fireworks-hdr/webgl2-renderer.d.ts +20 -0
- package/dist/components/fireworks-hdr/webgl2-renderer.js +517 -0
- package/dist/components/fireworks-hdr/webgpu-renderer.d.ts +51 -0
- package/dist/components/fireworks-hdr/webgpu-renderer.js +461 -0
- package/dist/components/fireworks-hdr/webgpu-types.d.ts +159 -0
- package/dist/components/flickering-grid/FlickeringGrid.d.ts +33 -0
- package/dist/components/flickering-grid/FlickeringGrid.js +154 -0
- package/dist/components/flickering-grid/index.d.ts +2 -0
- package/dist/components/flip-card/FlipCard.d.ts +8 -0
- package/dist/components/flip-card/FlipCard.js +35 -0
- package/dist/components/flip-card/index.d.ts +2 -0
- package/dist/components/flip-words/FlipWords.d.ts +16 -0
- package/dist/components/flip-words/FlipWords.js +82 -0
- package/dist/components/flip-words/index.d.ts +2 -0
- package/dist/components/fluid-cursor/FluidCursor.d.ts +61 -0
- package/dist/components/fluid-cursor/FluidCursor.js +1479 -0
- package/dist/components/fluid-cursor/fluid-shared.d.ts +74 -0
- package/dist/components/fluid-cursor/fluid-shared.js +120 -0
- package/dist/components/fluid-cursor/index.d.ts +8 -0
- package/dist/components/fluid-cursor/webgpu-engine.d.ts +36 -0
- package/dist/components/fluid-cursor/webgpu-engine.js +922 -0
- package/dist/components/focus/Focus.d.ts +24 -0
- package/dist/components/focus/Focus.js +103 -0
- package/dist/components/focus/index.d.ts +2 -0
- package/dist/components/form-field/FormField.d.ts +46 -0
- package/dist/components/form-field/FormField.js +151 -0
- package/dist/components/form-field/index.d.ts +2 -0
- package/dist/components/frosted-glass/FrostedGlass.d.ts +48 -0
- package/dist/components/frosted-glass/FrostedGlass.js +89 -0
- package/dist/components/frosted-glass/index.d.ts +2 -0
- package/dist/components/glare-card/GlareCard.d.ts +8 -0
- package/dist/components/glare-card/GlareCard.js +103 -0
- package/dist/components/glare-card/index.d.ts +2 -0
- package/dist/components/glow-border/GlowBorder.d.ts +8 -0
- package/dist/components/glow-border/GlowBorder.js +39 -0
- package/dist/components/glow-border/index.d.ts +2 -0
- package/dist/components/glowing-effect/GlowingEffect.d.ts +23 -0
- package/dist/components/glowing-effect/GlowingEffect.js +157 -0
- package/dist/components/glowing-effect/index.d.ts +2 -0
- package/dist/components/gradient-button/GradientButton.d.ts +28 -0
- package/dist/components/gradient-button/GradientButton.js +66 -0
- package/dist/components/gradient-button/index.d.ts +2 -0
- package/dist/components/hover-card/HoverCard.d.ts +57 -0
- package/dist/components/hover-card/HoverCard.js +139 -0
- package/dist/components/hover-card/index.d.ts +2 -0
- package/dist/components/hyper-text/HyperText.d.ts +25 -0
- package/dist/components/hyper-text/HyperText.js +102 -0
- package/dist/components/hyper-text/index.d.ts +2 -0
- package/dist/components/icon-button/IconButton.d.ts +46 -0
- package/dist/components/icon-button/IconButton.js +62 -0
- package/dist/components/icon-button/index.d.ts +2 -0
- package/dist/components/image-generation/ImageGeneration.d.ts +33 -0
- package/dist/components/image-generation/ImageGeneration.js +131 -0
- package/dist/components/image-generation/index.d.ts +2 -0
- package/dist/components/image-trail-cursor/ImageTrailCursor.d.ts +15 -0
- package/dist/components/image-trail-cursor/ImageTrailCursor.js +75 -0
- package/dist/components/image-trail-cursor/index.d.ts +3 -0
- package/dist/components/image-trail-cursor/trail-variants.d.ts +112 -0
- package/dist/components/image-trail-cursor/trail-variants.js +787 -0
- package/dist/components/inline-citation/InlineCitation.d.ts +23 -0
- package/dist/components/inline-citation/InlineCitation.js +179 -0
- package/dist/components/inline-citation/index.d.ts +2 -0
- package/dist/components/input/Input.d.ts +41 -0
- package/dist/components/input/Input.js +74 -0
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/interactive-grid-pattern/InteractiveGridPattern.d.ts +17 -0
- package/dist/components/interactive-grid-pattern/InteractiveGridPattern.js +89 -0
- package/dist/components/interactive-grid-pattern/index.d.ts +2 -0
- package/dist/components/interactive-hover-button/InteractiveHoverButton.d.ts +18 -0
- package/dist/components/interactive-hover-button/InteractiveHoverButton.js +66 -0
- package/dist/components/interactive-hover-button/index.d.ts +2 -0
- package/dist/components/label/Label.d.ts +18 -0
- package/dist/components/label/Label.js +28 -0
- package/dist/components/label/index.d.ts +2 -0
- package/dist/components/letter-pullup/LetterPullup.d.ts +16 -0
- package/dist/components/letter-pullup/LetterPullup.js +27 -0
- package/dist/components/letter-pullup/index.d.ts +2 -0
- package/dist/components/line-hover-link/LineHoverLink.d.ts +33 -0
- package/dist/components/line-hover-link/LineHoverLink.js +69 -0
- package/dist/components/line-hover-link/index.d.ts +2 -0
- package/dist/components/line-reveal/LineReveal.d.ts +31 -0
- package/dist/components/line-reveal/LineReveal.js +117 -0
- package/dist/components/line-reveal/index.d.ts +2 -0
- package/dist/components/line-shadow-text/LineShadowText.d.ts +18 -0
- package/dist/components/line-shadow-text/LineShadowText.js +26 -0
- package/dist/components/line-shadow-text/index.d.ts +2 -0
- package/dist/components/link/Link.d.ts +30 -0
- package/dist/components/link/Link.js +82 -0
- package/dist/components/link/index.d.ts +2 -0
- package/dist/components/liquid-glass/LiquidGlass.d.ts +49 -0
- package/dist/components/liquid-glass/LiquidGlass.js +165 -0
- package/dist/components/liquid-glass/index.d.ts +2 -0
- package/dist/components/liquid-text/LiquidText.d.ts +35 -0
- package/dist/components/liquid-text/LiquidText.js +882 -0
- package/dist/components/liquid-text/index.d.ts +2 -0
- package/dist/components/logo-cloud/AnimatedLogoCloud.d.ts +13 -0
- package/dist/components/logo-cloud/AnimatedLogoCloud.js +38 -0
- package/dist/components/logo-cloud/IconLogoCloud.d.ts +10 -0
- package/dist/components/logo-cloud/IconLogoCloud.js +20 -0
- package/dist/components/logo-cloud/StaticLogoCloud.d.ts +28 -0
- package/dist/components/logo-cloud/StaticLogoCloud.js +45 -0
- package/dist/components/logo-cloud/index.d.ts +6 -0
- package/dist/components/magnetic/Magnetic.d.ts +35 -0
- package/dist/components/magnetic/Magnetic.js +113 -0
- package/dist/components/magnetic/index.d.ts +2 -0
- package/dist/components/marquee/Marquee.d.ts +16 -0
- package/dist/components/marquee/Marquee.js +39 -0
- package/dist/components/marquee/ReviewCard.d.ts +8 -0
- package/dist/components/marquee/ReviewCard.js +17 -0
- package/dist/components/marquee/index.d.ts +4 -0
- package/dist/components/matrix-rain/MatrixRain.d.ts +35 -0
- package/dist/components/matrix-rain/MatrixRain.js +130 -0
- package/dist/components/matrix-rain/index.d.ts +2 -0
- package/dist/components/meteors/Meteors.d.ts +21 -0
- package/dist/components/meteors/Meteors.js +45 -0
- package/dist/components/meteors/index.d.ts +2 -0
- package/dist/components/mosaic-glow/MosaicGlow.d.ts +47 -0
- package/dist/components/mosaic-glow/MosaicGlow.js +438 -0
- package/dist/components/mosaic-glow/index.d.ts +2 -0
- package/dist/components/mosaic-glow/mosaic-glow-core.d.ts +94 -0
- package/dist/components/mosaic-glow/mosaic-glow-core.js +190 -0
- package/dist/components/navbar/Navbar.d.ts +25 -0
- package/dist/components/navbar/Navbar.js +27 -0
- package/dist/components/navbar/NavbarLink.d.ts +37 -0
- package/dist/components/navbar/NavbarLink.js +48 -0
- package/dist/components/navbar/index.d.ts +4 -0
- package/dist/components/navigation-menu/NavigationMenu.d.ts +28 -0
- package/dist/components/navigation-menu/NavigationMenu.js +202 -0
- package/dist/components/navigation-menu/NavigationMenuContent.d.ts +8 -0
- package/dist/components/navigation-menu/NavigationMenuContent.js +77 -0
- package/dist/components/navigation-menu/NavigationMenuItem.d.ts +20 -0
- package/dist/components/navigation-menu/NavigationMenuItem.js +18 -0
- package/dist/components/navigation-menu/NavigationMenuLink.d.ts +31 -0
- package/dist/components/navigation-menu/NavigationMenuLink.js +41 -0
- package/dist/components/navigation-menu/NavigationMenuList.d.ts +8 -0
- package/dist/components/navigation-menu/NavigationMenuList.js +33 -0
- package/dist/components/navigation-menu/NavigationMenuTrigger.d.ts +8 -0
- package/dist/components/navigation-menu/NavigationMenuTrigger.js +90 -0
- package/dist/components/navigation-menu/index.d.ts +14 -0
- package/dist/components/navigation-menu/types.d.ts +107 -0
- package/dist/components/navigation-menu/types.js +32 -0
- package/dist/components/neon-border/NeonBorder.d.ts +22 -0
- package/dist/components/neon-border/NeonBorder.js +50 -0
- package/dist/components/neon-border/index.d.ts +2 -0
- package/dist/components/noise-reveal/NoiseReveal.d.ts +29 -0
- package/dist/components/noise-reveal/NoiseReveal.js +329 -0
- package/dist/components/noise-reveal/index.d.ts +2 -0
- package/dist/components/number-input/NumberInput.d.ts +40 -0
- package/dist/components/number-input/NumberInput.js +207 -0
- package/dist/components/number-input/index.d.ts +2 -0
- package/dist/components/number-ticker/NumberTicker.d.ts +22 -0
- package/dist/components/number-ticker/NumberTicker.js +106 -0
- package/dist/components/number-ticker/index.d.ts +2 -0
- package/dist/components/pagination/Pagination.d.ts +43 -0
- package/dist/components/pagination/Pagination.js +156 -0
- package/dist/components/pagination/index.d.ts +2 -0
- package/dist/components/pagination/pagination-range.d.ts +11 -0
- package/dist/components/pagination/pagination-range.js +35 -0
- package/dist/components/password-input/PasswordInput.d.ts +56 -0
- package/dist/components/password-input/PasswordInput.js +246 -0
- package/dist/components/password-input/index.d.ts +2 -0
- package/dist/components/pixel-loader/PixelLoader.d.ts +18 -0
- package/dist/components/pixel-loader/PixelLoader.js +56 -0
- package/dist/components/pixel-loader/index.d.ts +2 -0
- package/dist/components/popover/Popover.d.ts +49 -0
- package/dist/components/popover/Popover.js +81 -0
- package/dist/components/popover/PopoverContent.d.ts +21 -0
- package/dist/components/popover/PopoverContent.js +78 -0
- package/dist/components/popover/index.d.ts +6 -0
- package/dist/components/popover/types.d.ts +64 -0
- package/dist/components/popover/types.js +17 -0
- package/dist/components/presence/Presence.d.ts +40 -0
- package/dist/components/presence/Presence.js +49 -0
- package/dist/components/presence/index.d.ts +2 -0
- package/dist/components/pressable/Pressable.d.ts +27 -0
- package/dist/components/pressable/Pressable.js +86 -0
- package/dist/components/pressable/index.d.ts +2 -0
- package/dist/components/prompt-suggestions/PromptSuggestions.d.ts +25 -0
- package/dist/components/prompt-suggestions/PromptSuggestions.js +68 -0
- package/dist/components/prompt-suggestions/index.d.ts +2 -0
- package/dist/components/pulse-beam/PulseBeam.d.ts +44 -0
- package/dist/components/pulse-beam/PulseBeam.js +197 -0
- package/dist/components/pulse-beam/index.d.ts +2 -0
- package/dist/components/pulse-beam/pulse-beam-data.d.ts +81 -0
- package/dist/components/pulse-beam/pulse-beam-data.js +306 -0
- package/dist/components/pulse-beam/pulse-beam-loop.d.ts +26 -0
- package/dist/components/pulse-beam/pulse-beam-loop.js +58 -0
- package/dist/components/radio-group/RadioGroup.d.ts +56 -0
- package/dist/components/radio-group/RadioGroup.js +82 -0
- package/dist/components/radio-group/RadioGroupItem.d.ts +21 -0
- package/dist/components/radio-group/RadioGroupItem.js +47 -0
- package/dist/components/radio-group/index.d.ts +6 -0
- package/dist/components/radio-group/types.d.ts +50 -0
- package/dist/components/radio-group/types.js +7 -0
- package/dist/components/rainbow-button/RainbowButton.d.ts +21 -0
- package/dist/components/rainbow-button/RainbowButton.js +59 -0
- package/dist/components/rainbow-button/index.d.ts +2 -0
- package/dist/components/reasoning-panel/ReasoningPanel.d.ts +38 -0
- package/dist/components/reasoning-panel/ReasoningPanel.js +172 -0
- package/dist/components/reasoning-panel/index.d.ts +2 -0
- package/dist/components/recommendation-card/RecommendationCard.d.ts +53 -0
- package/dist/components/recommendation-card/RecommendationCard.js +234 -0
- package/dist/components/recommendation-card/index.d.ts +2 -0
- package/dist/components/reveal/Reveal.d.ts +36 -0
- package/dist/components/reveal/Reveal.js +138 -0
- package/dist/components/reveal/index.d.ts +2 -0
- package/dist/components/ripple/Ripple.d.ts +11 -0
- package/dist/components/ripple/Ripple.js +45 -0
- package/dist/components/ripple/index.d.ts +2 -0
- package/dist/components/ripple-button/RippleButton.d.ts +17 -0
- package/dist/components/ripple-button/RippleButton.js +77 -0
- package/dist/components/ripple-button/index.d.ts +2 -0
- package/dist/components/scroll-anchor/ScrollAnchor.d.ts +33 -0
- package/dist/components/scroll-anchor/ScrollAnchor.js +99 -0
- package/dist/components/scroll-anchor/index.d.ts +2 -0
- package/dist/components/scroll-progress/ScrollProgress.d.ts +39 -0
- package/dist/components/scroll-progress/ScrollProgress.js +118 -0
- package/dist/components/scroll-progress/index.d.ts +2 -0
- package/dist/components/search-input/SearchInput.d.ts +56 -0
- package/dist/components/search-input/SearchInput.js +192 -0
- package/dist/components/search-input/index.d.ts +2 -0
- package/dist/components/select/Select.d.ts +44 -0
- package/dist/components/select/Select.js +255 -0
- package/dist/components/select/SelectPanel.d.ts +33 -0
- package/dist/components/select/SelectPanel.js +108 -0
- package/dist/components/select/index.d.ts +3 -0
- package/dist/components/select/types.d.ts +83 -0
- package/dist/components/select/types.js +8 -0
- package/dist/components/sheet/Sheet.d.ts +40 -0
- package/dist/components/sheet/Sheet.js +183 -0
- package/dist/components/sheet/index.d.ts +2 -0
- package/dist/components/shimmer-button/ShimmerButton.d.ts +26 -0
- package/dist/components/shimmer-button/ShimmerButton.js +69 -0
- package/dist/components/shimmer-button/index.d.ts +2 -0
- package/dist/components/sidebar/Sidebar.d.ts +17 -0
- package/dist/components/sidebar/Sidebar.js +27 -0
- package/dist/components/sidebar/SidebarFooter.d.ts +10 -0
- package/dist/components/sidebar/SidebarFooter.js +31 -0
- package/dist/components/sidebar/SidebarGroup.d.ts +10 -0
- package/dist/components/sidebar/SidebarGroup.js +28 -0
- package/dist/components/sidebar/SidebarItem.d.ts +33 -0
- package/dist/components/sidebar/SidebarItem.js +81 -0
- package/dist/components/sidebar/SidebarSeparator.d.ts +5 -0
- package/dist/components/sidebar/SidebarSeparator.js +13 -0
- package/dist/components/sidebar/index.d.ts +12 -0
- package/dist/components/sidebar/types.d.ts +36 -0
- package/dist/components/sidebar/types.js +7 -0
- package/dist/components/skeleton/Skeleton.d.ts +35 -0
- package/dist/components/skeleton/Skeleton.js +106 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/slider/Slider.d.ts +32 -0
- package/dist/components/slider/Slider.js +119 -0
- package/dist/components/slider/index.d.ts +2 -0
- package/dist/components/smooth-cursor/SmoothCursor.d.ts +18 -0
- package/dist/components/smooth-cursor/SmoothCursor.js +186 -0
- package/dist/components/smooth-cursor/index.d.ts +2 -0
- package/dist/components/sources/SourceCard.d.ts +21 -0
- package/dist/components/sources/SourceCard.js +48 -0
- package/dist/components/sources/Sources.d.ts +31 -0
- package/dist/components/sources/Sources.js +39 -0
- package/dist/components/sources/SourcesList.d.ts +13 -0
- package/dist/components/sources/SourcesList.js +42 -0
- package/dist/components/sources/SourcesTrigger.d.ts +11 -0
- package/dist/components/sources/SourcesTrigger.js +50 -0
- package/dist/components/sources/index.d.ts +10 -0
- package/dist/components/sources/types.d.ts +45 -0
- package/dist/components/sources/types.js +7 -0
- package/dist/components/sparkles/Sparkles.d.ts +35 -0
- package/dist/components/sparkles/Sparkles.js +112 -0
- package/dist/components/sparkles/index.d.ts +2 -0
- package/dist/components/sparkles-text/SparklesText.d.ts +28 -0
- package/dist/components/sparkles-text/SparklesText.js +84 -0
- package/dist/components/sparkles-text/index.d.ts +2 -0
- package/dist/components/status-morph/StatusMorph.d.ts +47 -0
- package/dist/components/status-morph/StatusMorph.js +110 -0
- package/dist/components/status-morph/index.d.ts +2 -0
- package/dist/components/stepper/Step.d.ts +24 -0
- package/dist/components/stepper/Step.js +152 -0
- package/dist/components/stepper/Stepper.d.ts +38 -0
- package/dist/components/stepper/Stepper.js +79 -0
- package/dist/components/stepper/index.d.ts +6 -0
- package/dist/components/stepper/types.d.ts +66 -0
- package/dist/components/stepper/types.js +7 -0
- package/dist/components/sticky-scroll/StickyScroll.d.ts +40 -0
- package/dist/components/sticky-scroll/StickyScroll.js +163 -0
- package/dist/components/sticky-scroll/index.d.ts +2 -0
- package/dist/components/streaming-text/StreamingText.d.ts +20 -0
- package/dist/components/streaming-text/StreamingText.js +32 -0
- package/dist/components/streaming-text/index.d.ts +2 -0
- package/dist/components/subagent-list/SubagentList.d.ts +28 -0
- package/dist/components/subagent-list/SubagentList.js +167 -0
- package/dist/components/subagent-list/index.d.ts +2 -0
- package/dist/components/switch/Switch.d.ts +55 -0
- package/dist/components/switch/Switch.js +77 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/tabs/Tabs.d.ts +43 -0
- package/dist/components/tabs/Tabs.js +123 -0
- package/dist/components/tabs/TabsContent.d.ts +26 -0
- package/dist/components/tabs/TabsContent.js +64 -0
- package/dist/components/tabs/TabsList.d.ts +16 -0
- package/dist/components/tabs/TabsList.js +152 -0
- package/dist/components/tabs/TabsTrigger.d.ts +19 -0
- package/dist/components/tabs/TabsTrigger.js +138 -0
- package/dist/components/tabs/index.d.ts +10 -0
- package/dist/components/tabs/types.d.ts +94 -0
- package/dist/components/tabs/types.js +7 -0
- package/dist/components/terminal-block/TerminalBlock.d.ts +27 -0
- package/dist/components/terminal-block/TerminalBlock.js +120 -0
- package/dist/components/terminal-block/ansi.d.ts +30 -0
- package/dist/components/terminal-block/ansi.js +114 -0
- package/dist/components/terminal-block/index.d.ts +2 -0
- package/dist/components/terminal-text/TerminalText.d.ts +11 -0
- package/dist/components/terminal-text/TerminalText.js +140 -0
- package/dist/components/terminal-text/index.d.ts +2 -0
- package/dist/components/text-generate-effect/TextGenerateEffect.d.ts +9 -0
- package/dist/components/text-generate-effect/TextGenerateEffect.js +58 -0
- package/dist/components/text-generate-effect/index.d.ts +2 -0
- package/dist/components/text-reveal-card/TextRevealCard.d.ts +21 -0
- package/dist/components/text-reveal-card/TextRevealCard.js +107 -0
- package/dist/components/text-reveal-card/TextRevealStars.d.ts +25 -0
- package/dist/components/text-reveal-card/TextRevealStars.js +59 -0
- package/dist/components/text-reveal-card/index.d.ts +4 -0
- package/dist/components/text-roll/TextRoll.d.ts +43 -0
- package/dist/components/text-roll/TextRoll.js +242 -0
- package/dist/components/text-roll/index.d.ts +2 -0
- package/dist/components/text-roll/roll-transitions.d.ts +74 -0
- package/dist/components/text-roll/roll-transitions.js +31 -0
- package/dist/components/textarea/Textarea.d.ts +48 -0
- package/dist/components/textarea/Textarea.js +129 -0
- package/dist/components/textarea/index.d.ts +2 -0
- package/dist/components/thinking-indicator/ThinkingIndicator.d.ts +26 -0
- package/dist/components/thinking-indicator/ThinkingIndicator.js +60 -0
- package/dist/components/thinking-indicator/index.d.ts +2 -0
- package/dist/components/thread-list/ThreadList.d.ts +44 -0
- package/dist/components/thread-list/ThreadList.js +178 -0
- package/dist/components/thread-list/index.d.ts +2 -0
- package/dist/components/time-picker/TimePicker.d.ts +44 -0
- package/dist/components/time-picker/TimePicker.js +254 -0
- package/dist/components/time-picker/TimePickerPanel.d.ts +30 -0
- package/dist/components/time-picker/TimePickerPanel.js +94 -0
- package/dist/components/time-picker/index.d.ts +2 -0
- package/dist/components/time-picker/time-utils.d.ts +33 -0
- package/dist/components/time-picker/time-utils.js +65 -0
- package/dist/components/time-picker/types.d.ts +53 -0
- package/dist/components/time-picker/types.js +10 -0
- package/dist/components/timeline/Timeline.d.ts +18 -0
- package/dist/components/timeline/Timeline.js +96 -0
- package/dist/components/timeline/index.d.ts +2 -0
- package/dist/components/toast/Toast.d.ts +16 -0
- package/dist/components/toast/Toast.js +99 -0
- package/dist/components/toast/Toaster.d.ts +19 -0
- package/dist/components/toast/Toaster.js +147 -0
- package/dist/components/toast/index.d.ts +6 -0
- package/dist/components/toast/store.d.ts +102 -0
- package/dist/components/toast/store.js +118 -0
- package/dist/components/toggle/Toggle.d.ts +28 -0
- package/dist/components/toggle/Toggle.js +69 -0
- package/dist/components/toggle/index.d.ts +2 -0
- package/dist/components/toggle-group/ToggleGroup.d.ts +42 -0
- package/dist/components/toggle-group/ToggleGroup.js +150 -0
- package/dist/components/toggle-group/ToggleGroupItem.d.ts +21 -0
- package/dist/components/toggle-group/ToggleGroupItem.js +100 -0
- package/dist/components/toggle-group/index.d.ts +6 -0
- package/dist/components/toggle-group/types.d.ts +75 -0
- package/dist/components/toggle-group/types.js +7 -0
- package/dist/components/tool-call/ToolCall.d.ts +39 -0
- package/dist/components/tool-call/ToolCall.js +195 -0
- package/dist/components/tool-call/index.d.ts +2 -0
- package/dist/components/tool-timeline/ToolTimeline.d.ts +31 -0
- package/dist/components/tool-timeline/ToolTimeline.js +99 -0
- package/dist/components/tool-timeline/index.d.ts +2 -0
- package/dist/components/tooltip/Tooltip.d.ts +36 -0
- package/dist/components/tooltip/Tooltip.js +214 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tracing-beam/TracingBeam.d.ts +11 -0
- package/dist/components/tracing-beam/TracingBeam.js +163 -0
- package/dist/components/tracing-beam/index.d.ts +2 -0
- package/dist/components/typing-indicator/TypingIndicator.d.ts +17 -0
- package/dist/components/typing-indicator/TypingIndicator.js +47 -0
- package/dist/components/typing-indicator/index.d.ts +2 -0
- package/dist/components/voice-input/VoiceInput.d.ts +60 -0
- package/dist/components/voice-input/VoiceInput.js +268 -0
- package/dist/components/voice-input/index.d.ts +2 -0
- package/dist/components/web-search/WebSearch.d.ts +37 -0
- package/dist/components/web-search/WebSearch.js +135 -0
- package/dist/components/web-search/index.d.ts +2 -0
- package/dist/index.d.ts +148 -0
- package/dist/index.js +489 -0
- package/dist/internals/Portal.d.ts +35 -0
- package/dist/internals/Portal.js +37 -0
- package/dist/internals/StreamText.d.ts +20 -0
- package/dist/internals/StreamText.js +25 -0
- package/dist/internals/ai-types.d.ts +117 -0
- package/dist/internals/anchor-position.d.ts +79 -0
- package/dist/internals/anchor-position.js +154 -0
- package/dist/internals/calendar-core.d.ts +26 -0
- package/dist/internals/calendar-core.js +57 -0
- package/dist/internals/diff.d.ts +38 -0
- package/dist/internals/diff.js +176 -0
- package/dist/internals/dismissable.d.ts +76 -0
- package/dist/internals/dismissable.js +105 -0
- package/dist/internals/dom/context.d.ts +16 -0
- package/dist/internals/dom/context.js +20 -0
- package/dist/internals/dom/ssr.d.ts +21 -0
- package/dist/internals/dom/ssr.js +21 -0
- package/dist/internals/dom/types.d.ts +9 -0
- package/dist/internals/dom/use-composed-refs.d.ts +15 -0
- package/dist/internals/dom/use-composed-refs.js +34 -0
- package/dist/internals/dom/use-element-ref.d.ts +11 -0
- package/dist/internals/dom/use-element-ref.js +12 -0
- package/dist/internals/dom/use-event-callback.d.ts +14 -0
- package/dist/internals/dom/use-event-callback.js +12 -0
- package/dist/internals/dom/use-inert-attribute.d.ts +26 -0
- package/dist/internals/dom/use-inert-attribute.js +22 -0
- package/dist/internals/dom/use-live-ref.d.ts +10 -0
- package/dist/internals/dom/use-live-ref.js +12 -0
- package/dist/internals/field.d.ts +136 -0
- package/dist/internals/field.js +33 -0
- package/dist/internals/float.d.ts +47 -0
- package/dist/internals/float.js +31 -0
- package/dist/internals/focus-trap.d.ts +82 -0
- package/dist/internals/focus-trap.js +145 -0
- package/dist/internals/host.d.ts +38 -0
- package/dist/internals/host.js +24 -0
- package/dist/internals/listbox.d.ts +101 -0
- package/dist/internals/listbox.js +171 -0
- package/dist/internals/markdown/Markdown.d.ts +22 -0
- package/dist/internals/markdown/Markdown.js +53 -0
- package/dist/internals/markdown/MarkdownInline.d.ts +5 -0
- package/dist/internals/markdown/MarkdownInline.js +40 -0
- package/dist/internals/markdown.d.ts +66 -0
- package/dist/internals/markdown.js +467 -0
- package/dist/internals/menu.d.ts +121 -0
- package/dist/internals/menu.js +217 -0
- package/dist/internals/motion/anchored.d.ts +104 -0
- package/dist/internals/motion/anchored.js +44 -0
- package/dist/internals/motion/animate.d.ts +92 -0
- package/dist/internals/motion/animate.js +84 -0
- package/dist/internals/motion/easing.d.ts +20 -0
- package/dist/internals/motion/easing.js +13 -0
- package/dist/internals/motion/haptics.d.ts +42 -0
- package/dist/internals/motion/haptics.js +29 -0
- package/dist/internals/motion/in-view.d.ts +67 -0
- package/dist/internals/motion/in-view.js +97 -0
- package/dist/internals/motion/media-query.d.ts +50 -0
- package/dist/internals/motion/media-query.js +54 -0
- package/dist/internals/motion/presence.d.ts +108 -0
- package/dist/internals/motion/presence.js +197 -0
- package/dist/internals/motion/presets.d.ts +34 -0
- package/dist/internals/motion/presets.js +19 -0
- package/dist/internals/motion/raf.d.ts +35 -0
- package/dist/internals/motion/raf.js +27 -0
- package/dist/internals/motion/stagger.d.ts +32 -0
- package/dist/internals/motion/stagger.js +15 -0
- package/dist/internals/motion/tokens.d.ts +97 -0
- package/dist/internals/motion/tokens.js +18 -0
- package/dist/internals/motion/transitions.d.ts +66 -0
- package/dist/internals/motion/transitions.js +41 -0
- package/dist/internals/motion/types.d.ts +17 -0
- package/dist/internals/relative-time.d.ts +25 -0
- package/dist/internals/relative-time.js +46 -0
- package/dist/internals/scroll-lock.d.ts +26 -0
- package/dist/internals/scroll-lock.js +65 -0
- package/dist/internals/use-anchor-position.d.ts +54 -0
- package/dist/internals/use-anchor-position.js +87 -0
- package/dist/internals/use-autoscroll.d.ts +43 -0
- package/dist/internals/use-autoscroll.js +128 -0
- package/dist/internals/use-copy.d.ts +54 -0
- package/dist/internals/use-copy.js +67 -0
- package/dist/internals/use-elapsed.d.ts +96 -0
- package/dist/internals/use-elapsed.js +195 -0
- package/dist/internals/use-float.d.ts +49 -0
- package/dist/internals/use-float.js +150 -0
- package/dist/internals/use-id.d.ts +22 -0
- package/dist/internals/use-id.js +20 -0
- package/dist/internals/use-text-stream.d.ts +94 -0
- package/dist/internals/use-text-stream.js +133 -0
- package/dist/internals/waveform-core.d.ts +33 -0
- package/dist/internals/waveform-core.js +39 -0
- package/dist/sound/SoundToggle.d.ts +23 -0
- package/dist/sound/SoundToggle.js +96 -0
- package/dist/sound/engine.d.ts +67 -0
- package/dist/sound/engine.js +370 -0
- package/dist/sound/index.d.ts +7 -0
- package/dist/sound/sound-feedback.d.ts +77 -0
- package/dist/sound/sound-feedback.js +152 -0
- package/dist/sound/sound.d.ts +98 -0
- package/dist/sound/sound.js +309 -0
- package/dist/sound/themes.d.ts +19 -0
- package/dist/sound/themes.js +355 -0
- package/dist/sound/types.d.ts +125 -0
- package/dist/sound/types.js +54 -0
- package/dist/sound/use-sound.d.ts +53 -0
- package/dist/sound/use-sound.js +82 -0
- package/dist/styles.css +7975 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +8 -0
- package/package.json +96 -0
- package/tailwind.css +132 -0
|
@@ -0,0 +1,1479 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useRef, useEffect } from "react";
|
|
4
|
+
import { useLiveRef } from "../../internals/dom/use-live-ref.js";
|
|
5
|
+
import { cn } from "../../utils.js";
|
|
6
|
+
import { hexToRgb, DEV, wrap, pointerPrototype, scaleRadiusForContainer, HSVtoRGB } from "./fluid-shared.js";
|
|
7
|
+
import { startWebGpuFluid } from "./webgpu-engine.js";
|
|
8
|
+
function FluidCursor({
|
|
9
|
+
simResolution = 128,
|
|
10
|
+
dyeResolution = 1440,
|
|
11
|
+
captureResolution = 512,
|
|
12
|
+
densityDissipation = 3.5,
|
|
13
|
+
velocityDissipation = 2,
|
|
14
|
+
pressure = 0.1,
|
|
15
|
+
pressureIterations = 20,
|
|
16
|
+
curl = 3,
|
|
17
|
+
splatRadius = 0.2,
|
|
18
|
+
splatForce = 6e3,
|
|
19
|
+
shading = true,
|
|
20
|
+
colorUpdateSpeed = 10,
|
|
21
|
+
backColor = { r: 0.5, g: 0, b: 0 },
|
|
22
|
+
transparent = true,
|
|
23
|
+
fluidColor,
|
|
24
|
+
fluidColors,
|
|
25
|
+
colorIntensity = 0.15,
|
|
26
|
+
className = "",
|
|
27
|
+
autoSplat = false,
|
|
28
|
+
autoSplatInterval = 1500,
|
|
29
|
+
interactive = true,
|
|
30
|
+
pauseWhenHidden = true,
|
|
31
|
+
splatOnMount = false,
|
|
32
|
+
allowMultiple = false,
|
|
33
|
+
contained = true,
|
|
34
|
+
hdr = false,
|
|
35
|
+
hdrBoost = 1.5,
|
|
36
|
+
dither = false,
|
|
37
|
+
ditherPixelSize = 3,
|
|
38
|
+
ditherLevels = 4,
|
|
39
|
+
onReady
|
|
40
|
+
}) {
|
|
41
|
+
const [derived] = useState(() => ({
|
|
42
|
+
clampedColorIntensity: Math.max(0, Math.min(1, colorIntensity)),
|
|
43
|
+
clampedHdrBoost: Math.max(1, Math.min(4, hdrBoost)),
|
|
44
|
+
clampedDitherPixelSize: Math.max(1, ditherPixelSize),
|
|
45
|
+
clampedDitherLevels: Math.max(2, Math.min(16, Math.floor(ditherLevels))),
|
|
46
|
+
resolvedBackColor: typeof backColor === "string" ? hexToRgb(backColor) : backColor
|
|
47
|
+
}));
|
|
48
|
+
const canvasRef = useRef(null);
|
|
49
|
+
const activeInstanceRef = useRef(null);
|
|
50
|
+
const mountCounterRef = useRef(0);
|
|
51
|
+
const colorCacheRef = useRef({
|
|
52
|
+
colorIndex: 0,
|
|
53
|
+
cachedFluidColorHex: void 0,
|
|
54
|
+
cachedFluidColor: null,
|
|
55
|
+
cachedFluidColorsRef: void 0,
|
|
56
|
+
cachedFluidColorsScaled: []
|
|
57
|
+
});
|
|
58
|
+
const fluidColorRef = useLiveRef(fluidColor);
|
|
59
|
+
const fluidColorsRef = useLiveRef(fluidColors);
|
|
60
|
+
const containedRef = useLiveRef(contained);
|
|
61
|
+
const onReadyRef = useLiveRef(onReady);
|
|
62
|
+
function getScaledColor(hex) {
|
|
63
|
+
const { r, g, b } = hexToRgb(hex);
|
|
64
|
+
return {
|
|
65
|
+
r: r * derived.clampedColorIntensity,
|
|
66
|
+
g: g * derived.clampedColorIntensity,
|
|
67
|
+
b: b * derived.clampedColorIntensity
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function getCachedFluidColor(hex) {
|
|
71
|
+
const cache = colorCacheRef.current;
|
|
72
|
+
if (cache.cachedFluidColor === null || cache.cachedFluidColorHex !== hex) {
|
|
73
|
+
cache.cachedFluidColorHex = hex;
|
|
74
|
+
cache.cachedFluidColor = getScaledColor(hex);
|
|
75
|
+
}
|
|
76
|
+
return cache.cachedFluidColor;
|
|
77
|
+
}
|
|
78
|
+
function getCachedFluidColors(colors) {
|
|
79
|
+
const cache = colorCacheRef.current;
|
|
80
|
+
if (cache.cachedFluidColorsRef !== colors) {
|
|
81
|
+
cache.cachedFluidColorsRef = colors;
|
|
82
|
+
cache.cachedFluidColorsScaled = colors.map((hex) => getScaledColor(hex));
|
|
83
|
+
}
|
|
84
|
+
return cache.cachedFluidColorsScaled;
|
|
85
|
+
}
|
|
86
|
+
function generateColor() {
|
|
87
|
+
const cache = colorCacheRef.current;
|
|
88
|
+
if (fluidColorRef.current) {
|
|
89
|
+
return getCachedFluidColor(fluidColorRef.current);
|
|
90
|
+
}
|
|
91
|
+
const palette = fluidColorsRef.current;
|
|
92
|
+
if (palette && palette.length > 0) {
|
|
93
|
+
const colors = getCachedFluidColors(palette);
|
|
94
|
+
const idx = cache.colorIndex % colors.length;
|
|
95
|
+
cache.colorIndex++;
|
|
96
|
+
return colors[idx];
|
|
97
|
+
}
|
|
98
|
+
const c = HSVtoRGB(Math.random(), 1, 1);
|
|
99
|
+
c.r *= derived.clampedColorIntensity;
|
|
100
|
+
c.g *= derived.clampedColorIntensity;
|
|
101
|
+
c.b *= derived.clampedColorIntensity;
|
|
102
|
+
return c;
|
|
103
|
+
}
|
|
104
|
+
function registerInstance(cleanup) {
|
|
105
|
+
if (!allowMultiple) {
|
|
106
|
+
if (activeInstanceRef.current) {
|
|
107
|
+
if (DEV) {
|
|
108
|
+
console.warn(
|
|
109
|
+
"[FluidCursor] Destroying previous instance. Only one instance is allowed by default. Use `allowMultiple={true}` to opt out of singleton behavior."
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
activeInstanceRef.current();
|
|
113
|
+
}
|
|
114
|
+
activeInstanceRef.current = cleanup;
|
|
115
|
+
return () => {
|
|
116
|
+
cleanup();
|
|
117
|
+
if (activeInstanceRef.current === cleanup) {
|
|
118
|
+
activeInstanceRef.current = null;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return cleanup;
|
|
123
|
+
}
|
|
124
|
+
const noRendererHandle = {
|
|
125
|
+
moveTo() {
|
|
126
|
+
},
|
|
127
|
+
penUp() {
|
|
128
|
+
},
|
|
129
|
+
burst() {
|
|
130
|
+
},
|
|
131
|
+
renderLevel: "none"
|
|
132
|
+
};
|
|
133
|
+
function notifyReady(handle) {
|
|
134
|
+
const callback = onReadyRef.current;
|
|
135
|
+
if (!callback) return;
|
|
136
|
+
try {
|
|
137
|
+
callback(handle);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
queueMicrotask(() => {
|
|
140
|
+
throw error;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
const canvasNode = canvasRef.current;
|
|
146
|
+
if (!canvasNode) return;
|
|
147
|
+
const canvas = canvasNode;
|
|
148
|
+
const mountToken = ++mountCounterRef.current;
|
|
149
|
+
const pointers = [pointerPrototype()];
|
|
150
|
+
const config = {
|
|
151
|
+
SIM_RESOLUTION: simResolution,
|
|
152
|
+
DYE_RESOLUTION: dyeResolution,
|
|
153
|
+
DENSITY_DISSIPATION: densityDissipation,
|
|
154
|
+
VELOCITY_DISSIPATION: velocityDissipation,
|
|
155
|
+
PRESSURE: pressure,
|
|
156
|
+
PRESSURE_ITERATIONS: pressureIterations,
|
|
157
|
+
CURL: curl,
|
|
158
|
+
SPLAT_RADIUS: splatRadius,
|
|
159
|
+
SPLAT_FORCE: splatForce,
|
|
160
|
+
SHADING: shading,
|
|
161
|
+
COLOR_UPDATE_SPEED: colorUpdateSpeed,
|
|
162
|
+
BACK_COLOR: derived.resolvedBackColor,
|
|
163
|
+
DITHER: dither,
|
|
164
|
+
DITHER_PIXEL_SIZE: derived.clampedDitherPixelSize,
|
|
165
|
+
DITHER_LEVELS: derived.clampedDitherLevels
|
|
166
|
+
};
|
|
167
|
+
if (hdr && !dither && typeof navigator !== "undefined" && "gpu" in navigator) {
|
|
168
|
+
let disposed = false;
|
|
169
|
+
let activeCleanup = null;
|
|
170
|
+
startWebGpuFluid(canvas, {
|
|
171
|
+
simResolution: config.SIM_RESOLUTION,
|
|
172
|
+
dyeResolution: config.DYE_RESOLUTION,
|
|
173
|
+
densityDissipation: config.DENSITY_DISSIPATION,
|
|
174
|
+
velocityDissipation: config.VELOCITY_DISSIPATION,
|
|
175
|
+
pressure: config.PRESSURE,
|
|
176
|
+
pressureIterations: config.PRESSURE_ITERATIONS,
|
|
177
|
+
curl: config.CURL,
|
|
178
|
+
splatRadius: config.SPLAT_RADIUS,
|
|
179
|
+
splatForce: config.SPLAT_FORCE,
|
|
180
|
+
shading: config.SHADING,
|
|
181
|
+
colorUpdateSpeed: config.COLOR_UPDATE_SPEED,
|
|
182
|
+
exposure: derived.clampedHdrBoost,
|
|
183
|
+
contained,
|
|
184
|
+
interactive,
|
|
185
|
+
autoSplat,
|
|
186
|
+
autoSplatInterval,
|
|
187
|
+
pauseWhenHidden,
|
|
188
|
+
splatOnMount,
|
|
189
|
+
generateColor
|
|
190
|
+
}).then((handle) => {
|
|
191
|
+
if (disposed) {
|
|
192
|
+
handle?.cleanup();
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (!allowMultiple && mountToken !== mountCounterRef.current) {
|
|
196
|
+
handle?.cleanup();
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (!handle) {
|
|
200
|
+
activeCleanup = startWebGl() ?? null;
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
activeCleanup = registerInstance(handle.cleanup);
|
|
204
|
+
notifyReady(handle);
|
|
205
|
+
}).catch((error) => {
|
|
206
|
+
if (DEV) {
|
|
207
|
+
console.warn("[FluidCursor] WebGPU setup failed, falling back to WebGL:", error);
|
|
208
|
+
}
|
|
209
|
+
if (!disposed) activeCleanup = startWebGl() ?? null;
|
|
210
|
+
});
|
|
211
|
+
return () => {
|
|
212
|
+
disposed = true;
|
|
213
|
+
activeCleanup?.();
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
return startWebGl();
|
|
217
|
+
function startWebGl() {
|
|
218
|
+
const glDisposers = [];
|
|
219
|
+
let renderLevel = "webgl-sdr";
|
|
220
|
+
const autopilotPointer = onReady ? pointerPrototype() : null;
|
|
221
|
+
if (autopilotPointer) pointers.push(autopilotPointer);
|
|
222
|
+
let penWasUp = true;
|
|
223
|
+
const context = getWebGLContext(canvas);
|
|
224
|
+
if (!context.gl || !context.ext) {
|
|
225
|
+
notifyReady(noRendererHandle);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const gl = context.gl;
|
|
229
|
+
const ext = context.ext;
|
|
230
|
+
if (!ext.supportLinearFiltering) {
|
|
231
|
+
config.DYE_RESOLUTION = 256;
|
|
232
|
+
config.SHADING = false;
|
|
233
|
+
}
|
|
234
|
+
function getWebGLContext(canvas2) {
|
|
235
|
+
const params = {
|
|
236
|
+
alpha: true,
|
|
237
|
+
depth: false,
|
|
238
|
+
stencil: false,
|
|
239
|
+
antialias: false,
|
|
240
|
+
preserveDrawingBuffer: false
|
|
241
|
+
};
|
|
242
|
+
let gl2 = canvas2.getContext("webgl2", params);
|
|
243
|
+
if (!gl2) {
|
|
244
|
+
gl2 = canvas2.getContext("webgl", params) || canvas2.getContext("experimental-webgl", params);
|
|
245
|
+
}
|
|
246
|
+
if (!gl2) {
|
|
247
|
+
console.error("Unable to initialize WebGL.");
|
|
248
|
+
return { gl: null, ext: null };
|
|
249
|
+
}
|
|
250
|
+
if (hdr && "drawingBufferColorSpace" in gl2) {
|
|
251
|
+
try {
|
|
252
|
+
gl2.drawingBufferColorSpace = "display-p3";
|
|
253
|
+
if (gl2.drawingBufferColorSpace === "display-p3") {
|
|
254
|
+
renderLevel = "webgl-p3";
|
|
255
|
+
}
|
|
256
|
+
} catch {
|
|
257
|
+
}
|
|
258
|
+
if (DEV) {
|
|
259
|
+
console.info(
|
|
260
|
+
renderLevel === "webgl-p3" ? "[FluidCursor] HDR level: webgl-p3 (wide gamut fallback)" : "[FluidCursor] HDR level: webgl-sdr (display-p3 drawing buffer rejected)"
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
const isWebGL2 = "drawBuffers" in gl2;
|
|
265
|
+
let supportLinearFiltering = false;
|
|
266
|
+
let halfFloat = null;
|
|
267
|
+
if (isWebGL2) {
|
|
268
|
+
gl2.getExtension("EXT_color_buffer_float");
|
|
269
|
+
supportLinearFiltering = !!gl2.getExtension(
|
|
270
|
+
"OES_texture_float_linear"
|
|
271
|
+
);
|
|
272
|
+
} else {
|
|
273
|
+
halfFloat = gl2.getExtension("OES_texture_half_float");
|
|
274
|
+
supportLinearFiltering = !!gl2.getExtension("OES_texture_half_float_linear");
|
|
275
|
+
}
|
|
276
|
+
gl2.clearColor(0, 0, 0, 1);
|
|
277
|
+
const halfFloatTexType = isWebGL2 ? gl2.HALF_FLOAT : halfFloat && halfFloat.HALF_FLOAT_OES || 0;
|
|
278
|
+
let formatRGBA;
|
|
279
|
+
let formatRG;
|
|
280
|
+
let formatR;
|
|
281
|
+
if (isWebGL2) {
|
|
282
|
+
formatRGBA = getSupportedFormat(
|
|
283
|
+
gl2,
|
|
284
|
+
gl2.RGBA16F,
|
|
285
|
+
gl2.RGBA,
|
|
286
|
+
halfFloatTexType
|
|
287
|
+
);
|
|
288
|
+
formatRG = getSupportedFormat(
|
|
289
|
+
gl2,
|
|
290
|
+
gl2.RG16F,
|
|
291
|
+
gl2.RG,
|
|
292
|
+
halfFloatTexType
|
|
293
|
+
);
|
|
294
|
+
formatR = getSupportedFormat(
|
|
295
|
+
gl2,
|
|
296
|
+
gl2.R16F,
|
|
297
|
+
gl2.RED,
|
|
298
|
+
halfFloatTexType
|
|
299
|
+
);
|
|
300
|
+
} else {
|
|
301
|
+
formatRGBA = getSupportedFormat(gl2, gl2.RGBA, gl2.RGBA, halfFloatTexType);
|
|
302
|
+
formatRG = getSupportedFormat(gl2, gl2.RGBA, gl2.RGBA, halfFloatTexType);
|
|
303
|
+
formatR = getSupportedFormat(gl2, gl2.RGBA, gl2.RGBA, halfFloatTexType);
|
|
304
|
+
}
|
|
305
|
+
return {
|
|
306
|
+
gl: gl2,
|
|
307
|
+
ext: {
|
|
308
|
+
formatRGBA,
|
|
309
|
+
formatRG,
|
|
310
|
+
formatR,
|
|
311
|
+
halfFloatTexType,
|
|
312
|
+
supportLinearFiltering
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
function getSupportedFormat(gl2, internalFormat, format, type) {
|
|
317
|
+
if (!supportRenderTextureFormat(gl2, internalFormat, format, type)) {
|
|
318
|
+
if ("drawBuffers" in gl2) {
|
|
319
|
+
const gl22 = gl2;
|
|
320
|
+
switch (internalFormat) {
|
|
321
|
+
case gl22.R16F:
|
|
322
|
+
return getSupportedFormat(gl22, gl22.RG16F, gl22.RG, type);
|
|
323
|
+
case gl22.RG16F:
|
|
324
|
+
return getSupportedFormat(gl22, gl22.RGBA16F, gl22.RGBA, type);
|
|
325
|
+
default:
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
return { internalFormat, format };
|
|
332
|
+
}
|
|
333
|
+
function supportRenderTextureFormat(gl2, internalFormat, format, type) {
|
|
334
|
+
const texture = gl2.createTexture();
|
|
335
|
+
if (!texture) return false;
|
|
336
|
+
glDisposers.push(() => gl2.deleteTexture(texture));
|
|
337
|
+
gl2.bindTexture(gl2.TEXTURE_2D, texture);
|
|
338
|
+
gl2.texParameteri(gl2.TEXTURE_2D, gl2.TEXTURE_MIN_FILTER, gl2.NEAREST);
|
|
339
|
+
gl2.texParameteri(gl2.TEXTURE_2D, gl2.TEXTURE_MAG_FILTER, gl2.NEAREST);
|
|
340
|
+
gl2.texParameteri(gl2.TEXTURE_2D, gl2.TEXTURE_WRAP_S, gl2.CLAMP_TO_EDGE);
|
|
341
|
+
gl2.texParameteri(gl2.TEXTURE_2D, gl2.TEXTURE_WRAP_T, gl2.CLAMP_TO_EDGE);
|
|
342
|
+
gl2.texImage2D(gl2.TEXTURE_2D, 0, internalFormat, 4, 4, 0, format, type, null);
|
|
343
|
+
const fbo = gl2.createFramebuffer();
|
|
344
|
+
if (!fbo) return false;
|
|
345
|
+
glDisposers.push(() => gl2.deleteFramebuffer(fbo));
|
|
346
|
+
gl2.bindFramebuffer(gl2.FRAMEBUFFER, fbo);
|
|
347
|
+
gl2.framebufferTexture2D(gl2.FRAMEBUFFER, gl2.COLOR_ATTACHMENT0, gl2.TEXTURE_2D, texture, 0);
|
|
348
|
+
const status = gl2.checkFramebufferStatus(gl2.FRAMEBUFFER);
|
|
349
|
+
return status === gl2.FRAMEBUFFER_COMPLETE;
|
|
350
|
+
}
|
|
351
|
+
function hashCode(s) {
|
|
352
|
+
if (!s.length) return 0;
|
|
353
|
+
let hash = 0;
|
|
354
|
+
for (let i = 0; i < s.length; i++) {
|
|
355
|
+
hash = (hash << 5) - hash + s.charCodeAt(i);
|
|
356
|
+
hash |= 0;
|
|
357
|
+
}
|
|
358
|
+
return hash;
|
|
359
|
+
}
|
|
360
|
+
function addKeywords(source, keywords) {
|
|
361
|
+
if (!keywords) return source;
|
|
362
|
+
let keywordsString = "";
|
|
363
|
+
for (const keyword of keywords) {
|
|
364
|
+
keywordsString += `#define ${keyword}
|
|
365
|
+
`;
|
|
366
|
+
}
|
|
367
|
+
return keywordsString + source;
|
|
368
|
+
}
|
|
369
|
+
function compileShader(type, source, keywords = null) {
|
|
370
|
+
const shaderSource = addKeywords(source, keywords);
|
|
371
|
+
const shader = gl.createShader(type);
|
|
372
|
+
if (!shader) return null;
|
|
373
|
+
glDisposers.push(() => gl.deleteShader(shader));
|
|
374
|
+
gl.shaderSource(shader, shaderSource);
|
|
375
|
+
gl.compileShader(shader);
|
|
376
|
+
return shader;
|
|
377
|
+
}
|
|
378
|
+
function createProgram(vertexShader, fragmentShader) {
|
|
379
|
+
if (!vertexShader || !fragmentShader) return null;
|
|
380
|
+
const program = gl.createProgram();
|
|
381
|
+
if (!program) return null;
|
|
382
|
+
glDisposers.push(() => gl.deleteProgram(program));
|
|
383
|
+
gl.attachShader(program, vertexShader);
|
|
384
|
+
gl.attachShader(program, fragmentShader);
|
|
385
|
+
gl.linkProgram(program);
|
|
386
|
+
return program;
|
|
387
|
+
}
|
|
388
|
+
function getUniforms(program) {
|
|
389
|
+
const uniforms = {};
|
|
390
|
+
const uniformCount = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
|
|
391
|
+
for (let i = 0; i < uniformCount; i++) {
|
|
392
|
+
const uniformInfo = gl.getActiveUniform(program, i);
|
|
393
|
+
if (uniformInfo) {
|
|
394
|
+
uniforms[uniformInfo.name] = gl.getUniformLocation(program, uniformInfo.name);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return uniforms;
|
|
398
|
+
}
|
|
399
|
+
class Program {
|
|
400
|
+
program;
|
|
401
|
+
uniforms;
|
|
402
|
+
constructor(vertexShader, fragmentShader) {
|
|
403
|
+
this.program = createProgram(vertexShader, fragmentShader);
|
|
404
|
+
this.uniforms = this.program ? getUniforms(this.program) : {};
|
|
405
|
+
}
|
|
406
|
+
bind() {
|
|
407
|
+
if (this.program) gl.useProgram(this.program);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
class Material {
|
|
411
|
+
vertexShader;
|
|
412
|
+
fragmentShaderSource;
|
|
413
|
+
programs;
|
|
414
|
+
activeProgram;
|
|
415
|
+
uniforms;
|
|
416
|
+
constructor(vertexShader, fragmentShaderSource) {
|
|
417
|
+
this.vertexShader = vertexShader;
|
|
418
|
+
this.fragmentShaderSource = fragmentShaderSource;
|
|
419
|
+
this.programs = {};
|
|
420
|
+
this.activeProgram = null;
|
|
421
|
+
this.uniforms = {};
|
|
422
|
+
}
|
|
423
|
+
setKeywords(keywords) {
|
|
424
|
+
let hash = 0;
|
|
425
|
+
for (const kw of keywords) {
|
|
426
|
+
hash += hashCode(kw);
|
|
427
|
+
}
|
|
428
|
+
let program = this.programs[hash];
|
|
429
|
+
if (program == null) {
|
|
430
|
+
const fragmentShader = compileShader(
|
|
431
|
+
gl.FRAGMENT_SHADER,
|
|
432
|
+
this.fragmentShaderSource,
|
|
433
|
+
keywords
|
|
434
|
+
);
|
|
435
|
+
program = createProgram(this.vertexShader, fragmentShader);
|
|
436
|
+
this.programs[hash] = program;
|
|
437
|
+
}
|
|
438
|
+
if (program === this.activeProgram) return;
|
|
439
|
+
if (program) {
|
|
440
|
+
this.uniforms = getUniforms(program);
|
|
441
|
+
}
|
|
442
|
+
this.activeProgram = program;
|
|
443
|
+
}
|
|
444
|
+
bind() {
|
|
445
|
+
if (this.activeProgram) {
|
|
446
|
+
gl.useProgram(this.activeProgram);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
const baseVertexShader = compileShader(
|
|
451
|
+
gl.VERTEX_SHADER,
|
|
452
|
+
`
|
|
453
|
+
precision highp float;
|
|
454
|
+
attribute vec2 aPosition;
|
|
455
|
+
varying vec2 vUv;
|
|
456
|
+
varying vec2 vL;
|
|
457
|
+
varying vec2 vR;
|
|
458
|
+
varying vec2 vT;
|
|
459
|
+
varying vec2 vB;
|
|
460
|
+
uniform vec2 texelSize;
|
|
461
|
+
|
|
462
|
+
void main () {
|
|
463
|
+
vUv = aPosition * 0.5 + 0.5;
|
|
464
|
+
vL = vUv - vec2(texelSize.x, 0.0);
|
|
465
|
+
vR = vUv + vec2(texelSize.x, 0.0);
|
|
466
|
+
vT = vUv + vec2(0.0, texelSize.y);
|
|
467
|
+
vB = vUv - vec2(0.0, texelSize.y);
|
|
468
|
+
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
469
|
+
}
|
|
470
|
+
`
|
|
471
|
+
);
|
|
472
|
+
const copyShader = compileShader(
|
|
473
|
+
gl.FRAGMENT_SHADER,
|
|
474
|
+
`
|
|
475
|
+
precision mediump float;
|
|
476
|
+
precision mediump sampler2D;
|
|
477
|
+
varying highp vec2 vUv;
|
|
478
|
+
uniform sampler2D uTexture;
|
|
479
|
+
|
|
480
|
+
void main () {
|
|
481
|
+
gl_FragColor = texture2D(uTexture, vUv);
|
|
482
|
+
}
|
|
483
|
+
`
|
|
484
|
+
);
|
|
485
|
+
const clearShader = compileShader(
|
|
486
|
+
gl.FRAGMENT_SHADER,
|
|
487
|
+
`
|
|
488
|
+
precision mediump float;
|
|
489
|
+
precision mediump sampler2D;
|
|
490
|
+
varying highp vec2 vUv;
|
|
491
|
+
uniform sampler2D uTexture;
|
|
492
|
+
uniform float value;
|
|
493
|
+
|
|
494
|
+
void main () {
|
|
495
|
+
gl_FragColor = value * texture2D(uTexture, vUv);
|
|
496
|
+
}
|
|
497
|
+
`
|
|
498
|
+
);
|
|
499
|
+
const displayShaderSource = `
|
|
500
|
+
precision highp float;
|
|
501
|
+
precision highp sampler2D;
|
|
502
|
+
varying vec2 vUv;
|
|
503
|
+
varying vec2 vL;
|
|
504
|
+
varying vec2 vR;
|
|
505
|
+
varying vec2 vT;
|
|
506
|
+
varying vec2 vB;
|
|
507
|
+
uniform sampler2D uTexture;
|
|
508
|
+
uniform vec2 texelSize;
|
|
509
|
+
#ifdef DITHERING
|
|
510
|
+
uniform float uDitherPixel;
|
|
511
|
+
uniform float uDitherLevels;
|
|
512
|
+
#endif
|
|
513
|
+
|
|
514
|
+
vec3 linearToGamma (vec3 color) {
|
|
515
|
+
color = max(color, vec3(0));
|
|
516
|
+
return max(1.055 * pow(color, vec3(0.416666667)) - 0.055, vec3(0));
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
#ifdef DITHERING
|
|
520
|
+
// Recursive ordered-dither thresholds (4x4 Bayer, 16 levels).
|
|
521
|
+
// GLSL ES 1.00-safe: floor/fract arithmetic only — no arrays,
|
|
522
|
+
// no integer ops, no dynamic indexing.
|
|
523
|
+
float bayer2 (vec2 a) {
|
|
524
|
+
a = floor(a);
|
|
525
|
+
return fract(a.x * 0.5 + a.y * a.y * 0.75);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
float bayer4 (vec2 a) {
|
|
529
|
+
return bayer2(a * 0.5) * 0.25 + bayer2(a);
|
|
530
|
+
}
|
|
531
|
+
#endif
|
|
532
|
+
|
|
533
|
+
void main () {
|
|
534
|
+
#ifdef DITHERING
|
|
535
|
+
// One cell = one chunky pixel: every fragment in the cell samples
|
|
536
|
+
// the dye at the cell center and shares one Bayer threshold, so
|
|
537
|
+
// the cell renders as a solid square dot.
|
|
538
|
+
vec2 cell = floor(gl_FragCoord.xy / uDitherPixel);
|
|
539
|
+
vec2 uv = (cell + 0.5) * uDitherPixel * texelSize;
|
|
540
|
+
vec3 c = clamp(texture2D(uTexture, uv).rgb, 0.0, 1.0);
|
|
541
|
+
|
|
542
|
+
float steps = uDitherLevels - 1.0;
|
|
543
|
+
c = floor(c * steps + bayer4(cell)) / steps;
|
|
544
|
+
|
|
545
|
+
// Alpha from the quantized color: cells that quantize to black
|
|
546
|
+
// stay fully transparent, so dot density encodes brightness
|
|
547
|
+
// with no grey haze over the background.
|
|
548
|
+
float a = max(c.r, max(c.g, c.b));
|
|
549
|
+
gl_FragColor = vec4(c, a);
|
|
550
|
+
#else
|
|
551
|
+
vec3 c = texture2D(uTexture, vUv).rgb;
|
|
552
|
+
#ifdef SHADING
|
|
553
|
+
vec3 lc = texture2D(uTexture, vL).rgb;
|
|
554
|
+
vec3 rc = texture2D(uTexture, vR).rgb;
|
|
555
|
+
vec3 tc = texture2D(uTexture, vT).rgb;
|
|
556
|
+
vec3 bc = texture2D(uTexture, vB).rgb;
|
|
557
|
+
|
|
558
|
+
float dx = length(rc) - length(lc);
|
|
559
|
+
float dy = length(tc) - length(bc);
|
|
560
|
+
|
|
561
|
+
vec3 n = normalize(vec3(dx, dy, length(texelSize)));
|
|
562
|
+
vec3 l = vec3(0.0, 0.0, 1.0);
|
|
563
|
+
|
|
564
|
+
float diffuse = clamp(dot(n, l) + 0.7, 0.7, 1.0);
|
|
565
|
+
c *= diffuse;
|
|
566
|
+
#endif
|
|
567
|
+
|
|
568
|
+
float a = max(c.r, max(c.g, c.b));
|
|
569
|
+
gl_FragColor = vec4(c, a);
|
|
570
|
+
#endif
|
|
571
|
+
}
|
|
572
|
+
`;
|
|
573
|
+
const splatShader = compileShader(
|
|
574
|
+
gl.FRAGMENT_SHADER,
|
|
575
|
+
`
|
|
576
|
+
precision highp float;
|
|
577
|
+
precision highp sampler2D;
|
|
578
|
+
varying vec2 vUv;
|
|
579
|
+
uniform sampler2D uTarget;
|
|
580
|
+
uniform float aspectRatio;
|
|
581
|
+
uniform vec3 color;
|
|
582
|
+
uniform vec2 point;
|
|
583
|
+
uniform float radius;
|
|
584
|
+
|
|
585
|
+
void main () {
|
|
586
|
+
vec2 p = vUv - point.xy;
|
|
587
|
+
p.x *= aspectRatio;
|
|
588
|
+
vec3 splat = exp(-dot(p, p) / radius) * color;
|
|
589
|
+
vec3 base = texture2D(uTarget, vUv).xyz;
|
|
590
|
+
gl_FragColor = vec4(base + splat, 1.0);
|
|
591
|
+
}
|
|
592
|
+
`
|
|
593
|
+
);
|
|
594
|
+
const advectionShader = compileShader(
|
|
595
|
+
gl.FRAGMENT_SHADER,
|
|
596
|
+
`
|
|
597
|
+
precision highp float;
|
|
598
|
+
precision highp sampler2D;
|
|
599
|
+
varying vec2 vUv;
|
|
600
|
+
uniform sampler2D uVelocity;
|
|
601
|
+
uniform sampler2D uSource;
|
|
602
|
+
uniform vec2 texelSize;
|
|
603
|
+
uniform vec2 dyeTexelSize;
|
|
604
|
+
uniform float dt;
|
|
605
|
+
uniform float dissipation;
|
|
606
|
+
|
|
607
|
+
vec4 bilerp (sampler2D sam, vec2 uv, vec2 tsize) {
|
|
608
|
+
vec2 st = uv / tsize - 0.5;
|
|
609
|
+
vec2 iuv = floor(st);
|
|
610
|
+
vec2 fuv = fract(st);
|
|
611
|
+
|
|
612
|
+
vec4 a = texture2D(sam, (iuv + vec2(0.5, 0.5)) * tsize);
|
|
613
|
+
vec4 b = texture2D(sam, (iuv + vec2(1.5, 0.5)) * tsize);
|
|
614
|
+
vec4 c = texture2D(sam, (iuv + vec2(0.5, 1.5)) * tsize);
|
|
615
|
+
vec4 d = texture2D(sam, (iuv + vec2(1.5, 1.5)) * tsize);
|
|
616
|
+
|
|
617
|
+
return mix(mix(a, b, fuv.x), mix(c, d, fuv.x), fuv.y);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
void main () {
|
|
621
|
+
#ifdef MANUAL_FILTERING
|
|
622
|
+
vec2 coord = vUv - dt * bilerp(uVelocity, vUv, texelSize).xy * texelSize;
|
|
623
|
+
vec4 result = bilerp(uSource, coord, dyeTexelSize);
|
|
624
|
+
#else
|
|
625
|
+
vec2 coord = vUv - dt * texture2D(uVelocity, vUv).xy * texelSize;
|
|
626
|
+
vec4 result = texture2D(uSource, coord);
|
|
627
|
+
#endif
|
|
628
|
+
float decay = 1.0 + dissipation * dt;
|
|
629
|
+
gl_FragColor = result / decay;
|
|
630
|
+
}
|
|
631
|
+
`,
|
|
632
|
+
ext.supportLinearFiltering ? null : ["MANUAL_FILTERING"]
|
|
633
|
+
);
|
|
634
|
+
const divergenceShader = compileShader(
|
|
635
|
+
gl.FRAGMENT_SHADER,
|
|
636
|
+
`
|
|
637
|
+
precision mediump float;
|
|
638
|
+
precision mediump sampler2D;
|
|
639
|
+
varying highp vec2 vUv;
|
|
640
|
+
varying highp vec2 vL;
|
|
641
|
+
varying highp vec2 vR;
|
|
642
|
+
varying highp vec2 vT;
|
|
643
|
+
varying highp vec2 vB;
|
|
644
|
+
uniform sampler2D uVelocity;
|
|
645
|
+
|
|
646
|
+
void main () {
|
|
647
|
+
float L = texture2D(uVelocity, vL).x;
|
|
648
|
+
float R = texture2D(uVelocity, vR).x;
|
|
649
|
+
float T = texture2D(uVelocity, vT).y;
|
|
650
|
+
float B = texture2D(uVelocity, vB).y;
|
|
651
|
+
|
|
652
|
+
vec2 C = texture2D(uVelocity, vUv).xy;
|
|
653
|
+
if (vL.x < 0.0) { L = -C.x; }
|
|
654
|
+
if (vR.x > 1.0) { R = -C.x; }
|
|
655
|
+
if (vT.y > 1.0) { T = -C.y; }
|
|
656
|
+
if (vB.y < 0.0) { B = -C.y; }
|
|
657
|
+
|
|
658
|
+
float div = 0.5 * (R - L + T - B);
|
|
659
|
+
gl_FragColor = vec4(div, 0.0, 0.0, 1.0);
|
|
660
|
+
}
|
|
661
|
+
`
|
|
662
|
+
);
|
|
663
|
+
const curlShader = compileShader(
|
|
664
|
+
gl.FRAGMENT_SHADER,
|
|
665
|
+
`
|
|
666
|
+
precision mediump float;
|
|
667
|
+
precision mediump sampler2D;
|
|
668
|
+
varying highp vec2 vUv;
|
|
669
|
+
varying highp vec2 vL;
|
|
670
|
+
varying highp vec2 vR;
|
|
671
|
+
varying highp vec2 vT;
|
|
672
|
+
varying highp vec2 vB;
|
|
673
|
+
uniform sampler2D uVelocity;
|
|
674
|
+
|
|
675
|
+
void main () {
|
|
676
|
+
float L = texture2D(uVelocity, vL).y;
|
|
677
|
+
float R = texture2D(uVelocity, vR).y;
|
|
678
|
+
float T = texture2D(uVelocity, vT).x;
|
|
679
|
+
float B = texture2D(uVelocity, vB).x;
|
|
680
|
+
float vorticity = R - L - T + B;
|
|
681
|
+
gl_FragColor = vec4(0.5 * vorticity, 0.0, 0.0, 1.0);
|
|
682
|
+
}
|
|
683
|
+
`
|
|
684
|
+
);
|
|
685
|
+
const vorticityShader = compileShader(
|
|
686
|
+
gl.FRAGMENT_SHADER,
|
|
687
|
+
`
|
|
688
|
+
precision highp float;
|
|
689
|
+
precision highp sampler2D;
|
|
690
|
+
varying vec2 vUv;
|
|
691
|
+
varying vec2 vL;
|
|
692
|
+
varying vec2 vR;
|
|
693
|
+
varying vec2 vT;
|
|
694
|
+
varying vec2 vB;
|
|
695
|
+
uniform sampler2D uVelocity;
|
|
696
|
+
uniform sampler2D uCurl;
|
|
697
|
+
uniform float curl;
|
|
698
|
+
uniform float dt;
|
|
699
|
+
|
|
700
|
+
void main () {
|
|
701
|
+
float L = texture2D(uCurl, vL).x;
|
|
702
|
+
float R = texture2D(uCurl, vR).x;
|
|
703
|
+
float T = texture2D(uCurl, vT).x;
|
|
704
|
+
float B = texture2D(uCurl, vB).x;
|
|
705
|
+
float C = texture2D(uCurl, vUv).x;
|
|
706
|
+
|
|
707
|
+
vec2 force = 0.5 * vec2(abs(T) - abs(B), abs(R) - abs(L));
|
|
708
|
+
force /= length(force) + 0.0001;
|
|
709
|
+
force *= curl * C;
|
|
710
|
+
force.y *= -1.0;
|
|
711
|
+
|
|
712
|
+
vec2 velocity = texture2D(uVelocity, vUv).xy;
|
|
713
|
+
velocity += force * dt;
|
|
714
|
+
velocity = min(max(velocity, -1000.0), 1000.0);
|
|
715
|
+
gl_FragColor = vec4(velocity, 0.0, 1.0);
|
|
716
|
+
}
|
|
717
|
+
`
|
|
718
|
+
);
|
|
719
|
+
const pressureShader = compileShader(
|
|
720
|
+
gl.FRAGMENT_SHADER,
|
|
721
|
+
`
|
|
722
|
+
precision mediump float;
|
|
723
|
+
precision mediump sampler2D;
|
|
724
|
+
varying highp vec2 vUv;
|
|
725
|
+
varying highp vec2 vL;
|
|
726
|
+
varying highp vec2 vR;
|
|
727
|
+
varying highp vec2 vT;
|
|
728
|
+
varying highp vec2 vB;
|
|
729
|
+
uniform sampler2D uPressure;
|
|
730
|
+
uniform sampler2D uDivergence;
|
|
731
|
+
|
|
732
|
+
void main () {
|
|
733
|
+
float L = texture2D(uPressure, vL).x;
|
|
734
|
+
float R = texture2D(uPressure, vR).x;
|
|
735
|
+
float T = texture2D(uPressure, vT).x;
|
|
736
|
+
float B = texture2D(uPressure, vB).x;
|
|
737
|
+
float C = texture2D(uPressure, vUv).x;
|
|
738
|
+
float divergence = texture2D(uDivergence, vUv).x;
|
|
739
|
+
float pressure = (L + R + B + T - divergence) * 0.25;
|
|
740
|
+
gl_FragColor = vec4(pressure, 0.0, 0.0, 1.0);
|
|
741
|
+
}
|
|
742
|
+
`
|
|
743
|
+
);
|
|
744
|
+
const gradientSubtractShader = compileShader(
|
|
745
|
+
gl.FRAGMENT_SHADER,
|
|
746
|
+
`
|
|
747
|
+
precision mediump float;
|
|
748
|
+
precision mediump sampler2D;
|
|
749
|
+
varying highp vec2 vUv;
|
|
750
|
+
varying highp vec2 vL;
|
|
751
|
+
varying highp vec2 vR;
|
|
752
|
+
varying highp vec2 vT;
|
|
753
|
+
varying highp vec2 vB;
|
|
754
|
+
uniform sampler2D uPressure;
|
|
755
|
+
uniform sampler2D uVelocity;
|
|
756
|
+
|
|
757
|
+
void main () {
|
|
758
|
+
float L = texture2D(uPressure, vL).x;
|
|
759
|
+
float R = texture2D(uPressure, vR).x;
|
|
760
|
+
float T = texture2D(uPressure, vT).x;
|
|
761
|
+
float B = texture2D(uPressure, vB).x;
|
|
762
|
+
vec2 velocity = texture2D(uVelocity, vUv).xy;
|
|
763
|
+
velocity.xy -= vec2(R - L, T - B);
|
|
764
|
+
gl_FragColor = vec4(velocity, 0.0, 1.0);
|
|
765
|
+
}
|
|
766
|
+
`
|
|
767
|
+
);
|
|
768
|
+
const blit = (() => {
|
|
769
|
+
const buffer = gl.createBuffer();
|
|
770
|
+
glDisposers.push(() => gl.deleteBuffer(buffer));
|
|
771
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
772
|
+
gl.bufferData(
|
|
773
|
+
gl.ARRAY_BUFFER,
|
|
774
|
+
new Float32Array([-1, -1, -1, 1, 1, 1, 1, -1]),
|
|
775
|
+
gl.STATIC_DRAW
|
|
776
|
+
);
|
|
777
|
+
const elemBuffer = gl.createBuffer();
|
|
778
|
+
glDisposers.push(() => gl.deleteBuffer(elemBuffer));
|
|
779
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elemBuffer);
|
|
780
|
+
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array([0, 1, 2, 0, 2, 3]), gl.STATIC_DRAW);
|
|
781
|
+
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
|
|
782
|
+
gl.enableVertexAttribArray(0);
|
|
783
|
+
return (target, doClear = false) => {
|
|
784
|
+
if (!gl) return;
|
|
785
|
+
if (!target) {
|
|
786
|
+
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
|
|
787
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
788
|
+
} else {
|
|
789
|
+
gl.viewport(0, 0, target.width, target.height);
|
|
790
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, target.fbo);
|
|
791
|
+
}
|
|
792
|
+
if (doClear) {
|
|
793
|
+
gl.clearColor(0, 0, 0, 1);
|
|
794
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
795
|
+
}
|
|
796
|
+
gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
|
|
797
|
+
};
|
|
798
|
+
})();
|
|
799
|
+
let dye;
|
|
800
|
+
let velocity;
|
|
801
|
+
let divergenceFBO;
|
|
802
|
+
let curlFBO;
|
|
803
|
+
let pressureFBO;
|
|
804
|
+
const copyProgram = new Program(baseVertexShader, copyShader);
|
|
805
|
+
const clearProgram = new Program(baseVertexShader, clearShader);
|
|
806
|
+
const splatProgram = new Program(baseVertexShader, splatShader);
|
|
807
|
+
const advectionProgram = new Program(baseVertexShader, advectionShader);
|
|
808
|
+
const divergenceProgram = new Program(baseVertexShader, divergenceShader);
|
|
809
|
+
const curlProgram = new Program(baseVertexShader, curlShader);
|
|
810
|
+
const vorticityProgram = new Program(baseVertexShader, vorticityShader);
|
|
811
|
+
const pressureProgram = new Program(baseVertexShader, pressureShader);
|
|
812
|
+
const gradienSubtractProgram = new Program(baseVertexShader, gradientSubtractShader);
|
|
813
|
+
const displayMaterial = new Material(baseVertexShader, displayShaderSource);
|
|
814
|
+
function createFBO(w, h, internalFormat, format, type, param) {
|
|
815
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
816
|
+
const texture = gl.createTexture();
|
|
817
|
+
glDisposers.push(() => gl.deleteTexture(texture));
|
|
818
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
819
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, param);
|
|
820
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, param);
|
|
821
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
822
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
823
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, w, h, 0, format, type, null);
|
|
824
|
+
const fbo = gl.createFramebuffer();
|
|
825
|
+
glDisposers.push(() => gl.deleteFramebuffer(fbo));
|
|
826
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
|
|
827
|
+
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
|
|
828
|
+
gl.viewport(0, 0, w, h);
|
|
829
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
830
|
+
const texelSizeX = 1 / w;
|
|
831
|
+
const texelSizeY = 1 / h;
|
|
832
|
+
return {
|
|
833
|
+
texture,
|
|
834
|
+
fbo,
|
|
835
|
+
width: w,
|
|
836
|
+
height: h,
|
|
837
|
+
texelSizeX,
|
|
838
|
+
texelSizeY,
|
|
839
|
+
attach(id) {
|
|
840
|
+
gl.activeTexture(gl.TEXTURE0 + id);
|
|
841
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
842
|
+
return id;
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
function createDoubleFBO(w, h, internalFormat, format, type, param) {
|
|
847
|
+
const fbo1 = createFBO(w, h, internalFormat, format, type, param);
|
|
848
|
+
const fbo2 = createFBO(w, h, internalFormat, format, type, param);
|
|
849
|
+
return {
|
|
850
|
+
width: w,
|
|
851
|
+
height: h,
|
|
852
|
+
texelSizeX: fbo1.texelSizeX,
|
|
853
|
+
texelSizeY: fbo1.texelSizeY,
|
|
854
|
+
read: fbo1,
|
|
855
|
+
write: fbo2,
|
|
856
|
+
swap() {
|
|
857
|
+
const tmp = this.read;
|
|
858
|
+
this.read = this.write;
|
|
859
|
+
this.write = tmp;
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
function resizeFBO(target, w, h, internalFormat, format, type, param) {
|
|
864
|
+
const newFBO = createFBO(w, h, internalFormat, format, type, param);
|
|
865
|
+
copyProgram.bind();
|
|
866
|
+
if (copyProgram.uniforms.uTexture)
|
|
867
|
+
gl.uniform1i(copyProgram.uniforms.uTexture, target.attach(0));
|
|
868
|
+
blit(newFBO, false);
|
|
869
|
+
return newFBO;
|
|
870
|
+
}
|
|
871
|
+
function resizeDoubleFBO(target, w, h, internalFormat, format, type, param) {
|
|
872
|
+
if (target.width === w && target.height === h) return target;
|
|
873
|
+
target.read = resizeFBO(target.read, w, h, internalFormat, format, type, param);
|
|
874
|
+
target.write = createFBO(w, h, internalFormat, format, type, param);
|
|
875
|
+
target.width = w;
|
|
876
|
+
target.height = h;
|
|
877
|
+
target.texelSizeX = 1 / w;
|
|
878
|
+
target.texelSizeY = 1 / h;
|
|
879
|
+
return target;
|
|
880
|
+
}
|
|
881
|
+
function initFramebuffers() {
|
|
882
|
+
const simRes = getResolution(config.SIM_RESOLUTION);
|
|
883
|
+
const dyeRes = getResolution(config.DYE_RESOLUTION);
|
|
884
|
+
const texType = ext.halfFloatTexType;
|
|
885
|
+
const rgba = ext.formatRGBA;
|
|
886
|
+
const rg = ext.formatRG;
|
|
887
|
+
const r = ext.formatR;
|
|
888
|
+
const filtering = ext.supportLinearFiltering ? gl.LINEAR : gl.NEAREST;
|
|
889
|
+
gl.disable(gl.BLEND);
|
|
890
|
+
if (!dye) {
|
|
891
|
+
dye = createDoubleFBO(
|
|
892
|
+
dyeRes.width,
|
|
893
|
+
dyeRes.height,
|
|
894
|
+
rgba.internalFormat,
|
|
895
|
+
rgba.format,
|
|
896
|
+
texType,
|
|
897
|
+
filtering
|
|
898
|
+
);
|
|
899
|
+
} else {
|
|
900
|
+
dye = resizeDoubleFBO(
|
|
901
|
+
dye,
|
|
902
|
+
dyeRes.width,
|
|
903
|
+
dyeRes.height,
|
|
904
|
+
rgba.internalFormat,
|
|
905
|
+
rgba.format,
|
|
906
|
+
texType,
|
|
907
|
+
filtering
|
|
908
|
+
);
|
|
909
|
+
}
|
|
910
|
+
if (!velocity) {
|
|
911
|
+
velocity = createDoubleFBO(
|
|
912
|
+
simRes.width,
|
|
913
|
+
simRes.height,
|
|
914
|
+
rg.internalFormat,
|
|
915
|
+
rg.format,
|
|
916
|
+
texType,
|
|
917
|
+
filtering
|
|
918
|
+
);
|
|
919
|
+
} else {
|
|
920
|
+
velocity = resizeDoubleFBO(
|
|
921
|
+
velocity,
|
|
922
|
+
simRes.width,
|
|
923
|
+
simRes.height,
|
|
924
|
+
rg.internalFormat,
|
|
925
|
+
rg.format,
|
|
926
|
+
texType,
|
|
927
|
+
filtering
|
|
928
|
+
);
|
|
929
|
+
}
|
|
930
|
+
divergenceFBO = createFBO(
|
|
931
|
+
simRes.width,
|
|
932
|
+
simRes.height,
|
|
933
|
+
r.internalFormat,
|
|
934
|
+
r.format,
|
|
935
|
+
texType,
|
|
936
|
+
gl.NEAREST
|
|
937
|
+
);
|
|
938
|
+
curlFBO = createFBO(
|
|
939
|
+
simRes.width,
|
|
940
|
+
simRes.height,
|
|
941
|
+
r.internalFormat,
|
|
942
|
+
r.format,
|
|
943
|
+
texType,
|
|
944
|
+
gl.NEAREST
|
|
945
|
+
);
|
|
946
|
+
pressureFBO = createDoubleFBO(
|
|
947
|
+
simRes.width,
|
|
948
|
+
simRes.height,
|
|
949
|
+
r.internalFormat,
|
|
950
|
+
r.format,
|
|
951
|
+
texType,
|
|
952
|
+
gl.NEAREST
|
|
953
|
+
);
|
|
954
|
+
}
|
|
955
|
+
function updateKeywords() {
|
|
956
|
+
const displayKeywords = [];
|
|
957
|
+
if (config.SHADING) displayKeywords.push("SHADING");
|
|
958
|
+
if (config.DITHER) displayKeywords.push("DITHERING");
|
|
959
|
+
displayMaterial.setKeywords(displayKeywords);
|
|
960
|
+
}
|
|
961
|
+
function getResolution(resolution) {
|
|
962
|
+
const w = gl.drawingBufferWidth;
|
|
963
|
+
const h = gl.drawingBufferHeight;
|
|
964
|
+
const aspectRatio = w / h;
|
|
965
|
+
const aspect = aspectRatio < 1 ? 1 / aspectRatio : aspectRatio;
|
|
966
|
+
const min = Math.round(resolution);
|
|
967
|
+
const max = Math.round(resolution * aspect);
|
|
968
|
+
if (w > h) {
|
|
969
|
+
return { width: max, height: min };
|
|
970
|
+
}
|
|
971
|
+
return { width: min, height: max };
|
|
972
|
+
}
|
|
973
|
+
function scaleByPixelRatio(input) {
|
|
974
|
+
const pixelRatio = window.devicePixelRatio || 1;
|
|
975
|
+
return Math.floor(input * pixelRatio);
|
|
976
|
+
}
|
|
977
|
+
let canvasRectCache = null;
|
|
978
|
+
function updateCanvasRectCache() {
|
|
979
|
+
if (containedRef.current && canvas) canvasRectCache = canvas.getBoundingClientRect();
|
|
980
|
+
}
|
|
981
|
+
if (contained) {
|
|
982
|
+
window.addEventListener("resize", updateCanvasRectCache, { passive: true });
|
|
983
|
+
window.addEventListener("scroll", updateCanvasRectCache, { passive: true });
|
|
984
|
+
updateCanvasRectCache();
|
|
985
|
+
}
|
|
986
|
+
function getCanvasPos(clientX, clientY) {
|
|
987
|
+
if (containedRef.current) {
|
|
988
|
+
if (!canvasRectCache) updateCanvasRectCache();
|
|
989
|
+
const rect = canvasRectCache;
|
|
990
|
+
return {
|
|
991
|
+
x: scaleByPixelRatio(clientX - rect.left),
|
|
992
|
+
y: scaleByPixelRatio(clientY - rect.top)
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
return { x: scaleByPixelRatio(clientX), y: scaleByPixelRatio(clientY) };
|
|
996
|
+
}
|
|
997
|
+
updateKeywords();
|
|
998
|
+
initFramebuffers();
|
|
999
|
+
let lastUpdateTime = Date.now();
|
|
1000
|
+
let colorUpdateTimer = 0;
|
|
1001
|
+
let animationFrameId;
|
|
1002
|
+
let isVisible = true;
|
|
1003
|
+
function updateFrame() {
|
|
1004
|
+
if (!isVisible) return;
|
|
1005
|
+
const dt = calcDeltaTime();
|
|
1006
|
+
if (resizeCanvas()) initFramebuffers();
|
|
1007
|
+
updateColors(dt);
|
|
1008
|
+
applyInputs();
|
|
1009
|
+
step(dt);
|
|
1010
|
+
render(null);
|
|
1011
|
+
animationFrameId = requestAnimationFrame(updateFrame);
|
|
1012
|
+
}
|
|
1013
|
+
function calcDeltaTime() {
|
|
1014
|
+
const now = Date.now();
|
|
1015
|
+
let dt = (now - lastUpdateTime) / 1e3;
|
|
1016
|
+
dt = Math.min(dt, 0.016666);
|
|
1017
|
+
lastUpdateTime = now;
|
|
1018
|
+
return dt;
|
|
1019
|
+
}
|
|
1020
|
+
function resizeCanvas() {
|
|
1021
|
+
const width = scaleByPixelRatio(canvas.clientWidth);
|
|
1022
|
+
const height = scaleByPixelRatio(canvas.clientHeight);
|
|
1023
|
+
if (canvas.width !== width || canvas.height !== height) {
|
|
1024
|
+
canvas.width = width;
|
|
1025
|
+
canvas.height = height;
|
|
1026
|
+
return true;
|
|
1027
|
+
}
|
|
1028
|
+
return false;
|
|
1029
|
+
}
|
|
1030
|
+
function updateColors(dt) {
|
|
1031
|
+
colorUpdateTimer += dt * config.COLOR_UPDATE_SPEED;
|
|
1032
|
+
if (colorUpdateTimer >= 1) {
|
|
1033
|
+
colorUpdateTimer = wrap(colorUpdateTimer, 0, 1);
|
|
1034
|
+
pointers.forEach((p) => {
|
|
1035
|
+
if (p === autopilotPointer) return;
|
|
1036
|
+
p.color = generateColor();
|
|
1037
|
+
});
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
function applyInputs() {
|
|
1041
|
+
for (const p of pointers) {
|
|
1042
|
+
if (p.moved) {
|
|
1043
|
+
p.moved = false;
|
|
1044
|
+
splatPointer(p);
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
function step(dt) {
|
|
1049
|
+
gl.disable(gl.BLEND);
|
|
1050
|
+
curlProgram.bind();
|
|
1051
|
+
if (curlProgram.uniforms.texelSize) {
|
|
1052
|
+
gl.uniform2f(curlProgram.uniforms.texelSize, velocity.texelSizeX, velocity.texelSizeY);
|
|
1053
|
+
}
|
|
1054
|
+
if (curlProgram.uniforms.uVelocity) {
|
|
1055
|
+
gl.uniform1i(curlProgram.uniforms.uVelocity, velocity.read.attach(0));
|
|
1056
|
+
}
|
|
1057
|
+
blit(curlFBO);
|
|
1058
|
+
vorticityProgram.bind();
|
|
1059
|
+
if (vorticityProgram.uniforms.texelSize) {
|
|
1060
|
+
gl.uniform2f(
|
|
1061
|
+
vorticityProgram.uniforms.texelSize,
|
|
1062
|
+
velocity.texelSizeX,
|
|
1063
|
+
velocity.texelSizeY
|
|
1064
|
+
);
|
|
1065
|
+
}
|
|
1066
|
+
if (vorticityProgram.uniforms.uVelocity) {
|
|
1067
|
+
gl.uniform1i(vorticityProgram.uniforms.uVelocity, velocity.read.attach(0));
|
|
1068
|
+
}
|
|
1069
|
+
if (vorticityProgram.uniforms.uCurl) {
|
|
1070
|
+
gl.uniform1i(vorticityProgram.uniforms.uCurl, curlFBO.attach(1));
|
|
1071
|
+
}
|
|
1072
|
+
if (vorticityProgram.uniforms.curl) {
|
|
1073
|
+
gl.uniform1f(vorticityProgram.uniforms.curl, config.CURL);
|
|
1074
|
+
}
|
|
1075
|
+
if (vorticityProgram.uniforms.dt) {
|
|
1076
|
+
gl.uniform1f(vorticityProgram.uniforms.dt, dt);
|
|
1077
|
+
}
|
|
1078
|
+
blit(velocity.write);
|
|
1079
|
+
velocity.swap();
|
|
1080
|
+
divergenceProgram.bind();
|
|
1081
|
+
if (divergenceProgram.uniforms.texelSize) {
|
|
1082
|
+
gl.uniform2f(
|
|
1083
|
+
divergenceProgram.uniforms.texelSize,
|
|
1084
|
+
velocity.texelSizeX,
|
|
1085
|
+
velocity.texelSizeY
|
|
1086
|
+
);
|
|
1087
|
+
}
|
|
1088
|
+
if (divergenceProgram.uniforms.uVelocity) {
|
|
1089
|
+
gl.uniform1i(divergenceProgram.uniforms.uVelocity, velocity.read.attach(0));
|
|
1090
|
+
}
|
|
1091
|
+
blit(divergenceFBO);
|
|
1092
|
+
clearProgram.bind();
|
|
1093
|
+
if (clearProgram.uniforms.uTexture) {
|
|
1094
|
+
gl.uniform1i(clearProgram.uniforms.uTexture, pressureFBO.read.attach(0));
|
|
1095
|
+
}
|
|
1096
|
+
if (clearProgram.uniforms.value) {
|
|
1097
|
+
gl.uniform1f(clearProgram.uniforms.value, config.PRESSURE);
|
|
1098
|
+
}
|
|
1099
|
+
blit(pressureFBO.write);
|
|
1100
|
+
pressureFBO.swap();
|
|
1101
|
+
pressureProgram.bind();
|
|
1102
|
+
if (pressureProgram.uniforms.texelSize) {
|
|
1103
|
+
gl.uniform2f(
|
|
1104
|
+
pressureProgram.uniforms.texelSize,
|
|
1105
|
+
velocity.texelSizeX,
|
|
1106
|
+
velocity.texelSizeY
|
|
1107
|
+
);
|
|
1108
|
+
}
|
|
1109
|
+
if (pressureProgram.uniforms.uDivergence) {
|
|
1110
|
+
gl.uniform1i(pressureProgram.uniforms.uDivergence, divergenceFBO.attach(0));
|
|
1111
|
+
}
|
|
1112
|
+
for (let i = 0; i < config.PRESSURE_ITERATIONS; i++) {
|
|
1113
|
+
if (pressureProgram.uniforms.uPressure) {
|
|
1114
|
+
gl.uniform1i(pressureProgram.uniforms.uPressure, pressureFBO.read.attach(1));
|
|
1115
|
+
}
|
|
1116
|
+
blit(pressureFBO.write);
|
|
1117
|
+
pressureFBO.swap();
|
|
1118
|
+
}
|
|
1119
|
+
gradienSubtractProgram.bind();
|
|
1120
|
+
if (gradienSubtractProgram.uniforms.texelSize) {
|
|
1121
|
+
gl.uniform2f(
|
|
1122
|
+
gradienSubtractProgram.uniforms.texelSize,
|
|
1123
|
+
velocity.texelSizeX,
|
|
1124
|
+
velocity.texelSizeY
|
|
1125
|
+
);
|
|
1126
|
+
}
|
|
1127
|
+
if (gradienSubtractProgram.uniforms.uPressure) {
|
|
1128
|
+
gl.uniform1i(gradienSubtractProgram.uniforms.uPressure, pressureFBO.read.attach(0));
|
|
1129
|
+
}
|
|
1130
|
+
if (gradienSubtractProgram.uniforms.uVelocity) {
|
|
1131
|
+
gl.uniform1i(gradienSubtractProgram.uniforms.uVelocity, velocity.read.attach(1));
|
|
1132
|
+
}
|
|
1133
|
+
blit(velocity.write);
|
|
1134
|
+
velocity.swap();
|
|
1135
|
+
advectionProgram.bind();
|
|
1136
|
+
if (advectionProgram.uniforms.texelSize) {
|
|
1137
|
+
gl.uniform2f(
|
|
1138
|
+
advectionProgram.uniforms.texelSize,
|
|
1139
|
+
velocity.texelSizeX,
|
|
1140
|
+
velocity.texelSizeY
|
|
1141
|
+
);
|
|
1142
|
+
}
|
|
1143
|
+
if (!ext.supportLinearFiltering && advectionProgram.uniforms.dyeTexelSize) {
|
|
1144
|
+
gl.uniform2f(
|
|
1145
|
+
advectionProgram.uniforms.dyeTexelSize,
|
|
1146
|
+
velocity.texelSizeX,
|
|
1147
|
+
velocity.texelSizeY
|
|
1148
|
+
);
|
|
1149
|
+
}
|
|
1150
|
+
const velocityId = velocity.read.attach(0);
|
|
1151
|
+
if (advectionProgram.uniforms.uVelocity) {
|
|
1152
|
+
gl.uniform1i(advectionProgram.uniforms.uVelocity, velocityId);
|
|
1153
|
+
}
|
|
1154
|
+
if (advectionProgram.uniforms.uSource) {
|
|
1155
|
+
gl.uniform1i(advectionProgram.uniforms.uSource, velocityId);
|
|
1156
|
+
}
|
|
1157
|
+
if (advectionProgram.uniforms.dt) {
|
|
1158
|
+
gl.uniform1f(advectionProgram.uniforms.dt, dt);
|
|
1159
|
+
}
|
|
1160
|
+
if (advectionProgram.uniforms.dissipation) {
|
|
1161
|
+
gl.uniform1f(advectionProgram.uniforms.dissipation, config.VELOCITY_DISSIPATION);
|
|
1162
|
+
}
|
|
1163
|
+
blit(velocity.write);
|
|
1164
|
+
velocity.swap();
|
|
1165
|
+
if (!ext.supportLinearFiltering && advectionProgram.uniforms.dyeTexelSize) {
|
|
1166
|
+
gl.uniform2f(advectionProgram.uniforms.dyeTexelSize, dye.texelSizeX, dye.texelSizeY);
|
|
1167
|
+
}
|
|
1168
|
+
if (advectionProgram.uniforms.uVelocity) {
|
|
1169
|
+
gl.uniform1i(advectionProgram.uniforms.uVelocity, velocity.read.attach(0));
|
|
1170
|
+
}
|
|
1171
|
+
if (advectionProgram.uniforms.uSource) {
|
|
1172
|
+
gl.uniform1i(advectionProgram.uniforms.uSource, dye.read.attach(1));
|
|
1173
|
+
}
|
|
1174
|
+
if (advectionProgram.uniforms.dissipation) {
|
|
1175
|
+
gl.uniform1f(advectionProgram.uniforms.dissipation, config.DENSITY_DISSIPATION);
|
|
1176
|
+
}
|
|
1177
|
+
blit(dye.write);
|
|
1178
|
+
dye.swap();
|
|
1179
|
+
}
|
|
1180
|
+
function render(target) {
|
|
1181
|
+
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
|
1182
|
+
gl.enable(gl.BLEND);
|
|
1183
|
+
drawDisplay(target);
|
|
1184
|
+
}
|
|
1185
|
+
function drawDisplay(target) {
|
|
1186
|
+
const width = gl.drawingBufferWidth;
|
|
1187
|
+
const height = gl.drawingBufferHeight;
|
|
1188
|
+
displayMaterial.bind();
|
|
1189
|
+
if ((config.SHADING || config.DITHER) && displayMaterial.uniforms.texelSize) {
|
|
1190
|
+
gl.uniform2f(displayMaterial.uniforms.texelSize, 1 / width, 1 / height);
|
|
1191
|
+
}
|
|
1192
|
+
if (displayMaterial.uniforms.uTexture) {
|
|
1193
|
+
gl.uniform1i(displayMaterial.uniforms.uTexture, dye.read.attach(0));
|
|
1194
|
+
}
|
|
1195
|
+
if (config.DITHER) {
|
|
1196
|
+
if (displayMaterial.uniforms.uDitherPixel) {
|
|
1197
|
+
gl.uniform1f(
|
|
1198
|
+
displayMaterial.uniforms.uDitherPixel,
|
|
1199
|
+
config.DITHER_PIXEL_SIZE * (window.devicePixelRatio || 1)
|
|
1200
|
+
);
|
|
1201
|
+
}
|
|
1202
|
+
if (displayMaterial.uniforms.uDitherLevels) {
|
|
1203
|
+
gl.uniform1f(displayMaterial.uniforms.uDitherLevels, config.DITHER_LEVELS);
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
blit(target, false);
|
|
1207
|
+
}
|
|
1208
|
+
function splatPointer(pointer) {
|
|
1209
|
+
const dx = pointer.deltaX * config.SPLAT_FORCE;
|
|
1210
|
+
const dy = pointer.deltaY * config.SPLAT_FORCE;
|
|
1211
|
+
splat(pointer.texcoordX, pointer.texcoordY, dx, dy, pointer.color);
|
|
1212
|
+
}
|
|
1213
|
+
function clickSplat(pointer) {
|
|
1214
|
+
const color = generateColor();
|
|
1215
|
+
color.r *= 10;
|
|
1216
|
+
color.g *= 10;
|
|
1217
|
+
color.b *= 10;
|
|
1218
|
+
const dx = 10 * (Math.random() - 0.5);
|
|
1219
|
+
const dy = 30 * (Math.random() - 0.5);
|
|
1220
|
+
splat(pointer.texcoordX, pointer.texcoordY, dx, dy, color);
|
|
1221
|
+
}
|
|
1222
|
+
function splat(x, y, dx, dy, color) {
|
|
1223
|
+
splatProgram.bind();
|
|
1224
|
+
if (splatProgram.uniforms.uTarget) {
|
|
1225
|
+
gl.uniform1i(splatProgram.uniforms.uTarget, velocity.read.attach(0));
|
|
1226
|
+
}
|
|
1227
|
+
if (splatProgram.uniforms.aspectRatio) {
|
|
1228
|
+
gl.uniform1f(splatProgram.uniforms.aspectRatio, canvas.width / canvas.height);
|
|
1229
|
+
}
|
|
1230
|
+
if (splatProgram.uniforms.point) {
|
|
1231
|
+
gl.uniform2f(splatProgram.uniforms.point, x, y);
|
|
1232
|
+
}
|
|
1233
|
+
if (splatProgram.uniforms.color) {
|
|
1234
|
+
gl.uniform3f(splatProgram.uniforms.color, dx, dy, 0);
|
|
1235
|
+
}
|
|
1236
|
+
if (splatProgram.uniforms.radius) {
|
|
1237
|
+
let radius = correctRadius(config.SPLAT_RADIUS / 100);
|
|
1238
|
+
if (containedRef.current) {
|
|
1239
|
+
radius = scaleRadiusForContainer(radius, canvas.clientHeight, window.innerHeight);
|
|
1240
|
+
}
|
|
1241
|
+
gl.uniform1f(splatProgram.uniforms.radius, radius);
|
|
1242
|
+
}
|
|
1243
|
+
blit(velocity.write);
|
|
1244
|
+
velocity.swap();
|
|
1245
|
+
if (splatProgram.uniforms.uTarget) {
|
|
1246
|
+
gl.uniform1i(splatProgram.uniforms.uTarget, dye.read.attach(0));
|
|
1247
|
+
}
|
|
1248
|
+
if (splatProgram.uniforms.color) {
|
|
1249
|
+
gl.uniform3f(splatProgram.uniforms.color, color.r, color.g, color.b);
|
|
1250
|
+
}
|
|
1251
|
+
blit(dye.write);
|
|
1252
|
+
dye.swap();
|
|
1253
|
+
}
|
|
1254
|
+
let splatFrameId = 0;
|
|
1255
|
+
function multipleSplats(steps) {
|
|
1256
|
+
const angle = Math.random() * Math.PI * 2;
|
|
1257
|
+
const cx = 0.25 + Math.random() * 0.5;
|
|
1258
|
+
const cy = 0.25 + Math.random() * 0.5;
|
|
1259
|
+
const arcSpan = Math.PI * (0.8 + Math.random() * 0.8);
|
|
1260
|
+
let i = 0;
|
|
1261
|
+
function step2() {
|
|
1262
|
+
if (i >= steps) return;
|
|
1263
|
+
const t = i / Math.max(1, steps - 1);
|
|
1264
|
+
const a = angle + t * arcSpan;
|
|
1265
|
+
const r = 0.15 + 0.05 * Math.sin(t * Math.PI);
|
|
1266
|
+
const x = cx + Math.cos(a) * r;
|
|
1267
|
+
const y = cy + Math.sin(a) * r;
|
|
1268
|
+
const color = generateColor();
|
|
1269
|
+
splat(
|
|
1270
|
+
x,
|
|
1271
|
+
y,
|
|
1272
|
+
-Math.sin(a) * config.SPLAT_FORCE * 0.5,
|
|
1273
|
+
Math.cos(a) * config.SPLAT_FORCE * 0.5,
|
|
1274
|
+
color
|
|
1275
|
+
);
|
|
1276
|
+
i++;
|
|
1277
|
+
if (i < steps) splatFrameId = requestAnimationFrame(step2);
|
|
1278
|
+
}
|
|
1279
|
+
splatFrameId = requestAnimationFrame(step2);
|
|
1280
|
+
}
|
|
1281
|
+
function correctRadius(radius) {
|
|
1282
|
+
const aspectRatio = canvas.width / canvas.height;
|
|
1283
|
+
if (aspectRatio > 1) radius *= aspectRatio;
|
|
1284
|
+
return radius;
|
|
1285
|
+
}
|
|
1286
|
+
function updatePointerDownData(pointer, id, posX, posY) {
|
|
1287
|
+
pointer.id = id;
|
|
1288
|
+
pointer.down = true;
|
|
1289
|
+
pointer.moved = false;
|
|
1290
|
+
pointer.texcoordX = posX / canvas.width;
|
|
1291
|
+
pointer.texcoordY = 1 - posY / canvas.height;
|
|
1292
|
+
pointer.prevTexcoordX = pointer.texcoordX;
|
|
1293
|
+
pointer.prevTexcoordY = pointer.texcoordY;
|
|
1294
|
+
pointer.deltaX = 0;
|
|
1295
|
+
pointer.deltaY = 0;
|
|
1296
|
+
pointer.color = generateColor();
|
|
1297
|
+
}
|
|
1298
|
+
function updatePointerMoveData(pointer, posX, posY, color) {
|
|
1299
|
+
pointer.prevTexcoordX = pointer.texcoordX;
|
|
1300
|
+
pointer.prevTexcoordY = pointer.texcoordY;
|
|
1301
|
+
pointer.texcoordX = posX / canvas.width;
|
|
1302
|
+
pointer.texcoordY = 1 - posY / canvas.height;
|
|
1303
|
+
pointer.deltaX = correctDeltaX(pointer.texcoordX - pointer.prevTexcoordX);
|
|
1304
|
+
pointer.deltaY = correctDeltaY(pointer.texcoordY - pointer.prevTexcoordY);
|
|
1305
|
+
pointer.moved = Math.abs(pointer.deltaX) > 0 || Math.abs(pointer.deltaY) > 0;
|
|
1306
|
+
pointer.color = color;
|
|
1307
|
+
}
|
|
1308
|
+
function correctDeltaX(delta) {
|
|
1309
|
+
const aspectRatio = canvas.width / canvas.height;
|
|
1310
|
+
if (aspectRatio < 1) delta *= aspectRatio;
|
|
1311
|
+
return delta;
|
|
1312
|
+
}
|
|
1313
|
+
function correctDeltaY(delta) {
|
|
1314
|
+
const aspectRatio = canvas.width / canvas.height;
|
|
1315
|
+
if (aspectRatio > 1) delta /= aspectRatio;
|
|
1316
|
+
return delta;
|
|
1317
|
+
}
|
|
1318
|
+
function autopilotMoveTo(x, y, color) {
|
|
1319
|
+
if (!autopilotPointer) return;
|
|
1320
|
+
const posX = x * canvas.width;
|
|
1321
|
+
const posY = y * canvas.height;
|
|
1322
|
+
if (penWasUp) {
|
|
1323
|
+
penWasUp = false;
|
|
1324
|
+
autopilotPointer.down = true;
|
|
1325
|
+
autopilotPointer.moved = false;
|
|
1326
|
+
autopilotPointer.texcoordX = posX / canvas.width;
|
|
1327
|
+
autopilotPointer.texcoordY = 1 - posY / canvas.height;
|
|
1328
|
+
autopilotPointer.prevTexcoordX = autopilotPointer.texcoordX;
|
|
1329
|
+
autopilotPointer.prevTexcoordY = autopilotPointer.texcoordY;
|
|
1330
|
+
autopilotPointer.deltaX = 0;
|
|
1331
|
+
autopilotPointer.deltaY = 0;
|
|
1332
|
+
autopilotPointer.color = color ?? generateColor();
|
|
1333
|
+
return;
|
|
1334
|
+
}
|
|
1335
|
+
updatePointerMoveData(autopilotPointer, posX, posY, color ?? autopilotPointer.color);
|
|
1336
|
+
}
|
|
1337
|
+
function autopilotPenUp() {
|
|
1338
|
+
penWasUp = true;
|
|
1339
|
+
if (autopilotPointer) autopilotPointer.down = false;
|
|
1340
|
+
}
|
|
1341
|
+
function autopilotBurst(x, y, dx, dy, color) {
|
|
1342
|
+
splat(x, 1 - y, dx, -dy, color);
|
|
1343
|
+
}
|
|
1344
|
+
function handleMouseDown(e) {
|
|
1345
|
+
const pointer = pointers[0];
|
|
1346
|
+
const { x: posX, y: posY } = getCanvasPos(e.clientX, e.clientY);
|
|
1347
|
+
updatePointerDownData(pointer, -1, posX, posY);
|
|
1348
|
+
clickSplat(pointer);
|
|
1349
|
+
}
|
|
1350
|
+
function handleFirstMouseMove(e) {
|
|
1351
|
+
const pointer = pointers[0];
|
|
1352
|
+
const { x: posX, y: posY } = getCanvasPos(e.clientX, e.clientY);
|
|
1353
|
+
const color = generateColor();
|
|
1354
|
+
updatePointerMoveData(pointer, posX, posY, color);
|
|
1355
|
+
document.body.removeEventListener("mousemove", handleFirstMouseMove);
|
|
1356
|
+
}
|
|
1357
|
+
function handleMouseMove(e) {
|
|
1358
|
+
const pointer = pointers[0];
|
|
1359
|
+
const { x: posX, y: posY } = getCanvasPos(e.clientX, e.clientY);
|
|
1360
|
+
updatePointerMoveData(pointer, posX, posY, pointer.color);
|
|
1361
|
+
}
|
|
1362
|
+
function handleFirstTouchStart(e) {
|
|
1363
|
+
const touches = e.targetTouches;
|
|
1364
|
+
const pointer = pointers[0];
|
|
1365
|
+
for (let i = 0; i < touches.length; i++) {
|
|
1366
|
+
const touch = touches[i];
|
|
1367
|
+
const { x: posX, y: posY } = getCanvasPos(touch.clientX, touch.clientY);
|
|
1368
|
+
updatePointerDownData(pointer, touch.identifier, posX, posY);
|
|
1369
|
+
}
|
|
1370
|
+
document.body.removeEventListener("touchstart", handleFirstTouchStart);
|
|
1371
|
+
}
|
|
1372
|
+
function handleTouchStart(e) {
|
|
1373
|
+
const touches = e.targetTouches;
|
|
1374
|
+
const pointer = pointers[0];
|
|
1375
|
+
for (let i = 0; i < touches.length; i++) {
|
|
1376
|
+
const touch = touches[i];
|
|
1377
|
+
const { x: posX, y: posY } = getCanvasPos(touch.clientX, touch.clientY);
|
|
1378
|
+
updatePointerDownData(pointer, touch.identifier, posX, posY);
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
function handleTouchMove(e) {
|
|
1382
|
+
const touches = e.targetTouches;
|
|
1383
|
+
const pointer = pointers[0];
|
|
1384
|
+
for (let i = 0; i < touches.length; i++) {
|
|
1385
|
+
const touch = touches[i];
|
|
1386
|
+
const { x: posX, y: posY } = getCanvasPos(touch.clientX, touch.clientY);
|
|
1387
|
+
updatePointerMoveData(pointer, posX, posY, pointer.color);
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
if (interactive) {
|
|
1391
|
+
window.addEventListener("mousedown", handleMouseDown);
|
|
1392
|
+
document.body.addEventListener("mousemove", handleFirstMouseMove);
|
|
1393
|
+
window.addEventListener("mousemove", handleMouseMove);
|
|
1394
|
+
document.body.addEventListener("touchstart", handleFirstTouchStart);
|
|
1395
|
+
window.addEventListener("touchstart", handleTouchStart, false);
|
|
1396
|
+
window.addEventListener("touchmove", handleTouchMove, false);
|
|
1397
|
+
}
|
|
1398
|
+
let observer = null;
|
|
1399
|
+
if (pauseWhenHidden) {
|
|
1400
|
+
observer = new IntersectionObserver(
|
|
1401
|
+
([entry]) => {
|
|
1402
|
+
const wasVisible = isVisible;
|
|
1403
|
+
isVisible = entry.isIntersecting;
|
|
1404
|
+
if (isVisible && !wasVisible) {
|
|
1405
|
+
lastUpdateTime = Date.now();
|
|
1406
|
+
animationFrameId = requestAnimationFrame(updateFrame);
|
|
1407
|
+
}
|
|
1408
|
+
},
|
|
1409
|
+
{ threshold: 0 }
|
|
1410
|
+
);
|
|
1411
|
+
observer.observe(canvas);
|
|
1412
|
+
}
|
|
1413
|
+
updateFrame();
|
|
1414
|
+
if (splatOnMount) multipleSplats(Math.floor(Math.random() * 6) + 10);
|
|
1415
|
+
let autoSplatTimer = null;
|
|
1416
|
+
if (autoSplat) {
|
|
1417
|
+
autoSplatTimer = setInterval(() => {
|
|
1418
|
+
const color = generateColor();
|
|
1419
|
+
splat(
|
|
1420
|
+
Math.random(),
|
|
1421
|
+
Math.random(),
|
|
1422
|
+
(Math.random() - 0.5) * 200,
|
|
1423
|
+
(Math.random() - 0.5) * 200,
|
|
1424
|
+
color
|
|
1425
|
+
);
|
|
1426
|
+
}, autoSplatInterval);
|
|
1427
|
+
}
|
|
1428
|
+
function cleanup() {
|
|
1429
|
+
cancelAnimationFrame(animationFrameId);
|
|
1430
|
+
cancelAnimationFrame(splatFrameId);
|
|
1431
|
+
if (observer) observer.disconnect();
|
|
1432
|
+
if (autoSplatTimer) clearInterval(autoSplatTimer);
|
|
1433
|
+
if (interactive) {
|
|
1434
|
+
window.removeEventListener("mousedown", handleMouseDown);
|
|
1435
|
+
document.body.removeEventListener("mousemove", handleFirstMouseMove);
|
|
1436
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
1437
|
+
document.body.removeEventListener("touchstart", handleFirstTouchStart);
|
|
1438
|
+
window.removeEventListener("touchstart", handleTouchStart);
|
|
1439
|
+
window.removeEventListener("touchmove", handleTouchMove);
|
|
1440
|
+
}
|
|
1441
|
+
if (contained) {
|
|
1442
|
+
window.removeEventListener("resize", updateCanvasRectCache);
|
|
1443
|
+
window.removeEventListener("scroll", updateCanvasRectCache);
|
|
1444
|
+
}
|
|
1445
|
+
for (const dispose2 of glDisposers) dispose2();
|
|
1446
|
+
glDisposers.length = 0;
|
|
1447
|
+
}
|
|
1448
|
+
const dispose = registerInstance(cleanup);
|
|
1449
|
+
notifyReady({
|
|
1450
|
+
moveTo: autopilotMoveTo,
|
|
1451
|
+
penUp: autopilotPenUp,
|
|
1452
|
+
burst: autopilotBurst,
|
|
1453
|
+
renderLevel
|
|
1454
|
+
});
|
|
1455
|
+
return dispose;
|
|
1456
|
+
}
|
|
1457
|
+
}, []);
|
|
1458
|
+
return /* @__PURE__ */ jsx(
|
|
1459
|
+
"div",
|
|
1460
|
+
{
|
|
1461
|
+
className: cn(
|
|
1462
|
+
contained ? "pointer-events-none absolute inset-0 h-full w-full" : "pointer-events-none fixed top-0 left-0 z-50 size-full",
|
|
1463
|
+
className
|
|
1464
|
+
),
|
|
1465
|
+
children: /* @__PURE__ */ jsx(
|
|
1466
|
+
"canvas",
|
|
1467
|
+
{
|
|
1468
|
+
ref: canvasRef,
|
|
1469
|
+
className: contained ? "block h-full w-full" : "block h-screen w-screen"
|
|
1470
|
+
}
|
|
1471
|
+
)
|
|
1472
|
+
}
|
|
1473
|
+
);
|
|
1474
|
+
}
|
|
1475
|
+
const FluidCursorAdvanced = FluidCursor;
|
|
1476
|
+
export {
|
|
1477
|
+
FluidCursor,
|
|
1478
|
+
FluidCursorAdvanced
|
|
1479
|
+
};
|