Skip to content

Commit

Permalink
Undo exposing animationsMultiplier via Entity API
Browse files Browse the repository at this point in the history
  • Loading branch information
Shehata committed Jan 16, 2019
1 parent 15c98a4 commit 1a20d10
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 90 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Change Log
* Added support for polylines on 3D Tiles. [#7437](https://github.com/AnalyticalGraphicsInc/cesium/pull/7437)
* Added `classificationType` property to `PolylineGraphics` and `GroundPolylinePrimitive` which specifies whether a polyline clamped to ground should be clamped to terrain, 3D Tiles, or both. [#7437](https://github.com/AnalyticalGraphicsInc/cesium/pull/7437)
* Added the ability to specify the width of the intersection volume for `Scene.sampleHeight`, `Scene.clampToHeight`, `Scene.sampleHeightMostDetailed`, and `Scene.clampToHeightMostDetailed`. [#7287](https://github.com/AnalyticalGraphicsInc/cesium/pull/7287)
* Added a [new Sandcastle example](https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/?src=Time%20Dynamic%20Wheels.html) on using `nodeTransformations` to rotate a model's wheels based on its velocity. [#7361](https://github.com/AnalyticalGraphicsInc/cesium/pull/7361)

##### Fixes :wrench:
* Fixed an issue where classification primitives with the `CESIUM_3D_TILE` classification type would render on terrain. [#7422](https://github.com/AnalyticalGraphicsInc/cesium/pull/7422)
Expand All @@ -31,7 +32,6 @@ Change Log
* The `specularEnvironmentMaps` and `sphericalHarmonicCoefficients` properties of `Model` and `Cesium3DTileset` can be used to override the values from the scene for specific models and tilesets.
* The `luminanceAtZenith` property of `Model` and `Cesium3DTileset` adjusts the luminance of the procedural image-based lighting.
* Double click away from an entity to un-track it [#7285](https://github.com/AnalyticalGraphicsInc/cesium/pull/7285)
* Added a new `animationsMultiplier` property on `ModelGraphics` to control the playback speed of glTF animations. [#7361](https://github.com/AnalyticalGraphicsInc/cesium/pull/7361).

##### Fixes :wrench:
* Fixed 3D Tiles visibility checking when running multiple passes within the same frame. [#7289](https://github.com/AnalyticalGraphicsInc/cesium/pull/7289)
Expand Down
13 changes: 1 addition & 12 deletions Source/DataSources/ModelGraphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ define([
* @param {Property} [options.incrementallyLoadTextures=true] Determine if textures may continue to stream in after the model is loaded.
* @param {Property} [options.runAnimations=true] A boolean Property specifying if glTF animations specified in the model should be started.
* @param {Property} [options.clampAnimations=true] A boolean Property specifying if glTF animations should hold the last pose for time durations with no keyframes.
* @param {Property} [options.nodeTransformations] An object, where keys are names of nodes, and values are {@link TranslationRotationScale} Properties describing the transformation to apply to that node.
* @param {PropertyBag} [options.nodeTransformations] An object, where keys are names of nodes, and values are {@link TranslationRotationScale} Properties describing the transformation to apply to that node.
* @param {Property} [options.shadows=ShadowMode.ENABLED] An enum Property specifying whether the model casts or receives shadows from each light source.
* @param {Property} [options.heightReference=HeightReference.NONE] A Property specifying what the height is relative to.
* @param {Property} [options.distanceDisplayCondition] A Property specifying at what distance from the camera that this model will be displayed.
Expand Down Expand Up @@ -79,7 +79,6 @@ define([
this._uriSubscription = undefined;
this._runAnimations = undefined;
this._clampAnimations = undefined;
this._animationsMultiplier = undefined;
this._runAnimationsSubscription = undefined;
this._nodeTransformations = undefined;
this._nodeTransformationsSubscription = undefined;
Expand Down Expand Up @@ -191,14 +190,6 @@ define([
*/
runAnimations : createPropertyDescriptor('runAnimations'),

/**
* Gets or sets the numeric Property specifying the relative speed to play the glTF animations.
* @memberof ModelGraphics.prototype
* @type {Property}
* @default 1.0
*/
animationsMultiplier : createPropertyDescriptor('animationsMultiplier'),

/**
* Gets or sets the boolean Property specifying if glTF animations should hold the last pose for time durations with no keyframes.
* @memberof ModelGraphics.prototype
Expand Down Expand Up @@ -313,7 +304,6 @@ define([
result.uri = this.uri;
result.runAnimations = this.runAnimations;
result.clampAnimations = this.clampAnimations;
result.animationsMultiplier = this.animationsMultiplier;
result.nodeTransformations = this.nodeTransformations;
result.heightReference = this._heightReference;
result.distanceDisplayCondition = this.distanceDisplayCondition;
Expand Down Expand Up @@ -351,7 +341,6 @@ define([
this.uri = defaultValue(this.uri, source.uri);
this.runAnimations = defaultValue(this.runAnimations, source.runAnimations);
this.clampAnimations = defaultValue(this.clampAnimations, source.clampAnimations);
this.animationsMultiplier = defaultValue(this.animationsMultiplier, source.animationsMultiplier);
this.heightReference = defaultValue(this.heightReference, source.heightReference);
this.distanceDisplayCondition = defaultValue(this.distanceDisplayCondition, source.distanceDisplayCondition);
this.silhouetteColor = defaultValue(this.silhouetteColor, source.silhouetteColor);
Expand Down
14 changes: 1 addition & 13 deletions Source/DataSources/ModelVisualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ define([
var defaultColorBlendMode = ColorBlendMode.HIGHLIGHT;
var defaultColorBlendAmount = 0.5;
var defaultImageBasedLightingFactor = new Cartesian2(1.0, 1.0);
var defaultAnimationMultiplier = 1.0;

var modelMatrixScratch = new Matrix4();
var nodeMatrixScratch = new Matrix4();
Expand Down Expand Up @@ -139,8 +138,7 @@ define([
animationsRunning : false,
nodeTransformationsScratch : {},
originalNodeMatrixHash : {},
loadFail : false,
multiplier : defaultAnimationMultiplier
loadFail : false
};
modelHash[entity.id] = modelData;

Expand All @@ -167,7 +165,6 @@ define([

if (model.ready) {
var runAnimations = Property.getValueOrDefault(modelGraphics._runAnimations, time, true);
var multiplier = Property.getValueOrDefault(modelGraphics._animationsMultiplier, time, defaultAnimationMultiplier);
if (modelData.animationsRunning !== runAnimations) {
if (runAnimations) {
model.activeAnimations.addAll({
Expand All @@ -179,15 +176,6 @@ define([
modelData.animationsRunning = runAnimations;
}

if (modelData.animationsRunning && modelData.multiplier !== multiplier) {
var animationLength = model.activeAnimations.length;
for (var j = 0; j < animationLength; ++j) {
var animation = model.activeAnimations.get(j);
animation.multiplier = multiplier;
}
modelData.multiplier = multiplier;
}

// Apply node transformations
var nodeTransformations = Property.getValueOrUndefined(modelGraphics._nodeTransformations, time, modelData.nodeTransformationsScratch);
if (defined(nodeTransformations)) {
Expand Down
12 changes: 1 addition & 11 deletions Source/Scene/ModelAnimation.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
define([
'../Core/Check',
'../Core/defaultValue',
'../Core/defineProperties',
'../Core/defined',
Expand All @@ -9,7 +8,6 @@ define([
'./ModelAnimationLoop',
'./ModelAnimationState'
], function(
Check,
defaultValue,
defineProperties,
defined,
Expand Down Expand Up @@ -120,7 +118,6 @@ define([
// Set during animation update
this._computedStartTime = undefined;
this._duration = undefined;
this._multiplierChanged = false;

// To avoid allocations in ModelAnimationCollection.update
var that = this;
Expand Down Expand Up @@ -211,20 +208,13 @@ define([
* @memberof ModelAnimation.prototype
*
* @type {Number}
* @readonly
*
* @default 1.0
*/
multiplier : {
get : function() {
return this._multiplier;
},
set : function(multiplier) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number.greaterThan('multiplier', multiplier, 0);
//>>includeEnd('debug');

this._multiplier = multiplier;
this._multiplierChanged = true;
}
},

Expand Down
3 changes: 1 addition & 2 deletions Source/Scene/ModelAnimationCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,8 @@ define([
scheduledAnimation._computedStartTime = JulianDate.addSeconds(defaultValue(scheduledAnimation.startTime, sceneTime), scheduledAnimation.delay, new JulianDate());
}

if (!defined(scheduledAnimation._duration) || scheduledAnimation._multiplierChanged) {
if (!defined(scheduledAnimation._duration)) {
scheduledAnimation._duration = runtimeAnimation.stopTime * (1.0 / scheduledAnimation.multiplier);
scheduledAnimation._multiplierChanged = false;
}

var startTime = scheduledAnimation._computedStartTime;
Expand Down
11 changes: 0 additions & 11 deletions Specs/DataSources/ModelGraphicsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ defineSuite([
incrementallyLoadTextures : false,
runAnimations : false,
clampAnimations : false,
animationsMultiplier : 1.5,
shadows : ShadowMode.DISABLED,
heightReference : HeightReference.CLAMP_TO_GROUND,
distanceDisplayCondition : new DistanceDisplayCondition(),
Expand Down Expand Up @@ -81,7 +80,6 @@ defineSuite([
expect(model.lightColor).toBeInstanceOf(ConstantProperty);
expect(model.runAnimations).toBeInstanceOf(ConstantProperty);
expect(model.clampAnimations).toBeInstanceOf(ConstantProperty);
expect(model.animationsMultiplier).toBeInstanceOf(ConstantProperty);

expect(model.nodeTransformations).toBeInstanceOf(PropertyBag);

Expand All @@ -104,7 +102,6 @@ defineSuite([
expect(model.lightColor.getValue()).toEqual(options.lightColor);
expect(model.runAnimations.getValue()).toEqual(options.runAnimations);
expect(model.clampAnimations.getValue()).toEqual(options.clampAnimations);
expect(model.animationsMultiplier.getValue()).toEqual(options.animationsMultiplier);

var actualNodeTransformations = model.nodeTransformations.getValue(new JulianDate());
var expectedNodeTransformations = options.nodeTransformations;
Expand Down Expand Up @@ -136,7 +133,6 @@ defineSuite([
source.lightColor = new ConstantProperty(new Color(1.0, 1.0, 0.0, 1.0));
source.runAnimations = new ConstantProperty(true);
source.clampAnimations = new ConstantProperty(true);
source.animationsMultiplier = new ConstantProperty(1.5);
source.nodeTransformations = {
node1 : new NodeTransformationProperty({
translation : Cartesian3.UNIT_Y,
Expand Down Expand Up @@ -170,7 +166,6 @@ defineSuite([
expect(target.lightColor).toBe(source.lightColor);
expect(target.runAnimations).toBe(source.runAnimations);
expect(target.clampAnimations).toBe(source.clampAnimations);
expect(target.animationsMultiplier).toBe(source.animationsMultiplier);
expect(target.nodeTransformations).toEqual(source.nodeTransformations);
});

Expand All @@ -195,7 +190,6 @@ defineSuite([
source.lightColor = new ConstantProperty(new Color(1.0, 1.0, 0.0, 1.0));
source.runAnimations = new ConstantProperty(true);
source.clampAnimations = new ConstantProperty(true);
source.animationsMultiplier = new ConstantProperty(1.5);
source.nodeTransformations = {
transform : new NodeTransformationProperty()
};
Expand All @@ -219,7 +213,6 @@ defineSuite([
var lightColor = new ConstantProperty(new Color(1.0, 1.0, 0.0, 1.0));
var runAnimations = new ConstantProperty(true);
var clampAnimations = new ConstantProperty(true);
var animationsMultiplier = new ConstantProperty(2.0);
var nodeTransformations = new PropertyBag({
transform : new NodeTransformationProperty()
});
Expand All @@ -244,7 +237,6 @@ defineSuite([
target.lightColor = lightColor;
target.runAnimations = runAnimations;
target.clampAnimations = clampAnimations;
target.animationsMultiplier = animationsMultiplier;
target.nodeTransformations = nodeTransformations;

target.merge(source);
Expand All @@ -268,7 +260,6 @@ defineSuite([
expect(target.lightColor).toBe(lightColor);
expect(target.runAnimations).toBe(runAnimations);
expect(target.clampAnimations).toBe(clampAnimations);
expect(target.animationsMultiplier).toBe(animationsMultiplier);
expect(target.nodeTransformations).toBe(nodeTransformations);
});

Expand All @@ -293,7 +284,6 @@ defineSuite([
source.lightColor = new ConstantProperty(new Color(1.0, 1.0, 0.0, 1.0));
source.runAnimations = new ConstantProperty(true);
source.clampAnimations = new ConstantProperty(true);
source.animationsMultiplier = new ConstantProperty(1.5);
source.nodeTransformations = {
node1 : new NodeTransformationProperty(),
node2 : new NodeTransformationProperty()
Expand All @@ -319,7 +309,6 @@ defineSuite([
expect(result.lightColor).toBe(source.lightColor);
expect(result.runAnimations).toBe(source.runAnimations);
expect(result.clampAnimations).toBe(source.clampAnimations);
expect(result.animationsMultiplier).toBe(source.animationsMultiplier);
expect(result.nodeTransformations).toEqual(source.nodeTransformations);
});

Expand Down
40 changes: 0 additions & 40 deletions Specs/DataSources/ModelVisualizerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ defineSuite([
'use strict';

var boxUrl = './Data/Models/Box/CesiumBoxTest.gltf';
var animBoxesUrl = './Data/Models/anim-test-1-boxes/anim-test-1-boxes.gltf';

var scene;
var visualizer;
Expand Down Expand Up @@ -263,45 +262,6 @@ defineSuite([
expect(modelPrimitive.id).toEqual(testObject);
});

it('correctly updates animationsMultiplier property on all animations.', function() {
var entityCollection = new EntityCollection();
visualizer = new ModelVisualizer(scene, entityCollection);

var time = JulianDate.now();
var testObject = entityCollection.getOrCreateEntity('test');
var model = new ModelGraphics();
testObject.model = model;

testObject.position = new ConstantProperty(new Cartesian3(5678, 1234, 1101112));
model.uri = new ConstantProperty(animBoxesUrl);
visualizer.update(time);

var modelPrimitive = scene.primitives.get(0);

return pollToPromise(function() {
scene.render();
return modelPrimitive.ready;
}).then(function() {
visualizer.update(time);
var animationLength = modelPrimitive.activeAnimations.length;
var animation;
var i;

for (i = 0; i < animationLength; ++i) {
animation = modelPrimitive.activeAnimations.get(i);
expect(animation.multiplier).toEqual(1.0);
}

model.animationsMultiplier = 2.0;
visualizer.update(time);

for (i = 0; i < animationLength; ++i) {
animation = modelPrimitive.activeAnimations.get(i);
expect(animation.multiplier).toEqual(2.0);
}
});
});

it('Computes bounding sphere.', function() {
var entityCollection = new EntityCollection();
visualizer = new ModelVisualizer(scene, entityCollection);
Expand Down

0 comments on commit 1a20d10

Please sign in to comment.