-
Notifications
You must be signed in to change notification settings - Fork 157
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
Validator - check that normals are unit length #116
Conversation
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.
Looks good!
validator/lib/utility.js
Outdated
result.z = 1.0 - (Math.abs(result.x) + Math.abs(result.y)); | ||
|
||
if (result.z < 0.0) | ||
{ |
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.
Style: put on one line: if (result.z < 0.0) {
@@ -183,22 +188,89 @@ function validateI3dm(content) { | |||
return 'Feature table property NORMAL_RIGHT is required when NORMAL_UP is present.'; | |||
} | |||
|
|||
if (defined(!featureTableJson.NORMAL_UP) && defined(featureTableJson.NORMAL_RIGHT)) { | |||
if (!defined(featureTableJson.NORMAL_UP) && defined(featureTableJson.NORMAL_RIGHT)) { |
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.
Good catches.
validator/lib/validateI3dm.js
Outdated
var i; | ||
|
||
if (defined(featureTableJson.NORMAL_UP)) { | ||
featureTable.featuresLength = featuresLength * 3; |
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.
Better practice is for featureTable.featuresLength
to always be set to featuresLength
, and then set the componentLength
argument of getPropertyArray
to 3.
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.
Also make any similar changes in validatePnts
.
validator/lib/validateI3dm.js
Outdated
|
||
if (defined(featureTableJson.NORMAL_UP)) { | ||
featureTable.featuresLength = featuresLength * 3; | ||
componentDatatype = ComponentDatatype.fromName(defaultValue(featureTableJson.NORMAL_UP.componentType, 'FLOAT', 3)); |
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.
Remove the last argument of the defaultValue
.
validator/lib/validateI3dm.js
Outdated
if(octUp) { | ||
octDecodeWithoutNormalization(normalUp[i*2], normalUp[i*2+1], 65535, normalUpVec3); | ||
} else { | ||
Cartesian3.fromElements(normalUp[i*3], normalUp[i*3+1], normalUp[i*3+2], normalUpVec3); |
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.
Cartesian3.unpack
is a little cleaner to use here.
validator/lib/validateI3dm.js
Outdated
|
||
if(defined(normalUp) && defined(normalRight)) { | ||
for(i = 0; i < featuresLength; i++) { | ||
var normalUpVec3 = new Cartesian3(); |
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.
Put this outside of the for loop so that we only have to allocate a Cartesian3
once.
Also rename to normalUp
.
validator/lib/validateI3dm.js
Outdated
return 'normal defined in NORMAL_UP must be of length 1.0'; | ||
} | ||
var normalRightMagnitude = Cartesian3.magnitude(normalRightVec3); | ||
if(Math.abs(normalRightMagnitude - 1.0) > Cesium.Math.EPSILON2) { |
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.
Throughout for style purposes add a space like if (
@lilleyse Should be good now! |
Fixes #112
Checks that normals are of unit length for i3dm and pnts.
Also checks that normal up and normal right are orthogonal for i3dm.
Created a helper function in utility.js for converting an oct-encoded vector to Catresian3, like cesium's
AttributeCompression.octDecodeInRange
, but without normalization.