bevy icon indicating copy to clipboard operation
bevy copied to clipboard

scene_viewer is crashed when loading gltf.

Open AllenDang opened this issue 3 years ago • 1 comments

Bevy version

0.9.0

[Optional] Relevant system information

If you cannot get Bevy to build or run on your machine, please include:

  • the Rust version you're using (you can get this by running cargo --version)
    • cargo 1.65.0 (4bc8f24d3 2022-10-20)
  • the operating system or browser used, including its version
    • macOS 13.0

What you did

run cargo run --release --example scene_viewer /Users/allen/Blender/Gandam/gltf/GDM.glb#Scene0`

What went wrong

scene_viewer crashed with following logs.

❯ cargo run --release --example scene_viewer "/Users/allen/Blender/Gandam/gltf/GDM.glb#Scene0"
    Finished release [optimized] target(s) in 0.13s
     Running `target/release/examples/scene_viewer '/Users/allen/Blender/Gandam/gltf/GDM.glb#Scene0'`

Controls:
    MOUSE       - Move camera orientation
    LClick/M    - Enable mouse movement
    WSAD        - forward/back/strafe left/right
    LShift      - 'run'
    E           - up
    Q           - down
    L           - animate light direction
    U           - toggle shadows
    C           - cycle through the camera controller and any cameras loaded from the scene
    5/6         - decrease/increase shadow projection width
    7/8         - decrease/increase shadow projection height
    9/0         - decrease/increase shadow projection near/far

    Space       - Play/Pause animation
    Enter       - Cycle through animations

2022-11-15T12:11:59.003031Z  INFO bevy_render::renderer: AdapterInfo { name: "Apple M1 Max", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
2022-11-15T12:11:59.131401Z  INFO scene_viewer: Loading /Users/allen/Blender/Gandam/gltf/GDM.glb#Scene0
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', examples/tools/scene_viewer.rs:113:28
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Additional information

The crash occurred at second line.

            if asset_server.get_load_state(&scene_handle.handle) == LoadState::Loaded {
                let gltf = gltf_assets.get(&scene_handle.handle).unwrap();

The scene-handle.handle is valid, and load state is loaded, gltf_assets should be able to get from it, but it returns None.

AllenDang avatar Nov 15 '22 12:11 AllenDang

I can reproduce this.

When I run the scene viewer this way, it works:

cargo run --example scene_viewer -- assets/models/animated/Fox.glb

But if I add the #Scene0 as recommended in the example doc

cargo run --example scene_viewer -- assets/models/animated/Fox.glb#Scene0

It crashes on line 113.

It makes sense that it would crash, since it is looking for an asset, but the scene path was provided. Wonder if it worked before. My suggestion would be to recommend using the raw path without the #Scene0 in the documentation.

nicopap avatar Nov 15 '22 12:11 nicopap