Skip to content

Commit 24c695a

Browse files
authored
Merge pull request #76 from FunTechInc/v1.1.3
type modification
2 parents 9d50c82 + 6bb6870 commit 24c695a

File tree

14 files changed

+33
-24
lines changed

14 files changed

+33
-24
lines changed

app/apple-icon.jpg

190 KB
Loading

app/gradation/Playground.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import * as THREE from "three";
4-
import { useEffect, useRef } from "react";
4+
import { useCallback, useEffect, useRef } from "react";
55
import { useFrame, useThree, extend } from "@react-three/fiber";
66
import {
77
useNoise,
@@ -36,14 +36,17 @@ const setConfig = (key: "marble" | "colorStrata" | "hsv") => {
3636

3737
function useDownloadCanvas() {
3838
const { gl } = useThree();
39-
const downloadImage = (filename = "image.png") => {
40-
const image = gl.domElement.toDataURL("image/png");
41-
const link = document.createElement("a");
42-
link.download = filename;
43-
link.href = image;
44-
link.click();
45-
link.remove();
46-
};
39+
const downloadImage = useCallback(
40+
(filename = "image.png") => {
41+
const image = gl.domElement.toDataURL("image/png");
42+
const link = document.createElement("a");
43+
link.download = filename;
44+
link.href = image;
45+
link.click();
46+
link.remove();
47+
},
48+
[gl]
49+
);
4750
return downloadImage;
4851
}
4952

packages/use-shader-fx/build/use-shader-fx.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/use-shader-fx/build/use-shader-fx.umd.cjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/use-shader-fx/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/use-shader-fx/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@funtech-inc/use-shader-fx",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"description": "⚡️ More FXs, Less GLSL",
55
"main": "./build/use-shader-fx.umd.cjs",
66
"module": "./build/use-shader-fx.js",

packages/use-shader-fx/src/fxs/interactions/useBrush/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ export type BrushParams = {
2727
/** Number of motion blur samples. Affects performance default: 5 */
2828
motionSample?: number;
2929
/** brush color , it accepts a function that returns THREE.Vector3.The function takes velocity:THREE.Vector2 as an argument. , default:THREE.Vector3(1.0, 1.0, 1.0) */
30-
color?: ((velocity: THREE.Vector2) => THREE.Vector3) | THREE.Vector3;
30+
color?:
31+
| ((velocity: THREE.Vector2) => THREE.Vector3)
32+
| THREE.Vector3
33+
| THREE.Color;
3134
/** Follows the cursor even if it loses speed , default:false */
3235
isCursor?: boolean;
3336
/** brush pressure (0 to 1) , default : 1.0 */
@@ -118,7 +121,7 @@ export const useBrush = ({
118121
}
119122
setUniform(material, "uVelocity", pointerValues.velocity);
120123

121-
const color: THREE.Vector3 =
124+
const color: THREE.Vector3 | THREE.Color =
122125
typeof params.color === "function"
123126
? params.color(pointerValues.velocity)
124127
: params.color!;

packages/use-shader-fx/src/fxs/interactions/useBrush/useMesh.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class BrushMaterial extends THREE.ShaderMaterial {
2424
uMouse: { value: number };
2525
uPrevMouse: { value: number };
2626
uVelocity: { value: number };
27-
uColor: { value: THREE.Vector3 };
27+
uColor: { value: THREE.Vector3 | THREE.Color };
2828
uIsCursor: { value: boolean };
2929
uPressureStart: { value: number };
3030
uPressureEnd: { value: number };

packages/use-shader-fx/src/fxs/interactions/useFluid/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ export type FluidParams = {
2727
/** splat radius , default:0.002 */
2828
splat_radius?: number;
2929
/** Fluid Color.THREE.Vector3 Alternatively, it accepts a function that returns THREE.Vector3.The function takes velocity:THREE.Vector2 as an argument. , default:THREE.Vector3(1.0, 1.0, 1.0) */
30-
fluid_color?: ((velocity: THREE.Vector2) => THREE.Vector3) | THREE.Vector3;
30+
fluid_color?:
31+
| ((velocity: THREE.Vector2) => THREE.Vector3)
32+
| THREE.Vector3
33+
| THREE.Color;
3134
/** When calling usePointer in a frame loop, setting PointerValues ​​to this value prevents double calls , default:false */
3235
pointerValues?: PointerValues | false;
3336
};
@@ -163,7 +166,7 @@ export const useFluid = ({
163166
updateDensityFBO(gl, ({ read }) => {
164167
setMeshMaterial(materials.splatMaterial);
165168
setUniform(materials.splatMaterial, "uTarget", read);
166-
const color: THREE.Vector3 =
169+
const color: THREE.Vector3 | THREE.Color =
167170
typeof params.fluid_color === "function"
168171
? params.fluid_color(pointerValues.velocity)
169172
: params.fluid_color!;

packages/use-shader-fx/src/fxs/interactions/useFluid/materials/useSplatMaterial.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class SplatMaterial extends THREE.ShaderMaterial {
77
uniforms!: {
88
uTarget: { value: THREE.Texture };
99
aspectRatio: { value: number };
10-
color: { value: THREE.Vector3 };
10+
color: { value: THREE.Vector3 | THREE.Color };
1111
point: { value: THREE.Vector2 };
1212
radius: { value: number };
1313
texelSize: { value: THREE.Vector2 };

0 commit comments

Comments
 (0)