-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gltf 2.0 #5641
Gltf 2.0 #5641
Changes from 120 commits
97c1a0d
2471b03
a8afa5e
2170ac5
20cef47
e4f4240
34b63c1
b20e8c4
ad83614
246a848
b4fd22a
c143152
9d8f635
ff84031
b9f304c
12b18cb
8383f57
07f9f44
48aa89d
95e541e
47f3631
3355a84
56cea8c
ee2fca2
9d4fbde
8c0c7e4
92a9696
2d337b4
e6aafe4
cf05283
80c9786
5901bde
860d56f
ebb29ca
b70b357
d959f46
a7ec3c8
8135029
c912f87
4c0054b
6ec4ed8
cad8794
b4a4b16
5ed44c3
298a203
b1e7f89
c9c20a6
29149db
b6a1d9d
b99554d
39514ee
a69ffd1
2d6aac6
99ad146
fec6a0b
878ba35
7e80149
daa974c
f6307d5
9abcc68
de9563b
543b3e5
e010cbe
b78fb0e
3525ec0
e2cab40
8b829f8
1a76302
52b0a9a
f4115d3
01ebf75
a26e072
d4c90c6
4664d52
74480a8
1dd1339
b8d0642
a9df1e6
0eb4d68
531408c
fc4bc50
991efd9
720fedd
d8cc327
8b01cfa
38f36ab
18ba7c0
2edfe41
93a9f96
d28da9d
5f4d86c
b472302
daaaaf6
5d10c5c
b6e2556
c1e63cd
1596185
817c659
1d4598c
182cafe
79dad91
50cf9cb
09307af
bc2a37b
7731c77
8b542e6
63991bf
255f236
0a51bcf
8bb50eb
6db39c5
61b53e9
4a4dbc1
e828f02
e2fca85
90fdc47
613c403
9c04df0
8387389
9f73909
516e7b2
b0186b6
f8f432c
9c2f5d1
611b5c7
b61b5a8
2a7e727
1e0ecef
40a1c04
ccd55dd
e006283
516d18c
67ea9ad
97fc4ec
1ec3181
f73cb3c
8610991
40835a6
14abad1
7996f7c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
/*global define*/ | ||
define([ | ||
'./defaultValue', | ||
'./defined', | ||
'./defineProperties', | ||
'./DeveloperError', | ||
'./Spline' | ||
], function( | ||
defaultValue, | ||
defined, | ||
defineProperties, | ||
DeveloperError, | ||
Spline) { | ||
'use strict'; | ||
|
||
/** | ||
* A spline that uses piecewise linear interpolation to create a curve. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The description should be tweaked to mentioned that its linear interpolation over an array of weight values used by morph targets. |
||
* | ||
* @alias WeightSpline | ||
* @constructor | ||
* | ||
* @param {Object} options Object with the following properties: | ||
* @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 {Number[]} options.points The array of floating-point control points given | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
* | ||
* @exception {DeveloperError} points.length must be greater than or equal to 2. | ||
* @exception {DeveloperError} times.length must be a factor of points.length. | ||
* | ||
* | ||
* @example | ||
* var times = [ 0.0, 1.5, 3.0, 4.5, 6.0 ]; | ||
* var spline = new Cesium.WeightSpline({ | ||
* times : times, | ||
* points : [ | ||
* [0.0, -1.0, 1.0], | ||
* [0.5, -0.5, 0.5], | ||
* [1.0, 0.0, 0.0], | ||
* [0.5, 0.5, -0.5], | ||
* [0.0, 1.0, -1.0] | ||
* ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this example be a contiguous array? |
||
* }); | ||
* | ||
* var p0 = spline.evaluate(times[0]); | ||
* | ||
* @see LinearSpline | ||
* @see HermiteSpline | ||
* @see CatmullRomSpline | ||
* @see QuaternionSpline | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add |
||
*/ | ||
function WeightSpline(options) { | ||
options = defaultValue(options, defaultValue.EMPTY_OBJECT); | ||
|
||
var points = options.points; | ||
var times = options.times; | ||
|
||
//>>includeStart('debug', pragmas.debug); | ||
if (!defined(points) || !defined(times)) { | ||
throw new DeveloperError('points and times are required.'); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For all new code use |
||
if (points.length < 2) { | ||
throw new DeveloperError('points.length must be greater than or equal to 2.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
} | ||
if (points.length % times.length !== 0) { | ||
throw new DeveloperError('times.length must be a factor of points.length.'); | ||
} | ||
//>>includeEnd('debug'); | ||
|
||
this._times = times; | ||
this._points = points; | ||
this._count = points.length / times.length; | ||
|
||
this._lastTimeIndex = 0; | ||
} | ||
|
||
defineProperties(WeightSpline.prototype, { | ||
/** | ||
* An array of times for the control points. | ||
* | ||
* @memberof WeightSpline.prototype | ||
* | ||
* @type {Number[]} | ||
* @readonly | ||
*/ | ||
times : { | ||
get : function() { | ||
return this._times; | ||
} | ||
}, | ||
|
||
/** | ||
* An array of floating-point array control points. | ||
* | ||
* @memberof WeightSpline.prototype | ||
* | ||
* @type {Number[][]} | ||
* @readonly | ||
*/ | ||
points : { | ||
get : function() { | ||
return this._points; | ||
} | ||
}, | ||
|
||
/** | ||
* The number of control point sets provided | ||
* | ||
* @memberof WeightSpline.prototype | ||
* | ||
* @type {Number} | ||
* @readonly | ||
*/ | ||
count: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this getter used externally? If not remove this and use |
||
get: function() { | ||
return this._count; | ||
} | ||
} | ||
}); | ||
|
||
/** | ||
* Finds an index <code>i</code> in <code>times</code> such that the parameter | ||
* <code>time</code> is in the interval <code>[times[i], times[i + 1]]</code>. | ||
* @function | ||
* | ||
* @param {Number} time The time. | ||
* @returns {Number} The index for the element at the start of the interval. | ||
* | ||
* @exception {DeveloperError} time must be in the range <code>[t<sub>0</sub>, t<sub>n</sub>]</code>, where <code>t<sub>0</sub></code> | ||
* is the first element in the array <code>times</code> and <code>t<sub>n</sub></code> is the last element | ||
* in the array <code>times</code>. | ||
*/ | ||
WeightSpline.prototype.findTimeInterval = Spline.prototype.findTimeInterval; | ||
|
||
/** | ||
* Evaluates the curve at a given time. | ||
* | ||
* @param {Number} time The time at which to evaluate the curve. | ||
* @param {Number[]} [result] The object onto which to store the result. | ||
* @returns {Number[]} The modified result parameter or a new instance of the point on the curve at the given time. | ||
* | ||
* @exception {DeveloperError} time must be in the range <code>[t<sub>0</sub>, t<sub>n</sub>]</code>, where <code>t<sub>0</sub></code> | ||
* is the first element in the array <code>times</code> and <code>t<sub>n</sub></code> is the last element | ||
* in the array <code>times</code>. | ||
*/ | ||
WeightSpline.prototype.evaluate = function(time, result) { | ||
var points = this.points; | ||
var times = this.times; | ||
|
||
var i = this._lastTimeIndex = this.findTimeInterval(time, this._lastTimeIndex); | ||
var u = (time - times[i]) / (times[i + 1] - times[i]); | ||
|
||
if (!defined(result)) { | ||
result = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While the code will still work, it is better to allocate the array with the correct size: |
||
} | ||
|
||
for (var j = 0; j < this.count; j++) { | ||
var index = (i * this.count) + j; | ||
result[j] = points[index] * (1.0 - u) + points[index + this.count] * (u); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The parentheses around |
||
} | ||
|
||
return result; | ||
}; | ||
|
||
return WeightSpline; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1436,6 +1436,23 @@ define([ | |
} | ||
}), | ||
|
||
czm_brdfLUT : new AutomaticUniform({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminder to write doc for this. |
||
size : 1, | ||
datatype : WebGLConstants.SAMPLER_2D, | ||
getValue : function(uniformState) { | ||
return uniformState.brdfLUT; | ||
} | ||
}), | ||
|
||
// TODO: Docs | ||
czm_cubeMap : new AutomaticUniform({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given @emackey's work on procedural reflections, remove |
||
size : 1, | ||
datatype : WebGLConstants.SAMPLER_CUBE, | ||
getValue : function(uniformState) { | ||
return uniformState.cubeMap; | ||
} | ||
}), | ||
|
||
/** | ||
* An automatic GLSL uniform representing a 3x3 rotation matrix that transforms | ||
* from True Equator Mean Equinox (TEME) axes to the pseudo-fixed axes at the current scene time. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
define([ | ||
'./Sampler', | ||
'../Core/BoundingRectangle', | ||
'../Core/Cartesian2', | ||
'../Core/Cartesian3', | ||
|
@@ -16,6 +17,7 @@ define([ | |
'../Core/Transforms', | ||
'../Scene/SceneMode' | ||
], function( | ||
Sampler, | ||
BoundingRectangle, | ||
Cartesian2, | ||
Cartesian3, | ||
|
@@ -150,6 +152,9 @@ define([ | |
this._orthographicIn3D = false; | ||
this._backgroundColor = new Color(); | ||
|
||
this._brdfLUT = new Sampler(); | ||
this._cubeMap = new Sampler(); | ||
|
||
this._fogDensity = undefined; | ||
|
||
this._imagerySplitPosition = 0.0; | ||
|
@@ -796,6 +801,20 @@ define([ | |
} | ||
}, | ||
|
||
// TODO: Docs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminder to write doc. |
||
brdfLUT : { | ||
get : function() { | ||
return this._brdfLUT; | ||
} | ||
}, | ||
|
||
// TODO: Docs | ||
cubeMap : { | ||
get : function() { | ||
return this._cubeMap; | ||
} | ||
}, | ||
|
||
/** | ||
* @memberof UniformState.prototype | ||
* @type {Number} | ||
|
@@ -975,6 +994,10 @@ define([ | |
|
||
setSunAndMoonDirections(this, frameState); | ||
|
||
this._brdfLUT = frameState.brdfLUT; | ||
|
||
this._cubeMap = frameState.cubeMap; | ||
|
||
this._fogDensity = frameState.fog.density; | ||
|
||
this._frameState = frameState; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the indentation to be consistent with other files like:
Also remove
/*global define*/
which is no longer used.