Currently, I am developing a simple game where players can add objects (cubes) to the scene at the position of a raycaster (mouse) click on a large ground plane. To prevent cubes from overlapping with each other, I have implemented basic collision detection. While I acknowledge that this may not be the most efficient method, it aligns with my current understanding as a beginner.
In the code snippet below, I check the positions of both the new object and existing objects. By calculating the distance between them, if it is less than 4096 (64*64), the new cube is added to the scene.
function onDocumentMouseDown( event ) {
// Event handling logic here
}
One of the limitations I have encountered is that the current implementation only works effectively for square objects. Can anyone assist me in adapting this logic to accommodate rectangle objects like THREE.BoxGeometry( 64, 64, 400)
?