asny / three-d

2D/3D renderer - makes it simple to draw stuff across platforms (including web)
MIT License
1.32k stars 110 forks source link

After loading a *.svg file, three-d may convert it to a texture please #145

Closed DerKarlos closed 2 years ago

DerKarlos commented 3 years ago

If an uri ends with ".svg" the loaded file is not a textaure but a Scripted Vector Graphic(?) and needs to be converted in a texture. The crate resvg is usefull. Rendering wit tiny_skia only works for binary, for WASM raqote may do it (I will test it) Anyway, after loading the svg file, three-d should convert it to a texture before inserting it in the file pool.

Another option for WASM may be to do the SVG to bitmap rendering by a browser Javascript API.

DerKarlos commented 3 years ago

raqote needs an interface to resvg: https://docs.rs/resvg-raqote/0.10.0". But the versions don't fit. I assume, resvg-raqote needs an update. In docs.rs, all sources of resvg-raqote exist (by some tricks) but I can't find a Git and no name of the creator.

When tree-d loads a texture/SVG in the GPU it could use the browser API to convert SVG to a bitmap. I will try to write some code. This seems the better way now. Do you agree?

asny commented 3 years ago

I agree that the svg needs to be converted to a bitmap and then the rest is supported by three-d. What the best way to convert and svg to a bitmap is, I don't know. But remember that it should be supported on both desktop and web.

emilk commented 2 years ago

Rasterizing an SVG is simple when using usvg and tiny_skia: https://github.com/emilk/egui/blob/master/egui_extras/src/image.rs#L144-L177

DerKarlos commented 2 years ago

Rasterizing an SVG is simple when using usvg and tiny_skia Yes, I used it. It did not build for WASM. And it would be creat, if it is (optionally) intecrated in the Assert-Load process.

asny commented 2 years ago

Closed in favour of this issue in the three-d-asset crate.