-
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
CZML model node transformations #3316
Changes from 17 commits
c3903fc
7a65133
818529e
895c914
9b48563
4462be8
f005d20
06ad0e8
9359a01
22f6ef3
f2e0d0e
8e4f397
46b8234
7a321e1
7755e22
8d38198
4a3b0b7
781952f
a90ddbc
8ea6732
21ee2ae
5bbf684
ac342c1
3147d89
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,61 @@ | ||
/*global define*/ | ||
define([ | ||
'../Core/Cartesian3', | ||
'../Core/defaultValue', | ||
'../Core/Matrix4', | ||
'../Core/Quaternion' | ||
], function( | ||
Cartesian3, | ||
defaultValue, | ||
Matrix4, | ||
Quaternion) { | ||
"use strict"; | ||
|
||
var defaultScale = new Cartesian3(1.0, 1.0, 1.0); | ||
var defaultTranslation = Cartesian3.ZERO; | ||
var defaultRotation = Quaternion.IDENTITY; | ||
|
||
/** | ||
* A set of transformations to apply to a particular node in a {@link Model}. | ||
* @alias NodeTransformation | ||
* @constructor | ||
* | ||
* @param {Cartesian3} [scale=new Cartesian3(1.0, 1.0, 1.0)] A {@link Cartesian3} specifying the (x, y, z) scaling to apply to the node. | ||
* @param {Cartesian3} [translation=Cartesian3.ZERO] A {@link Cartesian3} specifying the (x, y, z) translation to apply to the node. | ||
* @param {Quaternion.IDENTITY} [rotation=Quaternion.IDENTITY] A {@link Quaternion} specifying the (x, y, z, w) rotation to apply to the node. | ||
*/ | ||
var NodeTransformation = function(scale, translation, rotation) { | ||
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. I understand why this is in DataSources, but it certainly looks like something I would except to be in Core. Are we sure that we're never going to need something like this at the lower level? 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.
Throughout, the parameters should also be in that order: translation, rotation, scale. TRS, as it is called, is common in graphics and what we say in glTF. 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. OK, renamed to |
||
/** | ||
* The (x, y, z) scaling to apply to the node. | ||
* @type {Cartesian3} | ||
* @default new Cartesian3(1.0, 1.0, 1.0) | ||
*/ | ||
this.scale = Cartesian3.clone(defaultValue(scale, defaultScale)); | ||
|
||
/** | ||
* The (x, y, z) translation to apply to the node. | ||
* @type {Cartesian3} | ||
* @default Cartesian3.ZERO | ||
*/ | ||
this.translation = Cartesian3.clone(defaultValue(translation, defaultTranslation)); | ||
|
||
/** | ||
* The (x, y, z, w) rotation to apply to the node. | ||
* @type {Quaternion} | ||
* @default Quaternion.IDENTITY | ||
*/ | ||
this.rotation = Quaternion.clone(defaultValue(rotation, defaultRotation)); | ||
}; | ||
|
||
/** | ||
* Combine this transformation into a single {@link Matrix4}. | ||
* | ||
* @param {Matrix4} [result] The object onto which to store the result. | ||
* @returns {Matrix4} The modified result parameter or a new Matrix4 instance if one was not provided. | ||
*/ | ||
NodeTransformation.prototype.toMatrix = function(result) { | ||
return Matrix4.fromTranslationQuaternionRotationScale(this.translation, this.rotation, this.scale, result); | ||
}; | ||
|
||
return NodeTransformation; | ||
}); |
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.
This function is empty and can just be removed now.