PrincessGod / objTo3d-tiles

Convert obj model file to 3d tiles
https://princessgod.github.io/objTo3d-tiles
Apache License 2.0
778 stars 232 forks source link

When used as a library, return a Promise #46

Open addam opened 2 years ago

addam commented 2 years ago

The main function obj23dtiles(objPath, outputPath, options) used to return undefined, although there is much asynchronicity properly used inside of it. Because of this, it was not possible to properly wait on completion -- the only option would be to spawn node in a child process and wait for it to exit.

This pull request makes the relevant Promise to be returned outside, so that it is possible to just await obj23dtiles(...).

Note, other issues may arise from process.exit being used in the library code. Such calls should be moved to bin/obj23dtiles.js solely but I tried to keep this pull request as humble as possible.