draco icon indicating copy to clipboard operation
draco copied to clipboard

wasm path is not correct in electron environment

Open mankeheaven opened this issue 4 years ago • 3 comments

When use draco in my electron app, It fetch http://draco_encoder.wasm/

It's ok when I use it in my react useMount hooks, I can get table.wasm with code It fetch http://localhost:8238/table.wasm

  useMount(()=>{
    var otherTable = new WebAssembly.Table({ element: "anyfunc", initial: 2 });

      WebAssembly.instantiateStreaming(fetch('table.wasm',{credentials:"same-origin"}))
      .then(obj => {
        var tbl = obj.instance.exports.tbl as any;
        console.log(tbl.get(0)());  // 13
        console.log(tbl.get(1)());  // 42

        otherTable.set(0,tbl.get(0));
        otherTable.set(1,tbl.get(1));

        console.log(otherTable.get(0)());
        console.log(otherTable.get(1)());
      });
  })

But when I use gltf-pipeline, it depences on your draco, and ,it fetch http://draco_encoder.wasm/ And error is no such file or directory, open '\draco_encoder.wasm'

image

how does draco change the base url?

mankeheaven avatar Sep 22 '21 07:09 mankeheaven

I have seen the code in draco_decoder.js, I have no idea how to fix it, can you give me a help? 4JWMCF~CE%R50Z85P(`BEAA

mankeheaven avatar Sep 22 '21 08:09 mankeheaven

maybe the environment with electron renderer is wrong electron renderer has ENVIRONMENT_IS_NODE and ENVIRONMENT_IS_WEB

image

mankeheaven avatar Sep 22 '21 08:09 mankeheaven

I've solved this problem

I put the draco code in my electron main process, cause the renderer process has web environment and node environment

But I think your interface should provider a enviroment env to help those environment to define it by their own

mankeheaven avatar Sep 22 '21 09:09 mankeheaven