Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

88
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!