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

WASM external tilesets #62

Closed
paaaav opened this issue Oct 25, 2019 · 4 comments
Closed

WASM external tilesets #62

paaaav opened this issue Oct 25, 2019 · 4 comments
Milestone

Comments

@paaaav
Copy link

paaaav commented Oct 25, 2019

Hello,

how can I use external tilesets with WASM? The file API is not implemented for the WASM target. Therefore we have to deal with URLs in the internet.

Ideally I would like an API like

let map = parse_with_url(reader, Url::new("https://directory/tilemaps/")).unwrap();

If this is not possible I could make this work the following way

let tilesets = get_external_tilesets(reader).unwrap();
//request tilesets by url via Javascript, store them in my_external_tilesets, then enter WASM again
let map = parse_with_external_tilesets(reader, my_external_tilesets).unwrap();

Thanks

@MatthewFrench
Copy link

I also am running into this problem.

@mystal
Copy link
Contributor

mystal commented Jul 24, 2020

I had some luck with this a while back. The main issue is that this crate internally tries to open files, which does not work on WASM. So we need a way to tell it how to fetch data for external files when it's parsing. These changes tried to provide an API for doing just that:
https://github.com/mystal/rs-tiled/compare/4a456673b1a8e677534baa2e9ab59a520f9431f3..687a40133fea1dc0b23ba1588f4cf9d12b5b7d01

They're likely outdated, but could be useful to start from. They worked well enough last year for me to make a WASM build of a game running on top of good-web-game.

@koalefant
Copy link

I have the same problem, just added parse_with_file_loader that takes a closure for file loading:
#100

@mystal: it is a pity I haven't seen your change before implementing this.

@aleokdev aleokdev added this to the 1.0.0 milestone Jan 25, 2022
@aleokdev
Copy link
Contributor

Keeping track of this issue in #37.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants