javascript - Three.js/3D models - calculating few volumes of object -


i work 1 project in three.js , must solve 1 problem fast possible. need calculate few volumes of 3d object.

first need same here: how calculate volume of 3d mesh object surface of made triangles

and calculate in same way. entire object volume.

that enough if object doesn't need additional material when goes 3d printing. example if glass (an open cylinder) need calculate volume of additional material, used in printing of model. material "inside" glass , prevent floor of glass falling inside model.

i don't know how calculate that, less math knowledge think. there way calulate this? or maybe there way calculate "closed-mesh volume" even, when open 1 (like glass)?

edit: not have glass model, have model of box. box printed open side on bottom. need know "inside" volume.

sorry english, hope it's understandable.

enter image description here

here how calculate volume of object (exactly in link in 1st post):

function volumeoft(p1, p2, p3){     var v321 = p3.x*p2.y*p1.z;     var v231 = p2.x*p3.y*p1.z;     var v312 = p3.x*p1.y*p2.z;     var v132 = p1.x*p3.y*p2.z;     var v213 = p2.x*p1.y*p3.z;     var v123 = p1.x*p2.y*p3.z;     return (-v321 + v231 + v312 - v132 - v213 + v123)/6.0; }  function calculatevolume(object){     var volumes = 0.0;      for(var = 0; < object.geometry.faces.length; i++){         var pi = object.geometry.faces[i].a;         var qi = object.geometry.faces[i].b;         var ri = object.geometry.faces[i].c;          var p = new three.vector3(object.geometry.vertices[pi].x, object.geometry.vertices[pi].y, object.geometry.vertices[pi].z);         var q = new three.vector3(object.geometry.vertices[qi].x, object.geometry.vertices[qi].y, object.geometry.vertices[qi].z);         var r = new three.vector3(object.geometry.vertices[ri].x, object.geometry.vertices[ri].y, object.geometry.vertices[ri].z);         volumes += volumeoft(p, q, r);     }      loadedobjectvolume = math.abs(volumes); } 

i checked in other software , volume of object correct.

here how tried create convexgeometry:

var geometry = new three.stlloader().parse( contents ); geometry.sourcetype = "stl"; geometry.sourcefile = file.name;  geometry.computefacenormals(); geometry.computevertexnormals();  var convexgeometry = three.convexgeometry(geometry.vertices);  var material = new three.meshlambertmaterial({     color: 0xff0000,     emissive: 0x000000,     shading: three.flatshading });  var mesh = new three.mesh( geometry, material ); 

on line var convexgeometry = three.convexgeometry(geometry.vertices); browser hangs. models low verticies can go through (cube example).


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -