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

How to build the 'draco3d' npm package? #1017

Open
Apidcloud opened this issue Aug 25, 2023 · 1 comment
Open

How to build the 'draco3d' npm package? #1017

Apidcloud opened this issue Aug 25, 2023 · 1 comment

Comments

@Apidcloud
Copy link

Apidcloud commented Aug 25, 2023

Hello!

I need to rebuild the draco3d package with backwards compatibility off, but when I follow the BUILDING.md, it's only generating the following files:
image

Here's what I'm using:

  • cmake version 3.27.3
  • make GNU Make 3.81
  • latest emsdk:
    Resolving SDK alias 'latest' to '3.1.44'
    Resolving SDK version '3.1.44' to 'sdk-releases-b90507fcf011da61bacfca613569d882f7749552-64bit'
    Setting the following tools as active:
    node-16.20.0-64bit
    python-3.9.2-64bit
    releases-b90507fcf011da61bacfca613569d882f7749552-64bit

Also tried ./emsdk install 2.0.0 followed by ./emsdk activate 2.0.0, but the output is the same.

Steps:

  • clone repo, clone emsdk
  • $ git submodule update --init
  • $ mkdir build_dir && cd build_dir
  • $ export EMSCRIPTEN=/Users/name/workspace/Git/Github/emsdk/upstream/emscripten
  • $ cmake ../
  • $ cmake ../ -DCMAKE_TOOLCHAIN_FILE=cmake/Modules/Platform/Emscripten.cmake -DDRACO_WASM=ON -DDRACO_BACKWARDS_COMPATIBILITY=OFF
  • $ make

I also tried without -DDRACO_WASM=ON, but there's no javascript files being generated, to then use the closure compiler (as suggested in BUILDING.md).

What am I missing?

Thank you!

Edit:
Just found #793 but using the relative paths results in the same output. if there are no js files then it must be something with the emscripten installation, correct?
I tried the following, but there's still no js files:

  • $ export EMSCRIPTEN=../../emsdk/upstream/emscripten
  • $ cmake ../
  • $ cmake ../ -DCMAKE_TOOLCHAIN_FILE=../../emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DDRACO_BACKWARDS_COMPATIBILITY=OFF
  • $ make

Edit 2:

  • just remove the first cmake ../ to make it work (See below)

Remaining questions:

  • How to generate the draco_decoder_nodejs.js and draco_encoder_nodejs.js files? I'm guessing with the closure compiler, but not sure how to obtain the mangling one can see in those files within npm/draco3d
@Apidcloud
Copy link
Author

Apidcloud commented Aug 25, 2023

Ah. using this last version of paths without the intermediate cmake ../ worked. I tried without it before but I would get some error about not finding emscripten, so it makes sense.

For those wondering, here's what worked for me (with the latest emscripten):

  • $ export EMSCRIPTEN=../../emsdk/upstream/emscripten
  • $ cmake ../ -DCMAKE_TOOLCHAIN_FILE=../../emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DDRACO_WASM=ON -DDRACO_BACKWARDS_COMPATIBILITY=OFF

Can you just confirm the default flags you use to build draco3d? As mentioned above I'm only looking to change the backwards compatibility to off, but the output still differs.

For instance, should I use -DDRACO_JS_GLUE=OFF ?
What should I do to generate draco_decoder_nodejs ? Close compiler in simple or bundle mode don't seem to output the same as the draco_decoder_nodejs.js inside npm draco3d. I'm using Java 17.

Here's the current output (with js glue off) vs the npm draco3d files:
image

And here's the size comparison between the original npm draco3d package and the one I'm building locally:
image

Even in the wasm files there's a considerable file size difference.

But I must still be missing something more important, because when I replace the files and try to use this new rebuilt package, I get draco3d.createEncoderModule is not a function

I'll be happy to create a PR with all these details once I get it working.

@Apidcloud Apidcloud changed the title How to build the 'draco3d' package? How to build the 'draco3d' npm package? Aug 29, 2023
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

1 participant