Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Get 3D coordinate of mouse position from onClicked in QML

$
0
0
I created a 3D room by using Quad in QML. It looks like this, view from the top I would like to implement the “add furniture” function. When I click on the ground of the room, a table will appear at the clicked spot. That means I would have to get the 3D coordinate of the mouse position. But when I try something like Quad {         id: ground         scale: room.scale         effect: Effect {             color: "#ffffff"             decal: true         }         transform: [             Rotation3D {                 angle: 90                 axis: Qt.vector3d(1, 0, 0)             },             Rotation3D {                 angle: 90                 axis: Qt.vector3d(0, 1, 0)             },             Rotation3D {                 angle: 90                 axis: Qt.vector3d(0, 0, 1)             }         ]         onClicked: {             console.log("click on ground!");             console.log(mouse.x);         }     } The text “click on ground!” is successfully printed. But mouse.x cannot be displayed because it always says “ReferenceError: mouse is not defined” I checked http://blog.gmane.org/gmane.comp.lib.qt.3d/month=20120501 , and back then there was no provided solution in the QML API. I wonder if the 3D coordinates can be acquired through QML API now. If not, is there other possible implementation? Also is it possible to detect mouse event on the background (i.e. the black background in the image)? Or should I just add a large Quad in the back of the room…

Viewing all articles
Browse latest Browse all 4972

Trending Articles