我是 Threejs 的新手,我对试图在屏幕上显示的星星模型有疑问。这些点有效,但我收到以下消息:
THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.
在查看了我的代码并发现解决问题的部分是星星画布之后。星星画布:
const StarsCanvas = () => {
return (
<div className="w-full h-auto absolute inset-0 z-[-1]">
<Canvas camera={{ position: [0, 0, 1] }}>
<Suspense fallback={null}>
<Stars />
</Suspense>
<Preload all />
</Canvas>
</div>
);
};
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的画布,下面是星星组件:
星星:
import * as random from "maath/random/dist/maath-random.esm";
...
const Stars = (props) => {
const ref = useRef();
const [sphere] = useState(() =>
random.inSphere(new Float32Array(5000), { radius: 1.2 …Run Code Online (Sandbox Code Playgroud)