-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
More unary fns for 3d-tiles #4775
Changes from 37 commits
ffd91d1
3592d81
888a454
d9fbc91
a3be0fb
2d3dd6e
8d7e29d
9591c46
ba682da
d2ac9f3
cd6b804
664bf5c
bfe278c
e9fd5e1
59e2209
883dc4d
e6e37ac
7210fbd
7e390ea
8cb17a6
0c1313e
c2eb1ec
0635a06
7e85fd4
1bf372e
034b4f1
6945d48
eaaa724
af2704f
9e8ee76
7650e3d
792d246
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,15 @@ define([ | |
asin : Math.asin, | ||
atan : Math.atan, | ||
radians : CesiumMath.toRadians, | ||
degrees : CesiumMath.toDegrees | ||
degrees : CesiumMath.toDegrees, | ||
sign : Math.sign, | ||
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. Use |
||
floor : Math.floor, | ||
ceil : Math.ceil, | ||
exp : Math.exp, | ||
exp2 : exp2, | ||
log : Math.log, | ||
log2 : Math.log2, | ||
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. It turns out this is also not supported for IE. |
||
fract : fract | ||
}; | ||
|
||
/** | ||
|
@@ -362,6 +370,29 @@ define([ | |
} | ||
val = createRuntimeAst(expression, args[0]); | ||
return new Node(ExpressionNodeType.UNARY, call, val); | ||
} else if (call === 'round') { | ||
//>>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 === 'isExactClass' || call === 'isClass') { | ||
//>>includeStart('debug', pragmas.debug); | ||
if (argsLength < 1 || argsLength > 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 === 'getExactClassName') { | ||
//>>includeStart('debug', pragmas.debug); | ||
if (argsLength > 0) { | ||
throw new DeveloperError('Error: ' + call + ' does not take any argument.'); | ||
} | ||
//>>includeEnd('debug'); | ||
return new Node(ExpressionNodeType.UNARY, call); | ||
} else if (defined(unaryFunctions[call])) { | ||
//>>includeStart('debug', pragmas.debug); | ||
if (args.length < 1 || args.length > 1) { | ||
|
@@ -1119,7 +1150,15 @@ define([ | |
return expressions; | ||
} | ||
|
||
Node.prototype.getShaderExpression = function(attributePrefix, shaderState) { | ||
function fract(number) { | ||
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. Place these functions closer to the top, maybe right before |
||
return number - Math.floor(number); | ||
} | ||
|
||
function exp2(exponent) { | ||
return Math.pow(2.0,exponent); | ||
} | ||
|
||
Node.prototype.getShaderExpression = function(attributePrefix, shaderState, parent) { | ||
var color; | ||
var left; | ||
var right; | ||
|
@@ -1184,6 +1223,8 @@ define([ | |
return 'bool(' + left + ')'; | ||
} else if (value === 'Number') { | ||
return 'float(' + left + ')'; | ||
} else if (value === 'round') { | ||
return 'floor(' + left + '0.5)'; | ||
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. Try 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. Hahaha oof, that fixed it. Sorry! |
||
} else if (defined(unaryFunctions[value])) { | ||
return value + '(' + left + ')'; | ||
} else if (value === 'abs') { | ||
|
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.
Since
temperature
is always positive this style won't look very special. One idea could be using the sign of the ${POSITIONS} values (like the tests below).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.
Just a reminder about this comment.
fract
sort of applies here too. Even justsign(${temperature} - 0.5)
may be sufficient.