• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Pruebas Online
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

255
Vistas
What is the proper use of threejs Box3().getSize() method?

Everywhere on stackoverflow et al seem to agree that the proper use of the Box3() getSize() method is as follows:

const geometry = new THREE.BoxGeometry( 10, 10, 10 );
const material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
const cube = new THREE.Mesh( geometry, material );
scene.add( cube );

let cubeBoundingBox = new THREE.Box3().setFromObject( cube );
let boxSize = cubeBoundingBox.getSize();
console.log("BoxSize: " + boxSize);

However this doesn't seem to be the case. See the error in this example: https://jsfiddle.net/8L5dczmf/3/

I can see in the three.js documentation that getSize() is in fact supposed to be used this way... unless I'm reading .getSize ( target : Vector3 ) : Vector3 incorrectly. What is wrong with the code in the fiddle above then?

almost 3 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

You're expected to pass in a vector into which the result will be written:

// ...

let boxSize = new THREE.Vector3();
cubeBoundingBox.getSize(boxSize);

console.log("BoxSize: " + boxSize);
almost 3 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda