Skip to content

Commit 271d6b3

Browse files
authored
Merge pull request #5740 from moneimne/gltf-2.0
Removing quadrilateral interpolation
2 parents 8a926d3 + 2a680e7 commit 271d6b3

File tree

3 files changed

+5
-62
lines changed

3 files changed

+5
-62
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Change Log
2525
* Only one node is supported.
2626
* Only one mesh per node is supported.
2727
* Only one primitive per mesh is supported.
28+
* Fixed a glTF animation bug that caused certain animations to jitter. [#5740](https://github.com/AnalyticalGraphicsInc/cesium/pull/5740)
2829
* Updated documentation links to reflect new locations on cesiumjs.org and cesium.com.
2930

3031
### 1.41 - 2018-01-02

Source/Core/QuaternionSpline.js

+3-60
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,11 @@ define([
1414
Spline) {
1515
'use strict';
1616

17-
function computeInnerQuadrangles(points, firstInnerQuadrangle, lastInnerQuadrangle) {
18-
var length = points.length;
19-
var quads = new Array(length);
20-
21-
quads[0] = defined(firstInnerQuadrangle) ? firstInnerQuadrangle : points[0];
22-
quads[length - 1] = defined(lastInnerQuadrangle) ? lastInnerQuadrangle : points[length - 1];
23-
24-
for (var i = 1; i < length - 1; ++i) {
25-
quads[i] = Quaternion.computeInnerQuadrangle(points[i - 1], points[i], points[i + 1], new Quaternion());
26-
}
27-
28-
return quads;
29-
}
30-
3117
function createEvaluateFunction(spline) {
3218
var points = spline.points;
33-
var quads = spline.innerQuadrangles;
3419
var times = spline.times;
3520

36-
// use slerp interpolation for 2 points
37-
if (points.length < 3) {
38-
var t0 = times[0];
39-
var invSpan = 1.0 / (times[1] - t0);
40-
41-
var q0 = points[0];
42-
var q1 = points[1];
43-
44-
return function(time, result) {
45-
if (!defined(result)){
46-
result = new Quaternion();
47-
}
48-
var u = (time - t0) * invSpan;
49-
return Quaternion.fastSlerp(q0, q1, u, result);
50-
};
51-
}
52-
53-
// use quad interpolation for more than 3 points
21+
// use slerp interpolation
5422
return function(time, result) {
5523
if (!defined(result)){
5624
result = new Quaternion();
@@ -60,15 +28,13 @@ define([
6028

6129
var q0 = points[i];
6230
var q1 = points[i + 1];
63-
var s0 = quads[i];
64-
var s1 = quads[i + 1];
6531

66-
return Quaternion.fastSquad(q0, q1, s0, s1, u, result);
32+
return Quaternion.fastSlerp(q0, q1, u, result);
6733
};
6834
}
6935

7036
/**
71-
* A spline that uses spherical quadrangle (squad) interpolation to create a quaternion curve.
37+
* A spline that uses spherical linear (slerp) interpolation to create a quaternion curve.
7238
* The generated curve is in the class C<sup>1</sup>.
7339
*
7440
* @alias QuaternionSpline
@@ -78,10 +44,6 @@ define([
7844
* @param {Number[]} options.times An array of strictly increasing, unit-less, floating-point times at each point.
7945
* The values are in no way connected to the clock time. They are the parameterization for the curve.
8046
* @param {Quaternion[]} options.points The array of {@link Quaternion} control points.
81-
* @param {Quaternion} [options.firstInnerQuadrangle] The inner quadrangle of the curve at the first control point.
82-
* If the inner quadrangle is not given, it will be estimated.
83-
* @param {Quaternion} [options.lastInnerQuadrangle] The inner quadrangle of the curve at the last control point.
84-
* If the inner quadrangle is not given, it will be estimated.
8547
*
8648
* @exception {DeveloperError} points.length must be greater than or equal to 2.
8749
* @exception {DeveloperError} times.length must be equal to points.length.
@@ -96,8 +58,6 @@ define([
9658

9759
var points = options.points;
9860
var times = options.times;
99-
var firstInnerQuadrangle = options.firstInnerQuadrangle;
100-
var lastInnerQuadrangle = options.lastInnerQuadrangle;
10161

10262
//>>includeStart('debug', pragmas.debug);
10363
if (!defined(points) || !defined(times)) {
@@ -111,11 +71,8 @@ define([
11171
}
11272
//>>includeEnd('debug');
11373

114-
var innerQuadrangles = computeInnerQuadrangles(points, firstInnerQuadrangle, lastInnerQuadrangle);
115-
11674
this._times = times;
11775
this._points = points;
118-
this._innerQuadrangles = innerQuadrangles;
11976

12077
this._evaluateFunction = createEvaluateFunction(this);
12178
this._lastTimeIndex = 0;
@@ -148,20 +105,6 @@ define([
148105
get : function() {
149106
return this._points;
150107
}
151-
},
152-
153-
/**
154-
* An array of {@link Quaternion} inner quadrangles for the control points.
155-
*
156-
* @memberof QuaternionSpline.prototype
157-
*
158-
* @type {Quaternion[]}
159-
* @readonly
160-
*/
161-
innerQuadrangles : {
162-
get : function() {
163-
return this._innerQuadrangles;
164-
}
165108
}
166109
});
167110

Specs/Core/QuaternionSplineSpec.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ defineSuite([
7979
var time = (times[2] + times[1]) * 0.5;
8080
var t = (time - times[1]) / (times[2] - times[1]);
8181

82-
var quads = qs.innerQuadrangles;
8382
var actual = qs.evaluate(time);
84-
var expected = Quaternion.squad(points[1], points[2], quads[1], quads[2], t, new Quaternion());
83+
var expected = Quaternion.slerp(points[1], points[2], t, new Quaternion());
8584
expect(actual).toEqualEpsilon(expected, CesiumMath.EPSILON6);
8685
});
8786

0 commit comments

Comments
 (0)