aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/dynamictexture/main.qml
blob: fc36736e4578913a9018937c0a9e85960620f7b1 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

import QtQuick
import QtQuick3D

Window {
    id: window
    width: 1280
    height: 720
    visible: true
    color: "black"

    View3D {
        id: view
        anchors.fill:parent
        renderMode: View3D.Underlay

        environment: SceneEnvironment {
            backgroundMode: SceneEnvironment.Color
            clearColor: "black"
        }

        Doors {
            id: door
            targetItem: object2d
        }

        //! [picking]
        TapHandler {
            gesturePolicy: TapHandler.WithinBounds
            // qmllint disable signal-handler-parameters
            onTapped: {
                var result = view.pick(point.position.x, point.position.y);
                if (result.objectHit) {
                    console.log("pick dist", result.distance, "hit", result.objectHit,
                                "scene pos", result.scenePosition, "uv", result.uvPosition);
                    var pickedDoor = result.objectHit;
                    if (pickedDoor.state === "")
                        pickedDoor.state = "opened";
                    else
                        pickedDoor.state = "";

                }
            }
            // qmllint enable signal-handler-parameters
        }
        //! [picking]
    }

    //! [2d layer]
    Rectangle {
        id: object2d
        width: 500
        height: 700
        anchors.top: parent.top
        anchors.left: parent.left
        anchors.margins: 10

        CorkBoards { }

        clip: true
        layer.enabled: true
    }
    //! [2d layer]
}