2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2020 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2020-09-10 16:02:31 +03:00
|
|
|
|
2021-06-28 14:04:43 +03:00
|
|
|
import QtQuick3D 6.0
|
2020-09-10 16:02:31 +03:00
|
|
|
|
|
|
|
|
View3D {
|
|
|
|
|
id: root
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
environment: sceneEnv
|
2022-08-25 14:08:14 +03:00
|
|
|
camera: !envMode || (envMode === "SkyBox" && envValue === "preview_studio") ? studioCamera
|
|
|
|
|
: defaultCamera
|
2020-09-10 16:02:31 +03:00
|
|
|
|
|
|
|
|
property Material previewMaterial
|
2022-08-05 17:14:05 +03:00
|
|
|
property string envMode
|
|
|
|
|
property string envValue
|
|
|
|
|
property string modelSrc: "#Sphere"
|
2020-09-10 16:02:31 +03:00
|
|
|
|
2022-05-27 14:14:22 +03:00
|
|
|
function fitToViewPort(closeUp)
|
2022-02-02 17:56:16 +02:00
|
|
|
{
|
|
|
|
|
// No need to zoom this view, this is here just to avoid runtime warnings
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-10 16:02:31 +03:00
|
|
|
SceneEnvironment {
|
|
|
|
|
id: sceneEnv
|
|
|
|
|
antialiasingMode: SceneEnvironment.MSAA
|
|
|
|
|
antialiasingQuality: SceneEnvironment.High
|
2022-08-05 17:14:05 +03:00
|
|
|
backgroundMode: envMode === "Color" ? SceneEnvironment.Color
|
2022-08-25 14:08:14 +03:00
|
|
|
: envMode === "Basic" ? SceneEnvironment.Transparent
|
|
|
|
|
: SceneEnvironment.SkyBox
|
2022-08-05 17:14:05 +03:00
|
|
|
clearColor: envMode === "Color" ? envValue : "#000000"
|
2022-08-25 14:08:14 +03:00
|
|
|
lightProbe: !envMode || envMode === "SkyBox" ? skyBoxTex : null
|
2022-08-05 17:14:05 +03:00
|
|
|
|
|
|
|
|
Texture {
|
|
|
|
|
id: skyBoxTex
|
2022-08-25 14:08:14 +03:00
|
|
|
source: !envMode ? "../images/preview_studio.hdr"
|
|
|
|
|
: envMode === "SkyBox" ? "../images/" + envValue + ".hdr"
|
|
|
|
|
: ""
|
2022-08-05 17:14:05 +03:00
|
|
|
}
|
2020-09-10 16:02:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Node {
|
|
|
|
|
DirectionalLight {
|
2022-03-18 17:28:28 +02:00
|
|
|
eulerRotation.x: -26
|
2022-08-05 17:14:05 +03:00
|
|
|
eulerRotation.y: modelSrc === "#Cube" ? -10 : -50
|
2022-08-25 14:08:14 +03:00
|
|
|
brightness: envMode && envMode !== "SkyBox" ? 1 : 0
|
2020-09-10 16:02:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PerspectiveCamera {
|
2022-08-05 17:14:05 +03:00
|
|
|
id: defaultCamera
|
|
|
|
|
y: 70
|
|
|
|
|
z: 200
|
|
|
|
|
eulerRotation.x: -5.71
|
2020-09-10 16:02:31 +03:00
|
|
|
clipNear: 1
|
2022-03-18 17:28:28 +02:00
|
|
|
clipFar: 1000
|
2020-09-10 16:02:31 +03:00
|
|
|
}
|
|
|
|
|
|
2022-08-05 17:14:05 +03:00
|
|
|
PerspectiveCamera {
|
|
|
|
|
id: studioCamera
|
|
|
|
|
y: 232
|
|
|
|
|
z: 85
|
|
|
|
|
eulerRotation.x: -64.98
|
|
|
|
|
clipNear: 1
|
|
|
|
|
clipFar: 1000
|
|
|
|
|
}
|
2022-03-18 17:28:28 +02:00
|
|
|
|
2022-08-05 17:14:05 +03:00
|
|
|
Node {
|
|
|
|
|
rotation: root.camera.rotation
|
2022-03-18 17:28:28 +02:00
|
|
|
y: 50
|
2022-08-05 17:14:05 +03:00
|
|
|
Node {
|
|
|
|
|
y: modelSrc === "#Cone" ? -40 : 10
|
|
|
|
|
eulerRotation.x: 35
|
|
|
|
|
Model {
|
|
|
|
|
id: model
|
|
|
|
|
readonly property bool _edit3dLocked: true // Make this non-pickable
|
|
|
|
|
source: modelSrc ? modelSrc : "#Sphere"
|
|
|
|
|
eulerRotation.y: 45
|
|
|
|
|
materials: previewMaterial
|
|
|
|
|
scale: !modelSrc || modelSrc === "#Sphere"
|
|
|
|
|
? Qt.vector3d(1.7, 1.7, 1.7) : Qt.vector3d(1.2, 1.2, 1.2)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Model {
|
|
|
|
|
id: floorModel
|
|
|
|
|
source: "#Rectangle"
|
|
|
|
|
scale.y: 8
|
|
|
|
|
scale.x: 8
|
|
|
|
|
eulerRotation.x: -60
|
2022-08-25 14:08:14 +03:00
|
|
|
visible: envMode === "Basic"
|
2022-08-05 17:14:05 +03:00
|
|
|
materials: floorMaterial
|
|
|
|
|
DefaultMaterial {
|
|
|
|
|
id: floorMaterial
|
|
|
|
|
diffuseMap: floorTex
|
|
|
|
|
Texture {
|
|
|
|
|
id: floorTex
|
|
|
|
|
source: "../images/floor_tex.png"
|
|
|
|
|
scaleU: floorModel.scale.x
|
|
|
|
|
scaleV: floorModel.scale.y
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-10 16:02:31 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|