-
I'm trying to get Bevy Mod Picking to work on glTF objects, like so: // Add in custom object from Blender
commands
.spawn_bundle(SceneBundle {
scene: asset_server.load("gltf/test-box-binary/box.glb#Scene0"),
transform: Transform::from_xyz(2.0, 0.5, -4.0),
..default()
})
.insert_bundle(PickableBundle::default()); However, this doesn't work. The object doesn't react to hover or click, and the green debug cursor does not show up on hover. What do I need to do to get a glTF object working with Bevy Mod Picker? How can I further debug this? How did you get those complex monkey objects working? Any help is appreciated. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
You need to mark the actual meshes as pickable. You can do this by querying for meshes that are children of the gltf scene, and marking those entities with the applicable picking components. This will be made easier, and with an actual example, once the refactor is complete. See here: https://github.com/aevyrie/bevy_mod_picking/blob/fe3135648d4d33c2c9daf7d9afb0df520a980d4f/examples/gltf.rs |
Beta Was this translation helpful? Give feedback.
-
Hello, I just wanted to share the solution for this problem that I came up with. Maybe it can help someone To each gltf scene object I want to be selectable I add flag component:
Then I run a system that would search for entities with this component and recursively go through their children entities (scene seems to have N levels of nested children entities) and insert PickableBundle::default() to each child with mesh Solution for recursive query I found here:
I hope it can help someone somewhere |
Beta Was this translation helpful? Give feedback.
You need to mark the actual meshes as pickable. You can do this by querying for meshes that are children of the gltf scene, and marking those entities with the applicable picking components.
This will be made easier, and with an actual example, once the refactor is complete. See here: https://github.com/aevyrie/bevy_mod_picking/blob/fe3135648d4d33c2c9daf7d9afb0df520a980d4f/examples/gltf.rs