learn-wgpu
learn-wgpu copied to clipboard
Intermediate tutorial 12 error
@sotrh Hi Again!
When I run the code locally there seems to be an error in the model.rs file as the material vector seems to be empty
wgpu_integration.js?t=1659527167509:352 panicked at 'index out of bounds: the len is 0 but the index is 0', src/model.rs:207:29
Stack:
this is the error I get in my console.
Any help would be appreciated!
Does the model your using not have a material? The render pipeline I made requires a material. I should probably add a note about that, and maybe change the material: m.mesh.material_id.unwrap_or(0),
line in resource.rs
to use unwrap()
, or return an error.
I used the exact same config from the tutorial repo however I'm passing in an existing canvas to make the window
The existing canvas shouldn't be an issue. The material vector being empty suggests the model file you're using doesn't have any materials. The materials vector only gets populated from the obj's .mtl file. If the vector is empty, that means that they model doesn't have a .mtl file. Could you post the version of model.rs
that you have as well as the model file you're using?
@sotrh it was my silly error my bad. I am importing the wasm to svelte and didnt realise the content for the objs was being retrieved by a network call so the path was incorrect once imported.
Cheers