title: Collision detection using boundingBox not working well
body: <p>js and after watching some tutorials I'm currently working on a small project where I use boundingBox to detect if there's intersected boxes so a collision happens. But I don't know why the console always print true for <code>intersectsBox()</code> even if there's no collision.
  Here's my code for adding hitBoxes:</p>
  <pre><code>function carHitBox(car) {
      const hit = new THREE.Mesh(
          new THREE.BoxGeometry(60, 30, 30),
          new THREE.MeshBasicMaterial({
              color: 0xffffff,
              opacity: 0.5,
              transparent: true
          })
      );
      hit.material.visible = false;
      hit.position.z = 12;
  
      hit.geometry.computeBoundingBox();
  
      const helper = new THREE.BoxHelper(hit, 0xff0000);
      const box3d = new THREE.Box3().setFromObject(hit);
  
      car.add(hit, helper);
      return [hit, box3d];
  }
  function truckHitBox(truck) {
      const hit = new THREE.Mesh(
          new THREE.BoxGeometry(105, 35, 40),
          new THREE.MeshBasicMaterial({
              color: 0xffffff,
              opacity: 0.5,
              transparent: true
          })
      );
      hit.material.visible = false;
      hit.position.z = 12;
  
      hit.geometry.computeBoundingBox();
  
      const helper = new THREE.BoxHelper(hit, 0xff0000);
      const box3d = new THREE.Box3().setFromObject(hit);
  
      truck.add(hit, helper);
      return [hit, box3d];
  }
  </code></pre>
  <p>Here's my code for updating boundingBox position (already called in update loop):</p>
  <pre><code>function updateHitBox() {
                  playerHitBox.copy(hitMesh.geometry.boundingBox).applyMatrix4(hitMesh.matrixWorld);
                  otherVehicles.forEach((vehicle) =&gt; {
                      vehicle.box3d.copy(hitMesh.geometry.boundingBox).applyMatrix4(hitMesh.matrixWorld)
                  });
              }
  </code></pre>
  <p>And finally, here's my code for hit detection:</p>
  <pre><code>function hitDetection() {
      let crashBox = playerHitBox;
      otherVehicles.forEach((vehicle) =&gt; {
          var hit = crashBox.intersectsBox(vehicle.box3d);
          if (hit)
              console.log(&quot;hit!&quot;);
      });
  }
  </code></pre>
  <p>There's no error when running the program, but since I generate <code>otherVehicles</code> manually, as long as I generate one vehicle the console starts printing &quot;true&quot;... I'm completely lost. Thanks for your attention and help.</p>