我想让 React Spring 为 Three.js 中的材质属性设置动画。
但是,当我尝试这样做时出现错误:
THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.
这是我的代码,我正在尝试props.theta
从 6.3 动画到 1.3:
import React, { useRef, useState, useEffect } from 'react';
import { useFrame } from 'react-three-fiber';
import { useSpring, a } from 'react-spring/three';
function RingBuffer() {
const ringBuffer = useRef();
const props = useSpring({
to: async (next, cancel) => {
await next({ theta: 1.3 });
},
from: { theta: 6.3 },
});
useFrame(() => {
ringBuffer.current.rotation.z += 0.03;
});
return (
<a.mesh ref={ringBuffer}>
<a.ringBufferGeometry attach="geometry" args={[1, 2, 30, 30, 0, props.theta]} />
<meshLambertMaterial attach="material" wireframe={true} color={'#4FFF9C'} />
</a.mesh>
);
}
我正在使用 react-three-fiber,它是 Three.js 的反应协调器。