English中文

ConditionsExpression

new Cesium.ConditionsExpression(conditionsExpression, defines)

应用于样式的表达式 An expression for a style applied to a Cesium3DTileset.

评估使用定义的条件表达式 Evaluates a conditions expression defined using the 3D Tiles Styling language.

实现了 Implements the StyleExpression interface.

名称 Name 类型 Type 说明 Description
conditionsExpression object 可选 optional 使用 3D Tiles Styling 语言定义的条件表达式。 The conditions expression defined using the 3D Tiles Styling language.
defines object 可选 optional 在样式中定义。 Defines in the style.
示例: Example:
const expression = new Cesium.ConditionsExpression({
    conditions : [
        ['${Area} > 10, 'color("#FF0000")'],
        ['${id} !== "1"', 'color("#00FF00")'],
        ['true', 'color("#FFFFFF")']
    ]
});
expression.evaluateColor(feature, result); // returns a Cesium.Color object

成员 Members

readonly conditionsExpression : object

获取在 3D Tiles Styling 语言中定义的条件表达式。 Gets the conditions expression defined in the 3D Tiles Styling language.
默认值: Default Value: undefined

方法 Methods

evaluate(feature, result)boolean|number|string|RegExp|Cartesian2|Cartesian3|Cartesian4|Color

评估表达式的结果,可以选择使用提供的功能的属性。如果表达式的结果在 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 Boolean, Number, 或 , or String,将返回相应的 JavaScript 原始类型。如果结果是 , the corresponding JavaScript primitive type will be returned. If the result is a RegExp, 一个 JavaScript , a Javascript RegExp 对象将被返回。如果结果是 object will be returned. If the result is a Cartesian2, Cartesian3, 或 , or Cartesian4, 一个 , a Cartesian2, Cartesian3, 或 , or Cartesian4 对象将被返回。如果 object will be returned. If the result 参数是一个 argument is a Color, 的 , the Cartesian4 值被转换为 value is converted to a Color 然后返回。 and then returned.
名称 Name 类型 Type 说明 Description
feature Cesium3DTileFeature 其属性可用作表达式中的变量的特征。 The feature whose properties may be used as variables in the expression.
result object 可选 optional 用于存储结果的对象。 The object onto which to store the result.
返回: Returns:
计算表达式的结果。 The result of evaluating the expression.

evaluateColor(feature, result)Color

使用特征定义的值评估颜色表达式的结果。 Evaluates the result of a Color expression, using the values defined by a feature.

这相当于 This is equivalent to ConditionsExpression#evaluate 但总是返回一个 but always returns a Color object.

名称 Name 类型 Type 说明 Description
feature Cesium3DTileFeature 其属性可用作表达式中的变量的特征。 The feature whose properties may be used as variables in the expression.
result Color 可选 optional 存储结果的对象 The object in which to store the result
返回: Returns:
修改后的结果参数或新的 Color 实例(如果未提供)。 The modified result parameter or a new Color instance if one was not provided.
需要帮助吗?获得答案的最快方法是从社区和团队那里获得答案 Need help? The fastest way to get answers is from the community and team on the Cesium Forum.