How to stop camera from passing through the gltf model using @react-three/cannon?

I'm using the threejs GLTFLoader() to parse the gltf file and Physics from @react-three/cannon. Player is the camera component with wasd controls. ModelGroup returns a group of primitive components. I'm still able to pass through gltf models rendered as walls. How do I add physics correctly to the model in order to achieve the camera movement restriction ?

function App (){
    return(
        <Canvas>
            <Physics>
               <Player/>
               <ModelGroup models={gltfObjects} />
            <Physics/>
        <Canvas/>
    );
} 


Read more here: https://stackoverflow.com/questions/67941898/how-to-stop-camera-from-passing-through-the-gltf-model-using-react-three-cannon

Content Attribution

This content was originally published by user8997204 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: