blob: 58ab0a4f1dd0ce5be1643dc9123ce2d9d260ec33 [file] [log] [blame]
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example simple
\ingroup quick3d-examples
\title Qt Quick 3D - Simple Example
\brief Demonstrates how to render a simple scene in Qt Quick 3D.
\image simple.png
\e {Simple} demonstrates how to render a scene in Qt Quick 3D.
\section1 Setting Up the Scene
We set up the entire scene in the \e main.qml file.
To be able to use the types in the QtQuick3D module, we must import it:
\quotefromfile simple/main.qml
\skipto import QtQuick3D
\printuntil QtQuick3D
First of all, we define the environment of our simple scene. We just clear
the background color with 'skyblue' in this example.
\snippet simple/main.qml environment
And then, we define a camera which represents the viewport of the rendered
scene. In this example, we use \l PerspectiveCamera which shows perspective
viewport in a general 3D scene. Because we want to define some objects
around origin, we move this camera to the rear position and rotate slightly.
\snippet simple/main.qml camera
For the objects in the scene to be rendered correctly we need to add a light
source, in this example we'll be using a \l DirectionalLight
\snippet simple/main.qml light
\section1 Draw Simple Objects
Now, we draw some built-in objects.
In this example, we draw a red cylinder and a blue sphere using \l Model.
However, just drawing objects is too simple, so we make a round plate with
the red cylinder and add bouncing animation for the sphere.
\snippet simple/main.qml objects
*/