Skip to content

Commit 548109b

Browse files
authored
Merge pull request #74 from FunTechInc/minor-update
Minor update
2 parents d9d0ec1 + fb198d4 commit 548109b

File tree

237 files changed

+6033
-2995
lines changed

Some content is hidden

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

237 files changed

+6033
-2995
lines changed

.storybook/constant.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

.storybook/public/app-head.jpg

689 KB
Loading

.storybook/public/favicon.ico

116 KB
Binary file not shown.

.storybook/public/logo.svg

Lines changed: 49 additions & 16 deletions
Loading

.storybook/public/thumbnail.jpg

561 KB
Loading
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import * as React from "react";
2+
import type { StoryObj } from "@storybook/react";
3+
import { setArgTypes } from "../utils/setArgTypes";
4+
import { Setup } from "../utils/Setup";
5+
import type { Meta } from "@storybook/react";
6+
import { UseAlphaBlending } from "./UseAlphaBlending";
7+
import {
8+
ALPHABLENDING_PARAMS,
9+
AlphaBlendingParams,
10+
} from "../../packages/use-shader-fx/src/fxs/utils/useAlphaBlending";
11+
12+
const meta = {
13+
title: "utils/useAlphaBlending",
14+
component: UseAlphaBlending,
15+
tags: ["autodocs"],
16+
decorators: [(storyFn: any) => <Setup>{storyFn()}</Setup>],
17+
} satisfies Meta<typeof UseAlphaBlending>;
18+
export default meta;
19+
type Story = StoryObj<typeof meta>;
20+
21+
export const Default: Story = {
22+
args: ALPHABLENDING_PARAMS,
23+
argTypes: setArgTypes<AlphaBlendingParams>(ALPHABLENDING_PARAMS),
24+
};
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import * as React from "react";
2+
import * as THREE from "three";
3+
import { useFrame, useLoader, extend, useThree } from "@react-three/fiber";
4+
import { FxMaterial, FxMaterialProps } from "../../utils/fxMaterial";
5+
import GUI from "lil-gui";
6+
import { useGUI } from "../../utils/useGUI";
7+
import {
8+
useAlphaBlending,
9+
useMarble,
10+
useBrush,
11+
} from "../../packages/use-shader-fx/src";
12+
import {
13+
ALPHABLENDING_PARAMS,
14+
AlphaBlendingParams,
15+
} from "../../packages/use-shader-fx/src/fxs/utils/useAlphaBlending";
16+
17+
extend({ FxMaterial });
18+
19+
const CONFIG: AlphaBlendingParams = structuredClone(ALPHABLENDING_PARAMS);
20+
const setGUI = (gui: GUI) => {};
21+
const setConfig = () => {
22+
return {
23+
...CONFIG,
24+
} as AlphaBlendingParams;
25+
};
26+
27+
export const UseAlphaBlending = (args: AlphaBlendingParams) => {
28+
const updateGUI = useGUI(setGUI);
29+
const fxRef = React.useRef<FxMaterialProps>();
30+
const { size, dpr } = useThree((state) => {
31+
return { size: state.size, dpr: state.viewport.dpr };
32+
});
33+
34+
const [updateBrush, setBrush, { output: brush }] = useBrush({ size, dpr });
35+
const [update, set, { output }] = useAlphaBlending({ size, dpr });
36+
const [updateMarble, setMarble, { output: marble }] = useMarble({
37+
size,
38+
dpr,
39+
});
40+
41+
set({
42+
texture: marble,
43+
map: brush,
44+
});
45+
46+
useFrame((props) => {
47+
updateBrush(props);
48+
updateMarble(props);
49+
update(props);
50+
updateGUI();
51+
});
52+
53+
return (
54+
<mesh>
55+
<planeGeometry args={[2, 2]} />
56+
<fxMaterial
57+
key={FxMaterial.key}
58+
u_fx={output}
59+
u_alpha={0.0}
60+
ref={fxRef}
61+
/>
62+
</mesh>
63+
);
64+
};

