diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2015-07-21 10:12:29 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2015-07-25 10:07:38 +0000 |
commit | 9c95de596dfd6e1dc8630d4e020103646e1d0ae1 (patch) | |
tree | fd1cfbef1552029e1ab2fd0590b297a7da4303ef /examples/qt3d/loader-qml | |
parent | 37f9d95b848127706f417f91254fad3addcc40cd (diff) |
loader-qml: Added materials and animations
Helps ensure that property updates and complex nodes such as Materials are
properly created and updated dynamically
Change-Id: I126f971d2c94bcc45e368e9b2a15d0d1e7d456d4
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'examples/qt3d/loader-qml')
-rw-r--r-- | examples/qt3d/loader-qml/CuboidEntity.qml | 36 | ||||
-rw-r--r-- | examples/qt3d/loader-qml/SphereEntity.qml | 33 | ||||
-rw-r--r-- | examples/qt3d/loader-qml/main.qml | 13 |
3 files changed, 68 insertions, 14 deletions
diff --git a/examples/qt3d/loader-qml/CuboidEntity.qml b/examples/qt3d/loader-qml/CuboidEntity.qml index 9de96e1a3..5af463870 100644 --- a/examples/qt3d/loader-qml/CuboidEntity.qml +++ b/examples/qt3d/loader-qml/CuboidEntity.qml @@ -36,9 +36,10 @@ import Qt3D 2.0 import Qt3D.Renderer 2.0 +import QtQuick 2.4 as QQ2 Entity { - components: [ mesh, material, transform ] + components: [ mesh, phongMaterial, transform ] CuboidMesh { id: mesh @@ -47,16 +48,37 @@ Entity { xyMeshResolution: Qt.size(2, 2) } - Material { - id: material - effect : Effect { } + GoochMaterial { + id: phongMaterial } Transform { id: transform - - Scale { - scale: 3 + Scale { scale: 4 } + Rotate { + id: _rotate + axis: Qt.vector3d(0.0, 1.0, 0.0) } } + + QQ2.ColorAnimation { + target: phongMaterial + property: "warmColor" + from: "red" + to: "blue" + duration: 2500 + loops: QQ2.Animation.Infinite + running: true + } + + QQ2.NumberAnimation { + target: _rotate + property: "angle" + duration: 750 + loops: QQ2.Animation.Infinite + running: true + easing.type: QQ2.Easing.InOutQuad + from: 0 + to: 360 + } } diff --git a/examples/qt3d/loader-qml/SphereEntity.qml b/examples/qt3d/loader-qml/SphereEntity.qml index 2825b8253..f69ce0613 100644 --- a/examples/qt3d/loader-qml/SphereEntity.qml +++ b/examples/qt3d/loader-qml/SphereEntity.qml @@ -36,12 +36,43 @@ import Qt3D 2.0 import Qt3D.Renderer 2.0 +import QtQuick 2.4 as QQ2 Entity { - components: [ mesh, material ] + components: [ mesh, material, transform ] SphereMesh { id: mesh radius: 3 } + + Transform { + id: transform + + Scale { + id: _scale + scale: 3 + } + } + + QQ2.ColorAnimation { + target: material + property: "diffuse" + from: "yellow" + to: "orange" + duration: 1500 + loops: QQ2.Animation.Infinite + running: true + } + + QQ2.NumberAnimation { + target: _scale + property: "scale" + duration: 1500 + loops: QQ2.Animation.Infinite + running: true + easing.type: QQ2.Easing.InOutQuad + from: 1 + to: 1.5 + } } diff --git a/examples/qt3d/loader-qml/main.qml b/examples/qt3d/loader-qml/main.qml index 76eb524ec..569a03979 100644 --- a/examples/qt3d/loader-qml/main.qml +++ b/examples/qt3d/loader-qml/main.qml @@ -66,9 +66,9 @@ Entity { ] - Material { + PhongMaterial { id: material - effect : Effect { } + diffuse: "yellow" } TorusMesh { @@ -97,16 +97,17 @@ Entity { interval: 1000 running: true repeat: true + property bool hasSphere: true - onTriggered: loader.hasSphere = !loader.hasSphere + onTriggered: { + loader.source = hasSphere ? "qrc:/SphereEntity.qml" : "qrc:/CuboidEntity.qml" + hasSphere = !hasSphere + } } EntityLoader { id: loader - property bool hasSphere: true - components: [ revolutionTransform ] - source: hasSphere ? "qrc:/SphereEntity.qml" : "qrc:/CuboidEntity.qml" } Transform { |