r3f-motion 1.0.4 → 1.0.5

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/cjs/index.js CHANGED
@@ -32,6 +32,7 @@ const useRender = (Component, props, forwardedRef, instanceRef, initialValues) =
32
32
  * Create a callback ref that captures the Three.js instance
33
33
  */
34
34
  const callbackRef = react.useCallback((instance) => {
35
+ var _a;
35
36
  if (!instance)
36
37
  return;
37
38
  // Apply initial values immediately to prevent FOUC - but only once
@@ -70,6 +71,12 @@ const useRender = (Component, props, forwardedRef, instanceRef, initialValues) =
70
71
  colorProp.set(initialValues[key]);
71
72
  }
72
73
  }
74
+ else if (instance.uniforms &&
75
+ instance.uniforms[key] &&
76
+ typeof ((_a = instance.uniforms[key]) === null || _a === void 0 ? void 0 : _a.value) === "number") {
77
+ // Set ShaderMaterial uniform initial value
78
+ instance.uniforms[key].value = initialValues[key];
79
+ }
73
80
  else if (key in instance && typeof instance[key] === "number") {
74
81
  instance[key] = initialValues[key];
75
82
  }
@@ -447,6 +454,7 @@ function custom(Component) {
447
454
  "attenuationColor",
448
455
  ]);
449
456
  Object.entries(targetValues).forEach(([key, value]) => {
457
+ var _a;
450
458
  const opts = getPropertyOpts(key);
451
459
  const mapping = transformMap[key];
452
460
  if (mapping === null || mapping === void 0 ? void 0 : mapping.target) {
@@ -460,6 +468,14 @@ function custom(Component) {
460
468
  else if (colorKeys.has(key) && instance[key]) {
461
469
  animateColor(instance[key], value, opts, key);
462
470
  }
471
+ else if (instance.uniforms &&
472
+ instance.uniforms[key] &&
473
+ typeof ((_a = instance.uniforms[key]) === null || _a === void 0 ? void 0 : _a.value) === "number") {
474
+ // Animate ShaderMaterial uniforms (uniforms[key].value)
475
+ // Note: consumers must useMemo their uniforms prop to prevent
476
+ // R3F from overwriting animated values on re-render
477
+ createAnimation(instance.uniforms[key], { value: value }, opts, key);
478
+ }
463
479
  else if (key in instance && typeof instance[key] === "number") {
464
480
  createAnimation(instance, { [key]: value }, opts, key);
465
481
  }
@@ -166,6 +166,7 @@ function custom(Component) {
166
166
  "attenuationColor",
167
167
  ]);
168
168
  Object.entries(targetValues).forEach(([key, value]) => {
169
+ var _a;
169
170
  const opts = getPropertyOpts(key);
170
171
  const mapping = transformMap[key];
171
172
  if (mapping === null || mapping === void 0 ? void 0 : mapping.target) {
@@ -179,6 +180,14 @@ function custom(Component) {
179
180
  else if (colorKeys.has(key) && instance[key]) {
180
181
  animateColor(instance[key], value, opts, key);
181
182
  }
183
+ else if (instance.uniforms &&
184
+ instance.uniforms[key] &&
185
+ typeof ((_a = instance.uniforms[key]) === null || _a === void 0 ? void 0 : _a.value) === "number") {
186
+ // Animate ShaderMaterial uniforms (uniforms[key].value)
187
+ // Note: consumers must useMemo their uniforms prop to prevent
188
+ // R3F from overwriting animated values on re-render
189
+ createAnimation(instance.uniforms[key], { value: value }, opts, key);
190
+ }
182
191
  else if (key in instance && typeof instance[key] === "number") {
183
192
  createAnimation(instance, { [key]: value }, opts, key);
184
193
  }
@@ -7,6 +7,7 @@ const useRender = (Component, props, forwardedRef, instanceRef, initialValues) =
7
7
  * Create a callback ref that captures the Three.js instance
8
8
  */
9
9
  const callbackRef = useCallback((instance) => {
10
+ var _a;
10
11
  if (!instance)
11
12
  return;
12
13
  // Apply initial values immediately to prevent FOUC - but only once
@@ -45,6 +46,12 @@ const useRender = (Component, props, forwardedRef, instanceRef, initialValues) =
45
46
  colorProp.set(initialValues[key]);
46
47
  }
47
48
  }
49
+ else if (instance.uniforms &&
50
+ instance.uniforms[key] &&
51
+ typeof ((_a = instance.uniforms[key]) === null || _a === void 0 ? void 0 : _a.value) === "number") {
52
+ // Set ShaderMaterial uniform initial value
53
+ instance.uniforms[key].value = initialValues[key];
54
+ }
48
55
  else if (key in instance && typeof instance[key] === "number") {
49
56
  instance[key] = initialValues[key];
50
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "r3f-motion",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "A simple and powerful React animation library for @react-three/fiber leveraging motion.dev",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.mjs",