diff options
Diffstat (limited to 'examples/quick3d/intro')
-rw-r--r-- | examples/quick3d/intro/doc/intro.png | bin | 0 -> 13781 bytes | |||
-rw-r--r-- | examples/quick3d/intro/doc/intro.rst | 9 | ||||
-rw-r--r-- | examples/quick3d/intro/intro.pyproject | 3 | ||||
-rw-r--r-- | examples/quick3d/intro/main.py | 24 | ||||
-rw-r--r-- | examples/quick3d/intro/main.qml | 80 |
5 files changed, 116 insertions, 0 deletions
diff --git a/examples/quick3d/intro/doc/intro.png b/examples/quick3d/intro/doc/intro.png Binary files differnew file mode 100644 index 000000000..ae54997c4 --- /dev/null +++ b/examples/quick3d/intro/doc/intro.png diff --git a/examples/quick3d/intro/doc/intro.rst b/examples/quick3d/intro/doc/intro.rst new file mode 100644 index 000000000..0afebd5be --- /dev/null +++ b/examples/quick3d/intro/doc/intro.rst @@ -0,0 +1,9 @@ +Introduction Example Qt Quick 3D +================================ + +This example gives an introductory overview of the basic Quick 3D features by going +through the code of a simple example. + +.. image:: intro.png + :width: 400 + :alt: QtQuick3D Introduction Screenshot diff --git a/examples/quick3d/intro/intro.pyproject b/examples/quick3d/intro/intro.pyproject new file mode 100644 index 000000000..428f88dc1 --- /dev/null +++ b/examples/quick3d/intro/intro.pyproject @@ -0,0 +1,3 @@ +{ + "files": ["main.py", "main.qml"] +} diff --git a/examples/quick3d/intro/main.py b/examples/quick3d/intro/main.py new file mode 100644 index 000000000..827434038 --- /dev/null +++ b/examples/quick3d/intro/main.py @@ -0,0 +1,24 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +import os +import sys +from pathlib import Path +from PySide6.QtCore import QUrl +from PySide6.QtGui import QGuiApplication, QSurfaceFormat +from PySide6.QtQml import QQmlApplicationEngine + +from PySide6.QtQuick3D import QQuick3D + +if __name__ == "__main__": + app = QGuiApplication(sys.argv) + + QSurfaceFormat.setDefaultFormat(QQuick3D.idealSurfaceFormat(4)) + + engine = QQmlApplicationEngine() + qml_file = os.fspath(Path(__file__).resolve().parent / 'main.qml') + engine.load(QUrl.fromLocalFile(qml_file)) + if not engine.rootObjects(): + sys.exit(-1) + + sys.exit(app.exec()) diff --git a/examples/quick3d/intro/main.qml b/examples/quick3d/intro/main.qml new file mode 100644 index 000000000..648cfcf5c --- /dev/null +++ b/examples/quick3d/intro/main.qml @@ -0,0 +1,80 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +//! [import] +import QtQuick +import QtQuick3D +//! [import] + +Window { + id: window + width: 1280 + height: 720 + visible: true + + View3D { + id: view + anchors.fill: parent + + //! [environment] + environment: SceneEnvironment { + clearColor: "skyblue" + backgroundMode: SceneEnvironment.Color + } + //! [environment] + + //! [camera] + PerspectiveCamera { + position: Qt.vector3d(0, 200, 300) + eulerRotation.x: -30 + } + //! [camera] + + //! [light] + DirectionalLight { + eulerRotation.x: -30 + eulerRotation.y: -70 + } + //! [light] + + //! [objects] + Model { + position: Qt.vector3d(0, -200, 0) + source: "#Cylinder" + scale: Qt.vector3d(2, 0.2, 1) + materials: [ DefaultMaterial { + diffuseColor: "red" + } + ] + } + + Model { + position: Qt.vector3d(0, 150, 0) + source: "#Sphere" + + materials: [ DefaultMaterial { + diffuseColor: "blue" + } + ] + + //! [animation] + SequentialAnimation on y { + loops: Animation.Infinite + NumberAnimation { + duration: 3000 + to: -150 + from: 150 + easing.type:Easing.InQuad + } + NumberAnimation { + duration: 3000 + to: 150 + from: -150 + easing.type:Easing.OutQuad + } + } + //! [animation] + } + //! [objects] + } +} |