-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
3d tiles unary ops #4628
Conversation
addStyle('Cos', { | ||
color : "color() * cos(${temperature} - 0)" | ||
addStyle('Trigonometric Functions', { | ||
color : "color() * radians(cos(${temperature} - 0)) + color() * sin(${temperature} - 0) + color() * tan(${temperature} - 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.
Why the - 0
s?
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.
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)" | ||
|
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.
Minor, but extra whitespace
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.
I'm not sure where I should put it.
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.
@pjcozzi means just to remove it.
acos : Math.acos, | ||
asin : Math.asin, | ||
atan : Math.atan, | ||
radians : function(left) { |
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.
Here and below use the Cesium math functions: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Core/Math.js#L419-L440
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.
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
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.
Make sure CesiumMath is included correctly, check out https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Specs/Core/Cartesian4Spec.js for example.
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 it should be radians : CesiumMath.toRadians, degrees : CesiumMath.toDegrees
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.
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])) { |
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 abs
section above.
} | ||
|
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 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)); | ||
} | ||
} | ||
|
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.
Place this function closer to the other evaluate functions. Right above evaluateLiteral
is fine.
}).toThrowDeveloperError(); | ||
}); | ||
|
||
t('evaluates atan function', function() { |
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.
Should be it
.
|
||
it('evaluates radians function', function() { | ||
var expression = new Expression('radians(0)'); | ||
expect(expression.evaluate(undefined)).toEqual(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.
To improve this test use a value instead of 0. You can build the style string to support PI - like 'radians(' + Math.PI + ')'
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.
You can use radians(PI)
now: CesiumGS/3d-tiles#151
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.
You want me to convert radians to radians?
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.
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); |
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 tweak this test to something like degrees(360)
, toEqual(Math.PI)
. If floating precision is an issue, you can use toEqualEpsilon
.
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.
Whoops, meant 2 * Math.PI
}); | ||
|
||
addStyle('Arc Trigonometric Functions', { | ||
color : "color() * degrees(acos(${temperature} - 0)) + color() * asin(${temperature} - 0) + color() * atan(${temperature} - 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.
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)); | ||
} |
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.
Missing semicolon
}); | ||
|
||
addStyle('Arc Trigonometric Functions', { | ||
color : "color() * degrees(acos(${temperature})) + color() * asin(${temperature}) + color() * atan(${temperature}) - 30" |
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.
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() |
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.
For this area make sure to address these comments:
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.
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
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.
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
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.
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
.
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.
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:
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.
I don't think I follow. You mean all the statements like "//>>includeEnd('debug')" ?
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.
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.
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.
Ah I see you're newest commit, yeah that's what I meant.
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.
One last thing, the CesiumMath
in the second array needs to be at the same index.
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.
Gotcha, changed and committed, waiting on Travis now
Node.prototype._evaluateBooleanConversion = function(feature) { | ||
return Boolean(this._left.evaluate(feature)); | ||
}; | ||
|
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 this function, it is a duplicate of below. Also remove _evaluateAbsoluteValue
, _evaluateCosine
, _evaluateSquareRoot
.
@Dylan-Brown this is really close, just these few more comments. |
…going to commit small changes until the integration test passes CesiumGS#4603
In case you missed this comment, this should fix the failure: #4628 (comment) |
The error with the check is: EDIT: Nope. just relized I was converting 360 radians into degrees. |
}); | ||
|
||
it('evaluates degrees function', function() { | ||
var expression = new Expression('degrees(' + 2*Math.PI + ')'); |
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.
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)'
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.
Done!
Awesome I'm glad to merge this! |
Next up just add these functions to https://github.com/AnalyticalGraphicsInc/3d-tiles. |
Nice work here, thanks again @Dylan-Brown! |
PR for #4603