svg - Best way to generate 3D model from 2D coordinates in JavaScript 3D? -


i trying make complex 3d model cartesian coordinates parsed data provides z-coordinate , name each set of x, y coordinates. here method far:

var body_components = new map();  var bodygeo = new three.geometry();  parse();  scene.add(new three.mesh(bodygeo));    function parse(){    $.ajax({      url:'http://url/output2.txt',      success: function (data){              (var entry in data.split('\n')) {          var count = 0;          var namekey;          var path = new d3.path();          var layer_z_coordinate;            (var chunk in entry.split('\s')) {            if (/[0-9]+/.test(chunk)) {              //chunk layer number              layer_z_coordinate = parseint(chunk);            } else if (/[^0-9]+/.test(chunk)) {              //chunk name or lone '|', check if exists, add if necessary              if (!body_components.has(chunk) && chunk != "|") {                namekey = chunk;                                       body_components.set(namekey, path);              } else if (body_components.has(chunk)) {                }              } else {              //chunk entire block of coordinates                                                (var coordinatepair in chunk.split(':')) {                if (count % 10 == 0) {                  var xy = coordinatepair.split(',');                  //parseint() necessary?                  path.lineto(xy[0], xy[1]);                }                  count++;              }            }          }          path.closepath();          var shape = transformsvgpathexposed(path.tostring());          var options = {            steps: 2,            amount: 200,            bevelenabled: true,            bevelthickness: 1,            bevelsize: 1,            bevelsegments:           };          var outline = createmesh(new three.extrudegeometry(shape, options));          outline.updatematrix();          bodygeo.merge(outline.geometry, outline.matrix);        }      }    });  };

i not sure if using svg paths extruding them (which attempted above) best method. there lot of data using every tenth coordinate per entry, count variable for.

i considered making arrays containing vertices (adding z coordinate parsed x, y points) , making geometry using arrays, not sure if good.

please feel free ask more questions if clarification needed. , appreciated.


Comments