Can it be used with parallel.js
aradhyamathur opened this issue · 2 comments
I wanted to know if the voxelization process could be parallelized using parallel.js to process multiple obj files in parallel.
Hi!
I am not very familiar with paralell.js. However, since the actual voxelizer engine doesn’t use any GPU calculations, it should be quite possible to run several voxelization processes in parallel. I took a very quick look at the library, and from what I can tell you should be able to voxelize multiple OBJ files with it 👌
Upon running it with parallel.js the binvox do not get generated, also i did not observe error message. I created a function to export voxels from obj file paths. The function exportBinvox
takes the source and desitnation paths stored in paths
and exports the binvox.
Can you please guide what could be the possible cause for it ?
function exportBinvox(paths){
var manager = new THREE.LoadingManager();
var loader = new THREE.OBJLoader( manager );
loader.load(paths[0],
function(object){
const sampler = new Sampler('raycast', options);
const resolution = 512;
let data = sampler.sample(object, resolution);
const fs = require('fs');
const binexporter = new BINVOXExporter();
binexporter.parse(data, function (binvox) {
fs.writeFile(paths[1], Buffer.from(binvox), function(err){
if (err) return console.log(err);
});
});
},function ( xhr ) {
// console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
},
// called when loading has errors
function ( error ) {
console.log( 'An error happened : ' + paths[0]);
console.log(error);
}
)
}
var Parallel = require('paralleljs');
var p = new Parallel(paths);
log = function () { console.log('done'); };
p.map(exportBinvox).then(log)
console.log('done');