Why does BufferGeometry.computeBoundingBox() not work in this example

According to the documentation, calling computeBoundingBox() on a BufferGeometry should update the .boundingBox attribute. In my example below, a spinning cube is created and geometryCube.boundingBox should be displayed in the console. Why doesn’t it work?

<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8" />
    <title>TubeGeometry tests</title>
    <script type="importmap">
        "imports": {
          "three": "https://unpkg.com/three@0.148.0/build/three.module.js"
    <script type="module">
import * as THREE from 'three';

const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0x002000, 4, 6);
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);

const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);

const geometryCube = new THREE.BoxGeometry(2, 2, 2);
console.log('geometryCube.BoundingBox', geometryCube.BoundingBox); //output geometryCube.BoundingBox undefined
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00, transparent: true, opacity: 0.5 });
const meshCube = new THREE.Mesh(geometryCube, material);

camera.position.z = 5;
function animate() {
  meshCube.rotation.x += 0.01;
  meshCube.rotation.y += 0.01;
  renderer.render(scene, camera);


>Solution :

Is it as simple as it should be boundingBox, not BoundingBox

Leave a Reply