bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
33.7k stars 3.27k forks source link

Bevy WASM with trunk error loading gltf #6963

Open rodrigocam opened 1 year ago

rodrigocam commented 1 year ago

I'm having this issue when loading .gltf assets, using bevy targeting wasm with Trunk.

Discussed in https://github.com/bevyengine/bevy/discussions/5972

Originally posted by **Caligino** September 12, 2022 OK I managed to get my app to compile with trunk but when i go to serve it for testing it fails to load the glb asset and presumably it crashes. I added the copy options to the trunk config html file but still get the same error: ```WARN C:\Users\Aster\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_asset-0.8.1\src\asset_server.rs:455 encountered an error while loading an asset: invalid glTF file: expected value at line 1 column 1``` My only insight is that it might actually only want to load a gltf and not a glb file? Does anyone, preferably a wizard have any clue whats going on?
mockersf commented 1 year ago

what is the reply of the http query when it tries to load the file?

you can also use https://crates.io/crates/wasm-server-runner instead of trunk, it's easier to setup

rparrett commented 1 year ago

You likely need to add <link data-trunk rel="copy-dir" href="assets" /> to your index.html.

Trunk seems to be made for serving single page applications, so you're seeing it serve html up where a normal webserver would be giving you a 404 error for the missing asset.