Skip to content

Commit

Permalink
Merge pull request #5740 from moneimne/gltf-2.0
Browse files Browse the repository at this point in the history
Removing quadrilateral interpolation
  • Loading branch information
lilleyse authored Jan 10, 2018
2 parents 8a926d3 + 2a680e7 commit 271d6b3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 62 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
* Updated documentation links to reflect new locations on cesiumjs.org and cesium.com.

### 1.41 - 2018-01-02
Expand Down
63 changes: 3 additions & 60 deletions Source/Core/QuaternionSpline.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -60,15 +28,13 @@ 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);
};
}

/**
* 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 C<sup>1</sup>.
*
* @alias QuaternionSpline
Expand All @@ -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.
Expand All @@ -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)) {
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
}
});

Expand Down
3 changes: 1 addition & 2 deletions Specs/Core/QuaternionSplineSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down

0 comments on commit 271d6b3

Please sign in to comment.