mirror of https://github.com/qt/qt3d.git
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>
This commit is contained in:
parent
37f9d95b84
commit
9c95de596d
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue