aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick3d/xr_shared/XrGadget.qml
blob: 1dbb7e1f2d426deaf3330fd566794a65731dface (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick3D

pragma ComponentBehavior: Bound

Model {
    pickable: parent?.visible

    property vector3d pressPos
    property vector3d originalPos

    property bool grabbable: true

    property vector3d delta

    property Node controlledObject
    property bool selected: false

    enum CursorStyle {
        Hidden,
        Flat,
        Sphere
    }

    property int cursorStyle: XrGadget.CursorStyle.Hidden

    signal pressed(pos: vector3d, dir: vector3d)
    signal moved(delta: vector3d, dir: vector3d)

    function handleControllerPress(pos: vector3d, direction: vector3d) {
        pressPos = pos
        originalPos = controlledObject.position
        pressed(pressPos, direction)
    }

    function handleControllerMove(pos: vector3d, direction: vector3d) {
        delta = pos.minus(pressPos)
        moved(pos, direction)
    }
}