一个框架无关的 Web GPU 流体模拟库,基于 WebGL2 的 Stable Fluids 算法,提供可插拔渲染模式及 React/Vue/Svelte 适配器。

Stars

8

7 天增长

暂无数据

Fork 数

0

开放 Issue

0

开源协议

MIT

最近更新

2026-07-28

AI 仓库情报摘要
FR-AI / ANALYSIS

为什么值得关注

将高质量的 GPU 流体模拟与框架适配器、实时可调参数、多种发射器类型以及实验性 WebGPU 支持相结合,并内置性能优化和可访问性特性。

适合谁使用

  • 构建交互式着陆页或视觉特效的网页开发者
  • 使用 React、Vue 或 Svelte 并希望快速集成流体效果的开发者
  • 探索实时生成艺术的创意编程者与艺术家
  • AI 编码代理(提供专用 AGENTS.md 指南)

典型使用场景

  • 为营销或产品页面添加交互式背景流体效果
  • 在创意编程或生成艺术项目中实现实时视觉特效
  • 音频反应式可视化(通过音频发射器)
  • 用于展示流体动力学概念的教学演示

项目优势

  • 框架无关,并提供 React、Vue 和 Svelte 官方适配器
  • 五种渲染模式(染料、阈值、渐变、位移、自定义)及实验性 WebGPU 后端
  • 多种发射器类型:指针、环境、遮罩、程序化及音频
  • 所有模拟参数可实时调整;内置自动降质以维持性能

使用前须知

  • 需要 WebGL2 且支持 EXT_color_buffer_float(旧设备不支持)
  • 实验性 WebGPU 后端仅支持染料渲染和基本发射器
  • v0.5 版本可能不够稳定,部分功能(如遮罩、障碍物)暂仅限 WebGL2

README 快速开始

fluidkit

Live demo → · npm

Framework-agnostic GPU fluid simulation for the web. The sim engine (Stable Fluids on WebGL2) produces velocity/dye field textures; pluggable render modes consume them — smoky dye, flat posterized "sticker" liquid, or your own fragment shader.

Status: v0.5 — WebGL2 core with five render modes (dye, threshold, ramp, displacement, custom); pointer, ambient, programmatic, mask, and audio emitters; obstacles; React/Vue/Svelte adapters; CDN build; experimental WebGPU backend (try it).

Building with an AI coding agent? Point it at AGENTS.md — a complete guide with landing-page recipes, the liquid-vs-smoke look formula, and pitfalls.

Quickstart

npm install @dilukangelo/fluidkit
import { createFluid, threshold } from '@dilukangelo/fluidkit'

const fluid = createFluid(canvas, {
  emitters: { pointer: true, ambient: { strength: 0.2 } },
  render: threshold({
    levels: [{ cutoff: 0.1, color: '#ffc7ff' }],
    background: 'transparent',
  }),
})

That's it — interactive fluid on your canvas. Omit render for the classic smoky dye look.

API

fluid.splat(x, y, dx, dy, { color: '#ffc7ff', radius: 0.25 }) // programmatic droplet, x/y in [0,1], y up
fluid.params.curl = 45                                        // all sim params live-tunable
fluid.setRenderMode(dye())                                    // swap looks at runtime
const tex = fluid.getTexture('dye')                           // raw WebGLTexture for three.js/pixi
fluid.pause(); fluid.resume(); fluid.destroy()

Sim params (all optional in createFluid options, all live-tunable via fluid.params): simResolution (128), dyeResolution (1024), curl (30), pressureIterations (20), pressure (0.8), velocityDissipation (0.2), densityDissipation (1.0), gravity (0 — set 100–400 for pours/waterfalls), wind (0), speed (1), splatRadius (0.25), splatForce (6000).

Render modes

  • dye({ brightness, glow, glowRadius, background }) — classic smoky multicolor, with an optional neon halo.
  • threshold({ levels, background, outline, softness, lighting }) — up to 8 posterized levels with per-level alpha, edge A

项目描述

Framework-agnostic WebGL2 fluid simulation — decoupled sim engine + pluggable render modes (smoky dye, flat sticker-liquid, custom shaders). AI-agent ready.

相关仓库与替代方案

根据分类、Topic 和编程语言匹配的相似项目。

gnipbao
精选
gnipbao GitHub avatar

story-to-handdrawn-video

A Remotion-based tool that converts Chinese story text or ordered hand-drawn images into vertical hand-drawn diary-comic animation with handwritten captions, left-to-right reveals, optional page-curl transitions, and silent H.264 output for post-production dubbing.

AI 与机器学习AI 智能体
683
makecindy
精选
makecindy GitHub avatar

cindy

Cindy is an open-source AI agent that runs locally on your machine, integrates multiple AI harnesses and models, and provides memory, skills, and automation to perform real work in your projects and apps.

AI 与机器学习大语言模型
958
mereyabdenbekuly-ctrl
精选
mereyabdenbekuly-ctrl GitHub avatar

clodex-ide

Clodex is an open-source, local-first agentic IDE that combines persistent AI tasks, code, terminal, browser, Git, models, memory, and governed execution in one Electron workspace, currently in technical preview.

AI 与机器学习AI 智能体
859