Skip to content

Commit

Permalink
Add a test, and add animationTime to ModelAnimation options
Browse files Browse the repository at this point in the history
  • Loading branch information
markw65 committed Feb 9, 2021
1 parent d7297b9 commit bc967f3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Source/Scene/ModelAnimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function ModelAnimation(options, model, runtimeAnimation) {
* rather than deriving the local animation time from the current time
* and the above parameters.
*/
this.animationTime = undefined;
this.animationTime = options.animationTime;
this._prevAnimationTime = undefined;

/**
Expand Down
37 changes: 37 additions & 0 deletions Specs/Scene/ModelSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1870,6 +1870,43 @@ describe(
animBoxesModel.show = false;
});

it("animates with a explicit animation time", function () {
var time = JulianDate.fromDate(new Date("January 1, 2014 12:00:00 UTC"));
var animations = animBoxesModel.activeAnimations;
var a = animations.add({
name: "animation_1",
animationTime: 0,
});

var spyUpdate = jasmine.createSpy("listener");
a.update.addEventListener(spyUpdate);

animations.manualAnimation = true;
animBoxesModel.show = true;
scene.renderForSpecs(time);
a.animationTime = 0.5;
scene.renderForSpecs(JulianDate.addSeconds(time, 1.0, new JulianDate()));
a.animationTime = 1.7;
scene.renderForSpecs(JulianDate.addSeconds(time, 2.0, new JulianDate()));

expect(spyUpdate.calls.count()).toEqual(3);
expect(spyUpdate.calls.argsFor(0)[2]).toEqualEpsilon(
0.0,
CesiumMath.EPSILON14
);
expect(spyUpdate.calls.argsFor(1)[2]).toEqualEpsilon(
0.5,
CesiumMath.EPSILON14
);
expect(spyUpdate.calls.argsFor(2)[2]).toEqualEpsilon(
1.7,
CesiumMath.EPSILON14
);
expect(animations.remove(a)).toEqual(true);
animBoxesModel.show = false;
animations.manualAnimation = true;
});

it("animates with a multiplier", function () {
var time = JulianDate.fromDate(new Date("January 1, 2014 12:00:00 UTC"));
var animations = animBoxesModel.activeAnimations;
Expand Down

0 comments on commit bc967f3

Please sign in to comment.