Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can it be used with parallel.js #26

Open
aradhyamathur opened this issue Dec 21, 2020 · 2 comments
Open

Can it be used with parallel.js #26

aradhyamathur opened this issue Dec 21, 2020 · 2 comments

Comments

@aradhyamathur
Copy link

I wanted to know if the voxelization process could be parallelized using parallel.js to process multiple obj files in parallel.

@andstor
Copy link
Owner

andstor commented Dec 21, 2020

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 👌

@aradhyamathur
Copy link
Author

aradhyamathur commented Dec 22, 2020

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');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants