Skip to content

Commit dedf499

Browse files
author
takuma-hmng8
committed
fruid >= fluid
1 parent 60bb245 commit dedf499

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+94
-94
lines changed

Diff for: .storybook/stories/UseFruid.tsx renamed to .storybook/stories/UseFluid.tsx

+12-12
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import { FxMaterial, FxMaterialProps } from "../../utils/fxMaterial";
99
import { CONSTANT } from "../constant";
1010
import GUI from "lil-gui";
1111
import { useGUI } from "../../utils/useGUI";
12-
import { useFruid, useTransitionBg } from "../../packages/use-shader-fx/src";
12+
import { useFluid, useTransitionBg } from "../../packages/use-shader-fx/src";
1313
import {
14-
FRUID_PARAMS,
15-
FruidParams,
16-
} from "../../packages/use-shader-fx/src/hooks/useFruid";
14+
FLUID_PARAMS,
15+
FluidParams,
16+
} from "../../packages/use-shader-fx/src/hooks/useFluid";
1717

1818
extend({ FxMaterial, FxTextureMaterial });
1919

20-
const CONFIG: FruidParams = structuredClone(FRUID_PARAMS);
20+
const CONFIG: FluidParams = structuredClone(FLUID_PARAMS);
2121
const setGUI = (gui: GUI) => {
2222
gui.add(CONFIG, "density_dissipation", 0, 1, 0.01);
2323
gui.add(CONFIG, "velocity_dissipation", 0, 1, 0.01);
@@ -36,19 +36,19 @@ const setConfig = () => {
3636
pressure_iterations: CONFIG.pressure_iterations,
3737
curl_strength: CONFIG.curl_strength,
3838
splat_radius: CONFIG.splat_radius,
39-
} as FruidParams;
39+
} as FluidParams;
4040
};
4141

42-
export const UseFruid = (args: FruidParams) => {
42+
export const UseFluid = (args: FluidParams) => {
4343
const updateGUI = useGUI(setGUI);
4444

4545
const fxRef = React.useRef<FxMaterialProps>();
4646
const size = useThree((state) => state.size);
4747
const dpr = useThree((state) => state.viewport.dpr);
48-
const [updateFruid] = useFruid({ size, dpr });
48+
const [updateFluid] = useFluid({ size, dpr });
4949

5050
useFrame((props) => {
51-
const fx = updateFruid(props, setConfig());
51+
const fx = updateFluid(props, setConfig());
5252
fxRef.current!.u_fx = fx;
5353
updateGUI();
5454
});
@@ -61,12 +61,12 @@ export const UseFruid = (args: FruidParams) => {
6161
);
6262
};
6363

64-
export const UseFruidWithTexture = (args: FruidParams) => {
64+
export const UseFluidWithTexture = (args: FluidParams) => {
6565
const updateGUI = useGUI(setGUI);
6666
const fxRef = React.useRef<FxTextureMaterialProps>();
6767
const size = useThree((state) => state.size);
6868
const dpr = useThree((state) => state.viewport.dpr);
69-
const [updateFruid] = useFruid({ size, dpr });
69+
const [updateFluid] = useFluid({ size, dpr });
7070

7171
const [bg] = useLoader(THREE.TextureLoader, ["thumbnail.jpg"]);
7272
const [updateTransitionBg] = useTransitionBg({ size, dpr });
@@ -77,7 +77,7 @@ export const UseFruidWithTexture = (args: FruidParams) => {
7777
texture0: bg,
7878
});
7979

80-
const fx = updateFruid(props, setConfig());
80+
const fx = updateFluid(props, setConfig());
8181

8282
fxRef.current!.u_postFx = bgTexture;
8383
fxRef.current!.u_fx = fx;

Diff for: .storybook/stories/useFruid.stories.tsx renamed to .storybook/stories/useFluid.stories.tsx

+12-12
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@ import { setArgTypes } from "../utils/setArgTypes";
44
import { Setup } from "../utils/Setup";
55
import type { Meta } from "@storybook/react";
66
import {
7-
FRUID_PARAMS,
8-
FruidParams,
9-
} from "../../packages/use-shader-fx/src/hooks/useFruid";
10-
import { UseFruid, UseFruidWithTexture } from "./UseFruid";
7+
FLUID_PARAMS,
8+
FluidParams,
9+
} from "../../packages/use-shader-fx/src/hooks/useFluid";
10+
import { UseFluid, UseFluidWithTexture } from "./UseFluid";
1111

1212
const meta = {
13-
title: "useFruid",
14-
component: UseFruid,
13+
title: "useFluid",
14+
component: UseFluid,
1515
tags: ["autodocs"],
1616
decorators: [(storyFn: any) => <Setup>{storyFn()}</Setup>],
17-
} satisfies Meta<typeof UseFruid>;
17+
} satisfies Meta<typeof UseFluid>;
1818

