Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

90
Vistas
2D bounding rect from a mesh

I'm trying to figure out how to get the rect coords of a mesh for 2D projection.

I need X, Y, Width and Height.

After reading many SO posts and various blogs, it seems like none of them work with latest modern Three.JS and the documentation doesn't have a function for it.

How is this achieved?

Currently, I'm looking at using a Box3 and then project the Box3 to screen.

UPDATE My code looks like this

rect(mesh, camera, w, h){
        var bbox = new THREE.Box3().setFromObject(mesh);
        bbox.min.setFromMatrixPosition(mesh.matrixWorld);
        bbox.max.setFromMatrixPosition(mesh.matrixWorld);
        bbox = {
            min: bbox.min.project(camera),
            max: bbox.max.project(camera)
        }

        var to2D = which => {
            bbox[which] = {
                x: (bbox[which].x + 1) * w / 2,
                y: -(bbox[which].y - 1) * h / 2
            }
        }
        
        to2D('min')
        to2D('max')


        return {
            x: bbox.min.x,
            y: bbox.min.y,
            w: bbox.max.x - bbox.min.x,
            h: bbox.max.y - bbox.min.y
        }
    }

    return rect
}

The output is basically a single point with no rect width/height.

about 4 years ago · Juan Pablo Isaza
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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda