小编Yar*_*ido的帖子

React ThreeJs 渲染问题 - 计算半径为 NaN

我是 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)

three.js reactjs

3
推荐指数
1
解决办法
1267
查看次数

标签 统计

reactjs ×1

three.js ×1