# Volume calculation using potree/three.js?

I am using Potree/three.js web viewer for visualisation of 3D cloud points. I would like to compute the volume inside the user defined polygon. Potree supports only drawing a cube in measure tool. However Potree supports area measurement by irregular polyon but not volume.

How do I compute the volume using the user defined polygon?

I found an approach to calculate volume on Potree. after drawing a polygone area around the wanted element we can calculate the volume partially using a triangulation (in my case i used Delaunay triangulation using the js library "Delaunator"

``````const points = [[168, 180], [168, 178], [168, 179], [168, 181], [168, 183], ...];

const delaunay = Delaunator.from(points);
console.log(delaunay.triangles);
// [623, 636, 619,  636, 444, 619, ...]
``````

now after we have small triangles of the drawed polygone we are going to calculate partial volumes of pointcloud inside each triangle. to do that i calculated the coordinates of the center of each triangle and then get the Z value of the intersection with cloud point.

now that we have the are of each triangle and the z valu we can calculate parial volumes Vi = (triangleArea*height)/3

the total volume is the sum of partial volumes