summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Ottens <kevin.ottens@kdab.com>2014-12-17 12:35:40 +0100
committerSean Harmer <sean.harmer@kdab.com>2014-12-17 17:44:23 +0100
commit8c8fe2cb0d1b0d26090b7c7689b2f28ffce6a642 (patch)
treecae9bb74e670c1aff971d97461e91849687bb81b
parent88ac3a98e6969ee70f5e3aa62835c69ff9d1d547 (diff)
Add a new EntityLoader element
It also come with an example where we swap between two entities loaded from QML files. Change-Id: I09d5c5852ad5ea1e85d2acfffd51413de437ce22 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--examples/examples.pro1
-rw-r--r--examples/loader-qml/CuboidEntity.qml67
-rw-r--r--examples/loader-qml/SphereEntity.qml52
-rw-r--r--examples/loader-qml/loader-qml.pro13
-rw-r--r--examples/loader-qml/loader-qml.qrc7
-rw-r--r--examples/loader-qml/main.cpp65
-rw-r--r--examples/loader-qml/main.qml149
-rw-r--r--src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp2
-rw-r--r--src/quick3d/quick3d/items/items.pri3
-rw-r--r--src/quick3d/quick3d/items/quick3dentityloader.cpp214
-rw-r--r--src/quick3d/quick3d/items/quick3dentityloader.h95
-rw-r--r--src/quick3d/quick3d/items/quick3dentityloader_p.h90
-rw-r--r--src/quick3d/quick3d/quick3d.pro2
13 files changed, 759 insertions, 1 deletions
diff --git a/examples/examples.pro b/examples/examples.pro
index 2ccca671a..b94e16331 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -22,6 +22,7 @@ SUBDIRS += \
bigscene-cpp \
materials \
keyboardinput-qml \
+ loader-qml \
wave
# TODO Port the old examples to new APIs
diff --git a/examples/loader-qml/CuboidEntity.qml b/examples/loader-qml/CuboidEntity.qml
new file mode 100644
index 000000000..8858d3efa
--- /dev/null
+++ b/examples/loader-qml/CuboidEntity.qml
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt3D 2.0
+import Qt3D.Render 2.0
+
+Entity {
+ components: [ mesh, material, transform ]
+
+ CuboidMesh {
+ id: mesh
+ yzMeshResolution: Qt.size(2, 2)
+ xzMeshResolution: Qt.size(2, 2)
+ xyMeshResolution: Qt.size(2, 2)
+ }
+
+ Material {
+ id: material
+ effect : Effect { }
+ }
+
+ Transform {
+ id: transform
+
+ Scale {
+ scale: 3
+ }
+ }
+}
diff --git a/examples/loader-qml/SphereEntity.qml b/examples/loader-qml/SphereEntity.qml
new file mode 100644
index 000000000..2dfbe41d8
--- /dev/null
+++ b/examples/loader-qml/SphereEntity.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt3D 2.0
+import Qt3D.Render 2.0
+
+Entity {
+ components: [ mesh, material ]
+
+ SphereMesh {
+ id: mesh
+ radius: 3
+ }
+}
diff --git a/examples/loader-qml/loader-qml.pro b/examples/loader-qml/loader-qml.pro
new file mode 100644
index 000000000..d54671248
--- /dev/null
+++ b/examples/loader-qml/loader-qml.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+QT += 3dcore 3drenderer 3dquick qml quick
+
+SOURCES += \
+ main.cpp
+
+OTHER_FILES += \
+ main.qml \
+ SphereEntity.qml \
+ CuboidEntity.qml
+
+RESOURCES += \
+ loader-qml.qrc
diff --git a/examples/loader-qml/loader-qml.qrc b/examples/loader-qml/loader-qml.qrc
new file mode 100644
index 000000000..8cf177b62
--- /dev/null
+++ b/examples/loader-qml/loader-qml.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>SphereEntity.qml</file>
+ <file>CuboidEntity.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/loader-qml/main.cpp b/examples/loader-qml/main.cpp
new file mode 100644
index 000000000..a9d5d101d
--- /dev/null
+++ b/examples/loader-qml/main.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <Qt3DQuick/quickwindow.h>
+#include <Qt3DRenderer/qrenderaspect.h>
+
+#include <QGuiApplication>
+
+int main(int argc, char* argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ Qt3D::Quick::QuickWindow view;
+ Qt3D::Quick::QQmlAspectEngine engine;
+
+ engine.aspectEngine()->registerAspect(new Qt3D::QRenderAspect());
+ engine.aspectEngine()->initialize();
+ QVariantMap data;
+ data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
+ data.insert(QStringLiteral("window"), QVariant::fromValue(&view));
+ engine.aspectEngine()->setData(data);
+ engine.setSource(QUrl("qrc:/main.qml"));
+
+ view.show();
+
+ return app.exec();
+}
diff --git a/examples/loader-qml/main.qml b/examples/loader-qml/main.qml
new file mode 100644
index 000000000..15b2971c5
--- /dev/null
+++ b/examples/loader-qml/main.qml
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt3D 2.0
+import Qt3D.Render 2.0
+import QtQuick 2.2 as QQ2
+
+Entity {
+ id: sceneRoot
+
+ Camera {
+ id: camera
+ projectionType: CameraLens.PerspectiveProjection
+ fieldOfView: 45
+ aspectRatio: 16/9
+ nearPlane : 0.1
+ farPlane : 1000.0
+ position: Qt.vector3d( 0.0, 0.0, -40.0 )
+ upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
+ viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
+ }
+
+ Configuration {
+ controlledCamera: camera
+ }
+
+ components: [
+ FrameGraph {
+ activeFrameGraph: Viewport {
+ id: viewport
+ rect: Qt.rect(0.0, 0.0, 1.0, 1.0) // From Top Left
+ clearColor: Qt.rgba(0, 0.5, 1, 1)
+
+ CameraSelector {
+ id : cameraSelector
+ camera: camera
+
+ ClearBuffer {
+ buffers : ClearBuffer.ColorDepthBuffer
+ }
+ }
+ }
+ }
+ ]
+
+
+ Material {
+ id: material
+ effect : Effect { }
+ }
+
+ TorusMesh {
+ id: torusMesh
+ radius: 5
+ minorRadius: 1
+ rings: 100
+ slices: 20
+ }
+
+ Transform {
+ id: torusTransform
+ Scale { scale3D: Qt.vector3d(1.5, 1, 0.5) }
+ Rotate {
+ angle: 45
+ axis: Qt.vector3d(1, 0, 0)
+ }
+ }
+
+ Entity {
+ id: torusEntity
+ components: [ torusMesh, material, torusTransform ]
+ }
+
+ QQ2.Timer {
+ interval: 1000
+ running: true
+ repeat: true
+
+ onTriggered: loader.hasSphere = !loader.hasSphere
+ }
+
+ EntityLoader {
+ id: loader
+ property bool hasSphere: true
+
+ components: [ revolutionTransform ]
+ source: hasSphere ? "qrc:/SphereEntity.qml" : "qrc:/CuboidEntity.qml"
+ }
+
+ Transform {
+ id: revolutionTransform
+ Translate {
+ translation: Qt.vector3d(20, 0, 0)
+ }
+
+ Rotate {
+ id: sphereRotation
+ axis: Qt.vector3d(0, 1, 0)
+ QQ2.NumberAnimation {
+ target: sphereRotation
+ property: "angle"
+ duration: 10000
+ from: 0
+ to: 360
+
+ loops: QQ2.Animation.Infinite
+ running: true
+ }
+ }
+ }
+}
diff --git a/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp b/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp
index 2da408812..8db3d09f3 100644
--- a/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp
+++ b/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp
@@ -49,6 +49,7 @@
#include <Qt3DCore/qtranslatetransform.h>
#include <Qt3DCore/qrotatetransform.h>
#include <Qt3DQuick/quick3dentity.h>
+#include <Qt3DQuick/quick3dentityloader.h>
#include <Qt3DQuick/quick3dtransform.h>
#include <Qt3DQuick/quick3dconfiguration.h>
#include <private/qt3dquick_global_p.h>
@@ -64,6 +65,7 @@ void Qt3DQuick3DCorePlugin::registerTypes(const char *uri)
qmlRegisterType<Qt3D::Quick::Quick3DConfiguration>(uri, 2, 0, "Configuration");
qmlRegisterExtendedType<Qt3D::QEntity, Qt3D::Quick::Quick3DEntity>(uri, 2, 0, "Entity");
+ qmlRegisterType<Qt3D::Quick::Quick3DEntityLoader>(uri, 2, 0, "EntityLoader");
qmlRegisterExtendedType<Qt3D::QTransform, Qt3D::Quick::Quick3DTransform>(uri, 2, 0, "Transform");
// Ideally we want to make Node an uncreatable type
// We would need qmlRegisterUncreatableExtendedType for that
diff --git a/src/quick3d/quick3d/items/items.pri b/src/quick3d/quick3d/items/items.pri
index 199532964..edf00bd5e 100644
--- a/src/quick3d/quick3d/items/items.pri
+++ b/src/quick3d/quick3d/items/items.pri
@@ -1,12 +1,15 @@
HEADERS += \
$$PWD/quick3dnode.h \
$$PWD/quick3dentity.h \
+ $$PWD/quick3dentityloader.h \
+ $$PWD/quick3dentityloader_p.h \
$$PWD/quick3dtransform.h \
$$PWD/quick3dconfiguration.h
SOURCES += \
$$PWD/quick3dnode.cpp \
$$PWD/quick3dentity.cpp \
+ $$PWD/quick3dentityloader.cpp \
$$PWD/quick3dtransform.cpp \
$$PWD/quick3dconfiguration.cpp
diff --git a/src/quick3d/quick3d/items/quick3dentityloader.cpp b/src/quick3d/quick3d/items/quick3dentityloader.cpp
new file mode 100644
index 000000000..aa6ab05e3
--- /dev/null
+++ b/src/quick3d/quick3d/items/quick3dentityloader.cpp
@@ -0,0 +1,214 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "quick3dentityloader.h"
+#include "quick3dentityloader_p.h"
+
+#include <QQmlContext>
+#include <QQmlEngine>
+#include <QQmlIncubator>
+
+#include <QtQml/private/qqmlengine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+namespace Quick {
+
+class Quick3DEntityLoaderIncubator : public QQmlIncubator
+{
+public:
+ Quick3DEntityLoaderIncubator(Quick3DEntityLoaderPrivate *loader)
+ : QQmlIncubator(Asynchronous),
+ m_loader(loader)
+ {
+ }
+
+protected:
+ void setInitialState(QObject *object) Q_DECL_OVERRIDE
+ {
+ Q_ASSERT(m_loader->m_entity == Q_NULLPTR);
+ m_loader->m_entity = qobject_cast<QEntity*>(object);
+ Q_ASSERT(m_loader->m_entity != Q_NULLPTR);
+ m_loader->m_entity->setParent(m_loader->q_ptr);
+
+ Quick3DEntityLoader *loader = static_cast<Quick3DEntityLoader*>(m_loader->q_ptr);
+ emit loader->entityChanged();
+ }
+
+private:
+ Quick3DEntityLoaderPrivate *m_loader;
+};
+
+Quick3DEntityLoader::Quick3DEntityLoader(QNode *parent)
+ : QEntity(*new Quick3DEntityLoaderPrivate(this), parent)
+{
+}
+
+QObject *Quick3DEntityLoader::entity() const
+{
+ Q_D(const Quick3DEntityLoader);
+ return d->m_entity;
+}
+
+QUrl Quick3DEntityLoader::source() const
+{
+ Q_D(const Quick3DEntityLoader);
+ return d->m_source;
+}
+
+void Quick3DEntityLoader::setSource(const QUrl &url)
+{
+ Q_D(Quick3DEntityLoader);
+
+ if (url == d->m_source)
+ return;
+
+ d->clear();
+ d->m_source = url;
+ emit sourceChanged();
+ d->loadFromSource();
+}
+
+void Quick3DEntityLoader::copy(const QNode *ref)
+{
+ QNode::copy(ref);
+ const Quick3DEntityLoader *loader = static_cast<const Quick3DEntityLoader*>(ref);
+ d_func()->m_source = loader->d_func()->m_source;
+ d_func()->m_entity = static_cast<QEntity*>(QNode::clone(loader->d_func()->m_entity));
+ d_func()->m_entity->setParent(this);
+}
+
+Quick3DEntityLoaderPrivate::Quick3DEntityLoaderPrivate(Quick3DEntityLoader *qq)
+ : QEntityPrivate(qq),
+ m_incubator(Q_NULLPTR),
+ m_context(Q_NULLPTR),
+ m_component(Q_NULLPTR),
+ m_entity(Q_NULLPTR)
+{
+}
+
+void Quick3DEntityLoaderPrivate::clear()
+{
+ if (m_incubator) {
+ m_incubator->clear();
+ delete m_incubator;
+ m_incubator = Q_NULLPTR;
+ }
+
+ if (m_entity) {
+ m_entity->setParent(Q_NULLPTR);
+ delete m_entity;
+ m_entity = Q_NULLPTR;
+ }
+
+ if (m_component) {
+ delete m_component;
+ m_component = Q_NULLPTR;
+ }
+
+ if (m_context) {
+ delete m_context;
+ m_context = Q_NULLPTR;
+ }
+}
+
+void Quick3DEntityLoaderPrivate::loadFromSource()
+{
+ Q_Q(Quick3DEntityLoader);
+
+ if (m_source.isEmpty()) {
+ emit q->entityChanged();
+ return;
+ }
+
+ loadComponent(m_source);
+}
+
+void Quick3DEntityLoaderPrivate::loadComponent(const QUrl &source)
+{
+ Q_Q(Quick3DEntityLoader);
+
+ Q_ASSERT(m_entity == Q_NULLPTR);
+ Q_ASSERT(m_component == Q_NULLPTR);
+ Q_ASSERT(m_context == Q_NULLPTR);
+
+ m_component = new QQmlComponent(qmlEngine(q), q);
+ QObject::connect(m_component, SIGNAL(statusChanged(QQmlComponent::Status)),
+ q, SLOT(_q_componentStatusChanged(QQmlComponent::Status)));
+ m_component->loadUrl(source, QQmlComponent::Asynchronous);
+}
+
+void Quick3DEntityLoaderPrivate::_q_componentStatusChanged(QQmlComponent::Status status)
+{
+ Q_Q(Quick3DEntityLoader);
+
+ Q_ASSERT(m_entity == Q_NULLPTR);
+ Q_ASSERT(m_component != Q_NULLPTR);
+ Q_ASSERT(m_context == Q_NULLPTR);
+ Q_ASSERT(m_incubator == Q_NULLPTR);
+
+ if (!m_component->errors().isEmpty()) {
+ QQmlEnginePrivate::warning(qmlEngine(q), m_component->errors());
+ clear();
+ emit q->entityChanged();
+ return;
+ }
+
+ // Still loading
+ if (status != QQmlComponent::Ready)
+ return;
+
+ m_context = new QQmlContext(qmlContext(q));
+ m_context->setContextObject(q);
+
+ m_incubator = new Quick3DEntityLoaderIncubator(this);
+ m_component->create(*m_incubator, m_context);
+}
+
+} // Quick
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#include "moc_quick3dentityloader.cpp"
diff --git a/src/quick3d/quick3d/items/quick3dentityloader.h b/src/quick3d/quick3d/items/quick3dentityloader.h
new file mode 100644
index 000000000..12da21efd
--- /dev/null
+++ b/src/quick3d/quick3d/items/quick3dentityloader.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_QUICK_QUICK3DENTITYLOADER_H
+#define QT3D_QUICK_QUICK3DENTITYLOADER_H
+
+#include <QObject>
+#include <QUrl>
+
+#include <Qt3DCore/QEntity>
+
+#include <Qt3DQuick/qt3dquick_global.h>
+
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+class QEntity;
+
+namespace Quick {
+
+class Quick3DEntityLoaderPrivate;
+
+class QT3DQUICKSHARED_EXPORT Quick3DEntityLoader : public QEntity
+{
+ Q_OBJECT
+ Q_PROPERTY(QObject *entity READ entity NOTIFY entityChanged)
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+public:
+ explicit Quick3DEntityLoader(QNode *parent = 0);
+
+ QObject *entity() const;
+
+ QUrl source() const;
+ void setSource(const QUrl &url);
+
+Q_SIGNALS:
+ void entityChanged();
+ void sourceChanged();
+
+protected:
+ void copy(const QNode *ref) Q_DECL_OVERRIDE;
+
+private:
+ Q_DECLARE_PRIVATE(Quick3DEntityLoader)
+ Q_PRIVATE_SLOT(d_func(), void _q_componentStatusChanged(QQmlComponent::Status))
+ QT3D_CLONEABLE(Quick3DEntityLoader)
+};
+
+} // Quick;
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QUICK3DENTITYLOADER_H
diff --git a/src/quick3d/quick3d/items/quick3dentityloader_p.h b/src/quick3d/quick3d/items/quick3dentityloader_p.h
new file mode 100644
index 000000000..0ed970dc4
--- /dev/null
+++ b/src/quick3d/quick3d/items/quick3dentityloader_p.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_QUICK_QUICK3DENTITYLOADER_P_H
+#define QT3D_QUICK_QUICK3DENTITYLOADER_P_H
+
+#include "quick3dentityloader.h"
+
+#include <QQmlComponent>
+
+#include <Qt3DCore/private/qentity_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlIncubator;
+class QQmlContext;
+
+namespace Qt3D {
+
+class QEntity;
+
+namespace Quick {
+
+class Quick3DEntityLoaderIncubator;
+
+class Quick3DEntityLoaderPrivate : public QEntityPrivate
+{
+public:
+ Quick3DEntityLoaderPrivate(Quick3DEntityLoader *qq);
+
+ Q_DECLARE_PUBLIC(Quick3DEntityLoader)
+
+ void clear();
+ void loadFromSource();
+ void loadComponent(const QUrl &source);
+
+ void _q_componentStatusChanged(QQmlComponent::Status status);
+
+ QUrl m_source;
+ Quick3DEntityLoaderIncubator *m_incubator;
+ QQmlContext *m_context;
+ QQmlComponent *m_component;
+ QEntity *m_entity;
+};
+
+} // Quick
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QT3D_QUICK_QUICK3DENTITYLOADER_P_H
diff --git a/src/quick3d/quick3d/quick3d.pro b/src/quick3d/quick3d/quick3d.pro
index 78442693a..14647858b 100644
--- a/src/quick3d/quick3d/quick3d.pro
+++ b/src/quick3d/quick3d/quick3d.pro
@@ -1,6 +1,6 @@
TARGET = Qt3DQuick
-QT += core-private gui-private qml qml-private quick quick-private 3dcore
+QT += core-private gui-private qml qml-private quick quick-private 3dcore 3dcore-private
DEFINES += QT3DQUICK_LIBRARY