1919
export default meta;
2020
type Story = StoryObj<typeof meta>;
2121

2222
const storySetting = {
23-
args: FRUID_PARAMS,
24-
argTypes: setArgTypes<FruidParams>(FRUID_PARAMS),
23+
args: FLUID_PARAMS,
24+
argTypes: setArgTypes<FluidParams>(FLUID_PARAMS),
2525
};
26-
export const Fruid: Story = {
27-
render: (args) => <UseFruid {...args} />,
26+
export const Fluid: Story = {
27+
render: (args) => <UseFluid {...args} />,
2828
...storySetting,
2929
};
3030
export const WithTexture: Story = {
31-
render: (args) => <UseFruidWithTexture {...args} />,
31+
render: (args) => <UseFluidWithTexture {...args} />,
3232
...storySetting,
3333
};

Diff for: README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ From each `fxHooks`, you can receive [`updateFx`, `setParams`, `fxObject`] in ar
1818
3. `fxObject` - An object that holds various FX components, such as scene, camera, material, and renderTarget.
1919

2020
```js
21-
const [updateFx, setParams, fxObject] = useFruid(config);
21+
const [updateFx, setParams, fxObject] = useFluid(config);
2222
```
2323

2424
Execute `updateFx` in `useFrame`. The first argument receives the RootState from `useFrame`, and the second one takes `HookPrams`. Each fx has its `HookPrams`, and each type is exported.
@@ -41,15 +41,15 @@ This is the simplest example!
4141
import * as THREE from "three";
4242
import { useRef } from "react";
4343
import { useFrame, useThree } from "@react-three/fiber";
44-
import { useFruid } from "@hmng8/use-shader-fx";
44+
import { useFluid } from "@hmng8/use-shader-fx";
4545

4646
export const Demo = () => {
4747
const ref = useRef<THREE.ShaderMaterial>(null);
4848
const size = useThree((state) => state.size);
4949
const dpr = useThree((state) => state.viewport.dpr);
50-
const [updateFruid] = useFruid({ size, dpr });
50+
const [updateFluid] = useFluid({ size, dpr });
5151
useFrame((props) => {
52-
ref.current!.uniforms.u_fx.value = updateFruid(props);
52+
ref.current!.uniforms.u_fx.value = updateFluid(props);
5353
});
5454

5555
return (

Diff for: app/_demo/config.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as THREE from "three";
22
import GUI from "lil-gui";
33

4-
import { FRUID_PARAMS } from "@/packages/use-shader-fx/src/hooks/useFruid";
4+
import { FLUID_PARAMS } from "@/packages/use-shader-fx/src/hooks/useFluid";
55
import { FOGPROJECTION_PARAMS } from "@/packages/use-shader-fx/src/hooks/useFogProjection";
66

77
export const CONFIG = {
@@ -12,14 +12,14 @@ export const CONFIG = {
1212
fogEdge1: 1.0,
1313
distortionStrength: 0.2,
1414
},
15-
fruid: {
16-
...structuredClone(FRUID_PARAMS),
17-
fruidVec: new THREE.Vector3(),
18-
fruid_color: (velocity: THREE.Vector2) => {
15+
fluid: {
16+
...structuredClone(FLUID_PARAMS),
17+
fluidVec: new THREE.Vector3(),
18+
fluid_color: (velocity: THREE.Vector2) => {
1919
const rCol = Math.max(0.2, velocity.x * 100);
2020
const gCol = Math.max(0.2, velocity.y * 100);
2121
const bCol = Math.max(0.4, (rCol + gCol) / 2);
22-
return CONFIG.fruid.fruidVec.set(rCol, gCol, bCol);
22+
return CONFIG.fluid.fluidVec.set(rCol, gCol, bCol);
2323
},
2424
},
2525
};
@@ -31,11 +31,11 @@ export const setGUI = (gui: GUI) => {
3131
fogProjection.add(CONFIG.fogProjection, "fogEdge1", 0, 1, 0.01);
3232
fogProjection.addColor(CONFIG.fogProjection, "fogColor");
3333

34-
const fruid = gui.addFolder("fruid");
35-
fruid.add(CONFIG.fruid, "density_dissipation", 0, 1, 0.01);
36-
fruid.add(CONFIG.fruid, "velocity_dissipation", 0, 1, 0.01);
37-
fruid.add(CONFIG.fruid, "pressure_dissipation", 0, 1, 0.01);
38-
fruid.add(CONFIG.fruid, "velocity_acceleration", 0, 100, 1);
39-
fruid.add(CONFIG.fruid, "curl_strength", 0, 100, 1);
40-
fruid.add(CONFIG.fruid, "splat_radius", 0, 0.1, 0.001);
34+
const Fluid = gui.addFolder("Fluid");
35+
Fluid.add(CONFIG.fluid, "density_dissipation", 0, 1, 0.01);
36+
Fluid.add(CONFIG.fluid, "velocity_dissipation", 0, 1, 0.01);
37+
Fluid.add(CONFIG.fluid, "pressure_dissipation", 0, 1, 0.01);
38+
Fluid.add(CONFIG.fluid, "velocity_acceleration", 0, 100, 1);
39+
Fluid.add(CONFIG.fluid, "curl_strength", 0, 100, 1);
40+
Fluid.add(CONFIG.fluid, "splat_radius", 0, 0.1, 0.001);
4141
};

Diff for: app/_demo/index.tsx

+14-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
FxTransparentMaterialProps,
99
} from "@/utils/fxTransparentMaterial";
1010
import {
11-
useFruid,
11+
useFluid,
1212
useFogProjection,
1313
useNoise,
1414
} from "@/packages/use-shader-fx/src";
@@ -24,7 +24,7 @@ export const Demo = () => {
2424

2525
const [updateNoise] = useNoise({ size, dpr });
2626

27-
const [updateFruid, setFruid] = useFruid({
27+
const [updateFluid, setFluid] = useFluid({
2828
size,
2929
dpr,
3030
});
@@ -33,7 +33,7 @@ export const Demo = () => {
3333

3434
usePerformanceMonitor({
3535
onChange({ factor }) {
36-
setFruid({
36+
setFluid({
3737
pressure_iterations: Math.max(2, Math.floor(20 * factor)),
3838
});
3939
},
@@ -44,14 +44,14 @@ export const Demo = () => {
4444
timeStrength: 0.4,
4545
});
4646

47-
const fx = updateFruid(props, {
48-
density_dissipation: CONFIG.fruid.density_dissipation,
49-
velocity_dissipation: CONFIG.fruid.velocity_dissipation,
50-
velocity_acceleration: CONFIG.fruid.velocity_acceleration,
51-
pressure_dissipation: CONFIG.fruid.pressure_dissipation,
52-
curl_strength: CONFIG.fruid.curl_strength,
53-
splat_radius: CONFIG.fruid.splat_radius,
54-
fruid_color: CONFIG.fruid.fruid_color,
47+
const fx = updateFluid(props, {
48+
density_dissipation: CONFIG.fluid.density_dissipation,
49+
velocity_dissipation: CONFIG.fluid.velocity_dissipation,
50+
velocity_acceleration: CONFIG.fluid.velocity_acceleration,
51+
pressure_dissipation: CONFIG.fluid.pressure_dissipation,
52+
curl_strength: CONFIG.fluid.curl_strength,
53+
splat_radius: CONFIG.fluid.splat_radius,
54+
fluid_color: CONFIG.fluid.fluid_color,
5555
});
5656

5757
const postFx = updateFogProjection(props, {
@@ -88,15 +88,15 @@ the simplest demo
8888
// import * as THREE from "three";
8989
// import { useRef } from "react";
9090
// import { useFrame, useThree } from "@react-three/fiber";
91-
// import { useFruid } from "@hmng8/use-shader-fx";
91+
// import { useFluid } from "@hmng8/use-shader-fx";
9292

9393
// export const Demo = () => {
9494
// const ref = useRef<THREE.ShaderMaterial>(null);
9595
// const size = useThree((state) => state.size);
9696
// const dpr = useThree((state) => state.viewport.dpr);
97-
// const [updateFruid] = useFruid({ size, dpr });
97+
// const [updateFluid] = useFluid({ size, dpr });
9898
// useFrame((props) => {
99-
// ref.current!.uniforms.u_fx.value = updateFruid(props);
99+
// ref.current!.uniforms.u_fx.value = updateFluid(props);
100100
// });
101101

102102
// return (

Diff for: packages/use-shader-fx/build/use-shader-fx.js

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: packages/use-shader-fx/build/use-shader-fx.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)