diff options
author | Paul Lemire <paul.lemire350@gmail.com> | 2018-08-09 06:48:37 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2018-08-20 04:34:47 +0000 |
commit | 4030e1796ca10c0eeab4fcb6cc6000b5bdb08028 (patch) | |
tree | ecff3450a2794f65e6f9d8becc76400b6a2488f7 /tests/manual | |
parent | ebd195c59fe50c49dd28f27828afa802384d7011 (diff) |
EntityLoader: add sourceComponent property
Now handles either loading from file or from a Component
[ChangeLog] EntityLoader now also supports loading an Entity from a Component
Change-Id: I1988f897071e5527b36e1b494bba57e9ab165bd8
Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'tests/manual')
-rw-r--r-- | tests/manual/dynamic-model-loader-qml/main.qml | 75 |
1 files changed, 49 insertions, 26 deletions
diff --git a/tests/manual/dynamic-model-loader-qml/main.qml b/tests/manual/dynamic-model-loader-qml/main.qml index 72d0529b8..dc6b929cf 100644 --- a/tests/manual/dynamic-model-loader-qml/main.qml +++ b/tests/manual/dynamic-model-loader-qml/main.qml @@ -49,7 +49,7 @@ ****************************************************************************/ import QtQuick 2.2 as QQ2 -import Qt3D.Core 2.0 +import Qt3D.Core 2.12 import Qt3D.Render 2.0 import Qt3D.Input 2.0 import Qt3D.Extras 2.0 @@ -81,44 +81,27 @@ Entity { InputSettings { } ] - - PhongMaterial { - id: material - diffuse: "yellow" - } - - TorusMesh { - id: torusMesh - radius: 5 - minorRadius: 1 - rings: 100 - slices: 20 - } - - Transform { - id: torusTransform - scale3D: Qt.vector3d(1.5, 1, 0.5) - rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45) - } - - Entity { - id: torusEntity - components: [ torusMesh, material, torusTransform ] - } - QQ2.Timer { + id: timer interval: 1000 running: true repeat: true property bool addMore: true + property bool odd: false onTriggered: { if (instantiator.model > 10 || instantiator.model < 2) addMore = !addMore instantiator.model += (addMore ? 1 : -1) + odd = !odd } } + PhongMaterial { + id: material + diffuse: "yellow" + } + NodeInstantiator { id: instantiator model: 2 @@ -135,6 +118,46 @@ Entity { } source: model.index % 2 === 0 ? "qrc:/CuboidEntity.qml" : "qrc:/SphereEntity.qml" } + } + + + EntityLoader { + sourceComponent: timer.odd ? cylEntityCmp : torusEntityCmp + } + + QQ2.Component { + id: cylEntityCmp + Entity { + CylinderMesh { + id: cylMesh + } + PhongMaterial { + id: phong + } + components: [cylMesh, phong] + } } + + QQ2.Component { + id: torusEntityCmp + Entity { + TorusMesh { + id: torusMesh + radius: 5 + minorRadius: 1 + rings: 100 + slices: 20 + } + + Transform { + id: torusTransform + scale3D: Qt.vector3d(1.5, 1, 0.5) + rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45) + } + + components: [ torusMesh, material, torusTransform ] + } + } + } |