StyleExpression.js 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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/CesiumGS/3d-tiles/tree/main/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. * Evaluates the result of an expression, optionally using the provided feature's properties. If the result of
  21. * the expression in the
  22. * {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification/Styling|3D Tiles Styling language}
  23. * is of type <code>Boolean</code>, <code>Number</code>, or <code>String</code>, the corresponding JavaScript
  24. * primitive type will be returned. If the result is a <code>RegExp</code>, a Javascript <code>RegExp</code>
  25. * object will be returned. If the result is a <code>Cartesian2</code>, <code>Cartesian3</code>, or <code>Cartesian4</code>,
  26. * a {@link Cartesian2}, {@link Cartesian3}, or {@link Cartesian4} object will be returned. If the <code>result</code> argument is
  27. * a {@link Color}, the {@link Cartesian4} value is converted to a {@link Color} and then returned.
  28. *
  29. * @param {Cesium3DTileFeature} feature The feature whose properties may be used as variables in the expression.
  30. * @param {object} [result] The object onto which to store the result.
  31. * @returns {boolean|number|string|RegExp|Cartesian2|Cartesian3|Cartesian4|Color} The result of evaluating the expression.
  32. */
  33. StyleExpression.prototype.evaluate = function (feature, result) {
  34. DeveloperError.throwInstantiationError();
  35. };
  36. /**
  37. * Evaluates the result of a Color expression, optionally using the provided feature's properties.
  38. * <p>
  39. * This is equivalent to {@link StyleExpression#evaluate} but always returns a {@link Color} object.
  40. * </p>
  41. *
  42. * @param {Cesium3DTileFeature} feature The feature whose properties may be used as variables in the expression.
  43. * @param {Color} [result] The object in which to store the result.
  44. * @returns {Color} The modified result parameter or a new Color instance if one was not provided.
  45. */
  46. StyleExpression.prototype.evaluateColor = function (feature, result) {
  47. DeveloperError.throwInstantiationError();
  48. };
  49. /**
  50. * Gets the shader function for this expression.
  51. * Returns undefined if the shader function can't be generated from this expression.
  52. *
  53. * @param {string} functionSignature Signature of the generated function.
  54. * @param {object} variableSubstitutionMap Maps variable names to shader variable names.
  55. * @param {object} shaderState Stores information about the generated shader function, including whether it is translucent.
  56. * @param {string} returnType The return type of the generated function.
  57. *
  58. * @returns {string} The shader function.
  59. *
  60. * @private
  61. */
  62. StyleExpression.prototype.getShaderFunction = function (
  63. functionSignature,
  64. variableSubstitutionMap,
  65. shaderState,
  66. returnType
  67. ) {
  68. DeveloperError.throwInstantiationError();
  69. };
  70. /**
  71. * Gets the variables used by the expression.
  72. *
  73. * @returns {string[]} The variables used by the expression.
  74. *
  75. * @private
  76. */
  77. StyleExpression.prototype.getVariables = function () {
  78. DeveloperError.throwInstantiationError();
  79. };
  80. export default StyleExpression;