next.js planebuffergeometry不是three命名空间的一部分

qyyhg6bp  于 2023-08-04  发布在  其他
关注(0)|答案(1)|浏览(196)

我正在使用next.js构建一个three.js项目,但收到以下错误:
'planeBufferGeometry不是THREE命名空间的一部分。你忘了延长吗?请参阅:https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively
我是新来的js我不知道有什么问题
在第.js页中(用于app.js):

"use client"
import Image from 'next/image'
import styles from './page.module.css'
import { Canvas } from '@react-three/fiber'
import { Sky } from '@react-three/drei'
import Ground from './components/Ground'
import { Physics } from '@react-three/cannon'

export default function Home() {
  return (
    <>
      <Canvas>
        <Sky sunPosition={[100, 20, 100]} />
        <ambientLight intensity={0.5} />
        <Physics>
          <Ground />
        </Physics>
      </Canvas>
    </>
  )
}

字符串
在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}>
            <planeBufferGeometry attach="geometry" args={[100, 100]} />
            <meshStandardMaterial attach="material" map={groundTexture} />
        </mesh>
    )
}

export default Ground


我是新来的js我不知道有什么问题

kiz8lqtg

kiz8lqtg1#

three.js中,BufferGeometry别名已被弃用于所有具有r144的几何生成器。使用r154,别名最终从项目中删除。
所以总是使用像PlaneGeometryBoxGeometry这样的名称。

相关问题