I'm new to Qt3d and I need to handle user input on scene with multiple models. In particular i need to find with model the user has clicked. I try with mouseHandler and ObjectPicker but it seems not to work. Does someone have an example?
For example, if I have:
Entity {
Camera { id: camera ... }
FirstPersonCameraController {
camera: camera
}
components: [
RenderSettings{
activeFrameGraph: ForwardRenderer {
camera: camera
clearColor: "transparent"
},
InputSettings{}
]
MouseDevice {
id: mouse1
sensitivity: 0.1
}
SphereMesh {
id: sphereMesh
radius: 3
}
PhongMaterial{
id: material
}
Entity {
id: sphere1
components: [sphereMesh, material]
MouseHandler {
sourceDevice: mouse1
onClicked: console.log("[sphere 1] clicked"
}
}
Entity {
id: sphere2
components: [sphereMesh, material]
MouseHandler {
sourceDevice: mouse1
onClicked: console.log("[sphere 2] clicked"
}
}
}
I need to distinguish if the user clicks on sphere1 or sphere2, but if I click on the sphere I cannot see any log!
ObjectPicker
as a component of your entity. – Matt