Appearance
KBE3D / KBCore / Cesium / Expression
类: Expression
An expression for a style applied to a Cesium3DTileset. <p> Evaluates an expression defined using the 3D Tiles Styling language. </p> <p> Implements the StyleExpression interface. </p>
Examples
ts
const expression = new Cesium.Expression('(regExp("^Chest").test(${County})) && (${YearBuilt} >= 1970)');
expression.evaluate(feature); // returns true or false depending on the feature's propertiests
const expression = new Cesium.Expression('(${Temperature} > 90) ? color("red") : color("white")');
expression.evaluateColor(feature, result); // returns a Cesium.Color object参数
The expression defined using the 3D Tiles Styling language.
参数
Defines in the style.
属性
expression
readonlyexpression:string
Gets the expression defined in the 3D Tiles Styling language.
方法
evaluate()
evaluate(
feature:Cesium3DTileFeature,result?:any):string|number|boolean|RegExp|Color|Cartesian3|Cartesian2|Cartesian4
Evaluates the result of an expression, optionally using the provided feature's properties. If the result of the expression in the 3D Tiles Styling language is of type <code>Boolean</code>, <code>Number</code>, or <code>String</code>, the corresponding JavaScript primitive type will be returned. If the result is a <code>RegExp</code>, a Javascript <code>RegExp</code> object will be returned. If the result is a <code>Cartesian2</code>, <code>Cartesian3</code>, or <code>Cartesian4</code>, a Cartesian2, Cartesian3, or Cartesian4 object will be returned. If the <code>result</code> argument is a Color, the Cartesian4 value is converted to a Color and then returned.
参数
feature
The feature whose properties may be used as variables in the expression.
result?
any
The object onto which to store the result.
返回
string | number | boolean | RegExp | Color | Cartesian3 | Cartesian2 | Cartesian4
The result of evaluating the expression.
evaluateColor()
evaluateColor(
feature:Cesium3DTileFeature,result?:Color):Color
Evaluates the result of a Color expression, optionally using the provided feature's properties. <p> This is equivalent to Expression#evaluate but always returns a Color object. </p>
参数
feature
The feature whose properties may be used as variables in the expression.
result?
The object in which to store the result
返回
The modified result parameter or a new Color instance if one was not provided.
构造函数
构造函数
new Expression(
expression?:string,defines?:any):Expression
参数
expression?
string
defines?
any
返回
Expression
