react-three-fiber - 球体不考虑平面几何外的重力
问题描述
我有一个带有球体和平面的简单环境。这两个对象都包裹在一个物理组件中,并且物理工作,如果我移除平面,球体将会下降。但是当我在平面外运行球体时,球体不会下落。我不知道我是否误解了一些琐碎的事情,也许飞机比它看起来更宽?
我认为没有办法设置网格的宽度/深度,所以我认为它是 planeBufferGeometry 的宽度/深度重要吗?
import { Canvas } from '@react-three/fiber'
import { Sky, PointerLockControls } from '@react-three/drei'
import { Physics } from '@react-three/cannon'
import { Ground, Sphere } from '../components/'
export default function Game(props) {
return (
<>
<Canvas shadows colorManagement camera={{ fov: 45 }}>
<Sky sunPosition={[100, 10, 100]} />
<ambientLight intensity={0.3} />
<pointLight castShadow intensity={2.8} position={[100, 100, 100]} />
<Physics gravity={[0, -106, 0]}>
<Ground />
<Sphere />
</Physics>
<PointerLockControls />
</Canvas>
</>
)
}
Ground.js:
import { usePlane } from '@react-three/cannon'
import { useNormalTexture } from '@react-three/drei'
export default function Ground(props) {
const [ref] = usePlane(() => ({ rotation: [-Math.PI / 2, 0, 0], ...props }))
const [normalMap] = useNormalTexture(32, {
offset: [0, 0],
repeat: [100, 100],
anisotropy: 8
})
return (
<mesh ref={ref} receiveShadow>
<planeBufferGeometry attach="geometry" args={[50, 50]} />
<meshStandardMaterial
attach="material"
normalMap={normalMap}
color="#dadb84"
/>
</mesh>
)
}
解决方案
推荐阅读
- typescript - 如何键入一个打字稿函数,该函数将对象数组作为第一个参数,并将对象上预期的特定属性作为参数?
- spring-boot - 找不到任何 Elasticsearch 数据
- google-sheets - Vlookup 仅在 Google 表格中检查新行条目
- asp.net-core - 如何命名并将 Sendgrid api 密钥和名称添加到 appSetting.json
- excel - Excel 中的单元格自引用
- sql - 连接来自同一个表的两个聚合查询 - SQL Server
- c# - UAC 和通过 Windows 服务执行作业
- autohotkey - 如果尚未启动程序,如何启动程序,如果已启动,则将焦点放在?
- awk - awk:当列总和在一个范围内时提取行
- javascript - laravel 验证,如何在客户端添加验证规则?