Skip to content
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

Ability to load z-up models #4962

Merged
merged 5 commits into from
Feb 9, 2017
Merged

Ability to load z-up models #4962

merged 5 commits into from
Feb 9, 2017

Conversation

lilleyse
Copy link
Contributor

@lilleyse lilleyse commented Feb 7, 2017

For CesiumGS/3d-tiles#175

Added zUp undocumented option to Model. After I'm going to open a PR in the 3d-tiles branch for loading tilesets whose models are z-up.

@mramato
Copy link
Contributor

mramato commented Feb 7, 2017

Is the option undocumented because it's only going to be used internally by 3D Tiles?

@lilleyse
Copy link
Contributor Author

lilleyse commented Feb 7, 2017

At this point yes, but I could see its use as a public option too especially for georeferenced models.

@@ -624,6 +624,9 @@ define([
this._pickUniformMapLoaded = options.pickUniformMapLoaded;
this._ignoreCommands = defaultValue(options.ignoreCommands, false);

// By default models are y-up according to the glTF spec, however geo-referenced models will typically be z-up
this._zUp = defaultValue(options.zUp, false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you want to expose it like this? Why not expose it the same way as it will be in the 3D Tiles spec using x, y, and z enums here.

Also, drop the underscore and mark it @private.

@pjcozzi
Copy link
Contributor

pjcozzi commented Feb 8, 2017

Just that comment.

@lilleyse
Copy link
Contributor Author

lilleyse commented Feb 8, 2017

This supports all axes now via a pretty simple Axis class.

*
* @exports Axis
*/
var Axis = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mark this @private.

* @type {String}
* @constant
*/
X : 'X',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure we should use strings here? That is fine for the format, but generally not something we would do for the runtime.

Perhaps make these 0, 1, 2, and provide a static creation function? Perhaps even move yUpToZUp and zUpToZUp here as frozen properties for better cohesion.

@@ -85,7 +87,10 @@ defineSuite([
var texturedBoxCustomUrl = './Data/Models/Box-Textured-Custom/CesiumTexturedBoxTest.gltf';
var texturedBoxKhrBinaryUrl = './Data/Models/Box-Textured-Binary/CesiumTexturedBoxTest.glb';
var boxRtcUrl = './Data/Models/Box-RTC/Box.gltf';
var boxesEcefUrl = './Data/Models/Boxes-ECEF/ecef.glb';
var boxEcefXUpUrl = './Data/Models/Box-ECEF/ecef-x-up.gltf';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having three copies of the data, is it reasonable to have one copy (with squashed commits) and just have the test do a small change to the model at load? This will be less test data and easier to update to glTF 2.0.

@lilleyse
Copy link
Contributor Author

lilleyse commented Feb 8, 2017

Updated

@lilleyse
Copy link
Contributor Author

lilleyse commented Feb 8, 2017

I may as well include all possible axis conversions... I'll update when ready.

* @returns {Number} The axis enum.
*/
fromName : function(name) {
return Axis[name];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really sorry, but name is required so this should throw an exception, right?

* @private
* @readonly
*/
this.upAxis = defaultValue(options.upAxis, Axis.Y);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this user an explicit getter so readonly is enforced?

@lilleyse
Copy link
Contributor Author

lilleyse commented Feb 8, 2017

Ok this should be everything. I changed the x-up to z-up transform to use a negative rotation instead. If someone could double check all the conversions that would be good - but I think they are all correct for a right-handed coordinate system.

@pjcozzi pjcozzi merged commit 4e45e4b into master Feb 9, 2017
@pjcozzi pjcozzi deleted the model-z-up branch February 9, 2017 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants