From b3904c2c055f60f83eecc6f36f06569a0487cf34 Mon Sep 17 00:00:00 2001 From: Mohamad Moneimne Date: Fri, 11 Aug 2017 13:50:57 -0400 Subject: [PATCH 1/5] Removed quad interpolation for quaternions --- Source/Core/QuaternionSpline.js | 61 ++------------------------------- 1 file changed, 2 insertions(+), 59 deletions(-) diff --git a/Source/Core/QuaternionSpline.js b/Source/Core/QuaternionSpline.js index bfe4c792821c..332a303b8891 100644 --- a/Source/Core/QuaternionSpline.js +++ b/Source/Core/QuaternionSpline.js @@ -14,43 +14,11 @@ define([ Spline) { 'use strict'; - function computeInnerQuadrangles(points, firstInnerQuadrangle, lastInnerQuadrangle) { - var length = points.length; - var quads = new Array(length); - - quads[0] = defined(firstInnerQuadrangle) ? firstInnerQuadrangle : points[0]; - quads[length - 1] = defined(lastInnerQuadrangle) ? lastInnerQuadrangle : points[length - 1]; - - for (var i = 1; i < length - 1; ++i) { - quads[i] = Quaternion.computeInnerQuadrangle(points[i - 1], points[i], points[i + 1], new Quaternion()); - } - - return quads; - } - function createEvaluateFunction(spline) { var points = spline.points; - var quads = spline.innerQuadrangles; var times = spline.times; - // use slerp interpolation for 2 points - if (points.length < 3) { - var t0 = times[0]; - var invSpan = 1.0 / (times[1] - t0); - - var q0 = points[0]; - var q1 = points[1]; - - return function(time, result) { - if (!defined(result)){ - result = new Quaternion(); - } - var u = (time - t0) * invSpan; - return Quaternion.fastSlerp(q0, q1, u, result); - }; - } - - // use quad interpolation for more than 3 points + // use slerp interpolation return function(time, result) { if (!defined(result)){ result = new Quaternion(); @@ -60,10 +28,8 @@ define([ var q0 = points[i]; var q1 = points[i + 1]; - var s0 = quads[i]; - var s1 = quads[i + 1]; - return Quaternion.fastSquad(q0, q1, s0, s1, u, result); + return Quaternion.fastSlerp(q0, q1, u, result); }; } @@ -78,10 +44,6 @@ define([ * @param {Number[]} options.times An array of strictly increasing, unit-less, floating-point times at each point. * The values are in no way connected to the clock time. They are the parameterization for the curve. * @param {Quaternion[]} options.points The array of {@link Quaternion} control points. - * @param {Quaternion} [options.firstInnerQuadrangle] The inner quadrangle of the curve at the first control point. - * If the inner quadrangle is not given, it will be estimated. - * @param {Quaternion} [options.lastInnerQuadrangle] The inner quadrangle of the curve at the last control point. - * If the inner quadrangle is not given, it will be estimated. * * @exception {DeveloperError} points.length must be greater than or equal to 2. * @exception {DeveloperError} times.length must be equal to points.length. @@ -96,8 +58,6 @@ define([ var points = options.points; var times = options.times; - var firstInnerQuadrangle = options.firstInnerQuadrangle; - var lastInnerQuadrangle = options.lastInnerQuadrangle; //>>includeStart('debug', pragmas.debug); if (!defined(points) || !defined(times)) { @@ -111,11 +71,8 @@ define([ } //>>includeEnd('debug'); - var innerQuadrangles = computeInnerQuadrangles(points, firstInnerQuadrangle, lastInnerQuadrangle); - this._times = times; this._points = points; - this._innerQuadrangles = innerQuadrangles; this._evaluateFunction = createEvaluateFunction(this); this._lastTimeIndex = 0; @@ -148,20 +105,6 @@ define([ get : function() { return this._points; } - }, - - /** - * An array of {@link Quaternion} inner quadrangles for the control points. - * - * @memberof QuaternionSpline.prototype - * - * @type {Quaternion[]} - * @readonly - */ - innerQuadrangles : { - get : function() { - return this._innerQuadrangles; - } } }); From 88f2b01928230987e94d6c26310136c23df93fb1 Mon Sep 17 00:00:00 2001 From: Mohamad Moneimne Date: Fri, 11 Aug 2017 14:00:00 -0400 Subject: [PATCH 2/5] Updated tests to remove squad --- Specs/Core/QuaternionSplineSpec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Specs/Core/QuaternionSplineSpec.js b/Specs/Core/QuaternionSplineSpec.js index 04cbc5ccf3d4..4f1437754bf0 100644 --- a/Specs/Core/QuaternionSplineSpec.js +++ b/Specs/Core/QuaternionSplineSpec.js @@ -79,9 +79,8 @@ defineSuite([ var time = (times[2] + times[1]) * 0.5; var t = (time - times[1]) / (times[2] - times[1]); - var quads = qs.innerQuadrangles; var actual = qs.evaluate(time); - var expected = Quaternion.squad(points[1], points[2], quads[1], quads[2], t, new Quaternion()); + var expected = Quaternion.slerp(points[1], points[2], t, new Quaternion()); expect(actual).toEqualEpsilon(expected, CesiumMath.EPSILON6); }); From be0dce6d7279ff2834ba488ab9efe059597d3433 Mon Sep 17 00:00:00 2001 From: Mohamad Moneimne Date: Fri, 11 Aug 2017 15:12:26 -0400 Subject: [PATCH 3/5] Fixed eslint error --- Specs/Scene/Cesium3DTilesetSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Specs/Scene/Cesium3DTilesetSpec.js b/Specs/Scene/Cesium3DTilesetSpec.js index 9e52dc598cd2..a8352aee1dd0 100644 --- a/Specs/Scene/Cesium3DTilesetSpec.js +++ b/Specs/Scene/Cesium3DTilesetSpec.js @@ -231,7 +231,7 @@ defineSuite([ // override loadJson and replace incorrect url with correct url Cesium3DTileset.loadJson = function(tilesetUrl) { return originalLoadJson(path); - } + }; // setup tileset with invalid url (overridden loadJson should replace invalid url with correct url) var tileset = new Cesium3DTileset({ From 33a3d59c2c239b82dfbd28034baa83bd5b38e541 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Mon, 8 Jan 2018 20:21:58 -0500 Subject: [PATCH 4/5] Fix doc --- Source/Core/QuaternionSpline.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/QuaternionSpline.js b/Source/Core/QuaternionSpline.js index fb4f2386c78c..8ae986846227 100644 --- a/Source/Core/QuaternionSpline.js +++ b/Source/Core/QuaternionSpline.js @@ -34,7 +34,7 @@ define([ } /** - * A spline that uses spherical quadrangle (squad) interpolation to create a quaternion curve. + * A spline that uses spherical linear (slerp) interpolation to create a quaternion curve. * The generated curve is in the class C1. * * @alias QuaternionSpline From 2c3751e276dace62dbeb08b9524bb065fc10af91 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Mon, 8 Jan 2018 20:29:57 -0500 Subject: [PATCH 5/5] Updated CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index a7bc53f7dcae..fdde65412ac0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -25,6 +25,7 @@ Change Log * Only one node is supported. * Only one mesh per node is supported. * Only one primitive per mesh is supported. +* Fixed a glTF animation bug that caused certain animations to jitter. [#5740](https://github.com/AnalyticalGraphicsInc/cesium/pull/5740) ### 1.41 - 2018-01-02