You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Next.js开发Three.js项目遇planeBufferGeometry命名空间报错求助

问题解决:planeBufferGeometry 不在 THREE 命名空间报错

错误原因

Three.js 在 r125 版本后废弃了 PlaneBufferGeometry,统一合并到 PlaneGeometry 中(底层依然是 BufferGeometry 实现,性能无差异);同时在 react-three-fiber 中,Three.js 的类需要转换为短横线分隔的小写组件名使用。

修复步骤

修改 Ground.js 中的几何组件:
将原来的

<planeBufferGeometry attach="geometry" args={[100, 100]} />

替换为

<planeGeometry attach="geometry" args={[100, 100]} />

完整修复后的 Ground.js 代码

import { usePlane } from "@react-three/cannon";
import { groundTexture } from "../images/textures"
import * as THREE from "three";

const Ground = (props) => {
    const [ref] = usePlane(() => ({
        rotation: [-Math.PI / 4, 0, 0], position: [0, 0, 0]
    }))
    groundTexture.magFilter = THREE.NearestFilter;
    groundTexture.wrapS = groundTexture.wrapT = THREE.RepeatWrapping;
    groundTexture.repeat.set(100, 100);

    return (
        <mesh ref={ref}>
            <planeGeometry attach="geometry" args={[100, 100]} />
            <meshStandardMaterial attach="material" map={groundTexture} />
        </mesh>
    )
}

export default Ground

内容的提问来源于stack exchange,提问作者ayaz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 00:09:56