learn-wgpu icon indicating copy to clipboard operation
learn-wgpu copied to clipboard

Intermediate tutorial 12 error

Open 0xfourzerofour opened this issue 2 years ago • 3 comments

@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!

0xfourzerofour avatar Aug 03 '22 11:08 0xfourzerofour

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.

sotrh avatar Aug 05 '22 01:08 sotrh

I used the exact same config from the tutorial repo however I'm passing in an existing canvas to make the window

0xfourzerofour avatar Aug 05 '22 01:08 0xfourzerofour

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 avatar Aug 06 '22 18:08 sotrh

@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

0xfourzerofour avatar Aug 09 '22 05:08 0xfourzerofour