StyleExpression.js 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import DeveloperError from '../Core/DeveloperError.js';
  2. /**
  3. * An expression for a style applied to a {@link Cesium3DTileset}.
  4. * <p>
  5. * Derived classes of this interface evaluate expressions in the
  6. * {@link https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/Styling|3D Tiles Styling language}.
  7. * </p>
  8. * <p>
  9. * This type describes an interface and is not intended to be instantiated directly.
  10. * </p>
  11. *
  12. * @alias StyleExpression
  13. * @constructor
  14. *
  15. * @see Expression
  16. * @see ConditionsExpression
  17. */
  18. function StyleExpression() {
  19. }
  20. /**
  21. * Evaluates the result of an expression, optionally using the provided feature's properties. If the result of
  22. * the expression in the
  23. * {@link https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/Styling|3D Tiles Styling language}
  24. * is of type <code>Boolean</code>, <code>Number</code>, or <code>String</code>, the corresponding JavaScript
  25. * primitive type will be returned. If the result is a <code>RegExp</code>, a Javascript <code>RegExp</code>
  26. * object will be returned. If the result is a <code>Cartesian2</code>, <code>Cartesian3</code>, or <code>Cartesian4</code>,
  27. * a {@link Cartesian2}, {@link Cartesian3}, or {@link Cartesian4} object will be returned. If the <code>result</code> argument is
  28. * a {@link Color}, the {@link Cartesian4} value is converted to a {@link Color} and then returned.
  29. *
  30. * @param {Cesium3DTileFeature} feature The feature whose properties may be used as variables in the expression.
  31. * @param {Object} [result] The object onto which to store the result.
  32. * @returns {Boolean|Number|String|RegExp|Cartesian2|Cartesian3|Cartesian4|Color} The result of evaluating the expression.
  33. */
  34. StyleExpression.prototype.evaluate = function(feature, result) {
  35. DeveloperError.throwInstantiationError();
  36. };
  37. /**
  38. * Evaluates the result of a Color expression, optionally using the provided feature's properties.
  39. * <p>
  40. * This is equivalent to {@link StyleExpression#evaluate} but always returns a {@link Color} object.
  41. * </p>
  42. *
  43. * @param {Cesium3DTileFeature} feature The feature whose properties may be used as variables in the expression.
  44. * @param {Color} [result] The object in which to store the result.
  45. * @returns {Color} The modified result parameter or a new Color instance if one was not provided.
  46. */
  47. StyleExpression.prototype.evaluateColor = function(feature, result) {
  48. DeveloperError.throwInstantiationError();
  49. };
  50. /**
  51. * Gets the shader function for this expression.
  52. * Returns undefined if the shader function can't be generated from this expression.
  53. *
  54. * @param {String} functionName Name to give to the generated function.
  55. * @param {String} attributePrefix Prefix that is added to any variable names to access vertex attributes.
  56. * @param {Object} shaderState Stores information about the generated shader function, including whether it is translucent.
  57. * @param {String} returnType The return type of the generated function.
  58. *
  59. * @returns {String} The shader function.
  60. *
  61. * @private
  62. */
  63. StyleExpression.prototype.getShaderFunction = function(functionName, attributePrefix, shaderState, returnType) {
  64. DeveloperError.throwInstantiationError();
  65. };
  66. export default StyleExpression;