CesiumGS / gltf-pipeline

Content pipeline tools for optimizing glTF assets. :globe_with_meridians:
Apache License 2.0
1.91k stars 251 forks source link

Unable to convert gltf to glb #610

Closed liinnjohansson closed 2 years ago

liinnjohansson commented 2 years ago

I am trying to convert a gltf-model to glb with the latest Node version (17.9.0). I get the error below when running this command line in directory containing the gltf-model:

gltf-pipeline -i sphere.gltf -o sphere.glb

Error at new RuntimeError (C:\Users\flisa\AppData\Roaming\npm\node_modules\gltf- pipeline\node_modules\cesium\Build\CesiumUnminified\Cesium.js:7121:13) at fileURLToPath (C:\Users\flisa\AppData\Roaming\npm\node_modules\gltf-pipeline\lib\FileUrl.js:38:11) at readFile (C:\Users\flisa\AppData\Roaming\npm\node_modules\gltf-pipeline\lib\readResources.js:148:24) at readResource (C:\Users\flisa\AppData\Roaming\npm\node_modules\gltf-pipeline\lib\readResources.js:114:10) at readImage (C:\Users\flisa\AppData\Roaming\npm\node_modules\gltf-pipeline\lib\readResources.js:73:10) at C:\Users\flisa\AppData\Roaming\npm\node_modules\gltf-pipeline\lib\readResources.js:55:31 at Function.ForEach.object (C:\Users\flisa\AppData\Roaming\npm\node_modules\gltf-pipeline\lib\ForEach.js:44:21) at Function.ForEach.topLevel (C:\Users\flisa\AppData\Roaming\npm\node_modules\gltf-pipeline\lib\ForEach.js:63:18) at Function.ForEach.image (C:\Users\flisa\AppData\Roaming\npm\node_modules\gltf-pipeline\lib\ForEach.js:202:18) at C:\Users\flisa\AppData\Roaming\npm\node_modules\gltf-pipeline\lib\readResources.js:54:15 at tryCatcher (C:\Users\flisa\AppData\Roaming\npm\node_modules\gltf-pipeline\node_modules\bluebird\js\release\util.js:16:23) at Promise._settlePromiseFromHandler (C:\Users\flisa\AppData\Roaming\npm\node_modules\gltf-pipeline\node_modules\bluebird\js\release\promise.js:547:31) at Promise._settlePromise (C:\Users\flisa\AppData\Roaming\npm\node_modules\gltf-pipeline\node_modules\bluebird\js\release\promise.js:604:18) at Promise._settlePromise0 (C:\Users\flisa\AppData\Roaming\npm\node_modules\gltf-pipeline\node_modules\bluebird\js\release\promise.js:649:10) at Promise._settlePromises (C:\Users\flisa\AppData\Roaming\npm\node_modules\gltf-pipeline\node_modules\bluebird\js\release\promise.js:729:18) at Promise._fulfill (C:\Users\flisa\AppData\Roaming\npm\node_modules\gltf-pipeline\node_modules\bluebird\js\release\promise.js:673:18) { message: 'Expected path.protocol to start with file:' }

There is no problem to open and view model in a 3D-displayer. I am also using latest React version in this project.

Any suggestions?

lilleyse commented 2 years ago

It seems like it's unable to load a uri in your gltf. Based on the trace it's hitting this error:

  if (path.protocol !== "file:") {
    throw new RuntimeError("Expected path.protocol to start with file:");
  }

Does this give any ideas? Could you post your gltf?

liinnjohansson commented 2 years ago

Thanks for the reply! That sounds about right, I'll check with my colleague who made the model.

But if you have the time, it would be great if you could have a look as well!

Sphere_gltf.zip

lilleyse commented 2 years ago

Thanks for posting the glTF. The problem is here:

"images": [{"uri": "C:\\Users\\46767\\Desktop\\web3d\\Textur.png"}],

Try using a relative path instead.

liinnjohansson commented 2 years ago

Great! Now it works perfectly, thanks!