最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

reactjs - What is the correct way of adding textures to react-threerapier RigidBodies? - Stack Overflow

programmeradmin1浏览0评论

I am trying to add a react-three/drei texture to a rigid body like this:

                  <RigidBody type="fixed" name="floor" friction={0.7}>
                        {/* Collider 1: A 'box' collider with a certain material */}
                        <CuboidCollider restitution={0.9} friction={0.2} args={[100, 1, 100]} />

                        {/* Render geometry (visual only) */}
                        <mesh>
                            <boxGeometry args={[100, 1, 100]} />
                                <MeshReflectorMaterial
                                    blur={[300, 100]}
                                    resolution={2048}
                                    mixBlur={1}
                                    mixStrength={40}
                                    roughness={1}
                                    depthScale={1.2}
                                    minDepthThreshold={0.4}
                                    maxDepthThreshold={1.4}
                                    color="#101010"
                                    metalness={0.5}
                                />
                        </mesh>


                    </RigidBody>

The material appears to be rendered correctly and the collider behaves as I would expect but it seems to cause unexplained behaviours of my other objects in the scene - some go missing, some are teleported to a different place (????). All of this strangeness stops as soon as I remove the <mesh></mesh> code and comes back when I add it back in. What am I doing wrong?

EDIT: I', guessing that this is somehow related to performance/time to render and time steps since I'm getting the same weird disappearances etc when trying to add any other complex effects e.g. from react-three/postprocessing. Still no idea how to solve it though.

发布评论

评论列表(0)

  1. 暂无评论