aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/repeater3d/main.qml
blob: a9bf4aef026840b359a6503de483bfe2db0efe55 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only


import QtQuick
import QtQuick.Window
import QtQuick3D
import QtQuick3D.Helpers

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("3D repeater")

    function randomWithRange(min, max) {
        return Math.floor(Math.random() * (max - min + 1) ) + min;
    }

    Component {
        id: animatedCube

        Model {
            source: "#Cube"
            position: Qt.vector3d(randomWithRange(-300, 300),
                                  randomWithRange(-300, 300),
                                  randomWithRange(-300, 300))

            property real magnify: 5.0/randomWithRange(10, 100)/randomWithRange(1,10);


            scale: Qt.vector3d(magnify, magnify, magnify)

            materials: DefaultMaterial {
                diffuseColor: Qt.rgba(randomWithRange(0, 255) / 255,
                                      randomWithRange(0, 255) / 255,
                                      randomWithRange(0, 255) / 255,
                                      1.0);
            }
        }
    }

    View3D {
        id: viewport
        anchors.fill: parent
        environment: SceneEnvironment {
            clearColor: "black"
            backgroundMode: SceneEnvironment.Color
        }

        DirectionalLight {
            id: directionalLight
        }

        Node {

            PerspectiveCamera {
                z: 700
            }

            PropertyAnimation on eulerRotation.y {
                from: 0
                to: 360
                running: true
                duration: 50000
                loops: -1
            }
        }

        Repeater3D {
            eulerRotation: Qt.vector3d(15, 30, 45)
            position: Qt.vector3d(-100, -100, -100)
            model: 8000
            delegate: animatedCube
        }

    }
    DebugView {
        anchors.top: parent.top
        anchors.left: parent.left
        source: viewport
    }

}