r3f-vfx 0.1.2 → 0.1.3
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/dist/index.js +33 -32
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -69,11 +69,20 @@ var init_useCurveTextureAsync = __esm({
|
|
|
69
69
|
"src/useCurveTextureAsync.ts"() {
|
|
70
70
|
"use strict";
|
|
71
71
|
useCurveTextureAsync = (sizeCurve, opacityCurve, velocityCurve, rotationSpeedCurve, curveTexturePath = null) => {
|
|
72
|
+
const hasAnyCurve = sizeCurve || opacityCurve || velocityCurve || rotationSpeedCurve;
|
|
72
73
|
const textureRef = useRef(null);
|
|
73
74
|
if (!textureRef.current) {
|
|
74
|
-
|
|
75
|
+
if (!curveTexturePath && hasAnyCurve) {
|
|
76
|
+
textureRef.current = createCombinedCurveTexture(
|
|
77
|
+
sizeCurve,
|
|
78
|
+
opacityCurve,
|
|
79
|
+
velocityCurve,
|
|
80
|
+
rotationSpeedCurve
|
|
81
|
+
);
|
|
82
|
+
} else {
|
|
83
|
+
textureRef.current = createDefaultCurveTexture();
|
|
84
|
+
}
|
|
75
85
|
}
|
|
76
|
-
const hasAnyCurve = sizeCurve || opacityCurve || velocityCurve || rotationSpeedCurve;
|
|
77
86
|
useMemo(() => {
|
|
78
87
|
if (!curveTexturePath && hasAnyCurve && textureRef.current) {
|
|
79
88
|
const bakedTexture = createCombinedCurveTexture(
|
|
@@ -90,40 +99,32 @@ var init_useCurveTextureAsync = __esm({
|
|
|
90
99
|
}
|
|
91
100
|
bakedTexture.dispose();
|
|
92
101
|
}
|
|
93
|
-
}, [
|
|
94
|
-
sizeCurve,
|
|
95
|
-
opacityCurve,
|
|
96
|
-
velocityCurve,
|
|
97
|
-
rotationSpeedCurve,
|
|
98
|
-
curveTexturePath,
|
|
99
|
-
hasAnyCurve
|
|
100
|
-
]);
|
|
102
|
+
}, [sizeCurve, opacityCurve, velocityCurve, rotationSpeedCurve]);
|
|
101
103
|
useEffect(() => {
|
|
102
|
-
if (curveTexturePath
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
if (!curveTexturePath || !textureRef.current) return;
|
|
105
|
+
loadCurveTextureFromPath(curveTexturePath, textureRef.current).catch(
|
|
106
|
+
(err) => {
|
|
107
|
+
console.warn(
|
|
108
|
+
`Failed to load curve texture: ${curveTexturePath}, falling back to baking`,
|
|
109
|
+
err
|
|
110
|
+
);
|
|
111
|
+
if (hasAnyCurve && textureRef.current) {
|
|
112
|
+
const bakedTexture = createCombinedCurveTexture(
|
|
113
|
+
sizeCurve,
|
|
114
|
+
opacityCurve,
|
|
115
|
+
velocityCurve,
|
|
116
|
+
rotationSpeedCurve
|
|
108
117
|
);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
rotationSpeedCurve
|
|
115
|
-
);
|
|
116
|
-
const srcData = bakedTexture.image.data;
|
|
117
|
-
const dstData = textureRef.current.image.data;
|
|
118
|
-
if (srcData && dstData) {
|
|
119
|
-
dstData.set(srcData);
|
|
120
|
-
textureRef.current.needsUpdate = true;
|
|
121
|
-
}
|
|
122
|
-
bakedTexture.dispose();
|
|
118
|
+
const srcData = bakedTexture.image.data;
|
|
119
|
+
const dstData = textureRef.current.image.data;
|
|
120
|
+
if (srcData && dstData) {
|
|
121
|
+
dstData.set(srcData);
|
|
122
|
+
textureRef.current.needsUpdate = true;
|
|
123
123
|
}
|
|
124
|
+
bakedTexture.dispose();
|
|
124
125
|
}
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
}
|
|
127
|
+
);
|
|
127
128
|
}, [
|
|
128
129
|
curveTexturePath,
|
|
129
130
|
sizeCurve,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "r3f-vfx",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"prepublishOnly": "bun run copy-readme"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"core-vfx": "0.0.
|
|
27
|
+
"core-vfx": "0.0.6",
|
|
28
28
|
"zustand": "5.0.10"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|