I seem to be overlooking something quite fundamental, as I can't seem to find a solution in the documentation or any other working code examples. I am currently creating a basic museum using THREE.js libraries. While most of it is set up, I need to implement collision detection for the camera. Here's what I have so far:
var d = camera.position.distanceTo(plane_8.position);
if (d < 200) {
camera.position = previousPosition;
camera.rotation = previousRotation;
}
It seems simple enough and should work against at least one wall, but unfortunately, it doesn't. What could I possibly be missing? Below is the full code:
<html>
<head>
<title>#10 - WebGL - Three.js</title>
<style>canvas { width: 100%; height: 100% }</style>
</head>
<body>
<script src="js/three.js"></script>
<script src="js/THREEx.KeyboardState.js"></script>
<script>
// Code goes here
</script>
</body>