stdweb icon indicating copy to clipboard operation
stdweb copied to clipboard

If I use 'rand' library anywhere before rendering, it renders nothing on the website

Open ydl1991 opened this issue 5 years ago • 2 comments

anyone has tried this or knows why?

I tried to render some objects with random colors, and I created a vec of colors where I store the random color I generated using rng.gen_range() for rgb.

but if I try to render, it just shows white pages.

ydl1991 avatar Aug 04 '20 04:08 ydl1991

You might need to configure some feature flags to get it to use builtin browser APIs rather than some other method which isn't supported by Wasm in the browser.

teymour-aldridge avatar Aug 23 '20 15:08 teymour-aldridge

@ydl1991 Check out the console log in the browser. It will probably tell you that it had encountered a panic which is related to the thread_rng or target is not supported. Specifing this feature in the TOML [dependencies] section has helped me. Hope it helps.

rand = {version = "0.7.3", features = ['stdweb']}

iyakushev avatar Aug 30 '20 22:08 iyakushev