-
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
Merged
Merged
3d tiles unary ops #4628
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
ec8ff9e
added sin, tan #4603
Dylan-Brown d4eaf60
added acos, asin, atan #4603
Dylan-Brown 3c5b870
small adjustment for 3d demo, separated trig, arc trig functions #4603
Dylan-Brown 8bafd01
added radians, degrees, not to demo #4603
Dylan-Brown 68ac1a1
data driven #4603
Dylan-Brown c185368
data driven #4603 removed excess functions, added degrees/radians
Dylan-Brown 9dd5f1e
forgot to delete a few lines #4603
Dylan-Brown 5689d49
styling examples #4603
Dylan-Brown f951df0
fixed merge #4603
Dylan-Brown 31a3e76
updated based on suggestions #4603
Dylan-Brown 0f11c24
removed abs, sqrt section #4603
Dylan-Brown 0477a6f
updated conversion from 0 radians to pi #4603
Dylan-Brown 4ee3b34
removed duplicate functions, imported CesiumMath, styling update(?) #…
Dylan-Brown 9cd51cf
#4603 found math issue
Dylan-Brown 24cd1be
#4603 merge conflict resolved
Dylan-Brown 6c56dac
includes? #5603
Dylan-Brown d6fa4d7
I really don't understand this define function and can't test so I'm …
Dylan-Brown 91c6b69
#4603 hope this works
Dylan-Brown 4463339
updated test cases
Dylan-Brown 5d99266
nevermind
Dylan-Brown f94c4ce
alright
Dylan-Brown 341c363
alright pt. 2
Dylan-Brown 3b7f6e5
updated to reflect PI in the styling language
Dylan-Brown File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ define([ | |
'../Core/defineProperties', | ||
'../Core/DeveloperError', | ||
'../Core/isArray', | ||
'../Core/Math', | ||
'../ThirdParty/jsep', | ||
'./ExpressionNodeType' | ||
], function( | ||
|
@@ -13,6 +14,7 @@ define([ | |
defineProperties, | ||
DeveloperError, | ||
isArray, | ||
CesiumMath, | ||
jsep, | ||
ExpressionNodeType) { | ||
"use strict"; | ||
|
@@ -43,6 +45,19 @@ define([ | |
} | ||
}; | ||
|
||
var unaryFunctions = { | ||
abs : Math.abs, | ||
sqrt : Math.sqrt, | ||
cos : Math.cos, | ||
sin : Math.sin, | ||
tan : Math.tan, | ||
acos : Math.acos, | ||
asin : Math.asin, | ||
atan : Math.atan, | ||
radians : CesiumMath.toRadians, | ||
degrees : CesiumMath.toDegrees | ||
}; | ||
|
||
/** | ||
* Evaluates an expression defined using the | ||
* {@link https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/Styling|3D Tiles Styling language}. | ||
|
@@ -340,23 +355,7 @@ define([ | |
} | ||
val = createRuntimeAst(expression, args[0]); | ||
return new Node(ExpressionNodeType.UNARY, call, val); | ||
} else if (call === 'abs') { | ||
//>>includeStart('debug', pragmas.debug); | ||
if (args.length < 1 || args.length > 1) { | ||
throw new DeveloperError('Error: ' + call + ' requires exactly one argument.'); | ||
} | ||
//>>includeEnd('debug'); | ||
val = createRuntimeAst(expression, args[0]); | ||
return new Node(ExpressionNodeType.UNARY, call, val); | ||
} else if (call === 'cos') { | ||
//>>includeStart('debug', pragmas.debug); | ||
if (args.length < 1 || args.length > 1) { | ||
throw new DeveloperError('Error: ' + call + ' requires exactly one argument.'); | ||
} | ||
//>>includeEnd('debug'); | ||
val = createRuntimeAst(expression, args[0]); | ||
return new Node(ExpressionNodeType.UNARY, call, val); | ||
} else if (call === 'sqrt') { | ||
} else if (defined(unaryFunctions[call])) { | ||
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. Remove the |
||
//>>includeStart('debug', pragmas.debug); | ||
if (args.length < 1 || args.length > 1) { | ||
throw new DeveloperError('Error: ' + call + ' requires exactly one argument.'); | ||
|
@@ -599,12 +598,8 @@ define([ | |
node.evaluate = node._evaluateNaN; | ||
} else if (node._value === 'isFinite') { | ||
node.evaluate = node._evaluateIsFinite; | ||
} else if (node._value === 'abs') { | ||
node.evaluate = node._evaluateAbsoluteValue; | ||
} else if (node._value === 'cos') { | ||
node.evaluate = node._evaluateCosine; | ||
} else if (node._value === 'sqrt') { | ||
node.evaluate = node._evaluateSquareRoot; | ||
} else if (defined(unaryFunctions[node._value])) { | ||
node.evaluate = getEvaluateUnaryFunction(node._value); | ||
} else if (node._value === 'Boolean') { | ||
node.evaluate = node._evaluateBooleanConversion; | ||
} else if (node._value === 'Number') { | ||
|
@@ -643,6 +638,13 @@ define([ | |
return feature._content._tileset.timeSinceLoad; | ||
} | ||
|
||
function getEvaluateUnaryFunction(call) { | ||
var evaluate = unaryFunctions[call]; | ||
return function(feature) { | ||
return evaluate(this._left.evaluate(feature)); | ||
}; | ||
} | ||
|
||
Node.prototype._evaluateLiteral = function(frameState, feature) { | ||
return this._value; | ||
}; | ||
|
@@ -940,18 +942,6 @@ define([ | |
return isFinite(this._left.evaluate(frameState, feature)); | ||
}; | ||
|
||
Node.prototype._evaluateAbsoluteValue = function(frameState, feature) { | ||
return Math.abs(this._left.evaluate(frameState, feature)); | ||
}; | ||
|
||
Node.prototype._evaluateCosine = function(frameState, feature) { | ||
return Math.cos(this._left.evaluate(frameState, feature)); | ||
}; | ||
|
||
Node.prototype._evaluateSquareRoot = function(frameState, feature) { | ||
return Math.sqrt(this._left.evaluate(frameState, feature)); | ||
}; | ||
|
||
Node.prototype._evaluateBooleanConversion = function(frameState, feature) { | ||
return Boolean(this._left.evaluate(frameState, feature)); | ||
}; | ||
|
@@ -1169,6 +1159,8 @@ define([ | |
return 'bool(' + left + ')'; | ||
} else if (value === 'Number') { | ||
return 'float(' + left + ')'; | ||
} else if (defined(unaryFunctions[value])) { | ||
return value + '(' + left + ')'; | ||
} else if (value === 'abs') { | ||
return 'abs(' + left + ')'; | ||
} else if (value === 'cos') { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.