.storybook/stories/UseBlending.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@ import * as React from "react";
22
import * as THREE from "three";
33
import { useFrame, useLoader, extend, useThree } from "@react-three/fiber";
44
import { FxMaterial, FxMaterialProps } from "../../utils/fxMaterial";
5-
import { CONSTANT } from "../constant";
65
import GUI from "lil-gui";
76
import { useGUI } from "../../utils/useGUI";
87
import {
98
useBlending,
10-
useFxTexture,
119
useNoise,
1210
useBrightnessPicker,
1311
useFluid,
12+
useCoverTexture,
1413
} from "../../packages/use-shader-fx/src";
1514
import {
1615
BlendingParams,
1716
BLENDING_PARAMS,
18-
} from "../../packages/use-shader-fx/src/hooks/useBlending";
17+
} from "../../packages/use-shader-fx/src/fxs/utils/useBlending";
1918

2019
extend({ FxMaterial });
2120

@@ -36,14 +35,13 @@ const setConfig = () => {
3635
*/
3736
export const UseBlending = (args: BlendingParams) => {
3837
const updateGUI = useGUI(setGUI);
39-
const [bg] = useLoader(THREE.TextureLoader, ["thumbnail.jpg"]);
38+
const [bg] = useLoader(THREE.TextureLoader, ["momo.jpg"]);
4039
const fxRef = React.useRef<FxMaterialProps>();
4140
const { size, dpr } = useThree((state) => {
4241
return { size: state.size, dpr: state.viewport.dpr };
4342
});
44-
const [updateFxTexture] = useFxTexture({ size, dpr });
45-
const [updateNoise] = useNoise({ size, dpr });
46-
const [updateFluid, setFluid] = useFluid({ size, dpr });
43+
const [updateCover] = useCoverTexture({ size, dpr });
44+
const [updateFluid, setFluid, { output: fluid }] = useFluid({ size, dpr });
4745
const [updateBlending, setBlending] = useBlending({ size, dpr });
4846
const [updateBrightnessPicker] = useBrightnessPicker({ size, dpr });
4947

@@ -65,9 +63,8 @@ export const UseBlending = (args: BlendingParams) => {
6563
});
6664

6765
useFrame((props) => {
68-
const bgTexture = updateFxTexture(props, {
69-
textureResolution: CONSTANT.textureResolution,
70-
texture0: bg,
66+
const bgTexture = updateCover(props, {
67+
texture: bg,
7168
});
7269
const fluid = updateFluid(props);
7370
const picked = updateBrightnessPicker(props, { texture: fluid });

.storybook/stories/UseBrightnessPicker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import {
1212
BrightnessPickerParams,
1313
BRIGHTNESSPICKER_PARAMS,
14-
} from "../../packages/use-shader-fx/src/hooks/useBrightnessPicker";
14+
} from "../../packages/use-shader-fx/src/fxs/utils/useBrightnessPicker";
1515

1616
extend({ FxMaterial });
1717

.storybook/stories/UseBrush.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import { useFrame, extend, useThree, useLoader } from "@react-three/fiber";
44
import { FxMaterial, FxMaterialProps } from "../../utils/fxMaterial";
55
import GUI from "lil-gui";
66
import { useGUI } from "../../utils/useGUI";
7-
import { CONSTANT } from "../constant";
87
import { useBrush, useFxTexture } from "../../packages/use-shader-fx/src";
98
import {
109
BrushParams,
1110
BRUSH_PARAMS,
12-
} from "../../packages/use-shader-fx/src/hooks/useBrush";
11+
} from "../../packages/use-shader-fx/src/fxs/interactions/useBrush";
1312

1413
extend({ FxMaterial });
1514

@@ -57,16 +56,15 @@ export const UseBrushWithTexture = (args: BrushParams) => {
5756
return { size: state.size, dpr: state.viewport.dpr };
5857
});
5958
const [updateFxTexture] = useFxTexture({ size, dpr });
60-
const [updateBrush] = useBrush({ size, dpr });
59+
const [updateBrush, setBrush] = useBrush({ size, dpr });
6160

6261
useFrame((props) => {
6362
const bgTexture = updateFxTexture(props, {
64-
textureResolution: CONSTANT.textureResolution,
6563
texture0: bg,
6664
});
6765
const fx = updateBrush(props, {
68-
texture: bgTexture,
6966
...setConfig(),
67+
texture: bgTexture,
7068
});
7169
fxRef.current!.u_fx = fx;
7270
updateGUI();

0 commit comments

Comments
 (0)