Lights: Fix animation in example and add another

Looks like QML doesn't like animating only a single element of a 3d
vector. It seems to default the non-animating elements to 0. Instead
use a Vector3DAnimation.

Also added another animation to the transformation to make the
spotlight move back and forth in addition to sweeping it's local
direction angle.

Change-Id: Ief490752107b2b618dcf8500cb87561b3baea0bb
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
This commit is contained in:
Sean Harmer 2016-07-10 14:56:00 +01:00
parent 80f0e379b3
commit 2390fbeac2
1 changed files with 15 additions and 6 deletions

View File

@ -145,21 +145,30 @@ Entity
radius: 1
},
Transform {
translation: Qt.vector3d(-5.0, 40.0, -5.0)
translation: Qt.vector3d(-20.0, 40.0, 0.0)
Quick.SequentialAnimation on translation {
loops: Quick.Animation.Infinite
running: true
Quick.Vector3dAnimation { from: Qt.vector3d(-40.0, 40.0, 0.0); to: Qt.vector3d(40.0, 40.0, 0.0); duration: 5000 }
Quick.Vector3dAnimation { from: Qt.vector3d(40.0, 40.0, 0.0); to: Qt.vector3d(-40.0, 40.0, 0.0); duration: 5000 }
}
},
PhongMaterial {
diffuse: "white"
},
SpotLight {
localDirection: Qt.vector3d(1.0, -4.0, 0.0)
Quick.SequentialAnimation on localDirection.x {
Quick.NumberAnimation { from: -4.0; to: 4.0; duration: 5000 }
Quick.NumberAnimation { from: 4.0; to: -4.0; duration: 5000 }
localDirection: Qt.vector3d(0.0, -4.0, 0.0)
Quick.SequentialAnimation on localDirection {
loops: Quick.Animation.Infinite
running: true
Quick.Vector3dAnimation { from: Qt.vector3d(0.0, -4.0, -4.0); to: Qt.vector3d(0.0, -4.0, 4.0); duration: 1000 }
Quick.Vector3dAnimation { from: Qt.vector3d(0.0, -4.0, 4.0); to: Qt.vector3d(0.0, -4.0, -4.0); duration: 1000 }
}
color: "white"
cutOffAngle: 30
constantAttenuation: 1
intensity: 4
intensity: 2.5
}
]
}