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

3d tiles unary ops #4628

Merged
merged 23 commits into from
Nov 21, 2016
Merged

3d tiles unary ops #4628

merged 23 commits into from
Nov 21, 2016

Conversation

Dylan-Brown
Copy link
Contributor

PR for #4603

addStyle('Cos', {
color : "color() * cos(${temperature} - 0)"
addStyle('Trigonometric Functions', {
color : "color() * radians(cos(${temperature} - 0)) + color() * sin(${temperature} - 0) + color() * tan(${temperature} - 0)"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the - 0s?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I figured they would just be easier to tweak, but I'll remove them

color : "color() * cos(${temperature} - 0)"
addStyle('Trigonometric Functions', {
color : "color() * radians(cos(${temperature} - 0)) + color() * sin(${temperature} - 0) + color() * tan(${temperature} - 0)"

Copy link
Contributor

Choose a reason for hiding this comment

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

Minor, but extra whitespace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure where I should put it.

Copy link
Contributor

Choose a reason for hiding this comment

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

@pjcozzi means just to remove it.

acos : Math.acos,
asin : Math.asin,
atan : Math.atan,
radians : function(left) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I write
radians : CesiumMath.toRadians(), degrees : CesiumMath.toDegrees()
JSHint informs me that CesiumMath is undefined. I see the functions are defined in the file there. How do I reference them? Maybe this is a javascript thing I don't yet understand

Copy link
Contributor

Choose a reason for hiding this comment

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

Make sure CesiumMath is included correctly, check out https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Specs/Core/Cartesian4Spec.js for example.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also it should be radians : CesiumMath.toRadians, degrees : CesiumMath.toDegrees

Copy link
Contributor Author

Choose a reason for hiding this comment

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

alright finally done

@@ -346,7 +363,7 @@ define([
//>>includeEnd('debug');
val = createRuntimeAst(expression, args[0]);
return new Node(ExpressionNodeType.UNARY, call, val);
} else if (call === 'cos') {
} else if (defined(unaryFunctions[call])) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the abs section above.

}

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this empty line so that the else if below is attached, even though it is wrapped with a pragma.

return evaluate(this._left.evaluate(feature));
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Place this function closer to the other evaluate functions. Right above evaluateLiteral is fine.

}).toThrowDeveloperError();
});

t('evaluates atan function', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be it.


it('evaluates radians function', function() {
var expression = new Expression('radians(0)');
expect(expression.evaluate(undefined)).toEqual(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

To improve this test use a value instead of 0. You can build the style string to support PI - like 'radians(' + Math.PI + ')'

Copy link
Contributor

Choose a reason for hiding this comment

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

You can use radians(PI) now: CesiumGS/3d-tiles#151

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You want me to convert radians to radians?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah sorry, this comment applies to the degrees function. Also the degrees comment applies here.


it('evaluates degrees function', function() {
var expression = new Expression('degrees(0)');
expect(expression.evaluate(undefined)).toEqual(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Also tweak this test to something like degrees(360), toEqual(Math.PI). If floating precision is an issue, you can use toEqualEpsilon.

Copy link
Contributor

Choose a reason for hiding this comment

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

Whoops, meant 2 * Math.PI

});

addStyle('Arc Trigonometric Functions', {
color : "color() * degrees(acos(${temperature} - 0)) + color() * asin(${temperature} - 0) + color() * atan(${temperature} - 0)"
});
Copy link
Contributor

Choose a reason for hiding this comment

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

This test produces just a pure white, try tweaking the values a bit.

Also styling based on time is now possible with #4626 so you can incorporate that in some way.

var evaluate = unaryFunctions[call];
return function(feature) {
return evaluate(this._left.evaluate(feature));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing semicolon

});

addStyle('Arc Trigonometric Functions', {
color : "color() * degrees(acos(${temperature})) + color() * asin(${temperature}) + color() * atan(${temperature}) - 30"
Copy link
Contributor

Choose a reason for hiding this comment

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

These two samples still produce pure white. Try to tweak them a bit.

For the first one removing the +30 helps. For the second one both the -30 and the degrees are keeping it white. When the channels of the color are greater than 1.0 it will be white.

asin : Math.asin,
atan : Math.atan,
radians : CesiumMath.toRadians(),
degrees : CesiumMath.toDegrees()
Copy link
Contributor

Choose a reason for hiding this comment

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

For this area make sure to address these comments:

#4628 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've done as suggested, but I'm having trouble running a local copy of sandcastle so I'm trying to fix that now so I can come up with a better styling case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I redownloaded my repo and even though I'm on my 3d-tiles-unary-ops branch, the 3D tiles style sandcastle file is just gone, with a lot of others, even though they're showing up in my repo on github? I don't understand how that's happening

Copy link
Contributor

Choose a reason for hiding this comment

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

Is the html file gone or is the file just missing from the list in Sandcastle? If you haven't already make sure to do npm run build .

Copy link
Contributor Author

@Dylan-Brown Dylan-Brown Nov 18, 2016

Choose a reason for hiding this comment

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

Something weird happened but removing and readding the directory fixed it. However, when I run npm install it fails:

npm ERR! Linux 3.13.0-79-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! [email protected] postinstall: node install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'node install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the electron package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs electron
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls electron
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think I follow. You mean all the statements like "//>>includeEnd('debug')" ?

Copy link
Contributor

Choose a reason for hiding this comment

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

What you're doing in the screenshot is fine (though we alphabetize the order in the first first array instead of the second, so ../Core/Math should be after isArray). The code pushed to github has a bunch of unnecessary includes in it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see you're newest commit, yeah that's what I meant.

Copy link
Contributor

Choose a reason for hiding this comment

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

One last thing, the CesiumMath in the second array needs to be at the same index.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha, changed and committed, waiting on Travis now

Node.prototype._evaluateBooleanConversion = function(feature) {
return Boolean(this._left.evaluate(feature));
};

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this function, it is a duplicate of below. Also remove _evaluateAbsoluteValue, _evaluateCosine, _evaluateSquareRoot.

@lilleyse
Copy link
Contributor

@Dylan-Brown this is really close, just these few more comments.

@lilleyse
Copy link
Contributor

In case you missed this comment, this should fix the failure: #4628 (comment)

@Dylan-Brown
Copy link
Contributor Author

Dylan-Brown commented Nov 18, 2016

The error with the check is:
"Expected 20626.480624709635 to equal epsilon 6.283185307179586, 1e-10."
the test that fails is:
it('evaluates degrees function', function() { var expression = new Expression('degrees(360)'); expect(expression.evaluate(undefined)).toEqualEpsilon(2*Math.PI, CesiumMath.EPSILON10); });
I think this means there's something wrong with CesiumMath.toDegrees. Investigating now

EDIT: Nope. just relized I was converting 360 radians into degrees.

});

it('evaluates degrees function', function() {
var expression = new Expression('degrees(' + 2*Math.PI + ')');
Copy link
Contributor

Choose a reason for hiding this comment

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

All else looks good, this should be my last comment - Now with PI supported in the styling language just change this back to 'degrees(2 * PI)'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@lilleyse
Copy link
Contributor

Awesome I'm glad to merge this!

@lilleyse lilleyse merged commit d7f2aa6 into CesiumGS:3d-tiles Nov 21, 2016
@lilleyse
Copy link
Contributor

Next up just add these functions to https://github.com/AnalyticalGraphicsInc/3d-tiles.

@pjcozzi
Copy link
Contributor

pjcozzi commented Nov 21, 2016

Nice work here, thanks again @Dylan-Brown!

@Dylan-Brown Dylan-Brown deleted the 3d-tiles-unary-ops branch November 21, 2016 22:26
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