/****************************************************************************
**
** 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 dynamictexture
    \ingroup quick3d-examples
    \title Qt Quick 3D - Dynamic Texture Example
    \brief Demonstrates how to use a 2D layer as a 3D texture.
    \image dynamictexture.png

    This example shows how to use 2D content from Qt Quick and use it as a
    texture for 3D objects.  The 2D item used in this example is a fancy
    corkboard and it is textured onto a simple double door.

    \section1 The 2D scene

    The 2D content we use for this example is the \e CorkBoard scene from Qt
    Quick's \l {Qt Quick Examples - Touch Interaction}{Touch Interaction
    Example}. We put it in a Rectangle and show it on top of our View3D.

    \snippet dynamictexture/main.qml 2d layer

    We give the 2D object the name \c {object2d}, so we can refer to it later.


    \section1 The 3D view

    To use the 2D content in our 3D scene, we first have to put it into a material.
    The texture is identified by the \l {Texture::sourceItem}{sourceItem} property,
    referring back to \c object2d.
    \snippet dynamictexture/Doors.qml material

    We use the same material for each door, but different meshes. The meshes are
    designed so that the texture is divided evenly across the doors. In addition to setting
    the material and the source mesh, we also set the \l {Model::pickable}{pickable} property,
    so we can click on the doors to open and close them:

    \snippet dynamictexture/Doors.qml model heading
    \dots
    \snippet dynamictexture/Doors.qml model content

    Finally, we add some interaction to our 3D scene, using \l {View3D::pick}{View3D.pick}:

    \snippet dynamictexture/main.qml picking

    Each door will open when clicked and its state is set to \c {"opened"}.

    \snippet dynamictexture/Doors.qml state

*/
