blob: 88395b5836515fe72a2b1087a2563a948e504c2a (
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick3D
import QtQuick3D.Helpers
import QtQuick3D.Examples.OutlineRenderExtension
ApplicationWindow {
width: 640
height: 480
visible: true
title: qsTr("Stencil outline example")
ColumnLayout {
anchors.top: parent.top
anchors.left: parent.left
anchors.margins: 10
width: 250
RowLayout {
Layout.fillWidth: true
Label {
text: "Outline Color"
Layout.fillWidth: true
}
ColorPicker {
id: colorPicker
color: outlineMaterial.baseColor
onColorModified: (color) => {outlineMaterial.baseColor = color}
}
}
RowLayout {
Layout.fillWidth: true
Label {
text: "Outline Width (" + outlineRenderer.outlineScale.toFixed(2) + ")"
Layout.fillWidth: true
}
Slider {
value: 1.05
from: 1.00
to: 3.0
stepSize: 0.01
onValueChanged: outlineRenderer.outlineScale = value
}
}
Label {
text: "Click on a model to select it."
}
}
//! [1]
View3D {
id: view3d
anchors.topMargin: 100
anchors.fill: parent
extensions: [ OutlineRenderExtension {
id: outlineRenderer
outlineMaterial: outlineMaterial
}
]
//! [1]
PerspectiveCamera {
id: camera
z: 500
}
DirectionalLight {
}
DirectionalLight {
eulerRotation: Qt.vector3d(0, 180, 0)
position.z: -600
}
PrincipledMaterial {
id: outlineMaterial
baseColor: "blue"
lighting: PrincipledMaterial.NoLighting
}
Model {
source: "models/suzanne.mesh"
pickable: true
materials: PrincipledMaterial {
baseColor: "red"
}
}
Model {
position.x: 300
source: "models/suzanne.mesh"
pickable: true
materials: PrincipledMaterial {
baseColor: "green"
}
}
Model {
position.x: -300
source: "models/suzanne.mesh"
pickable: true
materials: PrincipledMaterial {
baseColor: "pink"
}
}
}
//! [2]
MouseArea {
anchors.fill: view3d
onClicked: (mouse)=> {
let hit = view3d.pick(mouse.x, mouse.y)
outlineRenderer.target = hit.objectHit
}
}
//! [2]
}
|