aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick3d/orderindependenttransparency/FireStick.qml
blob: 8f14d1d150f7d0ca36bbf4ed2d80b85fca1d8b23 (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
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick3D

Node {
    id: root
    property real stickSize : 1
    property real stickRotationX : 0
    property real stickRotationY : 0
    property real stickRotationZ : 0
    property real glowFactor: 1.0
    Model {
        source: "meshes/stick3.mesh"

        scale: Qt.vector3d(root.stickSize * 5, root.stickSize * 5, root.stickSize * 5)
        eulerRotation: Qt.vector3d(root.stickRotationX, root.stickRotationY, root.stickRotationZ)
        materials: [
            PrincipledMaterial {
                baseColorMap: Texture {
                    source: "images/stick_charred.png"
                    scaleU: 0.2
                }
            }
        ]
    }
    Model {
        source: "meshes/stick3.mesh"

        scale: Qt.vector3d(root.stickSize * 5.1, root.stickSize * 5.1, root.stickSize * 5.1)
        eulerRotation: Qt.vector3d(root.stickRotationX, root.stickRotationY, root.stickRotationZ)
        opacity: 0.95
        materials: [
            PrincipledMaterial {
                id: material
                property real ef

                baseColor: Qt.vector3d(0.1, 0.1, 0.1)

                emissiveMap: Texture {
                    source: "images/stick_heat3.png"
                    scaleU: 0.2
                }

                function emissiveFunction(time)
                {
                    var rad = Math.PI * 2.0 * time
                    var s = Math.sin(rad)
                    var e = 0.7 + 0.3 * s
                    return Qt.vector3d(e, e, e)
                }

                emissiveFactor: material.emissiveFunction(ef)
                NumberAnimation on ef {
                    from: 0.0
                    to: 1.0
                    duration: 2000 * root.glowFactor
                    loops: NumberAnimation.Infinite
                }
            }
        ]
    }
}