Calculating Surface Area of Created Shape in Three.js

Hello everyone,

I’ve created a tool that allows generating a flat ‘shape’ from an array of points that fills up with each user click, capturing their mouse coordinates. However, I’d like to calculate the surface area of the ‘shape’ I’ve created, but I don’t see any property that could help me. Do you have any idea how to proceed?

vous pouvez voir a quoi ressemblent les propriétés de la shape quand je log son ref :



An excerpt from my code here:

if (points.length <= 0) return;
    const newShape = new Shape();
        newShape.moveTo(points[0][0],points[0][1])
    
    points.map((point, index )=>{
    newShape.lineTo(point[0],point[1])
    console.log(newShape);
    })

    setTheShape(newShape) 


Bounding box area. Or calculate sum of square of all careated triangles of shape.

How can i achieve that ?
When i try to use it the Bounding box propertie remain empty :

geometryref.current.computeBoundingBox()

image

if you dont want to do the math, there is this

2 Likes

Or: ShapeUtils.area()

2 Likes